Centos7快速搭建 zabbix 4.4
一.環境簡介
環境準備
Linux 7.7.1908
nginx 1.16.1
zabbix-server 4.4
zabbix-agent 4.4
mysql 5.7.29
php 5.4.16
1.包下載
wget https://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm
2.關閉防火牆及selinux
systemctl stop firewalld && systemctl disable firewalld
sed -i 's/SELINUX=enforcing/SELINUX=disabled/'/etc/selinux/config
二.zabbix安裝配置
1.安裝Zabbix伺服器、前端、代理
rpm -i https://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm
yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent -y
2.配置Zabbix-server
mv /etc/zabbix/zabbix_server.conf /etc/zabbix/zabbix_server.conf.bak
vim /etc/zabbix/zabbix_server.conf
LogFile=/var/log/zabbix/zabbix_server.log LogFileSize=0 PidFile=/var/run/zabbix/zabbix_server.pid SocketDir=/var/run/zabbix DBHost=localhost DBName=zabbix DBUser=zabbix DBPassword=zabbix DBPort=3306 SNMPTrapperFile=/var/log/snmptrap/snmptrap.log CacheSize=1024M Timeout=4 AlertScriptsPath=/usr/lib/zabbix/alertscripts ExternalScripts=/usr/lib/zabbix/externalscripts LogSlowQueries=3000
3.配置zabbix-agent
mv /etc/zabbix/zabbix_agent.conf /etc/zabbix/zabbix_agent.conf.bak
vim /etc/zabbix/zabbix_agentd.conf
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server= ListenPort=10050
ServerActive=
Hostname=
Include=/etc/zabbix/zabbix_agentd.d/
三.資料庫安裝配置
1.安裝資料庫
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
yum localinstall mysql57-community-release-el7-8.noarch.rpm -y
2.檢查mysql源是否安裝成功
yum repolist enabled | grep mysql.*-community.*
yum install mysql-community-server -y
3.動MySQL服務
systemctl start mysqld
4.登入資料庫
grep 'temporary password' /var/log/mysqld.log
mysql -uroot -p
修改密碼,Lenvoo@123是你的新密碼
mysql> SET PASSWORD = PASSWORD('Lenovo@123');
如何解決ERROR 1819 (HY000): Your password does not satisfy the current policy requirements 呢?
#修改validate_password_policy引數的值
set global validate_password_policy=0;
#再修改密碼的長度
set global validate_password_length=1;
#再次執行修改密碼就可以了
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Lenovo@123';
#允許root遠端登陸*
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Lenovo@123' WITH GRANT OPTION;
5.建立zabbix資料庫和使用者
mysql –uroot –p
mysql> create database zabbix character set utf8;
Query OK, 1 row affected (0.00 sec)
mysql> grant all privileges on zabbix.* to 'zabbix'@'localhost' identified by 'zabbix';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
6.匯入模板資料
方法1
source /usr/share/doc/zabbix-server-mysql-4.4.1/create/schema.sql
source /usr/share/doc/zabbix-server-mysql-4.4.1/create/images.sql
source /usr/share/doc/zabbix-server-mysql-4.4.1/create/data.sql
方法2
zcat /usr/share/docc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
四.nginx安裝配置
1.安裝nginx
1.yum install nginx -y
2.配置nginx
vim /etc/nginx/conf.d/default.conf
...
location / {
root /usr/share/zabbix;
index index.php;
}
...
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/zabbix$fastcgi_script_name;
include fastcgi_params;
}
...
3.修改zabbix前端檔案許可權
chown nginx:nginx /usr/share/zabbix/*
chmod -R 755 /usr/share/zabbix/*
4.啟動nginx
systemctl restart nginx
5.PHP安裝配置
yum install php-fpm php-gd php-mbstring php-bcmath php-gd php-xmlwriter php-xmlreader -y
6.修改配置檔案
sed-is#max_execution_time = 30#max_execution_time = 600#g/etc/php.ini
sed-is#max_input_time = 60#max_input_time = 600#g/etc/php.ini
sed-is#memory_limit = 128M#memory_limit = 256M#g/etc/php.ini
sed-is#post_max_size = 8M#post_max_size = 32M#g/etc/php.ini
sed-is#upload_max_filesize = 2M#upload_max_filesize = 16M#g/etc/php.ini
sed-is/;date.timezone =/date.timezone = Asia\/Shanghai/g/etc/php.ini
7.啟動php-fpm
systemctl start php-fpm
8.啟動所有服務
systemctl start zabbix-server
systemctl start zabbix-agent
systemctl start nginx
systemctl start mysqld
systemctl start php-fpm
9.設定開機啟動項
systemctl enable zabbix-server zabbix-agent mysqld nginx php-fpm
10.檢查埠
[root@zabbix-server]# netstat -pntl
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 5118/php-fpm: maste
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 5046/nginx: master
tcp6 0 0 :::10050 :::* LISTEN 5577/zabbix_agentd
tcp6 0 0 :::10051 :::* LISTEN 4821/zabbix_server
tcp6 0 0 :::3306 :::* LISTEN 1703/mysqld
11.連線到新安裝的Zabbix前端: http://server_ip
本文版權歸作者所有,歡迎轉載,請務必新增原文連結。