天天看點

測試centos7安裝zabbix3.4

環境: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>

将該行改為

    DirectoryIndex index.html index.htm index.php

增加php應用的支援

重新開機httpd

 systemctl restart httpd.service

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

firewall-cmd --reload

2.配置zabbixzone package

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版本以上導入資料:

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圖示基本相同)

<a href="http://172.16.169.128/zabbix/setup.php">http://192.168.31.77/zabbix/setup.php</a>

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用戶端:

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 

netstat -anlpt

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

13、zabbix圖形中文亂碼

本文轉自 lcpljc 51CTO部落格,原文連結:http://blog.51cto.com/lcpljc/2052196,如需轉載請自行聯系原作者