zabbix程序组件
zabbix组件有:
- Zabbix_server,服务端守护进程.
- Zabbix_agentd,agent守护进程
- zabbix_proxy,代理服务器
- zabbix_database,存储系统,mysql,pgsql
- Zabbix_web,web GUI图形化界面
- Zabbix_get,命令行工具,测试向agent发起数据采集请求.
- Zabbix_sender,命令行工具,测试向server发送数据
- Zabbix_java_gateway,java网关
zabbix服务端部署
zabbix5.0版本对php版本的要求,最低是7.2.0版本;对php扩展组件版本也有要求,详细可查看官方文档
https://www.zabbix.com/documentation/5.0/zh/start
准备好一台Linux服务器,设置好IP地址,yum源等
1.设置主机名
[root@localhost ~]# hostnamectl set-hostname server
[root@localhost ~]# hostname
server
2.关闭防火墙,selinux
[root@localhost ~]# systemctl stop firewalld && systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost ~]# setenforce 0
[root@localhost ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
3.zabbix-server内存尽量更大点,4G为好(以下2G)
[root@localhost ~]# free -m
total used free shared buff/cache available
Mem: 1980 120 1446 9 414 1661
Swap: 2047 0 2047
4.获取zabbix下载源
rpm -Uvh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
5.更换zabbix.repo源为阿里的
sed -i 's#http://repo.zabbix.com#https://mirrors.aliyun.com/zabbix#' /etc/yum.repos.d/zabbix.repo
6.清空yum源缓存,生成新的缓存
yum clean all
yum makecache
7.安装zabbix server和agent
yum install -y zabbix-server-mysql zabbix-agent
8.安装Software Collections,便于后续安装高版本的php,默认yum安装php版本为5.4过低;SCL(Software Collections)可以在同一个操作系统上安装和使用多个版本的软件,而不会影响整个系统的安装包;软件包会安装在/opt/rh目录下;/etc/opt/rh/软件包所有配置文件都存储在目录中的相应的目录中
[root@localhost ~]# yum install -y centos-release-scl
9.在zabbix.repo源开启zabbix-front前端源
[zabbix-frontend]
name=Zabbix Official Repository frontend - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/$basearch/frontend
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
10.安装zabbix前端环境,且是安装在scl环境下
[root@localhost ~]# yum install -y zabbix-web-mysql-scl zabbix-apache-conf-scl
11.安装azbbix所需的数据库,mariadb/mysql
[root@localhost ~]# yum install mariadb-server -y
12.配置数据库开机启动
[root@localhost ~]# systemctl enable --now mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
13.初始化数据库并设置root密码
[root@localhost ~]# mysql_secure_installation
14.添加数据库用户以及zabbix所需的数据库信息
[root@localhost ~]# mysql -uroot -pqhj666
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> create user zabbix@localhost identified by 'qhj666';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> grant all on zabbix.* to zabbix@localhost;
Query OK, 0 rows affected (0.00 sec)
15.使用zabbix-mysql命令,导入数据库信息(这里-p后面指定的是zabbix数据库)
[root@localhost ~]# zcat /usr/share/doc/zabbix-server-mysql-5.0.11/create.sql.gz | mysql -uzabbix -p zabbix
Enter password:
16.修改zabbix server配置文件,修改数据库的密码
[root@localhost ~]# grep "^DBP" /etc/zabbix/zabbix_server.conf
DBPassword=qhj666
17.修改zabbix的php配置文件
[root@localhost ~]# tail -1 /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
php_value[date.timezone] = Asia/Shanghai
18.启动zabbix相关服务
[root@localhost ~]# systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
[root@localhost ~]# systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm
19.浏览器测试访问zabbix(默认账号Admin,密码zabbix)
192.168.10.50/zabbix
部署完成后
使用浏览器访问:http://192.168.10.50/zabbix
默认密码:Admin/zabbix