微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

zabbix部署

1.配置zabbix源

cat >/etc/yum.repos.d/zabbix.repo<<EOF
[zabbix]
name=Zabbix Official Repository - \$basearch
baseurl=https://mirror.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/x86_64/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX

[zabbix-non-supported]
name=Zabbix Official Repository non-supported - \$basearch 
baseurl=https://mirror.tuna.tsinghua.edu.cn/zabbix/non-supported/rhel/7/\$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=0
EOF

2.安装zabbix相关服务

yum install zabbix-server-MysqL zabbix-web-MysqL zabbix-get mariadb-server zabbix-java-gateway.x86_64 java-1.8.0 -y
rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-agent-4.0.36-1.el7.x86_64.rpm

3.初始化数据库

systemctl start mariadb
systemctl enable mariadb
MysqL_secure_installation
回车
n
y
y
y
y

MysqL
>:create database zabbix character set utf8 collate utf8_bin;
>:grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';

导入zabbix表结构和初始数据
zcat /usr/share/doc/zabbix-server-MysqL-4.0.*/create.sql.gz | MysqL -uzabbix -p zabbix

4.启动服务

vim /etc/zabbix/zabbix_server.conf
DBHost=localhost
dbname=zabbix
DBUser=zabbix
DBPassword=zabbix (数据库密码)

 

systemctl start zabbix-server
systemctl enable zabbix-server
systemctl start zabbix-agent && systemctl enable zabbix-agent
ps -ef | grep zabbix

 

 

vi /etc/httpd/conf.d/zabbix.conf
PHP_value date.timezone Asia/Shanghai

systemctl start httpd
systemctl enable httpd

 

http://10.0.0.71/zabbix

 

 

 

=====================================================================

 

《利用剧本批量部署客户端》

使用命令生成密钥
[root@ansible ~]# ssh-keygen

将公钥发送到所有安装zabbix客户端的主机
[root@ansible ~]# ssh-copy-id 10.0.0.7
[root@ansible ~]# ssh-copy-id 10.0.0.51

安装 ansible 软件
vim
[ansible]
name=ansible
baseurl=https://mirror.tuna.tsinghua.edu.cn/epel/7/x86_64/
gpgcheck=0

[root@ansible ~]# yum install -y epel-release
[root@ansible ~]# yum install -y ansible

修改配置文件,将zabbix 客户机添加进组,(在文末添加即可)
[root@ansible ~]# vim /etc/ansible/hosts
[webservers]
10.0.0.7
10.0.0.51

执行剧本
ansible-playbook -e server_ip=10.0.0.72 install_zabbix.yaml

 

 


(1) 检测语法
  ansible-playbook --Syntax-check /path/to/playbook.yaml
(2) 测试运行
  ansible-playbook -C /path/to/playbook.yaml
(3)运行
  ansible-playbook /path/to/playbook.yaml

 

 

 

 

剧本内容

- hosts: webservers
remote_user: root
tasks:
- name: rpm
shell: rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-agent-4.0.36-1.el7.x86_64.rpm
- name: zabbix_agentd.conf
shell: sed -i 's/Server=127.0.0.1/Server=10.0.0.72/g' /etc/zabbix/zabbix_agentd.conf
- name: start
shell: systemctl start zabbix-agent && systemctl enable zabbix-agent

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐