Chinaunix首页 | 论坛 | 博客
  • 博客访问: 250772
  • 博文数量: 49
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1334
  • 用 户 组: 普通用户
  • 注册时间: 2014-03-14 08:53
个人简介

勤于思考,默默学习。

文章分类

全部博文(49)

文章存档

2017年(1)

2016年(2)

2015年(1)

2014年(45)

我的朋友

分类: 系统运维

2015-03-05 17:37:31

环境配置:zabbix服务器IP地址为192.168.10.250/24
         被监控机为Linux server 192.168.10.1
=====================================================================================================


cd /etc/yum.repos.d/
mkdir test
mv C* test
cat >aa.repo < [bb]
name=bb
baseurl=file:///misc/cd/
enabled=1
gpgcheck=0
end


yum -y install gcc gcc-c++ autoconf httpd php mysql mysql-server php-mysql php-gd php-xml mysql-connector-odbc mysql-devel 
yum -y install libdbi-dbd-mysql httpd-manual mod_ssl mod_perl mod_auth_mysql php-ldap php-pear net-snmp-devel curl-devel php-xmlrpc
yum -y install php-mbstring php-bcmath


sed -i "s/;date.timezone =/date.timezone = Asia\/Shanghai/g" /etc/php.ini
sed -i "s#max_execution_time = 30#max_execution_time = 300#g" /etc/php.ini
sed -i "s#post_max_size = 8M#post_max_size = 32M#g" /etc/php.ini
sed -i "s#max_input_time = 60#max_input_time = 300#g" /etc/php.ini
sed -i "s#memory_limit = 128M#memory_limit = 128M#g" /etc/php.ini
sed -i "/;mbstring.func_overload = 0/ambstring.func_overload = 2\n" /etc/php.ini


chkconfig mysqld on
chkconfig httpd on
service mysqld start
service httpd start


groupadd zabbix -g 201
useradd -g zabbix -u 201 -m zabbix
cd ~
tar xzf zabbix-2.0.3.tar.gz
cd zabbix-2.0.3
./configure --prefix=/usr/local/zabbix --enable-server --enable-proxy --enable-agent --with-mysql=/usr/bin/mysql_config --with-net-snmp --with-libcurl 
make
make install


cat >> /etc/services < zabbix-agent 10050/tcp   #Zabbix Agent
zabbix-agent 10050/udp   #Zabbix Agent
zabbix-trapper 10051/tcp #Zabbix Trapper
zabbix-trapper 10051/udp #Zabbix Trappe
end


mysqladmin -uroot password 123456 (设置mysql 的root 密码)
mysql -uroot -p123456 (登陆数据库)
mysql>create database zabbix character set utf8;
mysql>grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
mysql>flush privileges;
mysql>\q


mysql -uzabbix -pzabbix zabbix < ./database/mysql/schema.sql
mysql -uzabbix -pzabbix zabbix < ./database/mysql/images.sql
mysql -uzabbix -pzabbix zabbix < ./database/mysql/data.sql


mkdir /var/log/zabbix
chown zabbix.zabbix /var/log/zabbix
ln -s /usr/local/zabbix/etc /etc/zabbix
ln -s /usr/local/zabbix/bin/* /usr/bin/
ln -s /usr/local/zabbix/sbin/* /usr/sbin/


cp misc/init.d/fedora/core/zabbix_* /etc/init.d/
chmod 755 /etc/init.d/zabbix_*
sed -i "s#BASEDIR=/usr/local#BASEDIR=/usr/local/zabbix#g" /etc/init.d/zabbix_server
sed -i "s#BASEDIR=/usr/local#BASEDIR=/usr/local/zabbix#g" /etc/init.d/zabbix_agentd


sed -i "s/DBUser\=root/DBUser\=zabbix/g" /etc/zabbix/zabbix_server.conf
sed -i "/# DBPassword=/aDBPassword=zabbix\n" /etc/zabbix/zabbix_server.conf
sed -i "s#tmp/zabbix_server.log#var/log/zabbix/zabbix_server.log#g" /etc/zabbix/zabbix_server.conf


sed -i "s/^Hostname=.*/Hostname=zabbix.example.com/g"  /etc/zabbix/zabbix_agentd.conf
sed -i "s/Server\=127.0.0.1/Server\=127.0.0.1,192.168.10.250/g"  /etc/zabbix/zabbix_agentd.conf
sed -i "s/ServerActive\=127.0.0.1/ServerActive\=192.168.10.250:10051/g"  /etc/zabbix/zabbix_agentd.conf
sed -i "s#tmp/zabbix_agentd.log#var/log/zabbix/zabbix_agentd.log#g"  /etc/zabbix/zabbix_agentd.conf
sed -i "/UnsafeUserParameters=0/aUnsafeUserParameters=1\n"  /etc/zabbix/zabbix_agentd.conf




cp -r ./frontends/php/ /var/www/html/zabbix
chown -R apache.apache /var/www/html/zabbix


chkconfig zabbix_server --add
chkconfig zabbix_agentd --add
service zabbix_server start
service zabbix_agentd start


  在浏览器中安装zabbix


=======================================================================================================


在Linux客户端(被监控机)操作如下:
yum -y install gcc 
groupadd zabbix -g 201
useradd -g zabbix -u 201 -m zabbix
tar xzf zabbix-2.0.3.tar.gz
cd zabbix-2.0.3
./configure --prefix=/usr/local/zabbix --enable-agent
make
make install
mkdir /var/log/zabbix
chown zabbix.zabbix /var/log/zabbix
cp misc/init.d/fedora/core/zabbix_agentd /etc/init.d/
chmod 755 /etc/init.d/zabbix_agentd
sed -i "s#BASEDIR=/usr/local#BASEDIR=/usr/local/zabbix#g" /etc/init.d/zabbix_agentd
ln -s /usr/local/zabbix/etc /etc/zabbix
ln -s /usr/local/zabbix/bin/* /usr/bin/
ln -s /usr/local/zabbix/sbin/* /usr/sbin/


cat >> /etc/services < zabbix-agent 10050/tcp   #Zabbix Agent
zabbix-agent 10050/udp   #Zabbix Agent
zabbix-trapper 10051/tcp #Zabbix Trapper
zabbix-trapper 10051/udp #Zabbix Trappe
end


## 监控服务器为10.250,被监控机(本机)为10.1 
sed -i "/SourceIP=.*/aSourceIP=192.168.10.1\n" /etc/zabbix/zabbix_agentd.conf 
sed -i "/ListenPort=.*/aListenPort=10050\n" /etc/zabbix/zabbix_agentd.conf
sed -i "s/Server\=127.0.0.1/Server\=192.168.10.250/g" /etc/zabbix/zabbix_agentd.conf
sed -i "s#tmp/zabbix_agentd.log#var/log/zabbix/zabbix_agentd.log#g" /etc/zabbix/zabbix_agentd.conf
sed -i "/UnsafeUserParameters=0/aUnsafeUserParameters=1\n" /etc/zabbix/zabbix_agentd.conf
sed -r -i "s/(ServerActive=.*)/#\1/" /etc/zabbix/zabbix_agentd.conf
chkconfig zabbix_agentd on
service zabbix_agentd start


yum -y install net-snmp
mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.bak
cat > /etc/snmp/snmpd.conf < com2sec mynetwork 192.168.10.250 public
com2sec mynetwork 127.0.0.1 public
group MyROGroup v2c mynetwork
access MyROGroup "" any noauth prefix all none none
view all included .1 80
end
chkconfig snmpd on
service snmpd start


========================================================================================================


windows 被监控主机操作
 1、在C:\Program Files\下创建zabbix文件夹
 2、解压zip包后:将包内bin/win64/下的所有文件复制到 C:\Program Files\zabbix下
 3、并在该目录下创建一个zabbix_agentd.conf文件,内容为
    LogFile=C:\Program Files\zabbix\zabbix_agentd.log
    Server=192.168.10.250
    UnsafeUserParameters=1
 4、进入cmd命令行:
 # cd C:\Program Files\zabbix
 安装zabbix客户端:
 # zabbix_agentd.exe -c "c:\Program Files\zabbix\zabbix_agentd.conf" -i
 启动zabbix服务:
 # zabbix_agentd.exe -c "c:\Program Files\zabbix\zabbix_agentd.conf" -s


参数含义:
 -c    制定配置文件所在位置
 -i    安装客户端
 -s    启动客户端
 -x    停止客户端
 -d    卸载客户端


========================================================================================================














阅读(2625) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~