码迷,mamicode.com
首页 > 其他好文 > 详细

zabbix安装部署

时间:2016-10-11 14:27:08      阅读:217      评论:0      收藏:0      [点我收藏+]

标签:zabbix部署

安装完成 puppet 部署zabbix2.4监控系统

[root@master ~]# rpm -ivh http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpm  


[root@master ~]# yum install -y zabbix-server-mysql zabbix-web-mysql mysql-server  


[root@master ~]# service mysqld start 


[root@master ~]# chkconfig mysqld on  


[root@master ~]# mysqladmin -u root password ‘123456‘ 


[root@master ~]# mysql -uroot -p123456  


mysql> create database zabbix character set utf8;  


mysql> grant all privileges on zabbix.* to zabbix@localhost identified by ‘123456‘;  


mysql> flush privileges; 


进入Zabbix数据库文件目录导入数据库信息  


[root@master ~]# cd /usr/share/doc/zabbix-server-mysql-2.4.3/create/ 


[root@master create]# mysql -uroot -p123456 zabbix < schema.sql 


[root@master create]# mysql -uroot -p123456 zabbix < images.sql 


[root@master create]# mysql -uroot -p123456 zabbix < data.sql  


3.修改Zabbix配置文件配置数据库相关信息  


[root@master ~]# vim /etc/zabbix/zabbix_server.conf 


DBHost=localhost 


DBName=zabbix 


DBUser=zabbix 


DBPassword=123456


4.设置PHP默认时区  


[root@master ~]# vim /etc/php.ini 


date.timezone = PRC


5.启动Zabbix和Apache服务

[root@master ~]# service zabbix-server start 


[root@master ~]# chkconfig zabbix-server on 


[root@master ~]# service httpd start 


[root@master ~]# chkconfig httpd on


访问:http://master.com/zabbix/setup.php   Admin/zabbix  登陆



编写Zabbix模块 


1.创建模块目录  


[root@master ~]# mkdir -p /etc/puppet/modules/zabbix/{manifests,templates}  


2.创建manifests文件

服务器端保存着所有对客户端服务器的配置代码,在puppet里面叫做manifest.客户端下载manifest之后,


可以根据manifest对服务器进行配置,例如软件包管理,用户管理和文件管理等等。  


Zabbix Agent程序采用官方提供的软件源,客户端配置文件采用模板方式进行文件下载,由于客户端需要指定


Zabbix Server,因此配置文件采用变量进行传递,最后使用“->”指定资源之间的依赖顺序关系。


[root@master ~]# vim /etc/puppet/modules/zabbix/manifests/init.pp 


class zabbix {  


package { ‘zabbix-agent‘: 


ensure => installed,  


require => Yumrepo["zabbix"], 


}  


yumrepo { ‘zabbix‘:  


baseurl => "http://repo.zabbix.com/zabbix/2.4/rhel/\$releasever/\$basearch/",  


descr => "Zabbix Official Repository", 


enabled => 1, 


gpgcheck => 0, 


}

file { ‘/etc/zabbix/zabbix_agentd.conf‘:  


content => template("zabbix/zabbix_agentd_conf.erb"), 


ensure => file, 


}  


service { ‘zabbix-agent‘: 


ensure => "running", 


hasstatus => true, 


enable => true,  


subscribe => [ File["/etc/zabbix/zabbix_agentd.conf"] ], 


}  


Package ["zabbix-agent"] -> File ["/etc/zabbix/zabbix_agentd.conf"] -> service ["zabbix-agent"] 


}

3.创建模板文件

[root@master ~]# vim /etc/puppet/modules/zabbix/templates/zabbix_agentd_conf.erb  


PidFile=/var/run/zabbix/zabbix_agentd.pid 


LogFile=/var/log/zabbix/zabbix_agentd.log 


EnableRemoteCommands=1 


LogRemoteCommands=1  


Server=<%= zabbix_server %> 


Hostname=<%= fqdn %> 


ListenIP=<%= ipaddress %>  


Include=/etc/zabbix/zabbix_agentd.d/

4.创建节点文件

[root@master ~]# mkdir /etc/puppet/manifests/nodes  


[root@master ~]# vim /etc/puppet/manifests/nodes/agentgroup.pp 


node /^client\d+\.com$/ { 


$zabbix_server = "master.com" 


include zabbix 


5.修改site.pp将测试节点载入Puppet

[root@master ~]# vim /etc/puppet/manifests/site.pp

Package {

allow_virtual => true,

}

import "nodes/agentgroup.pp"


节点agent1.com测试  


[root@agent ~]# puppet agent --test 



客户端安装

[root@client1 ~]# rpm -ivh http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpm  


[root@client1 ~]# yum install -y zabbix-agent 

[root@client1 ~]#  vi /etc/zabbix/zabbix_agent.conf

Server= 192.168.116.138   

ServerActive=192.168.116.138                                       #监控服务器的IP地址

Hostname= 192.168.116.136 



[root@client1 ~]# service zabbix-agent start


服务器器zabbix 汉化

下载simsun.ttc

将字体上传至/var/www/html/zabbix/fonts目录下

vim /var/www/html/zabbix/include/defines.inc.php        #修改以下两行


define(‘ZBX_FONT_NAME‘, ‘simsun‘);


define(‘ZBX_GRAPH_FONT_NAME‘,  ‘simsun‘);

登陆页面设置相应用户的默认语言Administrator—->Users(此处要保证显示的是用户,否则显示的都是用户组)


zabbix安装部署

标签:zabbix部署

原文地址:http://12030680.blog.51cto.com/12020680/1860623

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!