尝试 Zabbix的强大 安装篇

发布于 2019-12-05  360 次阅读


环境 CentOS 7.6 + Mysql8.0
部署
1.更新默认yum源 ,CentOS-Base.repo 改为aliyun
#直接替换主机内的CentOS-Base.repo
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all
yum makecache
2.关闭selinux
#默认是开启的,关闭后可以减少出现奇葩问题。
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
!!!关闭后,有条件建议reboot下服务器。
3.防火墙开放端口
#zabbix 端口是 10050,web服务是80
firewall-cmd --permanent --zone=public --add-port=10050/tcp
firewall-cmd --permanent --zone=public --add-port=10051/tcp
firewall-cmd --permanent --zone=public --add-port=80/tcp
firewall-cmd --reload
4.安装zabbix
- 安装zabbix源
rpm -ivh https://repo.zabbix.com/zabbix/4.2/rhel/7/x86_64/zabbix-release-4.2-1.el7.noarch.rpm
- 安装服务端以及相关包
yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent zabbix-get
5.安装数据库
yum install wget -y
wget -c https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
rpm -ivh mysql80-community-release-el7-1.noarch.rpm
yum install yum-utils -y
yum-config-manager --disable mysql80-community
yum-config-manager --enable mysql57-community
yum install mysql-community-server -y
# 启动mysql
systemctl start mysqld
# 开机启动
systemctl enable mysqld
6.修改root密码和创建zabbix用户和数据库
- 查看root临时密码
grep 'temporary password' /var/log/mysqld.log
W.p4>oX0g=,k
- 使用mysql临时登录,修改root密码
mysql -uroot -p
W.p4>oX0g=,k
- 修改mysql 密码
ALTER USER 'root'@'localhost' IDENTIFIED BY '7895123aA@';
- 创建zabbix用户和库
create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* to zabbix@localhost identified by "Zabbix@789";
- 退出mysql,后导入zabbix数据
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p'Zabbix@789' zabbix
7.zabbix服务端配置
- 修改/etc/zabbix/zabbix_server.conf文件,修改mysql连接密码
DBPassword=Zabbix@789
- 添加时区
sed -i.ori '19a php_value date.timezone Asia/Shanghai' /etc/httpd/conf.d/zabbix.conf
- 解决图形列表下中文乱码
yum -y install wqy-microhei-fonts
mv /usr/share/fonts/dejavu/DejaVuSans.ttf /usr/share/fonts/dejavu/DejaVuSans.ttf.bak
cp -f /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/share/fonts/dejavu/DejaVuSans.ttf
8.启动zabbix服务端并配置
- 启动zabbix服务、web服务
systemctl start zabbix-server httpd
- 开机启动zabbix服务、web服务
systemctl enable zabbix-server httpd
- 启动zabbix_agent 服务
systemctl enable zabbix-agent
systemctl start zabbix-agent


一沙一世界,一花一天堂。君掌盛无边,刹那成永恒。