1.环境准备
1.改名.关闭防火墙
[root@localhost ~]# hostname zabbix-server01
[root@localhost ~]# bash
[root@zabbix-server01 ~]# yum install -y net-tools
[root@zabbix-server01 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eno16780032: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
link/ether 00:0c:29:3c:40:99 brd ff:ff:ff:ff:ff:ff
inet 10.30.59.217/25 brd 10.30.59.255 scope global eno16780032
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe3c:4099/64 scope link
valid_lft forever preferred_lft forever
[root@zabbix-server01 ~]# ifconfig eno16780032 |awk 'NR==2{print $2}'
10.30.59.217
[root@zabbix-server01 ~]# sed -i 's/enforcing/disabled/' /etc/selinux/config
[root@zabbix-server01 ~]# setenforce 0
[root@zabbix-server01 ~]# systemctl disable --now firewalld
[root@zabbix-server01 ~]# reboot
2.查看内存,4G比较好
[root@zabbix-server01 ~]# free -m
total used free shared buff/cache available
Mem: 7823 142 7507 8 173 7497
Swap: 4095 0 4095
2.服务端部署
2.1源准备
1.获取zabbix的下载源
[root@zabbix-server01 ~]# rpm -Uvh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
Retrieving https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
warning: /var/tmp/rpm-tmp.0deSGC: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:zabbix-release-5.0-1.el7 ################################# [100%]
[root@zabbix-server01 ~]# ls /etc/yum.repos.d/
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo
CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo zabbix.repo
2.修改源,使其修改为国内阿里源,更快速下载
[root@zabbix-server1 ~]# sed -i 's#http://repo.zabbix.com#https://mirrors.aliyun.com/zabbix#' /etc/yum.repos.d/zabbix.repo
原来的:
[root@zabbix-server01 ~]# cat /etc/yum.repos.d/zabbix.repo
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=http://repo.zabbix.com/zabbix/5.0/rhel/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
[zabbix-frontend]
name=Zabbix Official Repository frontend - $basearch
baseurl=http://repo.zabbix.com/zabbix/5.0/rhel/7/$basearch/frontend
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
[zabbix-debuginfo]
name=Zabbix Official Repository debuginfo - $basearch
baseurl=http://repo.zabbix.com/zabbix/5.0/rhel/7/$basearch/debuginfo/
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
gpgcheck=1
[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=http://repo.zabbix.com/non-supported/rhel/7/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=1
[root@zabbix-server01 ~]#
现在的阿里:
3.清空缓存
[root@zabbix-server01 ~]# yum clean all
2.2安装Zabbix
1.安装zabbixserver和agent
[root@zabbix-server01 ~]# yum install zabbix-server-mysql zabbix-agent -y
2.安装工具,可以在机器上,使用多个版本的软件并且不会影响到整个系统的依赖环境:
[root@zabbix-server01 ~]# yum install -y centos-release-scl
3.修改配置文件,将[zabbix-frontend]下的enabled修改为1
[root@zabbix-server01 ~]# vi /etc/yum.repos.d/zabbix.repo (开启参数)
4.安装zabbix前端环境,且是安装scl环境下
[root@zabbix-server01 ~]# yum install -y zabbix-web-mysql-scl zabbix-apache-conf-scl
2.3安装mysql
1.安装zabbix所需的数据库(mariadb)
[root@zabbix-server01 ~]# yum install -y mariadb-server -y
2.配置数据库,开机启动
[root@zabbix-server01 ~]# systemctl enable --now mariadb //开机自启并且立即启动
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
3.MySQL初始化,并设置密码
[root@zabbix-server01 ~]# mysql_secure_installation
登录:
4.添加数据库用户,以及zabbix所需的数据库信息
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
3 rows in set (0.01 sec)
创建用户:
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 '000000';
Query OK, 0 rows affected (0.00 sec)
授权:
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost;
Query OK, 0 rows affected (0.00 sec)
刷新授权表:
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
退出:
MariaDB [(none)]> exit;
Bye
**5.使用zabbix-MySQL命令,导入数据库信息(读取压缩的内容,然后导入数据库)**
#mysql -u 用户名 -p 数据库名
[root@zabbix-server01 ~]# ls /usr/share/doc/zabbix-server-mysql*/create.sql.gz
/usr/share/doc/zabbix-server-mysql-5.0.12/create.sql.gz
[root@zabbix-server01 ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
Enter password:
[root@zabbix-server01 ~]# mysql -uzabbix -p000000
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 13
Server version: 5.5.68-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| zabbix |
+--------------------+
2 rows in set (0.00 sec)
MariaDB [(none)]> use zabbix
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MariaDB [zabbix]> show tables;
6.修改zabbix server配置文件,修改数据库的密码
[root@zabbix-server01 ~]# vi /etc/zabbix/zabbix_server.conf
检查一下
2.4Zabbix server配置数据库、PHP及启动进程
1.修改zabbix的PHP配置文件里的时区
[root@zabbix-server01 ~]# vi /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf (Asia/Shanghai)
[root@zabbix-server01 ~]# grep 'timezone' /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
php_value[date.timezone] = Asia/Shanghai
2.启动zabbix相关服务器
启动Zabbix server和agent进程,并为它们设置开机自启
[root@zabbix-server01 ~]# systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
[root@zabbix-server01 ~]# systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/rh-php72-php-fpm.service to /usr/lib/systemd/system/rh-php72-php-fpm.service.
3.访问zabbix的入口
检测组件是否正常
输入配置数据库zabbix用户密码:000000
下一步:
安装信息细节
成功安装
4.安装完成后默认账号密码
登录账号为:Admin
密码:zabbix
注意大小写
zabbix首页
过程报错的情况:(错误日志)
[root@zabbix-server1 ~]# tail -f /var/log/messages
[root@zabbix-server1 ~]# tail -f /var/log/zabbix/zabbix_server.log
Cannot bind socket to “/var/run/zabbix/zabbix_server_alerter.sock”: [13] Permission denied.
大写的尴尬结果是因为没有临时关闭SELINUX