yinian 发表于 2017-4-20 10:28:06

Zabbix 1.8 的安装过程

  Zabbix 是一个提供 Web 管理界面的开源系统/网络监控服务器。
官方的文档写得非常好,许多内容这里就不介绍了,可以直接看官方文档:
http://www.zabbix.com/documentation/
  本文只记录我的 Zabbix 1.8 的安装过程。
以下我要在同一台服务器上安装 Zabbix Server、Zabbix Proxy 和 Zabbix Agent。
  安装前先配置好PHP,要求支持 php-gd、php-bcmath、php-xml、php-mysql、php-net-socket、php-mbstring,即 configure 参数中加上 –with-gd –enable-bcmath –enable-xml –with-mysql –enable-sockets –enable-mbstring。
  我的配置参数如下:
  ./configure –prefix=/usr/local/php –with-config-file-path=/usr/local/php/etc –with-mysql=/usr/local/mysql –with-mysqli=/usr/local/mysql/bin/mysql_config –enable-fpm –enable-sockets –enable-pdo –with-pdo-mysql=/usr/local/mysql –with-gd –enable-bcmath –enable-xml –enable-mbstring
  下面开始安装 Zabbix:
  * 下载并解压:
  wget http://prdownloads.sourceforge.net/zabbix/zabbix-1.8.tar.gz?download
tar zxf zabbix-1.8.tar.gz
cd zabbix-1.8
  * 创建 zabbix 用户组和用户:
  groupadd zabbix
useradd zabbix -g zabbix
  * 创建 mysql 数据库:
  create database zabbix character set utf8;
  * 创建 mysql 用户:
  grant all on zabbix.* to zabbix@localhost identified by ‘zabbix’;
  * 导入表和数据:
  mysql -uroot -p zabbix < create/schema/mysql.sql
mysql -uroot -p zabbix < create/data/data.sql
mysql -uroot -p zabbix < create/data/images_mysql.sql
  * 配置编译:
  ./configure –enable-server –enable-proxy –enable-agent –with-mysql=/usr/local/mysql/bin/mysql_config –with-net-snmp –with-libcurl
make && make install
  配置参数说明:
  –enable-server 安装 Zabbix Server
–enable-proxy 安装 Zabbix Proxy
–enable-agent 安装 Zabbix Agent
–with-mysql 使用 mysql 做数据库服务器
–with-net-snmp 支持 SNMP
–with-libcurl 支持 curl,用于 web 监控
  * 服务端口定义:
编辑 /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 Trapper
  * 复制配置文件:
  mkdir /etc/zabbix
cp misc/conf/zabbix_server.conf /etc/zabbix/
cp misc/conf/zabbix_proxy.conf /etc/zabbix/
cp misc/conf/zabbix_agent.conf /etc/zabbix/
cp misc/conf/zabbix_agentd.conf /etc/zabbix/
  * 修改 zabbix server 配置文件 /etc/zabbix/zabbix_server.conf 中的数据库用户名和密码:
  DBUser=zabbix
DBPassword=zabbix
  * 安装启动脚本
  cp misc/init.d/gentoo/zabbix-server /etc/init.d/
cp misc/init.d/gentoo/zabbix-agentd /etc/init.d/
  添加可执行权限:
  chmod +x /etc/init.d/zabbix-server
chmod +x /etc/init.d/zabbix-agentd
  修改 zabbix-server 头部变量定义:
  NAME=zabbix_server
PATH=/bin:/usr/bin:/sbin:/usr/sbin
DAEMON=/usr/local/sbin/${NAME}
DESC=”Zabbix 1.4″
PID=/var/run/$NAME.pid
  修改 zabbix-agentd 头部变量定义:
  NAME=zabbix_agentd
PATH=/bin:/usr/bin:/sbin:/usr/sbin
DAEMON=/usr/local/sbin/${NAME}
DESC=”Zabbix 1.4″
PID=/var/run/$NAME.pid
  * 添加到启动服务:
  rc-update add zabbix-server default
rc-update add zabbix-agentd default
  * 启动 Zabbix Server:
  /etc/init.d/zabbix-server start
  我启动时提示错误:
  zabbix_server: error while loading shared libraries: libmysqlclient.so.16: cannot open shared object file: No such file or directory
  因为我的 mysql client 库不在系统默认库中,做以下修改后重新启动就可以了:
  echo /usr/local/mysql/lib/mysql/ >> /etc/ld.so.conf
ldconfig
  * 启动 Zabbix Agentd
  /etc/init.d/zabbix-agentd start
  * 复制 Web Interface 到 web 目录:
  cp -r frontends/php /work/www/zabbix
  * 新建 nginx 配置:
  server {
listen       80;
server_name  zabbix.local zabbix.hily;
  access_log  /work/www/logs/zabbix.local.access.log  main;
  location / {
root   /work/www/zabbix;
index  index.html index.htm index.php;
}
  location ~ \.php$ {
root           /work/www/zabbix;
fastcgi_index  index.php;
include        fastcgi_params;
}
  }
  * 开始安装 Zabbix Web Interface
打开 http://zabbix.local/,看到提示:
  Timezone for PHP is not set. Please set “date.timezone” option in php.ini.
  按照提示,修改 php.ini 中时区设置:
  date.timezone = Asia/Shanghai
  重启 PHP-FPM:
  /etc/init.d/php-fpm restart
  监测环境时提示:
http://hily.me/blog/wp-content/uploads/2010/01/1.png
再次修改 php.ini:
  post_max_size = 16M
max_execution_time = 300
mbstring.func_overload = 2
  解决后按提示继续安装即可。
  * 结束:
安装完后直接访问:
  http://zabbix.local/
  默认用户名和密码是:
Admin/zabbix
到此安装完成!
  – EOF –
页: [1]
查看完整版本: Zabbix 1.8 的安装过程