码迷,mamicode.com
首页 > 系统相关 > 详细

Linux监控和安全运维---zabbix安装及部署

时间:2015-07-27 00:38:02      阅读:524      评论:0      收藏:0      [点我收藏+]

标签:zabbix安装及部署

zabbix服务端安装

[root@client conf.d]# rpm -ivh http://www.aminglinux.com/bbs/data/attachment/forum/month_1211/epel-release-6-7.noarch.rpm

 

[root@client conf.d]# yum install -y  httpd mysql mysql-libs php php-mysql mysql-server php-bcmath php-gd php-mbstring

//安装lamp环境

[root@client conf.d]# yum install  zabbix20 zabbix20-agent zabbix20-server  zabbix20-server-mysql zabbix20-web zabbix20-web-mysql net-snmp-devel

//安装zabbix服务

 

[root@client conf.d]# /etc/init.d/zabbix-server start

[root@client conf.d]# /etc/init.d/zabbix-agent start

[root@client conf.d]# netstat -lnp |grep zabbix

tcp    0   0 0.0.0.0:10050      0.0.0.0:*             LISTEN      8507/zabbix_agentd

tcp    0    0 :::10050          :::*                  LISTEN      8507/zabbix_agentd

 

//zabbix_server还未启动

[root@client conf.d]# less /var/log/zabbix/zabbix_server.log          //查看日志信息

8484:20150621:155627.140 [Z3001] connection to database ‘zabbix‘ failed: [1044] Access denied for user ‘‘@‘localhost‘ to database ‘zabbix‘

  8484:20150621:155627.140 Cannot connect to the database. Exiting...

//不能连接到数据库

 

[root@client conf.d]# /etc/init.d/httpd start

[root@client conf.d]# /etc/init.d/mysqld start

 

[root@client conf.d]# mysql -uroot -p -e  "create database zabbix"

[root@client conf.d]# mysql -uroot -p --default-character-set=utf8 zabbix < /usr/share/zabbix-mysql/schema.sql

[root@client conf.d]# mysql -uroot -p --default-character-set=utf8 zabbix < /usr/share/zabbix-mysql/images.sql

 [root@client conf.d]# mysql -uroot -p --default-character-set=utf8  zabbix < /usr/share/zabbix-mysql/data.sql

 

[root@client conf.d]# /etc/init.d/zabbix-server start

[root@client conf.d]# !net

netstat -lnp |grep zabbix

tcp        0      0 0.0.0.0:10050               0.0.0.0:*                   LISTEN      8507/zabbix_agentd

tcp        0      0 :::10050                    :::*                        LISTEN      8507/zabbix_agentd

//还是只有zabbix_agentdserver未启动

[root@client conf.d]# tail /var/log/zabbix/zabbix_server.log

  8909:20150621:160536.422 [Z3001] connection to database ‘zabbix‘ failed: [1044] Access denied for user ‘‘@‘localhost‘ to database ‘zabbix‘

  8909:20150621:160536.422 Cannot connect to the database. Exiting...

//不能连接数据库

 

[root@client conf.d]# mysql -uroot -e "grant all on *.* to ‘zabbix‘@‘localhost‘ identified by ‘zabbix‘;"

 

root@client conf.d]# vim /etc/zabbix/zabbix_server.conf           //查看及修改

DBName=zabbix

DBUser=zabbix

DBPassword=zabbix

 

[root@client conf.d]# ls /var/lib/mysql/mysql.sock          //查看文件是否存在

/var/lib/mysql/mysql.sock

 

[root@client conf.d]# /etc/init.d/zabbix-server start

[root@client conf.d]# !net

netstat -lnp |grep zabbix

tcp   0   0 0.0.0.0:10050      0.0.0.0:*           LISTEN      8507/zabbix_agentd

tcp   0   0 0.0.0.0:10051      0.0.0.0:*           LISTEN      9175/zabbix_server

tcp   0   0 :::10050            :::*              LISTEN      8507/zabbix_agentd

tcp   0   0 :::10051               :::*           LISTEN      9175/zabbix_server

[root@client conf.d]# ps aux |grep zabbix

 

//查看都已启动

 

现网页开始安装zabbix

[root@client conf.d]# /etc/init.d/httpd restart

浏览器访问192.168.137.21/zabbix进入安装页面

技术分享

next

 

[root@client conf.d]# vim /etc/php.ini

post_max_size = 16M

max_execution_time = 300

max_input_time = 300

 

//修改检测未通过的选项

 

[root@client conf.d]# /etc/init.d/httpd restart

 

刷新页面,全部ok通过

技术分享

 

Database namezabbix

User          :zabbix

Password:zabbix

 

next

name:137.23自定义

技术分享

next-------finish

Username:admin

Password:zabbix

技术分享

 

登入:zabbix默认页面

技术分享

 

 

 

 

 

zabbix增加客户端监控

 

客户端

[root@Client ~]# yum install zabbix20-agent

root@Client ~]# vim /etc/zabbix_agentd.conf

Server=192.168.137.21                 //改成服务端的IP

ServerActive=0.0.0.0:10050             //监听所有IP10050端口

Hostname=wang

 

//自定义但要唯一

[root@Client ~]# /etc/init.d/zabbix-agent start

[root@Client ~]# ps aux |grep zabbix

//查看已启动

 

 

服务端:

服务端检测客户端hostname,能够检测出

[root@client conf.d]# zabbix_get -s 192.168.137.23 -p10050 -k "system.hostname"

Client

 

 

WEB页面下:

configuration------- hos--------- Create Host

技术分享

 

 

 

 

Host name 137.23 (自定义)

Visible namewang (自定义)

Agent interfaces:192.168.137.23         10050

 

save保存

点击Templates-----选择要监控的内容---Template OS Linux

技术分享

 

 

 

Configuration-----Hosts-----wang-------Templates----add(添加模板)------Template OS Linux

技术分享

select

技术分享

点开wang,监控的内容都在里面了

技术分享

 

 

zabbix设置邮件报警

服务端:

[root@client conf.d]# yum install -y sendmail

[root@client conf.d]# /etc/init.d/postfix start

 

[root@client conf.d]# mail -s "test" root </etc/passwd       //root发送test邮件

root@client conf.d]# mailq                              //查看有无未发出的邮件

/var/spool/mqueue is empty

                Total requests: 0

[root@client conf.d]# mail                           //收邮件

Heirloom Mail version 12.4 7/29/08.  Type ? for help.

"/var/spool/mail/root": 55 messages 1 new 55 unread

 U 53 root                  Sun Jun 21 17:19  64/2860  "test"

 

打入该邮件数字打开邮件

53

Message 53:

root:x:0:0:root:/root:/bin/bash

bin:x:1:1:bin:/bin:/sbin/nologin

daemon:x:2:2:daemon:/sbin:/sbin/nologin

adm:x:3:4:adm:/var/adm:/sbin/nologin

 

q退出

 

 

[root@client conf.d]# mkdir -p /home/zabbix/bin

[root@client conf.d]# vim /home/zabbix/bin/baojing.sh

#! /bin/bash

 echo "$3" |/bin/mail -s "$2" $1

 

[root@client conf.d]# chmod +x /home/zabbix/bin/baojing.sh

[root@client conf.d]# vim /etc/zabbix_server.conf

AlertScriptsPath=/home/zabbix/bin

ExternalScripts=/home/zabbix/bin

 

 

 

 

WEB页面下

Administration-------Media types----Create media type

技术分享

Description:baojing

Type:Script

Script name:baojing.sh

Enabled:

 

技术分享

save

技术分享

 

 

 

 

创建用户:Administration------ Users-----Users-----Create User

技术分享

 

技术分享

技术分享

技术分享

creat action

技术分享

 

技术分享

 

 

 

 

operation---new--

技术分享

 

 

技术分享

本文出自 “Linux学习笔记” 博客,请务必保留此出处http://9656134.blog.51cto.com/9646134/1678499

Linux监控和安全运维---zabbix安装及部署

标签:zabbix安装及部署

原文地址:http://9656134.blog.51cto.com/9646134/1678499

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