记一次部署zabbix

2019-10-24  本文已影响0人  带着小猪闯天下

1、部署

环境:关闭防火墙,selinux

systemctl stop firewalld
systemctl disabled firewalld
setenforce 0
sed -i '/^SELINUX=/cSELINUX=disabled' /etc/selinux/config

部署zabbix-server:

rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
 yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-get zabbix-agent

部署mysql:

yum -y install mariadb mariadb-server
systemctl enable mariadb
systemctl start mariadb

授权zabbix账号:

mysql
create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* to zabbix@localhost identified by '123';
 flush privileges;

初始化zabbix

cd /usr/share/doc/zabbix-server-mysql-3.2.3/
zcat create.sql.gz | mysql -uroot zabbix

修改zabbix配置文件(修改以下几行):
vim /etc/zabbix/zabbix_server.conf

DBHost=localhost  ##数据库主机
DBName=zabbix     ##上一步数据库里创建的库名
DBUser=zabbix     ##创建的zabbix用户
DBPassword=123    ##密码
systemctl enable zabbix-server.service 
systemctl start zabbix-server.service 

vim /etc/httpd/conf.d/zabbix.conf

php_value date.timezone Asia/Shanghai  ##时区设置为上海

systemctl enable httpd
systemctl start httpd

浏览器访问:http://zabbix-server-ip/zabbix

q.png

部署zabbix-agent

rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
yum -y install zabbix-agent

vim /etc/zabbix/zabbix_agentd.conf

Server=192.168.100.10,192.168.100.11             被动模式 zabbix-server-ip    
ServerActive=192.168.100.10,192.168.100.11    主动模式  zabbix-server-ip    (谁从我这里采集数据。)
Hostname=test                                                         建议使用  $HOSTNAME

systemctl start zabbix-agent
systemctl enable zabbix-agent
netstat -antlp |grep :10050

批量部署zabbix-agent
[root@bogon ansible]# cat zabbix-agent.yml

# zabbix-agent install
- hosts: hosts
  tasks:
  - name: add zabbix-agent repo
    yum: name=http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
         state=installed
  - name: install zabbix-agent
    yum: name=zabbix-agent
         state=installed
  - name: copy zabbix_agent.conf
    copy: src=/root/zabbix_agentd.conf
          dest=/etc/zabbix/
  - name: copy change_zabbix_agent.sh  ##此处脚本是修改zabbix-agent.conf里的Hostaneme为本机ip
    copy: src=/root/change_zabbix_agent.sh
          dest=/etc/zabbix/
  - name: change file zabbix_agent.conf
    shell: sh /etc/zabbix/change_zabbix_agent.sh
  - name: start zabbix-agent
    systemd: state=started
             name=zabbix-agent
             enabled=yes
上一篇下一篇

猜你喜欢

热点阅读