基於CentOS7.3安裝Zabbix3.2手記

一、安裝虛擬機

此處不做贅述

二、配置yum源

安裝epel源

[root@localhost ~]# yum -y install epel-release

安裝webtatic源

[root@localhost ~]# rpm -Uvh http://mirror.webtatic.com/yum/el7/webtatic-release.rpm

配置zabbix源

vim /etc/yum.repos.d/zabbix.repo
[zabbix]
name=zabbix
baseurl=http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/
enabled=1
gpgcheck=0

清空yum cache,重建yum緩存

[root@localhost ~]# yum clean all
[root@localhost ~]# yum repolist
[root@localhost ~]# yum makecache

三、升級PHP版本

由於zabbix3.2版本需要PHP5.6以上版本才能支持,默認centos安裝的php版本爲5.3.3,因此需要升級php版本。

1、查看當前php版本

[root@localhost ~]# php -v

2、移除當前已經安裝的php版本

[root@localhost ~]# yum remove php*

3、安裝php5.6版本

[root@localhost ~]# yum install -y php56w php56w-devel php56w-common php56w-mysql php56w-pdo php56w-opacache php56w-xml php56w-gd php56w-bcmath php56w-mbstring

[root@localhost ~]# php -v
PHP 5.6.30 (cli) (built: Jan 19 2017 22:50:24) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

四、安裝mariadb並編輯mariadb配置文件

1、安裝mariadb

[root@localhost ~]# yum install -y mariadb-server mariadb-libs mariadb-devel

2、編輯/etc/my.cnf.d/server.cnf,添加以下內容,防止中文亂碼

[root@localhost ~]# vim /etc/my.cnf.d/server.cnf
[mysqld]
#設置字符集爲utf8
character-set-server = utf8
collation-server = utf8_bin
skip-character-set-client-handshake
skip-external-locking
symbolic-links=0
innodb_buffer_pool_size = 2048M
innodb_log_file_size = 512M
sort_buffer_size = 2M
innodb_additional_mem_pool_size = 30M
innodb_log_buffer_size = 8M
key_buffer_size = 16M
log-bin=mysql-bin
expire_logs_days = 7
server-id=1001
innodb_data_file_path = ibdata1:1G
#讓innodb的每個表文件單獨存儲
innodb_file_per_table

3、啓動mariadb服務,並設置開機自動啓動

[root@localhost ~]# systemctl start mariadb
[root@localhost ~]# systemctl status mariadb
[root@localhost ~]# systemctl enable mariadb

4、設置mysql服務root密碼

[root@localhost ~]# mysqladmin -uroot password root

5、創建數據庫和用戶授權

[root@localhost ~]# mysql -uroot -proot

MariaDB [(none)]> create database zabbix character set utf8;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@'localhost' identified by 'zabbix';
Query OK, 0 rows affected (0.02 sec)

MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@'192.168.159.%' identified by 'zabbix';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> exit
Bye

五、安裝zabbix

1、yum安裝zabbix

[root@localhost ~]# yum install -y zabbix-agent zabbix-get zabbix-java-gateway zabbix-proxy zabbix-proxy-mysql zabbix-release zabbix-sender zabbix-server zabbix-server-mysql zabbix-web zabbix-web-mysql
#由於安裝zabbix的時候會默認安裝一個zabbix-server-pgsql的插件,我們必須把這個插件刪掉,後面zabbix才能默認連接mariadb,否則zabbix默認連接pgsql
[root@localhost ~]# yum remove -y zabbix-server-pgsql

2、解壓sql導入文件

[root@localhost ~]# cd /usr/share/doc/zabbix-server-mysql-3.2.7/

[root@localhost zabbix-server-mysql-3.2.7]# ls
AUTHORS  ChangeLog  COPYING  create.sql.gz  NEWS  README

[root@localhost zabbix-server-mysql-3.2.7]# gunzip create.sql.gz 

[root@localhost zabbix-server-mysql-3.2.7]# ls
AUTHORS  ChangeLog  COPYING  create.sql  NEWS  README

3、將sql文件導入mariadb

[root@localhost zabbix-server-mysql-3.2.4]# mysql -uzabbix -pzabbix

mysql> use zabbix;
Database changed

mysql> source /usr/share/doc/zabbix-server-mysql-3.2.7/create.sql ;

mysql> show tables;

mysql> exit;

3、編輯/etc/zabbix/zabbix_server.conf

vim /etc/zabbix/zabbix_server.conf
DBPassword=zabbix

4、創建需要的目錄

mkdir /etc/zabbix/alertscripts /etc/zabbix/externalscripts

5、啓動zabbix服務

[root@localhost ~]# setenforce 0
[root@localhost ~]# getenforce 
Permissive
[root@localhost ~]# systemctl restart zabbix-server
[root@localhost ~]# systemctl status zabbix-server
[root@localhost ~]# systemctl enable zabbix-server

六、配置apache服務,並啓動

1、編輯/etc/httpd/conf/httpd.conf,修改以下內容

vim /etc/httpd/conf/httpd.conf
ServerName localhost:80

2、啓動httpd服務,並開機自動啓動

[root@localhost ~]# systemctl start httpd
[root@localhost ~]# systemctl enable httpd

3、其他配置

停止iptables
[root@localhost ~]# service iptables stop
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Unloading modules:                               [  OK  ]

#如果有要求不能停止防火牆,則需要將http和https服務放行
[root@localhost ~]# firewall-cmd --permanent --add-service=http
success
[root@localhost ~]# firewall-cmd --permanent --add-service=https
success
[root@localhost ~]# firewall-cmd --reload
success
[root@localhost ~]# firewall-cmd --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: ens33 ens37
  sources: 
  services: dhcpv6-client http https ssh
  ports: 
  protocols: 
  masquerade: no
  forward-ports: 
  sourceports: 
  icmp-blocks: 
  rich rules: 

將/usr/share/目錄下的zabbix目錄複製到/var/www/html/目錄下
cp -r /usr/share/zabbix /var/www/html/

七、在瀏覽器中打開並繼續配置zabbix

1、在瀏覽器中打開http://192.168.159.253/zabbix
zabbix welcome

2、點擊下一步,此頁爲php的參數檢測,如果不通過,就修改到通過爲止,在php.ini那裏修改,記得改完要重啓httpd
check

3、修改php配置文件

[root@localhost ~]# vim /etc/php.ini
post_max_size = 16M
max_execution_time = 300
max_input_time = 300
date.timezone = Asia/Shanghai
bcmath.scale = 1
always_populate_raw_post_data = -1
#修改以上參數後保存退出

4、點擊back,重新點擊下一步檢查
檢查成功

5、點擊下一步,mysql數據庫檢測,用戶名和密碼填寫剛纔創建的zabbix
這裏寫圖片描述

6、點擊下一步,此頁保持默認
這裏寫圖片描述

7、信息總覽
這裏寫圖片描述

8、安裝完畢,點擊finish即可完成安裝。
這裏寫圖片描述

9、登錄,默認用戶名密碼爲admin/zabbix
這裏寫圖片描述
這裏寫圖片描述

八、安裝Grafana軟件

1、訪問Grafana官網,官網上提供有下載連接
https://grafana.com/grafana/download

2、下載並安裝Grafana

[root@localhost ~]# wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-4.4.3-1.x86_64.rpm 
[root@localhost ~]# yum -y localinstall grafana-4.4.3-1.x86_64.rpm 

3、啓動Grafana-server服務,並將grafana-server加入開機啓動

#重新加載systemd發現新的項目
[root@localhost ~]# systemctl daemon-reload
[root@localhost ~]# systemctl enable grafana-server.service 
Created symlink from /etc/systemd/system/multi-user.target.wants/grafana-server.service to /usr/lib/systemd/system/grafana-server.service.
[root@localhost ~]# systemctl start grafana-server.service 

4、打開瀏覽器輸入zabbix服務器的IP:3000既可以打開。用戶名密碼默認都是admin

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章