标签: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_agentd,server未启动
[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 name:zabbix
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 //监听所有IP和10050端口
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 name:wang (自定义)
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
标签:zabbix安装及部署
原文地址:http://9656134.blog.51cto.com/9646134/1678499