CentOS7安装部署Zabbix5.0

1 关闭防火墙并开机不启动

setenforce 0

sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config

systemctl stop firewalld.service

systemctl disable firewalld.service
 

2 安装部署 Zabbix 服务端

安装之前需要先搭建LAMP环境

  2.1 安装配置 Zabbix 专用 yum 源

warning: /var/tmp/rpm-tmp.yvWl8w: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
[root@centos7-83 ~]# yum install -y zabbix-server-mysql zabbix-web-mysql zabbix-agent
出现报错
0
原因:没有安装mysql-community-libs-compat
安装mysql-community-libs-compat
[root@centos7-83 ~]# rpm -ivh mysql-community-libs-compat-5.7.38-1.el7.x86_64.rpm
warning: mysql-community-libs-compat-5.7.38-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-libs-compat-5.7.3################################# [100%]
 

 2.2 安装 Zabbix 服务端组件

yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-get --nogpgcheck
出现报错
Transaction check error:
    file /etc/zabbix/zabbix_agentd.conf conflicts between attempted installs of zabbix-agent-5.0.24-1.el7.x86_64 and zabbix40-4.0.39-1.el7.x86_64
Error Summary
0
原因:zabbix版本冲突,是因为epel源里也有zabbix,epel源改名即可解决,重新执行 Zabbix 服务端组件命令即可
cd /etc/yum.repos.d/
mv epel.repo epel.repo.bak
重新执行
yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-get --nogpgcheck
 

   2.3 安装 Zabbix 前端组件

yum -y install centos-release-scl
编辑zabbix源文件,将zabbix-frontend配置项enable设置为1
vim /etc/yum.repos.d/zabbix.repo
[zabbix-frontend]
name=Zabbix Official Repository frontend - $basearch
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591

   2.4 安装 Zabbix 前端页面、初始数据库、php及httpd组件

yum -y install zabbix-web-mysql-scl zabbix-apache-conf-scl
 

  2.5 登录MySQL授权

mysql -u root -p
#创建zabbix数据库
mysql> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
#创建zabbix数据库用户和密码(密码需满足复杂度要求)
mysql> create user zabbix@localhost identified by 'Zabbix@123';
Query OK, 0 rows affected (0.01 sec)
#设置zabbix用户对zabbix数据库具有本地管理权限
mysql> grant all privileges on zabbix.* to zabbix@localhost;
Query OK, 0 rows affected (0.00 sec)

   2.6 开启远程访问

mysql> update user set host='%' where user='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> update user set host='%' where user='zabbix';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
 
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> quit;
Bye

    2.7 导入初始数据

zcat /usr/share/doc/zabbix-server-mysql-5.0.24/create.sql.gz | mysql -uzabbix -p'Zabbix@123' zabbix
 

3 初始化 Zabbix 配置

   3.1 配置数据库连接

vim /etc/zabbix/zabbix_server.conf
根据实际情况配置数据库连接
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=Zabbix@123
DBPort=3306
 

  3.2 设置时区

vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
去掉 php_value[date.timezone] = 前面的分号,填上海时区
php_value[date.timezone] = Asia/Shanghai
 

  3.3 设置字体,避免前台中文乱码

yum -y install wqy-microhei-fonts
mv /usr/share/fonts/dejavu/DejaVuSans.ttf /usr/share/fonts/dejavu/DejaVuSans.ttf.bak
cp -f /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/share/fonts/dejavu/DejaVuSans.ttf
 

   3.4 设置 Zabbix 及其相关服务开机启动

 

systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm

 

systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm
 
执行第一条命令的时候报错如下:
0
单独查rh-php72-php-fpm的状态
[root@centos7-83 ~]# systemctl status rh-php72-php-fpm
● rh-php72-php-fpm.service - The PHP FastCGI Process Manager
Loaded: loaded (/usr/lib/systemd/system/rh-php72-php-fpm.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Sun 2022-06-19 21:49:34 CST; 2min 23s ago
Process: 7448 ExecStart=/opt/rh/rh-php72/root/usr/sbin/php-fpm --nodaemonize (code=exited, status=78)
Main PID: 7448 (code=exited, status=78)
Jun 19 21:49:34 centos7-83 systemd[1]: Starting The PHP FastCGI Process Manager...
Jun 19 21:49:34 centos7-83 php-fpm[7448]: [19-Jun-2022 21:49:34] ERROR: unable to bind listening socket for address '127.0.0.1:9000...se (98)
Jun 19 21:49:34 centos7-83 php-fpm[7448]: [19-Jun-2022 21:49:34] ERROR: FPM initialization failed
Jun 19 21:49:34 centos7-83 systemd[1]: rh-php72-php-fpm.service: main process exited, code=exited, status=78/n/a
Jun 19 21:49:34 centos7-83 systemd[1]: Failed to start The PHP FastCGI Process Manager.
Jun 19 21:49:34 centos7-83 systemd[1]: Unit rh-php72-php-fpm.service entered failed state.
Jun 19 21:49:34 centos7-83 systemd[1]: rh-php72-php-fpm.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
查9000端口占用情况
[root@centos7-83 ~]# netstat -antup | grep 9000
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 927/php-fpm: master
[root@centos7-83 ~]# killall php-fpm
-bash: killall: command not found
安装killall命令
[root@centos7-83 ~]# yum install killall
[root@centos7-83 ~]# killall php-fpm
[root@centos7-83 ~]# systemctl restart rh-php72-php-fpm
[root@centos7-83 ~]# systemctl status rh-php72-php-fpm
● rh-php72-php-fpm.service - The PHP FastCGI Process Manager
Loaded: loaded (/usr/lib/systemd/system/rh-php72-php-fpm.service; enabled; vendor preset: disabled)
Active: active (running) since Sun 2022-06-19 21:57:00 CST; 7s ago
Main PID: 8217 (php-fpm)
Status: "Ready to handle connections"
Tasks: 11
Memory: 27.6M
CGroup: /system.slice/rh-php72-php-fpm.service
├─8217 php-fpm: master process (/etc/opt/rh/rh-php72/php-fpm.conf)
├─8219 php-fpm: pool www
├─8220 php-fpm: pool www
├─8221 php-fpm: pool www
├─8222 php-fpm: pool www
├─8223 php-fpm: pool www
├─8224 php-fpm: pool zabbix
├─8225 php-fpm: pool zabbix
├─8226 php-fpm: pool zabbix
├─8227 php-fpm: pool zabbix
└─8228 php-fpm: pool zabbix
Jun 19 21:57:00 centos7-83 systemd[1]: Starting The PHP FastCGI Process Manager...
Jun 19 21:57:00 centos7-83 systemd[1]: Started The PHP FastCGI Process Manager.
[root@centos7-83 ~]# netstat -antup | grep 9000
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 8217/php-fpm: maste
 

4  初始化安装界面

浏览器访问 http://你的IP/zabbix
0
 
连续2次 Next step,输入MySQL密码
0
一直 Next step 就好了,默认用户名是Admin,密码是zabbix
汉化
0
 
 
0
设置好之后就变成中文界面了

 

 

到这里 Zabbix server就安装完成了,客户端安装 zabbix agent 下回分解
 
posted @ 2022-06-19 22:23  北极之光的博客  阅读(1801)  评论(0编辑  收藏  举报