yao000 发表于 2019-1-23 12:18:21

CentOS 6.2 部署zabbix 2.0.6 +ubuntu 上部署agent

  1,环境要求:
            1,最小化安装centos6.2系统
            2,lamp环境
            3,mysql:本机安装可以,有远程数据库也可以.
  安装过程略,见相关文档.                     
            4,安装文件 : zabbix-2.0.6.tar.gz
            5,解压缩安装文件,在任意目录 tar xvf zabbix-2.0.6.tar.gz
   (这里默认为/usr/src下解压后生成文件夹 zabbix-2.0.6)
           6,关闭防火墙或打开80,10050,10051,10052端口
  2,安装zabbix
  安装相关依赖包
         yum installhttpd php php-devel php-gd php-bcmath php-mbstring mysql-server-xml php-mysqlgdnet-snmp net-snmp-develnet-snmp-utils gcc curl-devel make php-xml mysql mysql-server mysql-devel postfix
  openldap openldap-devel OpenIPMI OpenIPMI-devellibssh2 libssh2-devel
  sendmail -y
  3,设置启动项
  Chkconfig httpd on
        Chkconig mysqld on
        Chconfig snmpd on
  在/etc/rc.d/rc.local添加开机启动的命令。
  4,添加用户
# groupadd zabbix
  #Useradd–s /sbin/nologin zabbix–gzabbix
安装Fping:
# wget -c http://fping.org/dist/fping-3.4.tar.gz
# tar zxvf fping-3.4.tar.gz
# cd fping-3.4
# ./configure
# make && make install
# chown root:zabbix /usr/local/sbin/fping
# chmod 4710 /usr/local/sbin/fping
  

  5,安装参数
  官网下载地址http://www.zabbix.com/download.php
        tar zxvf zabbix-2.0.6.tar.gz
        cd zabbix-2.0.6
         ./configure -prefix=/usr/local/zabbix
                     --enable-server
                     --enable-agent
                     --enable-proxy
                 --with-mysql=/usr/bin/mysql_config
                    --with-net-snmp
                    --with-libcurl
                    --enable-java (需装jdk,设置环境变量)
                    --with-ldap (如果需要的话,可以开启,需安装openldap,openldap-devel )
                    --with-openipmi (如果需要的话,可以开启,需安装OpenIPMI,OpenIPMI-devel)
                    --with-ssh2(如果需要的话,可以开启,需安装libssh2,libssh2-devel)
(./configure --prefix=/usr/local/zabbix --enable-server --enable-agent--enable-proxy--with-mysql=/usr/bin/mysql_config--with-net-snmp --with-libcurl --enable-java --with-ldap --with-openipmi--with-ssh2 --with-libcurl
   )
  

  
               make && make install
  6,添加apache站点
      vi/etc/httpd/conf.d/zabbix.conf
Alias /zabbix/usr/local/zabbix

Options Indexes
Allow Override AuthConfig Options
Order allows ,deny
Allow from all

  7,拷贝站点文件到指定目录
Mv/usr/src/zabbix-2.0.6/frontends/php/usr/local/zabbix/php
Service httpdrestart
关闭防火墙墙或者开放10051 端口
  8,初始化数据库
  (若是刚安装的数据库,初始化密码为空)可以修改root的密码
  修改mysql中root的密码:
  shell>mysql -u root –p
  mysql>use user;
  mysql>update mysql.user set password =password('123456') where user='root'
  数据库文件位置;/usr/src/zabbix-2.0.6/database/mysql
mysql> create database zabbixcharacter set utf8;
Query OK, 1 row affected (0.05 sec)


mysql> create user 'zabbix'@'%' identified by '123456';
Query OK, 0 rows affected (0.16 sec)


mysql> grant all on zabbix.* to 'zabbix'@'%';
Query OK, 0 rows affected (0.03 sec)


mysql> flush privileges;
Query OK, 0 rows affected (0.04 sec)
导入Zabbix初始数据:
/usr/src/zabbix-2.0.6/database/mysql
# cd database/mysql/
# mysql -uroot -p
mysql> set sql_log_bin=0;
mysql> source ./schema.sql;
mysql> source ./images.sql;
mysql> source ./data.sql;
mysql> set sql_log_bin=1;
编辑/usr/local/zabbix/etc/zabbix_server.conf:
LogFile=/usr/local/zabbix/logs/zabbix_server.log
PidFile=/usr/local/zabbix/logs/zabbix_server.pid
DBHost=192.168.1.190
DBName=zabbix
DBUser=zabbix
DBPassword=123456
DBPort=3306
FpingLocation=/usr/local/sbin/fping
从安装目录拷贝zabbix_server脚本,并编辑:
# cd zabbix-2.0.6
# cp misc/init.d/fedora/core5/zabbix_server /etc/init.d/
# mkdir -p /usr/local/zabbix/logs
# chown -R zabbix:zabbix /usr/local/zabbix
# vi /etc/init.d/zabbix_server
# cat /etc/init.d/zabbix_server
...
ZABBIX_BIN="/usr/local/zabbix/sbin/zabbix_server"
CONF_FILE="/usr/local/zabbix/etc/zabbix_server.conf"
...
start() {
      ...
      daemon$ZABBIX_BIN -c $CONF_FILE
      ...
}


php.ini配置:
...
memory_limit = 128M
post_max_size = 16M
max_execution_time = 300
max_input_time = 300
session.auto_start = 0 ;必须为0
mbstring.func_overload = 2


   9,在浏览器中输入地址:http://IP/zabbix,通过web安装.
  出现以下界面
  http://blog.运维网.com/e/u/themes/default/images/spacer.gif
  

  若出现
  http://blog.运维网.com/e/u/themes/default/images/spacer.gif
·date(): It is not safe to rely on thesystem's timezone settings. You are *required* to use the date.timezone settingor the date_default_timezone_set() function. In case you used any of thosemethods and you are still getting this warning, you most likely misspelled thetimezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead
  请在服务段php.ini文件开头加入date.timezone=PRC; 重起httpd服务.
  点击Next
  http://blog.运维网.com/e/u/themes/default/images/spacer.gif
  

此页面显示了一些不符合要求的php配置,按要求更改即可.
全部调试ok后点击Next
  配置数据库信息
  http://blog.运维网.com/e/u/themes/default/images/spacer.gif
  配置服务器信息
  http://blog.运维网.com/e/u/themes/default/images/spacer.gif
  

  点击下一步,Next
  如果出现如下提示,请按照说明把文件放到指定目录下.
  http://blog.运维网.com/e/u/themes/default/images/spacer.gif
  点击完成,然后到浏览器输入http://ip/zabbix进入登陆页
  http://blog.运维网.com/e/u/themes/default/images/spacer.gif
  

  默认用户名:admin密码:zabbix
  

  http://blog.运维网.com/e/u/themes/default/images/spacer.gif
  

  10,至此web配置完成,但是会出现提示 服务器没有运行.
安装Zabbix agent:
# cd zabbix-2.0.6
# ./configure --prefix=/usr/local/zabbix --enable-agent
# make && make install
# cp misc/init.d/fedora/core5/zabbix_agentd /etc/init.d/
配置zabbix_agentd:
# groupadd zabbix
# useradd -g zabbix zabbix
# mkdir -p /usr/local/zabbix/logs
# chown zabbix:zabbix -R /usr/local/zabbix/
# vi /usr/local/zabbix/etc/zabbix_agentd.conf
# cat /usr/local/zabbix/etc/zabbix_agentd.conf
...
PidFile=/usr/local/zabbix/logs/zabbix_agentd.pid
LogFile=/usr/local/zabbix/logs/zabbix_agentd.log
Server=1.1.1.142
ListenPort=10050
ServerActive=1.1.1.142
Hostname=zabbix_node191
Timeout=15
Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/
...
配置Zabbix Agent启动脚本:
...
prog="Zabbix Agent"
ZABBIX_BIN="/usr/local/zabbix/sbin/zabbix_agentd"
CONF_FILE="/usr/local/zabbix/etc/zabbix_agentd.conf"
...
start() {
      ...
      daemon$ZABBIX_BIN -c $CONF_FILE
      ...
}
...
开启防火墙端口10050:
Ubuntu 部署zabbix-agent
  上面的配置是centos ,一下是debian 和Ubuntu
  安装和上面的一样
  配置conf文件和上面都一样
  不一样的是启动文件
  Cp /usr/src/zabbix-2.0.6/misc/init.d/debian/zabbix-agent/etc/init.d/
  Vim zabbix.agent
  DAEMON=/usr/local/zabbix/sbin/${NAME}
PID=/usr/local/zabbix/logs/zabbix_agentd.pid
$ chmod 755 /etc/init.d/zabbix-agent
$ update-rc.d zabbix-agent defaults
$ /etc/init.d/zabbix-agent start
$ /etc/init.d/zabbix-agent restart
  

  




页: [1]
查看完整版本: CentOS 6.2 部署zabbix 2.0.6 +ubuntu 上部署agent