ops2003 发表于 2015-9-9 08:59:32

zabbix监控服务器部署

1.服务器安装lamp环境
  # yuminstall gcc gcc-c++ autoconf httpd php mysql mysql-server php-mysql httpd-manual mod_ssl mod_perl mod_auth_mysql php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc php-bcmath mysql-connector-odbcmysql-devel libdbi-dbd-mysql net-snmp-devel curl-devel -y
2.配置lamp环境
  # vim /etc/php.ini
  date.timezone = Asia/Shanghai
  max_execution_time = 300
  max_input_time = 300   
  memory_limit = 128M
  post_max_size = 32M
  mbstring.func_overload = 2
  
  启动服务
  # service mysqld start
  # service httpd start
  添加到开机启动
  # chkconfig mysqld on
# chkconfig httpd on

3.下载并安装zabbix服务端
  # wget http://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/2.0.9/zabbix-2.0.9.tar.gz/download
  # groupadd zabbix -g 201
# useradd -g zabbix -u 201 -m zabbix
# tar zxf zabbix-2.0.9.tar.gz
  # cd zabbix-2.0.9
#
  # ./configure --prefix=/usr/local/zabbix --enable-se
rver --enable-proxy --enable-agent --with-mysql=/usr/bin/mysql_config --with-ne
t-snmp --with-libcurl
  # make && make install
  # echo $?
0
#
3.1添加zabbix到系统服务
  # vim /etc/services
  zabbix-agent    10050/tcp                     #zabbix agent
zabbix-agent    10050/udp                     #zabbix agent
zabbix-trapper10051/tcp                     #zabbix trapper
zabbix-trapper10051/udp                     #zabbix trapper
  # cd zabbix-2.0.9
  # mysqladmin -uroot password 'redhat'
  # mysql -uroot -p
  Enter password:
  Welcome to the MySQL monitor.
  Commands end with ; or \g.
  Your MySQL connection id is 3 Server version: 5.0.95 Source distribution
  Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
  Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.
  Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  mysql> create database zabbix character set utf8;
  Query OK, 1 row affected (0.00 sec)
  mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabb ix';
  Query OK, 0 rows affected (0.00 sec)
  mysql> flush privileges;
  Query OK, 0 rows affected (0.00 sec)
  mysql>
3.2 导入数据库
  # mysql -uzabbix -pzabbix zabbix < ./database/mysql/schema.sql
# mysql -uzabbix -pzabbix zabbix < ./database/mysql/images.sql
# mysql -uzabbix -pzabbix zabbix < ./database/mysql/data.sql         
3.3 创建软链接
  # 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/
  修改配置文件中的数据库用户名和密码
  # vim /etc/zabbix/zabbix_server.conf
  DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
  拷贝web程序到html目录下
  # cp -r /root/tools/zabbix-2.0.9/frontends/php/ /var/www/html/z
abbix
# chown -R zabbix.zabbix /var/www/html/zabbix/
  # cp /root/tools/zabbix-2.0.9/misc/init.d/fedora/core5/zabbix_s
erver /etc/init.d/
# cp /root/tools/zabbix-2.0.9/misc/init.d/fedora/core5/zabbix_a
gentd /etc/init.d/
#
  注:这个地方存放脚本的目录结构也有变化,没有redhat这个目录,只有cp的fedora目录里的启动脚本
  修改zabbix_server和zabbix_agentd文件
  # vim /etc/init.d/zabbix_server
  ZABBIX_BIN="/usr/sbin/zabbix_server"
  # vim /etc/init.d/zabbix_agentd
  ZABBIX_BIN="/usr/sbin/zabbix_agentd"
  启动
  # service zabbix_server start   
Starting Zabbix Server:
# service zabbix_agentd start
Starting Zabbix Agent:
#



  


  

  # chown -R apache:zabbix /var/www/html/zabbix/



  监控本机:configuration——hosts——enable


  
  
页: [1]
查看完整版本: zabbix监控服务器部署