Zabbix快速部署文档

Hi, Everyone!Welcome to DQF's Blog,For technical exchange, Please add QQ: 905030209,Thanks!

1.环境检查

[root@zabbix ~]# cat /etc/redhat-release 
CentOS Linux release 7.4.1708 (Core) 
[root@zabbix ~]# uname -r
3.10.0-693.el7.x86_64
[root@zabbix ~]# getenforce 
Disabled
[root@zabbix ~]# systemctl status firewalld.service 
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:firewalld(1)

2.安装Zabbix

#!/bin/bash
#zabbix-server script
#安装zabbix源、aliyun YUM源
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
#安装zabbix mariadb数据库
yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent mariadb mariadb-server zabbix-get -y
systemctl start mariadb.service
systemctl enable mariadb.service
#创建数据库
mysql -e 'create database zabbix character set utf8 collate utf8_bin;'
mysql -e 'grant all privileges on zabbix.* to zabbix@localhost identified by "zabbix";'
#导入数据
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
#配置zabbixserver连接mysql
sed -i.ori '115a DBPassword=zabbix' /etc/zabbix/zabbix_server.conf
#添加时区
sed -i.ori '19a php_value date.timezone  Asia/Shanghai' /etc/httpd/conf.d/zabbix.conf
#解决中文乱码
yum -y install wqy-microhei-fonts
\cp /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/share/fonts/dejavu/DejaVuSans.ttf
#启动服务
systemctl start zabbix-server
systemctl start httpd
#写入开机自启动
chmod +x /etc/rc.d/rc.local
cat >>/etc/rc.d/rc.local<<EOF
systemctl start mariadb.service
systemctl start httpd
systemctl start zabbix-server
EOF
#输出信息
echo "浏览器访问 http://`hostname -I|awk '{print $1}'`/zabbix"
#测试连通性
#zabbix_get -s 172.16.0.12 -p 10050 -k "system.cpu.load[all,avg1]"

3.客户端配置

#!/bin/bash
#安装zabbix源、aliyu nYUM源
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm

#安装zabbix客户端
yum install zabbix-agent -y
sed -i.ori 's#Server=127.0.0.1#Server=172.16.0.18#' /etc/zabbix/zabbix_agentd.conf
systemctl start  zabbix-agent.service

#写入开机自启动
chmod +x /etc/rc.d/rc.local
cat >>/etc/rc.d/rc.local<<EOF
systemctl start  zabbix-agent.service
EOF

4.自动注册

vim /etc/zabbix/zabbix_agentd.conf
ServerActive=172.16.1.61
# Hostname=Zabbix server
HostnameItem=system.hostname

systemctl restart zabbix-agent.service
netstat -tunlp|grep zabbix

5.参考文献

Zabbix官方文档
Zabbix图文部署

Leave a Reply

发表评论

电子邮件地址不会被公开。 必填项已用*标注

Blog Theme: FreeDom by DQF.