1、基础信息
信息
版本
centos
7.9
zbbix
zabbix6.4
2、下载zabbix 1 sudo wget https://cdn.zabbix.com/zabbix/sources/stable/7.0/zabbix-7.0.4.tar.gz
3、解压 1 tar xf zabbix-6.4.0.tar.gz -C /usr/local/src
4、取消c99模式 1 export CFLAGS="-std=gnu99"
5、编译 1 2 3 sudo apt -y install libsnmp-dev libevent-dev libpcre3-dev./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-postgresql=/usr/local/postgresql/bin/pg_config --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2
6、安装 1 make && make install 3^9ecewg&mUQnCa7
7、导入zabbix数据库 1 2 3 4 5 6 7 8 create role zabbix with login;alter user zabbix with password 'D2f8pUGYNmTKCqvd' ;create database zabbix with template template0 encoding 'UTF8' ;grant all on database zabbix to zabbix;/ usr/ local / src/ zabbix-6.4 .0 / database/ postgresql/ schema.sql/ usr/ local / src/ zabbix-6.4 .0 / database/ postgresql/ images.sql/ usr/ local / src/ zabbix-6.4 .0 / database/ postgresql/ data.sql
8、拷贝应用程序到指定目录 1 cp -r /usr/local/src/zabbix-6.4.0/ui /webapps/zabbix/
9、配置server 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 cat <<eof |tee >/usr/local/nginx/conf.d/zabbix.conf server { listen 80; server_name _; root /webapps/zabbix; index index.htm index.html index.php; location ~ \.php$ { include fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } } eof
10、页面访问
11、配置zaibbix_server 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 cat << eof |sudo tee /usr/local/zabbix-7.0.4/etc/zabbix_server.conf LogFile=/usr/local/zabbix-7.0.4/log/zabbix_server.log PidFile=/usr/local/zabbix-7.0.4/zabbix_server.pid DBName=zabbix DBUser=zabbix DBPort=2365 DBPassword=n422tx%KVY87QthM DBSocket=/data/mysql/mysql.sock StartPollers=10 Timeout=4 AlertScriptsPath=/usr/local/zabbix-7.0.4/alertscripts FpingLocation=/usr/sbin/fping LogSlowQueries=3000 eof cat << eof |sudo tee /usr/lib/systemd/system/zabbix-server.service [Unit] Description=Zabbix Server with MySQL DB After=syslog.target network.target mysqld.service [Service] Type=forking ExecStart=/usr/local/zabbix-7.0.4/sbin/zabbix_server -c /usr/local/zabbix-7.0.4/etc/zabbix_server.conf User=zabbix PIDFile=/usr/local/zabbix-7.0.4/zabbix_server.pid ExecStop=/bin/kill -s QUIT \$MAINPID ExecReload=/bin/kill -s HUP \$MAINPID [Install] WantedBy=multi-user.target eof
11、zabbix客户端安装 1 ./configure --prefix=/usr/local/zabbix --enable-agent --enable-java
12、make
13、修改配置文件 1 2 3 4 5 6 7 8 9 10 11 12 13 cat <<eof |sudo tee /usr/local/zabbix/etc/zabbix_agentd.conf LogFile=/usr/local/zabbix/zabbix_agentd.log PidFile=/usr/local/zabbix/zabbix_agentd.pid EnableRemoteCommands=1 Server=192.168.10.132 ServerActive=192.168.10.132 Hostname=zabbix-66.203.155.215 AllowRoot=1 UnsafeUserParameters=1 HostMetadataItem=system.uname UserParameter=system_info[*],/usr/local/zabbix/alertscripts/system_info.sh \$1 UserParameter=ng_status[*],/usr/local/zabbix/alertscripts/ng_status.sh \$1 eof
14、添加到系统服务 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 cat <<eof |sudo tee /usr/lib/systemd/system/zabbix-agent.service [Unit] Description=Zabbix Agent After=syslog.target network.target [Service] WorkingDirectory=/usr/local/zabbix Environment='CONFFILE=/usr/local/zabbix/etc/zabbix_agentd.conf' User=xinbo Type=forking Restart=on-failure PIDFile=/usr/local/zabbix/zabbix_agentd.pid KillMode=mixed ExecStart=/usr/local/zabbix/sbin/zabbix_agentd -c \$CONFFILE ExecStop=/bin/kill -s QUIT \$MAINPID EeecReload=/bin/kill -s HUP \$MAINPID [Install] WantedBy=multi-user.target eof
15、zabbix中文乱码解决 找到C:\Windows\Fonts 复制字体。上传到/webapps/zabbix/assets/fonts/(该处是自己zabbix ui目录下)
1 2 3 define('ZBX_GRAPH_FONT_NAME', 'DejaVuSans') 修改为 define('ZBX_GRAPH_FONT_NAME', 'simsun')
16、主机监控