一、进入官网
https://zabbix.com
二、安装过程
1、安装zabbix服务器的源
# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
清除缓存
#yum clean all
2、安装zabbixserver和连接mysql功能的软件
# yum install zabbix-server-mysql zabbix-agent -y
3、安装Zabbix前端包
# yum install centos-release-scl -y
编辑/etc/yum.repos.d/zabbix.repo仓库文件,开启 zabbix-frontend 源
[zabbix-frontend]
...
enabled=1
...
安装zabbix前端包
#yum install zabbix-web-mysql-scl zabbix-nginx-conf-scl
4、安装mariadb数据库
#yum install mariadb mariadb-server -y
mariadb是提供客户端命令的软件包
mariadb-server是服务器端的软件包
启动服务
#service mariadb start
设置开机启动
systemctl enable mariadb
检查是否开启
# ps -aux|grep mysqld
# netstat -anplut|grep mysqld
5、进入mysql,创建zabbix库
# mysql -uroot -p
mysql> create database zabbix character set utf8 collate utf8_bin; 创建zabbix数据库
mysql> create user zabbix@localhost identified by '123456'; 创建zabbix用户
mysql> grant all privileges on zabbix.* to zabbix@localhost; 授权zabbix库里面全部权限
mysql> set global log_bin_trust_function_creators = 1; 设置变量
mysql> quit;
mariadb的修改用户密码的命令:
MariaDB [(none)]> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('123456');
Query OK, 0 rows affected (0.002 sec)
导入初始化数据
# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p'123456' zabbix
# mysql -uroot -p
password
mysql> set global log_bin_trust_function_creators = 0;
mysql> quit;
6、为Zabbix server配置数据库
修改zabbix server的配置文件
# cd /etc/zabbix/
# vim zabbix_server.conf (在124行处添加)
DBPassword=123456
修改前端的配置文件
nginx:
# cd /etc/opt/rh/rh-nginx116/nginx/conf.d
# vim zabbix.conf
server {
listen 8080; #因为80给nginx占了,所以用8080
server_name 123.com; #可以任意写
}
php:
#cd /etc/opt/rh/rh-php72/php-fpm.d
# vim zabbix.conf
1)在第6行加上nginx
listen.acl_users = apache,nginx
2)在最后一行取消注释并设置正确的时区
php_value[date.timezone] = Asia/Shanghai #亚洲上海
7、关闭防火墙、SELINUX
# systemctl stop firewalld
# systemctl disable firewalld# setenforce 0
# vim /etc/selinux/config
修改为disabled
8、开启zabbix服务
重启服务
# systemctl restart zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm
开机启动
# systemctl enable zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm
9、配置zabbix前端页面
在windows上搜索http://ip地址:8080
看到这个界面恭喜你安装成功
默认登录的账号密码:
Admin/zabbix
三、问题总结
1、在安装过程中遇到Centos的官方仓库连接不上的问题,需要用阿里云的仓库(我上一篇文章有写)。
2、在使用centos-release-scl库的时候,任然需要连接上Centos的官方仓库,所以还是把它替换成阿里云的源。
# cd /etc/yum.repos.d/
将CentOS-SCLo-scl.repo库里的内容全部替换
# vim CentOS-SCLo-scl.repo
# CentOS-SCLo-rh.repo
#
# Please see http://wiki.centos.org/SpecialInterestGroup/SCLo for more
# information[centos-sclo-rh]
name=CentOS-7 - SCLo rh
baseurl=http://mirrors.aliyun.com/centos/7/sclo/$basearch/rh/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo[centos-sclo-rh-testing]
name=CentOS-7 - SCLo rh Testing
baseurl=http://mirrors.aliyun.com/centos/7/sclo/$basearch/rh/
gpgcheck=0
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo[centos-sclo-rh-source]
name=CentOS-7 - SCLo rh Sources
baseurl=http://vault.centos.org/centos/7/sclo/Source/rh/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo[centos-sclo-rh-debuginfo]
name=CentOS-7 - SCLo rh Debuginfo
baseurl=http://debuginfo.centos.org/centos/7/sclo/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
3、如何把zabbix的端口改成80呢?
进入/etc/opt/rh/rh-nginx116/nginx目录
1) 修改nginx.conf的配置文件
38 server {
39 listen 8080 default_server;
40 listen [::]:8080 default_server;
2)进入conf.d目录,修改zabbix.conf
server {
listen 80;
server_name 123.com;
3)重启zabbix服务