这是我记录的安装Zabbix 6.0的过程,由于监控规模较小,我没有使用agent。这是我第一次发布文章,请各位读者见谅,如果有任何错误之处,请务必指出。
1. 安装percona8.0
yum 源
http://telecom.mirrors.ustc.edu.cn/percona/ps-80/yum/release/
install
yum install http://telecom.mirrors.ustc.edu.cn/percona/ps-80/yum/release/7Server/RPMS/x86_64/percona-server-devel-8.0.13-3.1.el7.x86_64.rpm
yum install http://telecom.mirrors.ustc.edu.cn/percona/ps-80/yum/release/7Server/RPMS/x86_64/percona-server-client-8.0.13-3.1.el7.x86_64.rpm
yum install http://telecom.mirrors.ustc.edu.cn/percona/ps-80/yum/release/7Server/RPMS/x86_64/percona-server-shared-8.0.13-3.1.el7.x86_64.rpm
yum install http://telecom.mirrors.ustc.edu.cn/percona/ps-80/yum/release/7Server/RPMS/x86_64/percona-server-shared-compat-8.0.13-3.1.el7.x86_64.rpm
yum install http://telecom.mirrors.ustc.edu.cn/percona/ps-80/yum/release/7Server/RPMS/x86_64/percona-server-shared-8.0.13-3.1.el7.x86_64.rpm
yum install http://telecom.mirrors.ustc.edu.cn/percona/ps-80/yum/release/7Server/RPMS/x86_64/percona-server-client-8.0.13-3.1.el7.x86_64.rpm
yum install http://telecom.mirrors.ustc.edu.cn/percona/ps-80/yum/release/7Server/RPMS/x86_64/percona-server-server-8.0.13-3.1.el7.x86_64.rpm
yum install http://telecom.mirrors.ustc.edu.cn/percona/ps-80/yum/release/7Server/RPMS/x86_64/percona-server-devel-8.0.13-3.1.el7.x86_64.rpm
rpm -qa|grep percona
启动mysqld
systemctl start mysqld.service
查看初始密码
tail -f /var/log/mysqld.log
创建用户授权创建表
mysql -uroot -p<password>
mysql> create database zabbix character set utf8mb4 collate utf8mb4_bin;
mysql> create user 'zabbix'@'localhost' identified by '<password>';
(create user 'zabbix'@'%' identified with mysql_native_password by '<password>';)
mysql> grant all privileges on zabbix.* to 'zabbix'@'localhost';
(grant all privileges on zabbix.* to zabbix@'%';)
mysql> SET GLOBAL log_bin_trust_function_creators = 1;
mysql> quit;
注:alter user zabbix@'%' identified with mysql_native_password by ''; 更改密码插件为本地插件
导入数据
cd database/mysql
mysql -uzabbix -p<password> zabbix < schema.sql
mysql -uzabbix -p<password> zabbix < images.sql
mysql -uzabbix -p<password> zabbix < data.sql
注:严格按照以上顺序进行导入
gcc tcpclient.c -o tcpclient -std=c99
2.安装nginx
yum install nginx
配置nginx
vi /etc/nginx/nginx.conf
server {
listen 80;
server_name zabbix.cn;
location / {
# root /usr/share/nginx/zabbix/;
root /usr/share/nginx/html/;
index index.html index.htm index.php;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.php$ {
# root /usr/share/nginx/zabbix/;
root /usr/share/nginx/html/;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/zabbix$fastcgi_script_name;
#可以写死也可以用变量
include fastcgi_params;
}
}
3.安装php-fpm
安装以下组件 注意安装版本是否兼容
php73-php-bcmath.x86_64
php73-php-fpm.x86_64
php73-php-pecl-xmldiff.x86_64
php73-php-xml.x86_64
php73-php-mbstring.x86_64
php73-php-gd.x86_64
php73-php-mysqlnd.x86_64
php73-php-common.x86_64
php73-php-ldap.x86_64
php73-php-pdo.x86_64
php73-php-json.x86_64
配置php /etc/php-fpm.d
listen = 127.0.0.1:9000
user = nginx
group = nginx
注:/etc/opt/remi/php73/php.ini 后期在web端需要修改此文件 当前不用
启动php
测试nginx 能否访问php页面
4.安装Zabbix-Server
下载源码包
wget https://cdn.zabbix.com/zabbix/sources/stable/6.0/zabbix-6.0.16.tar.gz
解包编译
export CFLAGS="-std=gnu99" #在make install过程中出现报错经查实需要声明环境变量
./configure --prefix=/usr/local/zabbix/ --enable-server --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 --with-openipmi
(编译根据实际需求添加功能)
make install
配置
LogFile=/tmp/zabbix_server.log
DBName=zabbix
DBUser=zabbix
DBPassword=123456
Timeout=4
LogSlowQueries=3000
StatsAllowedIP=127.0.0.1
启动zabbix-server
查看日志确认是否启动正常以及当前支持功能
62856:20230416:202244.085 Starting Zabbix Server. Zabbix 6.0.16 (revision a90e18c0b6e).
62856:20230416:202244.085 ****** Enabled features ******
62856:20230416:202244.085 SNMP monitoring: YES
62856:20230416:202244.085 IPMI monitoring: YES
62856:20230416:202244.085 Web monitoring: YES
62856:20230416:202244.085 VMware monitoring: YES
62856:20230416:202244.085 SMTP authentication: YES
62856:20230416:202244.085 ODBC: NO
62856:20230416:202244.085 SSH support: NO
62856:20230416:202244.085 IPv6 support: YES
62856:20230416:202244.085 TLS support: NO
62856:20230416:202244.085 ******************************
62856:20230416:202244.085 using configuration file: /usr/local/zabbix/etc/zabbix_server.conf
62856:20230416:202244.112 current database version (mandatory/optional): 06000000/06000020
62856:20230416:202244.112 required mandatory version: 06000000
62858:20230416:202244.217 starting HA manager
62858:20230416:202244.229 HA manager started in active mode
62856:20230416:202244.230 server #0 started [main process]
62859:20230416:202244.231 server #1 started [service manager #1]
62860:20230416:202244.231 server #2 started [configuration syncer #1]
62863:20230416:202244.393 server #3 started [alert manager #1]
62864:20230416:202244.393 server #4 started [alerter #1]
62865:20230416:202244.394 server #5 started [alerter #2]
62866:20230416:202244.394 server #6 started [alerter #3]
62867:20230416:202244.394 server #7 started [preprocessing manager #1]
62868:20230416:202244.394 server #8 started [preprocessing worker #1]
5. 安装 Zabbix-web
nginx根目录创建zabbix目录
cp ./ui/* /usr/share/nginx/html/zabbix #把zabbix php的目录文件copy到zabbix里
打开http://192.168.10.1/zabbix
根据流程进行配置
注1:zabbix设置中文并解决乱码问题
find / -name fonts
/usr/share/zabbix/assets/fonts
上传字体(选用微软雅黑) 改名graphfont.ttf 即可
注2:最后会有一个无法创建的报错 根据页面提示下载zabbix.conf.php
放进/usr/share/nginx/html/zabbix/conf 即可