[root@localhost ~]# hostnamectl --static set-hostname zabbix
[root@zabbix ~]# systemctl stop iptables firewalld
[root@zabbix ~]# systemctl disable iptables firewalld
[root@zabbix ~]# sed -ri '/SELINUX=/cSELINUX=disabled' /etc/selinux/config
[root@zabbix ~]# setenforce 0 # 臨時關閉SELinux
[root@zabbix ~]# reboot
[root@zabbix ~]# systemctl start postfix
[root@zabbix ~]# systemctl enable postfix
[root@zabbix ~]# vim /etc/hosts
[root@zabbix ~]# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
[root@zabbix ~]# yum repolist
[root@zabbix ~]# yum -y install epel-release.noarch
[root@zabbix ~]# yum -y install zabbix-agent zabbix-get zabbix-sender zabbix-server-mysql
[root@zabbix ~]# yum -y install centos-release-scl
[root@zabbix ~]# vim /etc/yum.repos.d/zabbix.repo
[zabbix-frontend]
…
enabled=1
…
[root@zabbix ~]# yum -y install zabbix-web-mysql-scl zabbix-apache-conf-scl
[root@zabbix ~]# vim /etc/yum.repos.d/mariadb.repo
新增以下內容
[mariadb]
name = MariaDB
baseurl =https://mirrors.ustc.edu.cn/mariadb/yum/10.5/centos7-amd64
gpgkey=https://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1
[root@zabbix ~]# yum install -y MariaDB-server MariaDB-clien
找到[mysqld],在下面新增
[root@zabbix ~]# vim /etc/my.cnf.d/server.cnf
[mysqld]
skip_name_resolve = ON
innodb_file_per_table = ON
innodb_buffer_pool_size = 256M
max_connections = 2000
log-bin = master-log
[root@zabbix ~]# systemctl restart mariadb
[root@zabbix ~]# mysql_secure_installation # 初始化mariadb
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
MariaDB [(none)]> grant all on zabbix.* to 'zabbix'@'192.168.152.%' identified by '1234.com';
MariaDB [(none)]> flush privileges;
[root@zabbix ~]# rpm -ql zabbix-server-mysql
/etc/logrotate.d/zabbix-server /etc/zabbix/zabbix_server.conf
/usr/lib/systemd/system/zabbix-server.service
/usr/lib/tmpfiles.d/zabbix-server.conf /usr/lib/zabbix/alertscripts
/usr/lib/zabbix/externalscripts /usr/sbin/zabbix_server_mysql
/usr/share/doc/zabbix-server-mysql-5.0.2
/usr/share/doc/zabbix-server-mysql-5.0.2/AUTHORS
/usr/share/doc/zabbix-server-mysql-5.0.2/COPYING
/usr/share/doc/zabbix-server-mysql-5.0.2/ChangeLog
/usr/share/doc/zabbix-server-mysql-5.0.2/NEWS
/usr/share/doc/zabbix-server-mysql-5.0.2/README
/usr/share/doc/zabbix-server-mysql-5.0.2/create.sql.gz # 生成表的各種指令碼
/usr/share/doc/zabbix-server-mysql-5.0.2/double.sql
/usr/share/man/man8/zabbix_server.8.gz /var/log/zabbix /var/run/zabbix
[root@zabbix ~]# gzip -d /usr/share/doc/zabbix-server-mysql-5.0.2/create.sql.gz
[root@zabbix ~]# ls
anaconda-ks.cfg
①進入資料庫
sorce /usr/share/doc/zabbix-server-mysql-5.0.2/create.sql
②
[root@zabbix ~]# mysql -uzabbix -h192.168.37.111 -p'1234.com' zabbix < /usr/share/doc/zabbix-server-mysql-5.0.2/create.sql
[root@zabbix ~]# cd /etc/zabbix/
[root@zabbix zabbix]# ls
web zabbix_agentd.conf zabbix_agentd.d zabbix_server.conf
#為了方便我們以後恢復,我們把組態檔備份一下
[root@zabbix zabbix]# cp zabbix_server.conf{,.bak}
[root@zabbix zabbix]# vim zabbix_server.conf
ListenPort=10051 # 預設監聽埠
SourceIP=192.168.37.111 # 發取樣資料請求的 IP
LogType=file
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0 #紀錄檔卷動
DebugLevel=3 #紀錄檔級別
DBHost=192.168.49.170 #本機ip
DBName=zabbix #資料庫名稱
DBUser=zabbix #資料庫使用者
DBPassword=123.com #資料庫密碼
DBPort=3306 #資料庫埠
[root@zabbix zabbix]# systemctl start zabbix-server.service
[root@zabbix ~]# vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
php_value[date.timezone] = Asia/Shanghai
[root@qfedu.com ~]# systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
[root@qfedu.com ~]# systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm
[root@node1 ~]# wget https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
#######yum -y localinstall zabbix-release-5.0-1.el7.noarch.rpm #本地安裝
[root@node1 ~]# rpm -ivh zabbix-release-5.0-1.el7.noarch.rpm
[root@node1 ~]# yum -y install epel-release.noarch
[root@node1 ~]# yum install zabbix-agent zabbix-sender -y
[root@node1 ~]# cd /etc/zabbix/
[root@node1 zabbix]# ls
zabbix_agentd.conf zabbix_agentd.d
[root@node1 zabbix]# cp zabbix_agentd.conf{,.bak}
[root@node1 zabbix]# vim zabbix_agentd.conf
[root@node1 zabbix]# grep -Ev ‘^$|#’ zabbix_agentd.conf
PidFile=/var/run/zabbix/zabbix_agentd.pid LogType=file
LogFile=/var/log/zabbix/zabbix_agentd.log LogFileSize=0 DebugLevel=3
SourceIP=192.168.49.171 Server=192.168.49.170 ListenPort=10050
ListenIP=192.168.49.171 StartAgents=3 ServerActive=192.168.49.170
Hostname=node1 Include=/etc/zabbix/zabbix_agentd.d/*.conf
[root@node1 zabbix]# systemctl start zabbix-agent.service