Saltstack部署zabbix
Posted S4061222
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Saltstack部署zabbix相关的知识,希望对你有一定的参考价值。
一.实验环境:
server1为salt-master
server4为salt-minion,mariadb,zabbix-server,zabbix-web
server3为salt-minion,zabbix-agent
三台虚拟机都已经完成saltstack的部署(包括salt-master和salt-minion)
二.整体目录结构
三.Pillar目录
四.仓库 repos目录
五.数据库mariadb 目录
Create.sql.gz:复制得到
db-install:
pkg.installed:
- pkgs:
- mariadb-server
- mariadb
- mysql-python
service.running:
- name: mariadb
cmd.run:
- name: mysql -e "DELETE FROM mysql.user WHERE User='';" && mysql -e "DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');" && mysql -e "DROP DATABASE IF EXISTS test;" && mysql -e "DELETE FROM mysql.db WHERE Db='test' OR Db='test\\\\_%'" && mysql -e "FLUSH PRIVILEGES;"
- onlyif: mysql -e "show databases;"
mysql_user.present:(第一次部署后再次推需要删除)
- name: root
- password: westos
db-configure:
file.managed:
- name: /mnt/create.sql.gz
- source: salt://mariadb/files/create.sql.gz
mysql_database.present:
- name: zabbix
- character_set: utf8
- collate: utf8_bin
- connection_user: root
- connection_pass: westos
mysql_user.present:
- name: zabbix
- host: localhost
- password: westos
- connection_user: root
- connection_pass: westos
mysql_grants.present:
- grant: all privileges
- database: zabbix.*
- user: zabbix
- connection_user: root
- connection_pass: westos
cmd.wait:
- name: zcat /mnt/create.sql.gz | mysql -uroot -pwestos zabbix
- watch:
- mysql_database: db-configure
六.zabbix-server 目录
Zabbix_server.conf复制得到,
七.zabbix-agent 目录
Zabbix_agent.conf复制得到,修改以下内容:
Server= zabbixserver
ServerActive= zabbixserver
Hostname= hostname
八.zabbix-web 目录
Zabbix.conf复制得到,修改时区:
php_value date.timezone Asia/Shanghai
九.推送测试
[root@server1 pillar]# salt server4 state.highstate
(高推之前可以单个模块推送测试成功后进行)
浏览器输入访问:172.25.28.4/zabbix
以上是关于Saltstack部署zabbix的主要内容,如果未能解决你的问题,请参考以下文章