2、Zabbix规划及部署
2.1部署环境
2.1.1服务器系统
Centos 8/Centos 7
主机类型 | IP地址 |
---|---|
zabbix server | 10.0.0.11 |
zabbix 主动代理 | 10.0.0.21 |
zabbix 被动代理 | 10.0.0.31 |
mysql master | 10.0.0.10 |
mysql slave | 10.0.0.20 |
web server1 | 10.0.0.30 |
web server2 | 10.0.0.40 |
2.1.2系统环境
最小化安装操作系统,然后安装常用依赖包:
2.2yum/apt安装zabbix
产品手册:
https://www.zabbix.com/documentation/4.0/zh/manual
2.2.1安装zabbix server
https://www.zabbix.com/cn/download?zabbix=5.0&os_distribution=centos&os_version=8&db=mysql&ws=nginx
2.2.1.1yum/apt安装
#下载zabbix库
[root@zabbix-proxy-active ~]#rpm -Uvh https://repo.zabbix.com/zabbix/4.0/rhel/8/x86_64/zabbix-release-4.0-2.el8.noarch.rpm
[root@zabbix-proxy-active ~]#dnf clean all
#安装Zabbix server,Web前端,agent
[root@zabbix-proxy-active ~]#dnf install -y zabbix-server-mysql zabbix-web-mysql zabbix-agent
2.2.1.2准备数据库
#安装数据库(直接跑脚本-之前的文章有脚本)
[root@zabbix-mysql-master ~]# . mysql_5.7_8.0_Online.sh
[root@zabbix-mysql-master ~]# grep password /data/mysql/mysql.log
2021-12-16T09:10:29.215927Z 1 [Note] A temporary password is generated for root@localhost: no2TH>3:%u2r
2021-12-16T09:10:52.726556Z 2 [Note] Access denied for user 'root'@'localhost' (using password: NO)
#注意:查看一下网络连接(如果监听3306的地址不是任意地址那么需要修改一下配置文件指定地址为0.0.0.0)
[root@zabbix-mysql-master ~]# ss -ntl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 80 *:3306 *:*
LISTEN 0 128 *:111 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 [::]:111 [::]:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 100 [::1]:25 [::]:*
[root@zabbix-mysql-master ~]# vim /etc/my.cnf
[mysqld]
bind-address=0.0.0.0
#登录数据库
[root@zabbix-mysql-master ~]# mysql -uroot -p'no2TH>3:%u2r'
#修改掉默认的密码
mysql> alter user root@'localhost' identified by 'sunxiang';
Query OK, 0 rows affected (0.00 sec)
#创建数据库用于zabbix监控
mysql> create database zabbixtest character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
#创建zabbix用于连接数据库的账号,并且进行授权
mysql> create user zabbix@'10.0.0.%' identified by 'sunxiang';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on zabbixtest.* to zabbix@'10.0.0.%';
Query OK, 0 rows affected (0.00 sec)
2.2.1.3导入数据库
[root@zabbix-proxy-active ~]#zcat /usr/share/doc/zabbix-server-mysql/create.sql.gz | mysql -uzabbix -psunxiang -h10.0.0.10 zabbixtest
2.2.1.4连接测试
[root@zabbix-proxy-active ~]#yum install -y mysql-server #因为是centos8的系统我这边需要一个mysql客户端进行连接数据库服务器,所以就直接安装默认版本的mysql了,可以根据实际情况下载一个数据库客户端即可
[root@zabbix-proxy-active ~]#mysql -uzabbix -psunxiang -h10.0.0.10 zabbixtest
mysql: [Warning] Using a password on the command line interface can be insecure.
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 138
Server version: 5.7.34 MySQL Community Server (GPL)
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| zabbixtest |
+--------------------+
2 rows in set (0.00 sec)
mysql> show tables;
+----------------------------+
| Tables_in_zabbixtest |
+----------------------------+
| acknowledges |
| actions |
| alerts |
| application_discovery |
| application_prototype |
| application_template |
| applications |
| auditlog |
| auditlog_details |
| autoreg_host |
| conditions |
| config |
| corr_condition |
| corr_condition_group |
| corr_condition_tag |
| corr_condition_tagpair |
| corr_condition_tagvalue |
| corr_operation |
| correlation |
| dashboard |
| dashboard_user |
| dashboard_usrgrp |
| dbversion |
| dchecks |
| dhosts |
| drules |
| dservices |
| escalations |
| event_recovery |
| event_suppress |
| event_tag |
| events |
| expressions |
| functions |
| globalmacro |
| globalvars |
| graph_discovery |
| graph_theme |
| graphs |
| graphs_items |
| group_discovery |
| group_prototype |
| history |
| history_log |
| history_str |
| history_text |
| history_uint |
| host_discovery |
| host_inventory |
| hostmacro |
| hosts |
| hosts_groups |
| hosts_templates |
| housekeeper |
| hstgrp |
| httpstep |
| httpstep_field |
| httpstepitem |
| httptest |
| httptest_field |
| httptestitem |
| icon_map |
| icon_mapping |
| ids |
| images |
| interface |
| interface_discovery |
| item_application_prototype |
| item_condition |
| item_discovery |
| item_preproc |
| items |
| items_applications |
| maintenance_tag |
| maintenances |
| maintenances_groups |
| maintenances_hosts |
| maintenances_windows |
| mappings |
| media |
| media_type |
| opcommand |
| opcommand_grp |
| opcommand_hst |
| opconditions |
| operations |
| opgroup |
| opinventory |
| opmessage |
| opmessage_grp |
| opmessage_usr |
| optemplate |
| problem |
| problem_tag |
| profiles |
| proxy_autoreg_host |
| proxy_dhistory |
| proxy_history |
| regexps |
| rights |
| screen_user |
| screen_usrgrp |
| screens |
| screens_items |
| scripts |
| service_alarms |
| services |
| services_links |
| services_times |
| sessions |
| slides |
| slideshow_user |
| slideshow_usrgrp |
| slideshows |
| sysmap_element_trigger |
| sysmap_element_url |
| sysmap_shape |
| sysmap_url |
| sysmap_user |
| sysmap_usrgrp |
| sysmaps |
| sysmaps_elements |
| sysmaps_link_triggers |
| sysmaps_links |
| tag_filter |
| task |
| task_acknowledge |
| task_check_now |
| task_close_problem |
| task_remote_command |
| task_remote_command_result |
| timeperiods |
| trends |
| trends_uint |
| trigger_depends |
| trigger_discovery |
| trigger_tag |
| triggers |
| users |
| users_groups |
| usrgrp |
| valuemaps |
| widget |
| widget_field |
+----------------------------+
144 rows in set (0.00 sec)
2.2.1.5修改zabbix server配置文件
[root@zabbix-proxy-active ~]#cat /etc/zabbix/zabbix_server.conf | grep -Ev '^#|^$'
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
SocketDir=/var/run/zabbix
DBHost=10.0.0.10 #修改为mysql服务器地址
DBName=zabbixtest #修改为mysql服务器上创建的用于监控的数据库名
DBUser=zabbix #连接数据库的用户名
DBPassword=sunxiang #连接数据库的密码
2.2.1.6修改PHP配置文件
[root@zabbix-proxy-active ~]#vim /etc/php-fpm.d/zabbix.conf
; php_value[date.timezone] = Asia/Shanghai #修改时区
2.2.1.7重启服务
[root@zabbix-proxy-active ~]#systemctl enable --now zabbix-server zabbix-agent httpd php-fpm
#查看网络状态 (10051为默认端口)
[root@zabbix-proxy-active ~]#ss -ntl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:111 0.0.0.0:*
LISTEN 0 32 192.168.122.1:53 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 5 127.0.0.1:631 0.0.0.0:*
LISTEN 0 100 127.0.0.1:25 0.0.0.0:*
LISTEN 0 128 127.0.0.1:6010 0.0.0.0:*
LISTEN 0 128 127.0.0.1:6011 0.0.0.0:*
LISTEN 0 128 0.0.0.0:10050 0.0.0.0:*
LISTEN 0 128 0.0.0.0:10051 0.0.0.0:*
LISTEN 0 128 [::]:111 [::]:*
LISTEN 0 128 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 5 [::1]:631 [::]:*
LISTEN 0 100 [::1]:25 [::]:*
LISTEN 0 128 [::1]:6010 [::]:*
LISTEN 0 128 [::1]:6011 [::]:*
LISTEN 0 128 [::]:10050 [::]:*
LISTEN 0 128 [::]:10051 [::]:*
#查看日志
[root@zabbix-proxy-active ~]#tail /var/log/zabbix/zabbix_server.log
33956:20211216:102425.191 server #24 started [poller #3]
33961:20211216:102425.191 server #29 started [trapper #2]
33962:20211216:102425.192 server #30 started [trapper #3]
33964:20211216:102425.192 server #32 started [trapper #5]
33934:20211216:102425.193 server #2 started [alert manager #1]
33945:20211216:102425.193 server #13 started [discoverer #1]
33935:20211216:102425.194 server #3 started [alerter #1]
33954:20211216:102425.194 server #22 started [poller #1]
33940:20211216:102425.288 server #8 started [preprocessing worker #2]
33939:20211216:102425.288 server #7 started [preprocessing worker #1]
2.2.1.8web访问
http://10.0.0.21/zabbix #注意是zabbix服务器地址,不是mysql数据库地址
"/etc/zabbix/web/zabbix.conf.php"
这里出现错误了
修改配置文件
[root@zabbix-proxy-active ~]#vim /etc/zabbix/web/zabbix.conf.php
$ZBX_SERVER = '10.0.0.21';
#重启http服务
[root@zabbix-proxy-active ~]#systemctl restart httpd.service
刷新web页面
2.3编译安装zabbix
2.3.1下载源码包
[root@zabbix-server ~]#wget https://cdn.zabbix.com/zabbix/sources/stable/4.0/zabbix-4.0.36.tar.gz
2.3.2解决依赖关系
#centos
[root@zabbix-server ~]#yum install vim iotop bc gcc gcc-c++ glibc glibc-devel pcre pcre-devel openssl openssl-devel zip unzip zlib-devel net-tools lrzsz tree ntpdate telnet lsof tcpdump wget libevent libevent-devel
[root@zabbix-server ~]#yum install -y gcc libxml2-devel net-snmp net-snmp-devel curl curl-devel php php-bcmath php-mbstring mariadb mariadb-devel
#Ubuntu
[root@zabbix-server ~]#apt update
[root@zabbix-server ~]#apt-get install apache2 apache2-bin apache2-data apache2-utils fontconfig-config fonts-dejavu-core fping libapache2-mod-php libapache2-mod-php7.2 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libfontconfig1 libgd3 libiksemel3 libjbig0 libjpeg-turbo8 libjpeg8 liblua5.2-0 libodbc1 libopenipmi0 libsensors4 libsnmp-base libsnmp30 libsodium23 libssh2-1 libtiff5 libwebp6 libxpm4 php-bcmath php-common php-gd php-ldap php-mbstring php-mysql php-xml php7.2-bcmath php7.2-cli php7.2-common php7.2-gd php7.2-json php7.2-ldap php7.2-mbstring php7.2-mysql php7.2-opcache php7.2-readline php7.2-xml snmpd ssl-cert ttf-dejavu-core libmysqlclient-dev libxml2-dev libxml2 snmp libsnmp-dev libevent-dev openjdk-8-jdk curl libcurl4-openssl-dev
2.3.3编译安装zabbix
#解压
[root@zabbix-server ~]#mv zabbix-4.0.36.tar.gz /usr/local/src/
[root@zabbix-server ~]#cd /usr/local/src/
[root@zabbix-server /usr/local/src]#tar -xvf zabbix-4.0.36.tar.gz
[root@zabbix-server /usr/local/src]#ll
total 17212
drwxr-xr-x 13 sx sx 4096 Nov 29 16:53 zabbix-4.0.36
-rw-r--r-- 1 root root 17619115 Nov 29 17:03 zabbix-4.0.36.tar.gz
#开始编译安装
[root@zabbix-server /usr/local/src]cd zabbix-4.0.36/
[root@zabbix-server /usr/local/src/zabbix-4.0.36]#./configure --prefix=/apps/zabbix_server --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2 --enable-java
.
.
.
Configuration:
Detected OS: linux-gnu
Install path: /usr/local
Compilation arch: linux
Compiler: cc
Compiler flags: -g -O2
Library-specific flags:
database: -I/usr/include/mysql -m64
libXML2: -I/usr/include/libxml2
Net-SNMP: -I. -I/usr/include
Enable server: yes
Server details:
With database: MySQL
WEB Monitoring: cURL
SSL certificates: /usr/local/share/zabbix/ssl/certs
SSL keys: /usr/local/share/zabbix/ssl/keys
Native Jabber: no
SNMP: yes
IPMI: no
SSH: no
TLS: no
ODBC: no
Linker flags: -L/usr/lib64/mysql -L/usr/lib64 -rdynamic
Libraries: -lmysqlclient -lpthread -ldl -lz -lssl -lcrypto -lresolv -lm -lrt -lxml2 -lnetsnmp -lz -lpthread -levent -lcurl -lm -ldl -lresolv -lpcre
Configuration file: /usr/local/etc/zabbix_server.conf
External scripts: /usr/local/share/zabbix/externalscripts
Alert scripts: /usr/local/share/zabbix/alertscripts
Modules: /usr/local/lib/modules
Enable proxy: no
Enable agent: yes
Agent details:
TLS: no
Linker flags: -rdynamic
Libraries: -lz -lpthread -lcurl -lm -ldl -lresolv -lpcre
Configuration file: /usr/local/etc/zabbix_agentd.conf
Modules: /usr/local/lib/modules
Enable Java gateway: yes
Java gateway details:
Java compiler: javac
Java archiver: jar
LDAP support: no
IPv6 support: yes
***********************************************************
* Now run 'make install' *
* *
* Thank you for using Zabbix! *
* <http://www.zabbix.com> *
***********************************************************
#根据Makefile⽂文件⽣生成相应的模块
[root@zabbix-server /usr/local/src/zabbix-4.0.36]#make -j 2
.
.
.
make[1]: Entering directory '/usr/local/src/zabbix-4.0.36/man'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/usr/local/src/zabbix-4.0.36/man'
Making all in misc
make[1]: Entering directory '/usr/local/src/zabbix-4.0.36/misc'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/usr/local/src/zabbix-4.0.36/misc'
make[1]: Entering directory '/usr/local/src/zabbix-4.0.36'
make[1]: Nothing to be done for 'all-am'.
make[1]: Leaving directory '/usr/local/src/zabbix-4.0.36'
#将生成的模块和文件复制到相应的⽬录
[root@zabbix-server /usr/local/src/zabbix-4.0.36]#make install
.
.
.
make[2]: Leaving directory '/usr/local/src/zabbix-4.0.36/man'
make[1]: Leaving directory '/usr/local/src/zabbix-4.0.36/man'
Making install in misc
make[1]: Entering directory '/usr/local/src/zabbix-4.0.36/misc'
make[2]: Entering directory '/usr/local/src/zabbix-4.0.36/misc'
make[2]: Nothing to be done for 'install-exec-am'.
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/usr/local/src/zabbix-4.0.36/misc'
make[1]: Leaving directory '/usr/local/src/zabbix-4.0.36/misc'
make[1]: Entering directory '/usr/local/src/zabbix-4.0.36'
make[2]: Entering directory '/usr/local/src/zabbix-4.0.36'
make[2]: Nothing to be done for 'install-exec-am'.
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/usr/local/src/zabbix-4.0.36'
make[1]: Leaving directory '/usr/local/src/zabbix-4.0.36'
#查看定义的目录下是否生成文件
[root@zabbix-server ~]#ls /apps/zabbix_server/
bin etc lib sbin share
2.3.4准备数据库
#在数据库服务器上创建zabbix server用于连接的账号,并且进行授权
mysql> create user zabbix_server@'10.0.0.%' identified by 'sunxiang';
Query OK, 0 rows affected (0.03 sec)
mysql> grant all on zabbix_server.* to zabbix_server@'10.0.0.%';
Query OK, 0 rows affected (0.00 sec)
#创建zabbix server用于管理的数据库
mysql> create database zabbix_server character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
#在zabbix server上进行连接测试
[root@zabbix-server ~]#yum install -y mysql-server
[root@zabbix-server ~]#mysql -u'zabbix_server' -psunxiang -h10.0.0.10 zabbix_server
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1487
Server version: 5.7.34 MySQL Community Server (GPL)
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| zabbix_server |
+--------------------+
2 rows in set (0.01 sec)
mysql> show tables;
Empty set (0.00 sec)
2.3.5导入数据库
安装包中有自带的数据库,也可以下载官方提供的
SQL脚本:https://www.zabbix.com/documentation/4.0/zh/manual/appendix/install/db_scripts
SQL脚本:用于创建数据库schema和插入dataset。
Zabbix proxy 数据库只需要数据库 schema
Zabbix server 数据库在建立数据库 schema 后,还需要 dataset。
#这里就和yum安装不一样了,这里是根据需要导入编译安装包中带的数据库脚本
[root@zabbix-server ~]#cd /usr/local/src/zabbix-4.0.36/database/mysql/
[root@zabbix-server /usr/local/src/zabbix-4.0.36/database/mysql]#ls
data.sql images.sql Makefile Makefile.am Makefile.in schema.sql
[root@zabbix-server /usr/local/src/zabbix-4.0.36/database/mysql]#
[root@zabbix-server /usr/local/src/zabbix-4.0.36/database/mysql]#mysql -u'zabbix_server' -psunxiang -h10.0.0.10 zabbix_server < schema.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@zabbix-server /usr/local/src/zabbix-4.0.36/database/mysql]#mysql -u'zabbix_server' -psunxiang -h10.0.0.10 zabbix_server < images.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@zabbix-server /usr/local/src/zabbix-4.0.36/database/mysql]#mysql -u'zabbix_server' -psunxiang -h10.0.0.10 zabbix_server < data.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
2.3.6数据库验证
[root@zabbix-server /usr/local/src/zabbix-4.0.36/database/mysql]#mysql -u'zabbix_server' -psunxiang -h10.0.0.10 zabbix_server
mysql: [Warning] Using a password on the command line interface can be insecure.
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1515
Server version: 5.7.34 MySQL Community Server (GPL)
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show tables;
+----------------------------+
| Tables_in_zabbix_server |
+----------------------------+
| acknowledges |
| actions |
| alerts |
| application_discovery |
| application_prototype |
| application_template |
| applications |
| auditlog |
| auditlog_details |
| autoreg_host |
| conditions |
| config |
| corr_condition |
| corr_condition_group |
| corr_condition_tag |
| corr_condition_tagpair |
| corr_condition_tagvalue |
| corr_operation |
| correlation |
| dashboard |
#这里就不一一列出了,反正是导入成功了
2.3.7编辑zabbix server配置文件
[root@zabbix-server ~]#vim /apps/zabbix_server/etc/zabbix_server.conf
[root@zabbix-server ~]#cat /apps/zabbix_server/etc/zabbix_server.conf | grep -Ev '^#|^$'
LogFile=/tmp/zabbix_server.log
DBHost=10.0.0.10
DBName=zabbix_server
DBUser=zabbix_server
DBPassword=sunxiang
Timeout=4
LogSlowQueries=3000
2.3.8启动zabbix server
#创建用户和组
[root@zabbix-server ~]#groupadd zabbix
[root@zabbix-server ~]#useradd -g zabbix zabbix
#启动zabbix server服务
#[root@zabbix-server ~]#/apps/zabbix_server/sbin/zabbix_server -c /apps/zabbix_server/etc/zabbix_server.conf
#查看网络监听状态
[root@zabbix-server ~]#ss -ntl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 127.0.0.1:6010 0.0.0.0:*
LISTEN 0 128 127.0.0.1:6011 0.0.0.0:*
LISTEN 0 128 0.0.0.0:10051 0.0.0.0:*
LISTEN 0 128 0.0.0.0:111 0.0.0.0:*
LISTEN 0 32 192.168.122.1:53 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 5 127.0.0.1:631 0.0.0.0:*
LISTEN 0 100 127.0.0.1:25 0.0.0.0:*
LISTEN 0 128 [::1]:6010 [::]:*
LISTEN 0 128 [::1]:6011 [::]:*
LISTEN 0 128 [::]:111 [::]:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 5 [::1]:631 [::]:*
LISTEN 0 100 [::1]:25 [::]:*
2.3.9配置web界面
2.3.9.1拷贝web界面程序
#创建web访问时候的目录
[root@zabbix-server ~]#mkdir /var/www/html/zabbix
#找php文件
[root@zabbix-server ~]#cd /usr/local/src/zabbix-4.0.36/
[root@zabbix-server /usr/local/src/zabbix-4.0.36]#ls
aclocal.m4 compile config.sub depcomp m4 misc src
AUTHORS conf configure frontends Makefile missing
bin config.guess configure.ac include Makefile.am NEWS
build config.log COPYING INSTALL Makefile.in README
ChangeLog config.status database install-sh man sass
[root@zabbix-server /usr/local/src/zabbix-4.0.36]#cd frontends/php/
#将php文件复制到指定的web目录
[root@zabbix-server /usr/local/src/zabbix-4.0.36/frontends/php]#cp -a . /var/www/html/zabbix/
2.3.9.2访问web界面
http://10.0.0.11/zabbix
2.3.9.3web界面报错
2.3.9.4解决报错
#查看报错的信息缺少什么就下载什么
[root@zabbix-server ~]#yum install -y php-gd.x86_64 php-mysqlnd.x86_64 php-xml.x86_64 php-snmp.x86_64 php-ldap
#查看报错php与zabbix需求不符合的参数手动修改
[root@zabbix-server ~]#vim /etc/php.ini
#修改完成后重启服务
[root@zabbix-server ~]#systemctl restart httpd.service
[root@zabbix-server ~]#systemctl restart php-fpm.service
ok全部绿了
2.3.9.5配置数据库
2.3.9.6zabbix server配置
2.3.9.7信息确认
2.3.9.8创建配置文件
需要手动下载配置文件并上传至zabbix server的/var/www/html/zabbix/conf/zabbix.conf.php路径
[root@zabbix-server ~]#mv zabbix.conf.php /var/www/html/zabbix/conf/
2.3.9.9刷新页面
2.3.9.10登录
2.3.10启动zabbix agent服务
[root@zabbix-server ~]#/apps/zabbix_server/sbin/zabbix_agentd
[root@zabbix-server ~]#ss -ntl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 127.0.0.1:6010 0.0.0.0:*
LISTEN 0 128 127.0.0.1:6011 0.0.0.0:*
LISTEN 0 128 0.0.0.0:10050 0.0.0.0:*
LISTEN 0 128 0.0.0.0:10051 0.0.0.0:*
LISTEN 0 128 0.0.0.0:111 0.0.0.0:*
LISTEN 0 32 192.168.122.1:53 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 5 127.0.0.1:631 0.0.0.0:*
LISTEN 0 100 127.0.0.1:25 0.0.0.0:*
LISTEN 0 128 [::1]:6010 [::]:*
LISTEN 0 128 [::1]:6011 [::]:*
LISTEN 0 128 [::]:111 [::]:*
LISTEN 0 128 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 5 [::1]:631 [::]:*
LISTEN 0 100 [::1]:25 [::]:*
2.3.11zabbix server与agent启动文件
2.3.11.1zabbix server启动脚本
#先停止当前zabbix server进程
[root@zabbix-server ~]#lsof -i:10051
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
zabbix_se 83304 zabbix 7u IPv4 262840 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 83305 zabbix 7u IPv4 262840 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 83306 zabbix 7u IPv4 262840 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 83307 zabbix 7u IPv4 262840 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 83308 zabbix 7u IPv4 262840 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 83309 zabbix 7u IPv4 262840 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 83310 zabbix 7u IPv4 262840 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 83311 zabbix 7u IPv4 262840 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 83312 zabbix 7u IPv4 262840 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 83313 zabbix 7u IPv4 262840 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 83314 zabbix 7u IPv4 262840 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 83315 zabbix 7u IPv4 262840 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 83316 zabbix 7u IPv4 262840 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 83317 zabbix 7u IPv4 262840 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 83318 zabbix 7u IPv4 262840 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 83319 zabbix 7u IPv4 262840 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 83320 zabbix 7u IPv4 262840 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 83321 zabbix 7u IPv4 262840 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 83322 zabbix 7u IPv4 262840 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 83323 zabbix 7u IPv4 262840 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 83324 zabbix 7u IPv4 262840 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 83325 zabbix 7u IPv4 262840 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 83326 zabbix 7u IPv4 262840 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 83327 zabbix 7u IPv4 262840 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 83328 zabbix 7u IPv4 262840 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 83329 zabbix 7u IPv4 262840 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 83330 zabbix 7u IPv4 262840 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 83331 zabbix 7u IPv4 262840 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 83332 zabbix 7u IPv4 262840 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 83333 zabbix 7u IPv4 262840 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 83334 zabbix 7u IPv4 262840 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 83335 zabbix 7u IPv4 262840 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 83336 zabbix 7u IPv4 262840 0t0 TCP *:zabbix-trapper (LISTEN)
zabbix_se 83337 zabbix 7u IPv4 262840 0t0 TCP *:zabbix-trapper (LISTEN)
[root@zabbix-server ~]#pkill zabbix_server
[root@zabbix-server ~]#lsof -i:10051
#创建启动脚本
[root@zabbix-server ~]#cat /etc/systemd/system/zabbix-server.service
[Unit]
Description=Zabbix Server
After=syslog.target
After=network.target
[Service]
Environment="CONFFILE=/apps/zabbix_server/etc/zabbix_server.conf"
EnvironmentFile=-/etc/default/zabbix-server
Type=forking
Restart=on-failure
PIDFile=/tmp/zabbix_server.pid
KillMode=control-group
ExecStart=/apps/zabbix_server/sbin/zabbix_server -c $CONFFILE
ExecStop=/bin/kill -SIGTERM $MAINPID
RestartSec=10s
TimeoutSec=infinity
[Install]
WantedBy=multi-user.target
#启动服务并加入开机启动
[root@zabbix-server ~]#systemctl enable --now zabbix-server.service
[root@zabbix-server ~]#ss -ntl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 127.0.0.1:6010 0.0.0.0:*
LISTEN 0 128 127.0.0.1:6011 0.0.0.0:*
LISTEN 0 128 0.0.0.0:10050 0.0.0.0:*
LISTEN 0 128 0.0.0.0:10051 0.0.0.0:*
LISTEN 0 128 0.0.0.0:111 0.0.0.0:*
LISTEN 0 32 192.168.122.1:53 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 5 127.0.0.1:631 0.0.0.0:*
LISTEN 0 100 127.0.0.1:25 0.0.0.0:*
LISTEN 0 128 [::1]:6010 [::]:*
LISTEN 0 128 [::1]:6011 [::]:*
LISTEN 0 128 [::]:111 [::]:*
LISTEN 0 128 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 5 [::1]:631 [::]:*
LISTEN 0 100 [::1]:25 [::]:*
2.3.11.2zabbix agent启动脚本
#先停止当前zabbix_agent进程
[root@zabbix-server ~]#pkill zabbix_agentd
#创建启动脚本
[root@zabbix-server ~]#cat /etc/systemd/system/zabbix-agent.service
[Unit]
Description=Zabbix Agent
After=syslog.target
After=network.target
[Service]
Environment="CONFFILE=apps/zabbix_server/etc/zabbix_agentd.conf"
EnvironmentFile=-/etc/default/zabbix-agent
Type=forking
Restart=on-failure
PIDFile=/tmp/zabbix_agentd.pid
KillMode=control-group
ExecStart=/apps/zabbix_server/sbin/zabbix_agentd -c $CONFFILE
ExecStop=/bin/kill -SIGTERM $MAINPID
RestartSec=10s
User=zabbix
Group=zabbix
[Install]
WantedBy=multi-user.target
#启动服务并加入开机启动
[root@zabbix-server ~]#systemctl enable --now zabbix-agent.service
2.4web界面中文菜单环境
2.4.1中文系统无法选择
由于系统目前未安装中文语言环境所以无法选择中文显示
2.4.2Centos系统安装中文语言环境
#安装简体中文语言环境
[root@zabbix-server ~]#yum install -y langpacks-zh_CN.noarch
#修改本地语言配置文件
[root@zabbix-server ~]#vim /etc/locale.conf
LANG="zh_CN.UTF-8"
LANGUAGE="zh_CN.GB18030:zh_CN.GB2312:zh_CN"
SUPPORTED="zh_CN.GB18030:zh_CN:zh:en_US.UTF-8:en_US:en"
SYSFONT="lat0-sun16"
#重启服务器
[root@zabbix-server ~]#reboot
2.4.3验证web界面
此时可以选择中文了
此时虽然是中文显示的但是监控项中有些参数显示乱码
2.5监控项与乱码
系统有些监控项部分显示有乱码,是由于web界面显示为中文但是系统没有相关字体支持,因此需要相关字体的支持才能正常显示
2.5.1上传字体文件
2.5.1.1在windows拷贝字体
在Windows上找到控制面板–>字体–>楷体(或者其他个人喜欢的中文字体),然后将字体拷贝到windows系统其他目录,比如拷贝至windows当前用户的桌面。
2.5.1.2上传字体到zabbix web目录
[root@zabbix-server ~]#mv simkai.ttf /var/www/html/zabbix/assets/fonts/
[root@zabbix-server ~]#chown zabbix.zabbix /var/www/html/zabbix/assets/fonts/simkai.ttf
2.5.1.3修改zabbix文件调用新字体
[root@zabbix-server ~]#vim /var/www/html/zabbix/include/defines.inc.php
#将原先的DejaVuSans 修改为simkai
#修改后如下
[root@zabbix-server ~]#cat /var/www/html/zabbix/include/defines.inc.php | grep simkai
define('ZBX_GRAPH_FONT_NAME', 'simkai'); // font file name
define('ZBX_FONT_NAME', 'simkai');
2.5.1.4验证字体是否生效
通常不需要重启zabbix及apache,修改后的字体文件即可直接生效。