zabbix服务端安装
# 安装数据库软件
# Zabbxi数据库必须在Zabbix server或proxy安装的时候创建。
[root@localhost ~]# yum install -y mariadb-server
systemctl start mariadb #启动数据库
systemctl enable mariadb #设置开机自启
#进入数据库
mysql
# Zabbxi数据库必须在Zabbix server或proxy安装的时候创建。
[root@localhost ~]# yum install -y mariadb-server
systemctl start mariadb #启动数据库
systemctl enable mariadb #设置开机自启
#进入数据库
mysql
创建存储数据的库,并支持中文(库名:zabbix)
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
#授权连接数据库的用户,并设置密码(用户名:zabbix)
MariaDB [(none)]> create user zabbix@localhost identified by '123456';
#数据库授权
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost;
# 安装zabbix5.0储存库(二进制安装方式)
[root@localhost ~]# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
获取https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
警告:/var/tmp/rpm-tmp.qoLSuU: 头V4 RSA/SHA512 Signature, 密钥 ID a14fe591: NOKEY
准备中... ################################# [100%]
软件包 zabbix-release-5.0-1.el7.noarch 已经安装
# 安装zabbix软件包
[root@localhost ~]# yum install zabbix-server-mysql zabbix-agent -y
# 如果官方仓库无法连接,可将仓库地址改为清华大学,下边是清华大学仓库地址
[root@localhost ~]# vim /etc/yum.repos.d/zabbix.repo
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/5.0/rhel/7/$basearch/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
[zabbix-frontend]
name=Zabbix Official Repository frontend - $basearch
baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/5.0/rhel/7/$basearch/frontend
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
[zabbix-debuginfo]
name=Zabbix Official Repository debuginfo - $basearch
baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/5.0/rhel/7/$basearch/debuginfo/
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
gpgcheck=0
[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/non-supported/rhel/7/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=0
(如果缺包加入以下两个库
yum -y install epel-release
yum install centos-release-scl)
#安装zabbix前端软件包
zabbix-web-mysql-scl 用于连接数据库
zabbix-apache-conf-scl 用于连接apache
[root@localhost ~]# yum install -y zabbix-web-mysql-scl zabbix-apache-conf-scl
如果缺包加入以下两个库或修改源为上方的清华大学仓库
yum -y install epel-release
yum install centos-release-scl
#查看所有库
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
| zabbix |
+--------------------+
5 rows in set (0.01 sec)
#进入zabbix库
MariaDB [(none)]> use zabbix;
Database changed
#查看当前库下表
MariaDB [zabbix]> show tables;
Empty set (0.00 sec) #空
#在Zabbix服务器主机上,导入初始架构和数据。系统将提示您输
入新创建的密码
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
Enter password: password #输入zabbix用户密码(123456)
#Zabbix服务器配置数据库
vim /etc/zabbix/zabbix_server.conf
100 DBName=zabbix #存储监控数据的库名
116 DBUser=zabbix #连接数据库的用户
124 DBPassword=123456 #设置zabbix用户密码
#为Zabbix配置正确的时区
vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
php_value[date.timezone] = Asia/Shanghai #亚洲/上海
# 启动所有服务
systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
# 设置服务随机自启
systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm
# 查看zabbix服务占用端口信息
[root@localhost ~]# netstat -anptul | grep zabbix
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 1655/zabbix_agentd
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 1665/zabbix_server
tcp6 0 0 :::10050 :::* LISTEN 1655/zabbix_agentd
tcp6 0 0 :::10051 :::* LISTEN 1665/zabbix_server
文章评论