rockylinux8-安装zabbix6.0.30-LTS
系统环境:rockylinux8.10
zabbix版本:zabbix6.30
nginx版本nginx/1.26.1
php版本PHP 7.2.24
mysql版本8.0
zabbix-server安装 rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/8/x86_64/zabbix-release-6.0-4.el8.noarch.rpm dnf clean all #安装Zabbix server,Web前端,agent dnf install -y zabbix-server-mysql zabbix-web-mysql zabbix-nginx-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent #安装mysql8.0 yum install mysql-server -y #启动mysql systemctl restart mysqld #配置mysql #mysql -uroot -p create database zabbix character set utf8mb4 collate utf8mb4_bin; create user zabbix@localhost identified by '123456'; grant all privileges on zabbix.* to zabbix@localhost; set global log_bin_trust_function_creators = 1; #初绐化数据库的表,导入数据 #需要先关闭二进制日志 [root@mb ~]# mysql -uroot -p Enter password: mysql> set global log_bin_trust_function_creators = 1; ok #导入数据到zabbix库 [root@mb ~]# zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p123456 zabbix mysql: [Warning] Using a password on the command line interface can be insecure. #再次打开二进制日志 # mysql -uroot -p mysql> set global log_bin_trust_function_creators = 0; mysql> quit; #修改nginx的配置 [root@mb ~]# cat /etc/nginx/conf.d/zabbix.conf server { listen 80; server_name 172.168.10.21; root /usr/share/zabbix; index index.php; location = /favicon.ico { log_not_found off; } location / { try_files $uri $uri/ =404; } location /assets { access_log off; expires 10d; } location ~ /\.ht { deny all; } location ~ /(api\/|conf[^\.]|include|locale) { deny all; return 404; } location /vendor { deny all; return 404; } location ~ [^/]\.php(/|$) { fastcgi_pass unix:/run/php-fpm/zabbix.sock; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_index index.php; fastcgi_param DOCUMENT_ROOT /usr/share/zabbix; fastcgi_param SCRIPT_FILENAME /usr/share/zabbix$fastcgi_script_name; fastcgi_param PATH_TRANSLATED /usr/share/zabbix$fastcgi_script_name; include fastcgi_params; fastcgi_param QUERY_STRING $query_string; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length; fastcgi_intercept_errors on; fastcgi_ignore_client_abort off; fastcgi_connect_timeout 60; fastcgi_send_timeout 180; fastcgi_read_timeout 180; fastcgi_buffer_size 128k; fastcgi_buffers 4 256k; fastcgi_busy_buffers_size 256k; fastcgi_temp_file_write_size 256k; } } #修改php的配置 [root@mb tools]# cat /etc/php-fpm.d/zabbix.conf [zabbix] user = nginx group = nginx listen = /run/php-fpm/zabbix.sock listen.acl_users = apache,nginx listen.allowed_clients = 127.0.0.1 pm = dynamic pm.max_children = 50 pm.start_servers = 5 pm.min_spare_servers = 5 pm.max_spare_servers = 35 pm.max_requests = 200 php_value[session.save_handler] = files php_value[session.save_path] = /var/lib/php/session 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[max_input_vars] = 10000 #查看zabbix的配置 [root@mb tools]# grep -n '^[a-Z]' /etc/zabbix/zabbix_server.conf LogFile=/var/log/zabbix/zabbix_server.log LogFileSize=0 PidFile=/run/zabbix/zabbix_server.pid SocketDir=/run/zabbix DBHost=localhost DBName=zabbix DBUser=zabbix DBPassword=123456 SNMPTrapperFile=/var/log/snmptrap/snmptrap.log Timeout=4 LogSlowQueries=3000 StatsAllowedIP=127.0.0.1 #修改好的配置 [root@mb ~]# cat /etc/zabbix/zabbix_server.conf LogFile=/var/log/zabbix/zabbix_server.log LogFileSize=0 PidFile=/run/zabbix/zabbix_server.pid SocketDir=/run/zabbix DBHost=localhost DBName=zabbix DBUser=zabbix DBPassword=123456 SNMPTrapperFile=/var/log/snmptrap/snmptrap.log Timeout=4 LogSlowQueries=3000 StatsAllowedIP=127.0.0.1 #启动 systemctl restart zabbix-server zabbix-agent nginx php-fpm systemctl enable zabbix-server zabbix-agent nginx php-fpm #查看日志 [root@mb ~]# tail -F /var/log/zabbix/zabbix_server.log 4998:20240610:202436.493 server #43 started [history poller #5] 4996:20240610:202436.494 server #41 started [history poller #3] 4995:20240610:202436.495 server #40 started [history poller #2] 4992:20240610:202436.496 server #38 started [alert syncer #1] 4990:20240610:202436.499 server #36 started [trapper #5] 4987:20240610:202436.501 server #33 started [trapper #2] 4986:20240610:202436.502 server #32 started [trapper #1] 4962:20240610:202436.567 server #8 started [preprocessing worker #1] 4963:20240610:202436.567 server #9 started [preprocessing worker #2] 4964:20240610:202436.568 server #10 started [preprocessing worker #3] #端口检查 [root@mb ~]# netstat -lntup Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 870/sshd tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 4925/zabbix_agentd tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 4953/zabbix_server tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1/systemd tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 4937/nginx: master tcp6 0 0 :::22 :::* LISTEN 870/sshd tcp6 0 0 :::10050 :::* LISTEN 4925/zabbix_agentd tcp6 0 0 :::10051 :::* LISTEN 4953/zabbix_server tcp6 0 0 :::33060 :::* LISTEN 3242/mysqld tcp6 0 0 :::3306 :::* LISTEN 3242/mysqld tcp6 0 0 :::111 :::* LISTEN 1/systemd udp 0 0 0.0.0.0:111 0.0.0.0:* 1/systemd udp 0 0 127.0.0.1:323 0.0.0.0:* 862/chronyd udp6 0 0 :::111 :::* 1/systemd udp6 0 0 ::1:323 :::* 862/chronyd
提示无法创建配置文件
手动配置配置文件
[root@mb ~]# cat /etc/zabbix/web/zabbix.conf.php <?php // Zabbix GUI configuration file. $DB['TYPE'] = 'MYSQL'; $DB['SERVER'] = 'localhost'; $DB['PORT'] = '0'; $DB['DATABASE'] = 'zabbix'; $DB['USER'] = 'zabbix'; $DB['PASSWORD'] = '123456'; // Schema name. Used for PostgreSQL. $DB['SCHEMA'] = ''; // Used for TLS connection. $DB['ENCRYPTION'] = false; $DB['KEY_FILE'] = ''; $DB['CERT_FILE'] = ''; $DB['CA_FILE'] = ''; $DB['VERIFY_HOST'] = false; $DB['CIPHER_LIST'] = ''; // Vault configuration. Used if database credentials are stored in Vault secrets manager. $DB['VAULT_URL'] = ''; $DB['VAULT_DB_PATH'] = ''; $DB['VAULT_TOKEN'] = ''; // Use IEEE754 compatible value range for 64-bit Numeric (float) history values. // This option is enabled by default for new Zabbix installations. // For upgraded installations, please read database upgrade notes before enabling this option. $DB['DOUBLE_IEEE754'] = true; // Uncomment and set to desired values to override Zabbix hostname/IP and port. // $ZBX_SERVER = ''; // $ZBX_SERVER_PORT = ''; $ZBX_SERVER_NAME = 'zabbix-test';#这里可以修改主机的名称 $IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG; // Uncomment this block only if you are using Elasticsearch. // Elasticsearch url (can be string if same url is used for all types). //$HISTORY['url'] = [ // 'uint' => 'http://localhost:9200', // 'text' => 'http://localhost:9200' //]; // Value types stored in Elasticsearch. //$HISTORY['types'] = ['uint', 'text']; // Used for SAML authentication. // Uncomment to override the default paths to SP private key, SP and IdP X.509 certificates, and to set extra settings. //$SSO['SP_KEY'] = 'conf/certs/sp.key'; //$SSO['SP_CERT'] = 'conf/certs/sp.crt'; //$SSO['IDP_CERT'] = 'conf/certs/idp.crt'; //$SSO['SETTINGS'] = [];
配置完成刷新
输入账号Admin,密码zabbix
配置中文显示
解决图形乱码的问题
上传到服务器
[root@mb zabbix_agentd.d]# cd /usr/share/zabbix/assets/fonts/ [root@mb fonts]# ls graphfont.ttf #备份原来的字体 [root@mb fonts]# mv graphfont.ttf graphfont.ttf.backup #上传新的字体微软雅黑的msyh.ttc [root@mb fonts]# ll total 19240 lrwxrwxrwx 1 root root 33 Jun 10 18:43 graphfont.ttf.backup -> /etc/alternatives/zabbix-web-font -rw-r--r-- 1 root root 19701556 Jun 1 23:13 msyh.ttc #拷贝字体 [root@mb fonts]# cp -r msyh.ttc graphfont.ttf [root@mb fonts]# ll total 38480 -rw-r--r-- 1 root root 19701556 Jun 10 21:04 graphfont.ttf lrwxrwxrwx 1 root root 33 Jun 10 18:43 graphfont.ttf.backup -> /etc/alternatives/zabbix-web-font -rw-r--r-- 1 root root 19701556 Jun 1 23:13 msyh.ttc
web页面检查
zabbix-agent部署
[root@mb tools]# rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/8/x86_64/zabbix-release-6.0-1.el8.noarch.rpm Retrieving https://repo.zabbix.com/zabbix/6.0/rhel/8/x86_64/zabbix-release-6.0-1.el8.noarch.rpm warning: /var/tmp/rpm-tmp.Yd14jA: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY Verifying... ################################# [100%] Preparing... ################################# [100%] Updating / installing... 1:zabbix-release-6.0-1.el8 ################################# [100%] #安装完成以后自动配置zabbix的yum源 [root@mb yum.repos.d]# cat /etc/yum.repos.d/zabbix.repo [zabbix] name=Zabbix Official Repository - $basearch baseurl=https://repo.zabbix.com/zabbix/6.0/rhel/8/$basearch/ enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591 [zabbix-non-supported] name=Zabbix Official Repository non-supported - $basearch baseurl=https://repo.zabbix.com/non-supported/rhel/8/$basearch/ enabled=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX gpgcheck=1 #安装zabbix-agent2 dnf install -y zabbix-agent2 #修改配置文件 #Server=172.168.10.21和ServerActive=172.168.10.21配置完成后zabbix-agent将变成主动模式 [root@mb yum.repos.d]# grep -n '^[a-Z]' /etc/zabbix/zabbix_agent2.conf 13:PidFile=/run/zabbix/zabbix_agent2.pid 32:LogFile=/var/log/zabbix/zabbix_agent2.log 43:LogFileSize=0 80:Server=172.168.10.21 133:ServerActive=172.168.10.21 144:Hostname=Zabbix server 281:Include=/etc/zabbix/zabbix_agent2.d/*.conf 302:PluginSocket=/run/zabbix/agent.plugin.sock 345:ControlSocket=/run/zabbix/agent.sock 490:Include=./zabbix_agent2.d/plugins.d/*.conf #启动 systemctl restart zabbix-agent2 #检查端口 [root@mb yum.repos.d]# lsof -i:10050 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME zabbix_ag 1930 zabbix 9u IPv6 32565 0t0 TCP *:zabbix-agent (LISTEN) #检查进程 [root@mb yum.repos.d]# ps -ef|grep zabbix zabbix 1930 1 0 21:51 ? 00:00:00 /usr/sbin/zabbix_agent2 -c /etc/zabbix/zabbix_agent2.conf #查看日志 [root@mb yum.repos.d]# tail -F /var/log/zabbix/zabbix_agent2.log 2024/06/10 21:51:24.206695 using plugin 'VFSDir' (built-in) providing following interfaces: exporter 2024/06/10 21:51:24.206702 using plugin 'VfsFs' (built-in) providing following interfaces: exporter 2024/06/10 21:51:24.206713 using plugin 'WebCertificate' (built-in) providing following interfaces: exporter, configurator 2024/06/10 21:51:24.206724 using plugin 'WebPage' (built-in) providing following interfaces: exporter, configurator 2024/06/10 21:51:24.206730 using plugin 'ZabbixAsync' (built-in) providing following interfaces: exporter 2024/06/10 21:51:24.206738 using plugin 'ZabbixStats' (built-in) providing following interfaces: exporter, configurator 2024/06/10 21:51:24.206743 lowering the plugin ZabbixSync capacity to 1 as the configured capacity 100 exceeds limits 2024/06/10 21:51:24.206749 using plugin 'ZabbixSync' (built-in) providing following interfaces: exporter 2024/06/10 21:51:24.206918 Plugin communication protocol version is 6.0.13 2024/06/10 21:51:24.206976 Zabbix Agent2 hostname: [Zabbix server]
zabbix的web界面添加主机