服务器太多,还在不同的平台和账户,监控不便
整个 Zabbix 监控,开始吧
一、关闭防火墙并开机不启动
sudo setenforce 0
sudo sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
sudo systemctl stop firewalld.service
sudo systemctl disable firewalld.service
二、安装部署 Zabbix 服务端
1、安装配置 Zabbix 专用 yum 源
sudo rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
sudo yum clean all
sudo yum makecache fast
2、安装 Zabbix 服务端组件
sudo yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-get --nogpgcheck
安装过程可能会报错,zabbix版本冲突,是因为epel源里也有zabbix
Transaction check error:
file /usr/bin/zabbix_get conflicts between attempted installs of zabbix-get-5.0.19-1.el7.x86_64 and zabbix40-4.0.36-1.el7.x86_64
file /usr/share/man/man1/zabbix_get.1.gz conflicts between attempted installs of zabbix-get-5.0.19-1.el7.x86_64 and zabbix40-4.0.36-1.el7.x86_64 Error Summary
epel源改名即可解决,重新执行 Zabbix 服务端组件命令即可
cd /etc/yum.repos.d/
sudo mv epel.repo epel-bak
3、安装 Zabbix 前端组件
sudo yum -y install centos-release-scl
编辑配置文件
sudo vi /etc/yum.repos.d/zabbix.repo # 将其设为1
[zabbix-frontend]
...
enabled=1
...
4、安装 Zabbix 前端页面、初始数据库、php及httpd组件
sudo yum -y install zabbix-web-mysql-scl zabbix-apache-conf-scl
三、安装配置 MySQL
1、安装 yum 源
sudo rpm -ivh https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
2、安装MySQL组件
sudo yum -y install yum-utils
sudo yum-config-manager --disable mysql80-community
sudo yum-config-manager --enable mysql57-community
sudo yum install mysql-community-server -y
3、安装配置MySQL
wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.32-linux-glibc2.12-x86_64.tar.gz
sudo tar zxvf mysql-5.7.32-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
cd /usr/local/ sudo mv mysql-5.7.32-linux-glibc2.12-x86_64/ mysql
cd mysql sudo bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
#这一步需记住打印的临时密码
sudo cp support-files/mysql.server /etc/init.d/mysqld -r
sudo vim /usr/local/mysql/my.cnf [mysqld]
datadir=/usr/local/mysql/data
basedir=/usr/local/mysql
user=mysql
socket=/usr/local/mysql/var/mysql.sock
## Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
## instructions in http://fedoraproject.org/wiki/Systemd
#[mysqld_safe]
log-error=/usr/local/mysql/var/log/mysql/mysql.log
pid-file=/usr/local/mysql/var/run/mysql/mysql.pid
[client]
port=3306
socket=/usr/local/mysql/var/mysql.sock
4、创建文件夹及文件,并授权
sudo mkdir /usr/local/mysql/var/log/mysql
sudo mkdir /usr/local/mysql/var/run/mysql sudo touch /usr/local/mysql/var/log/mysql/mysql.log
sudo touch /usr/local/mysql/var/run/mysql/mysql.pid sudo chown -R mysql:mysql /usr/local/mysql/var/
5、启动 MySQL
sudo /etc/init.d/mysqld start
6、映射链接
sudo ln -s /usr/local/mysql/bin/mysql /usr/bin
sudo ln -s /usr/local/mysql/var/mysql.sock /tmp/mysql.sock
7、登录MySQL
mysql -uroot -p
# 输入临时密码
8、修改密码并授权
ALTER USER 'root'@'localhost' IDENTIFIED BY 'qwe123'; //单引号内自行设置
create database zabbix character set utf8 collate utf8_bin; //创建zabbix库
create user zabbix@localhost identified by 'Zabbix666'; //创建zabbix数据库用户、密码
grant all privileges on zabbix.* to zabbix@localhost; //设置zabbix用户对zabbix数据库具有本地管理权限
9、开启远程访问
use mysql;
update user set host='%' where user='root';
update user set host='%' where user='zabbix';
flush privileges; //刷新
quit; // 退出
10、导入初始数据
sudo zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p'qwe123' zabbix
四、初始化 Zabbix 配置
1、配置数据库连接
sudo vim /etc/zabbix/zabbix_server.conf
根据实际情况配置数据库连接
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=qwe123
DBPort=3306
2、设置时区
sudo vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
去掉 php_value[date.timezone] = 前面的分号,填上海时区
php_value[date.timezone] = Asia/Shanghai
3、设置字体,避免前台中文乱码
sudo yum -y install wqy-microhei-fonts
sudo mv /usr/share/fonts/dejavu/DejaVuSans.ttf /usr/share/fonts/dejavu/DejaVuSans.ttf.bak
sudo cp -f /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/share/fonts/dejavu/DejaVuSans.ttf
4、设置 Zabbix 及其相关服务开机启动
systemctl restart zabbix-server httpd rh-php72-php-fpm
systemctl enable zabbix-server httpd rh-php72-php-fpm
5、初始化安装界面
浏览器访问 http://你的IP/zabbix
连续2次 Next step,输入MySQL密码
一直 Next step 就好了,默认用户名是Admin,密码是zabbix
6、汉化
到这里 Zabbix server就安装完成了,客户端安装 zabbix agent 下回分解