1. 程式人生 > >測試centos7安裝zabbix3.4

測試centos7安裝zabbix3.4

zabbix

環境:centos7 x64 1501

實驗ip為:192.168.31.77


1.安裝必須軟件包

yum -y install httpd mariadb mariadb-server php php-gd php-mysql php php-gd php-mysql php-bcmath php-mbstring

修改apache的配置文件,默認首頁設置為php

vim /etc/httpd/conf/httpd.conf

找到:
AddType application/x-gzip .gz .tgz
在該行下面添加
AddType application/x-httpd-php .php
找到:
<IfModule dir_module>

DirectoryIndex index.html
</IfModule>
將該行改為
<IfModule dir_module>
DirectoryIndex index.html index.htm index.php
</IfModule>

增加php應用的支持

重啟httpd

systemctl restart httpd.service

firewall-cmd --add-port=80/tcp --permanent

firewall-cmd --reload

2.配置zabbixzone package

rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-1.el7.centos.noarch.rpm

3.安裝zabbix server

yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent zabbix-java-gateway -y

yum install zabbix-get

編輯/etc/httpd/conf.d/zabbix.conf

更改時區:

添加上海時區

php_value date.timezone Asia/Shanghai

重啟httpd生效配置

開啟mariadb

systemctl enable mariadb

systemctl start mariadb

然後設置數據庫密碼777777

mysqladmin -uroot password 777777

4.創建mariadb數據庫和用戶

mysql -uroot -p777777

create database zabbix character set utf8;

授權

grant all privileges on zabbix.* to 'zabbix'@'localhost' identified by 'zabbix';

刷新權限

flush privileges;

5.數據庫導入zabbix template

查看需要導入的數據表

ls -l /usr/share/doc/zabbix-server-mysql-3.4.0/

登錄zabbix數據庫

mysql -uzabbix -pzabbix

使用zabbix數據庫

use zabbix;

導入模板數據


---------------------------------------------------------------------------------------

備註:

2.0版本導入數據方法:

source /usr/share/doc/zabbix-server-mysql-2.4.8/create/schema.sql

source /usr/share/doc/zabbix-server-mysql-2.4.8/create/images.sql

source /usr/share/doc/zabbix-server-mysql-2.4.8/create/data.sql

或者:

# mysql -uroot -pttlsapwd zabbix <schema.sql

# mysql -uroot -pttlsapwd zabbix <images.sql

# mysql -uroot -pttlsapwd zabbix <data.sql

---------------------------------------------------------------------------------------

3.0版本以上導入數據:

zcat /usr/share/doc/zabbix-server-mysql-3.4.0/create.sql.gz | mysql -uzabbix -pzabbix zabbix

6.配置zabbix server

vi /etc/zabbix/zabbix_server.conf

開啟參數

DBName=zabbix

DBUser=zabbix

DBPassword=zabbix

7.配置zabbix-agent

vi /etc/zabbix/zabbix_agentd.conf

修改添加zabbix-server的ip

Server=127.0.0.1

修改

ServerActive=127.0.0.1

修改

Hostname=127.0.0.1

8.修改PHP配置

編輯文件/etc/php.ini


max_execution_time = 600

max_input_time = 600

memory_limit = 256

post_max_size = 32M

upload_max_filesize = 16M

date.timezone = Asia/Shanghai

9.修改Firewall和selinux設置

開放zabbix端口10050 和10051

firewall-cmd --permanent --add-port=10050/tcp

firewall-cmd --permanent --add-port=10051/tcp

systemctl restart firewalld

如果使用selinux,運行一下命令使apache可以和zabbix通信

setsebool -P httpd_can_connet_zabbix=1

啟動zabbix-server和zabbix-agent,重啟httpd,並設置開機自動啟動

systemctl start zabbix-server

systemctl start zabbix-agent

systemctl restart httpd

systemctl restart mariadb

systemctl enable zabbix-server

systemctl enable zabbix-agent

11.通過控制臺配置zabbix(2.4和3.4圖示基本相同)

http://192.168.31.77/zabbix/setup.php

12.客戶端安裝:

windows客戶端安裝


1.下載客戶端:zabbix_agentd.zip

2.在c盤創建文件夾zabbix,解壓conf和bin目錄

3.將conf下的zabbix_agentd.win.conf 修改為zabbix_agentd.conf

4.修改配置文件zabbix_agentd.conf:

  LogFile=C:\zabbix\zabbix_agentd.log

  Server=192.168.31.77 備註:-----zabbix server 源地址

  ServerActive=192.168.31.150

  Hostname=192.168.31.150 備註: ------本計算機名或IP

.安裝:

  cd C:\zabbix\bin

  zabbix_agentd.exe -c "C:\zabbix\conf\zabbix_agentd.conf" -i

啟動:

  zabbix_agentd.exe -c "C:\zabbix\conf\zabbix_agentd.conf" -s

-----------------------------------------

linux客戶端:

rpm -Uv http://repo.zabbix.com/zabbix/2.4/rhel/7/x86_64/zabbix-release-2.4-1.el7.noarch.rpm
yum install zabbix-sender zabbix-agent zabbix -y

sed -i "s/Server=127.0.0.1/Server=192.168.31.77/" /etc/zabbix/zabbix_agentd.conf
sed -i "s/ServerActive=127.0.0.1/ServerActive=192.168.31.77/" /etc/zabbix/zabbix_agentd.conf
sed -i "s/Hostname=Zabbix server/Hostname=192.168.31.50/" /etc/zabbix/zabbix_agentd.conf
systemctl enable zabbix-agent
systemctl start zabbix-agent
netstat -anlpt
firewall-cmd --add-port=10050/tcp --permanent
firewall-cmd --reload

13、zabbix圖形中文亂碼

cd /usr/share/zabbix/include
[root@zabbix-server include]# vi defines.inc.php

define('ZBX_FONT_NAME','simkai');

define('ZBX_GRAPH_FONT_NAME','simkai')

然後下載微軟楷體字體,改名為simkai傳入 /usr/share/zabbix/fonts目錄下即可


測試centos7安裝zabbix3.4