zabbix3.0安装过程记录
一 前言:经测试,同样的系统安装不同的zabbix版本,遇到的错误完全不一样,之前安装2.4.5版本基本很顺利,但是安装3.0.2遇到了好多新的问题,特此记录系统:centos6.7 zabbix版本:3.0.2
二 安装开发软件包
yum-y groupinstall "Development Tools"
三搭建lnmp环境1 升级php版本(注意:zabbix3.0要求php版本要在5.4以上),但是我们的centos6系统自带的php版本比较低
所以我们添加新的yum源
添加epel 源
rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
添加remi 源
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
安装PHP
# yum --enablerepo=remi,remi-php55 install php-fpm php-common php-devel php-mysqlnd php-mbstring php-mcrypt
php-gd php-xmlphp-bcmath
查看PHP 版本
# php -v
PHP 5.5.9 (cli) (built: Feb 11 2014 08:25:33)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
启动php-fpm
# service php-fpm start
2 安装nginx并能解析php文件cd /usr/local/src/
wget http://nginx.org/download/nginx-1.6.2.tar.gz
tar zxvf nginx-1.6.2.tar.gz
cd nginx-1.6.2
./configure--prefix=/usr/local/nginx --with-pcre
如果这一步报错提示./configure: error: theHTTP rewrite module requires the PCRE library.
则可以安装yum -y install pcre-devel 解决问题
更改配置文件nginx.conf把这部分的注释去掉并更改
location ~ \.php$ { root html; fastcgi_pass127.0.0.1:9000; fastcgi_indexindex.php; fastcgi_param SCRIPT_FILENAME/usr/local/nginx/html$fastcgi_script_name; include fastcgi_params; }
启动nginx 服务/usr/local/nginx/sbin/nginx-s reload
3 安装mysql即一些依赖包yum -y install mysqlmysql-server curl curl-devel net-snmp net-snmp-devel perl-DBI
然后启动mysql服务
三 同步服务端的时间,保持所有服务器时间一致避免出现时间不同导致的不可用的监控数据
ntpdate asia.pool.ntp.rog
四创建zabbix服务运行所需要的用户和组
groupadd-g 201 zabbix
useradd-g zabbix-u201 -m zabbix
五创建数据库mysql>create database zabbixcharacter set utf8; 创建数据库zabbix
mysql>
grant all privileges on zabbix.*to zabbix@localhost identified by 'zabbix';
(这步写的用户名和密码必须和zabbix_server.conf配置文件里的用户名和密码相同)
flush privileges;
六 下载解压zabbixwgethttp://120.52.73.49/tenet.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.0.3/zabbix-3.0.3.tar.gz
tar zxvf zabbix-3.0.3.tar.gz
cd zabbix-3.0.3
将zabbix初始数据导入数据库
mysql -uzabbix -pzabbixzabbix <database/mysql/schema.sql
mysql -uzabbix-pzabbix zabbix <database/mysql/images.sql
mysql -uzabbix-pzabbix zabbix <database/mysql/data.sql
七编译安装 ./configure
--prefix=/usr/local/zabbix
--enable-server--enable-agent --with-mysql --enable-ipv6--with-net-snmp --with-libcurl --with-ssh2 --enable-java##(监控tomcat需要写java这个)
会出现很多错误
error:Invalid Net-SNMP directory - unable to find net-snmp-config
yum installnet-snmp-devel
configure: error: Jabber librarynot found
#yum install iksemel-devel -y 即可,
configure: error: LIBXML2library not found
#yum install libxml2-devel -y
configure: error: unixODBClibrary not found
#yum install unixODBC-devel -y
configure: error: InvalidOPENIPMI directory - unable to findipmiif.h
#yum install OpenIPMI-devel
configure: error: Curl librarynot found
# yum install curl-devel -y
configure: error: SSH2 library not found
yum install -y libssh2-devel
然后 make && make install
八复制zabbix server、agent端的启动脚本,并设置执行权限
cpmisc/init.d/fedora/core/zabbix_server /etc/init.d/
cpmisc/init.d/fedora/core/zabbix_agentd /etc/init.d/
chmod +x/etc/init.d/zabbix_*
启动 zabbix服务
/etc/init.d/zabbix_serverstart
/etc/init.d/zabbix_agentdstart
你会发现启动的时候无法启动
解决办法:
# vim/etc/init.d/zabbix_server
BASEDIR=/usr/local/zabbix
# vim /etc/init.d/zabbix_agentd
BASEDIR=/usr/local/zabbix
其中/usr/local/zabbix是你zabbix安装的目录
九修改zabbix_server.conf配置文件 修改vim /usr/local/zabbix/etc/zabbix_server.conf
30:LogFile=/tmp/zabbix_server.log
77:DBName=zabbix
93:DBUser=zabbix
101:DBPassword=zabbix
108:DBSocket=/var/lib/mysql/mysql.sock(要跟数据库配置文件保持一致)
十 配置php文件 vi /etc/php.ini
date.timezone = Asia/Shanghai
max_execution_time = 300
max_input_time = 300
post_max_size = 32M
memory_limit = 128M
十一 配置web站点cdzabbi-3.0.3
cp -r frontends/php /usr/local/nginx/html/zabbix
十二在浏览器里面安装http://ip/zabbix/setup.php我只把报错的地方贴了出来。
第二步报错:
解决办法
vim /目录/zabbix/include/classes/setup/CFrontendSetup.php,找到下面代码、关于always-populate-raw-post-data;
添加 $current =-1;
如下所示:
1
2
3
4
5
6
7
8
9
10
11
public functioncheckPhpAlwaysPopulateRawPostData() {
$current =ini_get(‘always_populate_raw_post_data‘);
$current = -1;
return array(
‘name‘ => _(‘PHPalways_populate_raw_post_data‘),
‘current‘ =>($current != -1) ? _(‘on‘) : _(‘off‘),
‘required‘ =>_(‘off‘),
‘result‘ =>($current != -1) ? self::CHECK_FATAL : self::CHECK_OK,
‘error‘ => _(‘PHPalways_populate_raw_post_data must be set to -1.‘)
);
}
然后再回到页面刷新,正常:
最后一直到安装完毕没有再报错
十三设置中文安装完毕后,默认是不支持中文的,需要更改一个配置文件vim/usr/local/nginx/html/zabbix/include/locales.inc.php
'zh_CN' => ['name' => _('Chinese(zh_CN)'), 'display' => true],##把false改成true即可,然后更改语言你就看到中文了
十四总结 1 php需要升级,2.4版本不需要.
2搭建网站环境,我2.4之前用的是lamp,安装的时候没有任何问题,但是3.0用的lamp安装的时候不能解析php文件,故换成了lnmp。
3 zabbix2.4版本安装完成之后默认的就支持中文,但是3.0不支持,需要你改配置文件
十五客户端安装1安装编译环境
Yum install gcc*
2 增加zabbix用户,否则无法启动zabbix服务
groupadd-g 201 zabbix
useradd-g zabbix-u201 -m zabbix
3编译安装zabbix
tar -zxvfzabbix-3.0.3.tar.gzcd zabbix-3.0.3 ./configure --prefix=/usr/local/zabbix/ --enable-agentmakemake install
4 更改配置文件
cat /usr/local/zabbix/etc/zabbix_agentd.conf|grep-n ^[^#] 编辑下面四行21:LogFile=/tmp/zabbix_agentd.log81:Server=127.0.0.1,192.168.234.134##zabbix_server的ip122:ServerActive=192.168.234.134:10051133:Hostname=Zabbix server5 启动zabbix服务 Cpmisc/init.d/fedora/core/zabbix_agentd/etc/init.d/vim /etc/init.d/zabbix_agentd BASEDIR=/usr/local/zabbix ## BASEDIR=实际安装路径最后启动服务/etc/init.d/zabbix_agentd start6 测试客户端是否与服务端正常通信
在zabbix_server端测试
zabbix_get -s 客户端ip -p10050 -k"system.hostname"
页:
[1]