一、zabbix 安裝
1. zabbix下載地址
//repo.zabbix.com/zabbix
2. 安裝zabbix server
rpm -Uvh //repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.e7.noarch.rpm
yum clean all
yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent zabbix-get zabbix-sender -y
3. 安裝zabbix agent
zabbix server端必須要安裝一個zabbix agent。
[root]# yum install zabbix-agent -y
[root]# vi /etc/zabbix/zabbix_agentd.con f
PidFile=/run/zabbix/zabbix_server.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=x.x.x.x
ServerActive=x.x.x.x:10051
Hostname=zabbix-server
Include=/etc/zabbix/zabbix_agentd.d/*.conf
BufferSize=200
Timeout=30
二、MySQL安裝
1.創建mysql文件夾
cd /usr/local
mkdir mysql
2.下載資源完整包,并上傳到/usr/local/mysql
3.解壓mysql下載包
tar -xvf mysql-8.0.26-1.el7.x86_64.rpm-bundle.tar
4.查詢本地有沒有已存在安裝包和卸載
查詢:rpm -qa | grep mariadb
卸載:rpm -e mariadb-libs-5.5.60-1.el7_5.x86_64 --nodeps
5. 安裝順序
rpm -ivh mysql-community-common-8.0.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-plugins-8.0.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-compat-8.0.26-1.el7.x86_64.rpm
6.開啟mysql
systemctl start mysqld
7.查看數據庫的初始密碼,命令如下:
cat /var/log/mysqld.log | grep password(記錄一下密碼,修改要用)
8.修改密碼
登錄:mysql -u root -p
修改:ALTER USER "USER"@"localhost" IDENTIFIED BY "PASSWORD";
三、配置zabbix server
1.導入表,創建zabbix庫、zabbix用戶、導入zabbix數據
SQL> create database zabbix character set utf8 collate utf8_bin;
SQL> create user 'USER'@'%' identified by 'PASSWORD';
SQL> grant all privileges on zabbix.* to 'USER'@'%';
[root]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
2.配置zabbix-server連接mysql
[root]# vi /etc/zabbix/zabbix_server.conf
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/run/zabbix/zabbix_server.pid (要和service里的路徑一樣)
SocketDir=/var/run/zabbix
DBHost=localhost (這里,localhost還是127.0.0.1視情況而定)
DBName=zabbix
DBUser=zabbix
DBPassword=PASSWORD
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000
3.啟動zabbix server
[root]# systemctl start zabbix-server
[root]# systemctl enable zabbix-server
4.修改zabbix前端PHP配置
修改時區
[root]# vi /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/Shanghai
5.關閉firewall、selinux
systemctl stop firewalld.service
systemctl disable firewalld.service
vi /etc/selinux/config
將SELINUX改成disable(重啟后生效)
6.啟動httpd服務
[root]# vi /etc/httpd/conf
修改ServerName x.x.x.x:80 (同zabbix_agentd.conf中的server地址)
[root]# systemctl start httpd
[root]# systemctl enable httpd
7.登錄zabbix web
//x.x.x.x/zabbix
初始:Admin/zabbix
界面右上角 用戶-修改密碼為PASSWORD 語言改為中文。
四、web端配置
1.創建主機
配置--主機--創建主機
2.配置加密
配置--主機--選擇一臺主機--加密
共享密鑰一致性:TEST
PSK:****************************************************
五、常見報錯
1、mysql客戶端連接失敗:2059-Authentication plugin 'caching_sha2_password' can not be loaded: ...
解決方法:登錄數據庫后
use mysql
select user,host,plugin,authentication_string from user;
alter user 'USER'@'%' identified with mysql_native_password by 'PASSWORD';
2、zabbix web出現403錯誤。
vi /etc/httpd/conf
查看ServerName x.x.x.x:80有沒有成功添加
3、登錄時顯示Unable to select configuration.
出現這個錯誤是數據庫表導入失敗。刪除zabbix庫和zabbix用戶以后重新執行導入表,創建zabbix庫、zabbix用戶、導入zabbix數據
SQL> create database zabbix character set utf8 collate utf8_bin;
SQL> create user 'USER'@'%' identified by 'PASSWORD';
SQL> grant all privileges on zabbix.* to 'USER'@'%';
[root]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix (過程有一點長,不要中斷)