zabbix安装脚本

 1 #!/bin/bash
 2 #
 3 
 4 #安装zabbix源、aliyun YUM源
 5 #curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
 6 #curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
 7 rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
 8 
 9 #安装zabbix 
10 yum install -y zabbix-server-mysql zabbix-web-mysql
11 
12 #安装启动 mariadb数据库
13 yum install -y  mariadb-server
14 systemctl start mariadb.service
15 
16 #创建数据库
17 mysql -e 'create database zabbix character set utf8 collate utf8_bin;'
18 mysql -e 'grant all privileges on zabbix.* to zabbix@localhost identified by "zabbix";'
19 
20 #导入数据
21 zcat /usr/share/doc/zabbix-server-mysql-3.0.*/create.sql.gz|mysql -uzabbix -pzabbix zabbix
22 
23 #配置zabbixserver连接mysql
24 sed -i.ori '115a DBPassword=zabbix' /etc/zabbix/zabbix_server.conf
25 
26 #添加时区
27 sed -i.ori '18a php_value date.timezone  Asia/Shanghai' /etc/httpd/conf.d/zabbix.conf
28 
29 #解决中文乱码
30 yum -y install wqy-microhei-fonts
31 \cp /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/share/fonts/dejavu/DejaVuSans.ttf
32 
33 #启动服务
34 systemctl start zabbix-server
35 systemctl start httpd
36 
37 #写入开机自启动
38 chmod +x /etc/rc.d/rc.local
39 cat >>/etc/rc.d/rc.local<<EOF
40 systemctl start mariadb.service
41 systemctl start httpd
42 systemctl start zabbix-server
43 EOF
44 
45 #输出信息
46 echo "浏览器访问 http://`hostname -I|awk '{print $1}'`/zabbix"
 1 #!/bin/bash
 2 #
 3 
 4 #安装zabbix源、aliyu nYUM源
 5 #curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
 6 #curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
 7 rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
 8 
 9 #安装zabbix客户端
10 yum install zabbix-agent -y
11 sed -i.ori 's#Server=127.0.0.1#Server=172.16.9.9#' /etc/zabbix/zabbix_agentd.conf
12 systemctl start  zabbix-agent.service
13 
14 #写入开机自启动
15 chmod +x /etc/rc.d/rc.local
16 cat >>/etc/rc.d/rc.local<<EOF
17 systemctl start  zabbix-agent.service
18 EOF

猜你喜欢

转载自www.cnblogs.com/occl/p/9173772.html