1. 程式人生 > >CentOS7+zabbix3.4+YUM安裝部署

CentOS7+zabbix3.4+YUM安裝部署

版本資訊

作業系統:CentOS Linux release 7.5.1804 (Core)
資料庫:mysql 5.7.23
PHP Version 5.4.16
Apache/2.4.6
Zabbix 3.4

1.臨時關閉防火牆

# systemctl disable firewalld 
# systemctl stop firewalld 

2.更新yum

# yum clean all
# yum makecache 
# yum -y update 

3.時區時鐘配置

# timedatectl
Local time: Wed 2018
-08-29 04:33:17 PDT Universal time: Wed 2018-08-29 11:33:17 UTC RTC time: Wed 2018-08-29 11:33:17 Time zone: America/Los_Angeles (PDT, -0700) NTP enabled: yes NTP synchronized: yes RTC in local TZ: no DST active: yes Last DST change: DST began at Sun 2018-03-11 01:59
:59 PST Sun 2018-03-11 03:00:00 PDT Next DST change: DST ends (the clock jumps one hour backwards) at Sun 2018-11-04 01:59:59 PDT Sun 2018-11-04 01:00:00 PST # cd /etc # rm -rf localtime # ln -s /usr/share/zoneinfo/Asia/Shanghai localtime # ntpdate ntp.aliyun.com # crontab -e
*/5 * * * * /usr/sbin/ntpdate ntp.aliyun.com

4.安裝http

# yum -y install httpd httpd-manual mod_ssl mod_perl 

5.安裝mysql

# rpm -ivh http://repo.mysql.com/mysql57-community-release-el7.rpm
# yum -y install mysql-community-server mysql-community-libs mysql-community-devel mysql-community-common mysql-community-client

6.安裝php

# yum -y install php php-mysql php-common php-gd php-devel php-mcrypt php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath

測試PHP環境

# cat > /var/www/html/phpinfo.php
<?php
    phpinfo();
?>
訪問http://伺服器IP/phpinfo.php

7.啟動http

# systemctl enable httpd 
# systemctl start httpd 

8.啟動mysql

# systemctl enable mysqld
# systemctl start mysqld 

9.mysql安全配置

# cat /var/log/mysql.log 
root/8ERt>_wH.iCZ
# mysql_secure_installation 
重置資料庫賬號密碼:root/4dZvVXUVK%bmXKFl

新建資料庫zabbix和賬號
zabbix/CqedJUYVAE^W94nT

mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> create user 'zabbix'@'localhost' identified by 'CqedJUYVAE^W94nT';
mysql> grant all privileges on zabbix.* to 'zabbix'@'localhost' ;
mysql> flush privileges;

10.安裝zabbix_server

# rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
# yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-web zabbix-get 

11.安裝zabbix_agent

# yum -y install zabbix-agent zabbix-get zabbix-sender 

12.匯入zabbix表結構

# zcat /usr/share/doc/zabbix-server-mysql-3.4.13/create.sql.gz | mysql -uzabbix -p zabbix 

13.修改zabbix_server配置

# cd /etc/zabbix/
# cp zabbix_server.conf zabbix_server.conf.20180829
# egrep -v '^#|^$' zabbix_server.conf.20180829 > zabbix_server.conf
新增配置
DBPassword=CqedJUYVAE^W94nT

14.修改zabbix_agented配置

# cd /etc/zabbix/
# cp zabbix_agentd.conf zabbix_agentd.conf.20180829
# egrep -v '^#|^$' zabbix_agentd.conf.20180829 > zabbix_agentd.conf

15.zabbix前端php設定

# vi /etc/httpd/conf.d/zabbix.conf
php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
php_value always_populate_raw_post_data -1
php_value date.timezone Asia/Shanghai

16.PHP時區設定

# vi /etc/php.ini
date.timezone = Asia/Shanghai

17.啟動服務

# systemctl enable zabbix-server
# systemctl enable zabbix-agent
# systemctl start zabbix-server
# systemctl start zabbix-agent

18.登入

http://192.168.204.100/zabbix/
Admin/zabbix 

錯誤處理:

zabbix-server啟動失敗1

查日誌:
 76532:20180829:040236.040 using configuration file: /etc/zabbix/zabbix_server.conf
 76532:20180829:040236.044 [Z3001] connection to database 'zabbix' failed: [2059] Authentication plugin 'c
aching_sha2_password' cannot be loaded: /usr/lib64/mysql/plugin/caching_sha2_password.so: cannot open shar
ed object file: No such file or directory
 76532:20180829:040236.044 Cannot connect to the database. Exiting...

原因:
zabbix-server連線資料庫失敗

解決辦法:
mysql8.0注意事項
1.加密認證方式改回舊的,否則客戶端連線報錯
#vi /etc/my.cnf
default-authentication-plugin=mysql_native_password
mysql> use mysql;
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '4dZvVXUVK%bmXKFl';
mysql> ALTER USER 'zabbix'@'localhost' IDENTIFIED WITH mysql_native_password BY 'CqedJUYVAE^W94nT';
mysql> FLUSH PRIVILEGES;

zabbix-server啟動失敗2

查日誌:
zabbix_server [76545]: cannot open log: cannot create semaphore set: [28] No space left on device
zabbix_server [76548]: cannot open log: cannot create semaphore set: [28] No space left on device

原因:
伺服器共享記憶體不足導致


解決辦法:
# vi /etc/sysctl.conf 
kernel.sem = 500  64000   64      256
# sysctl -p /etc/sysctl.conf

再重啟zabbix-server服務即可