centos6.5 搭建zabbix3.0

Posted 借风拥你

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos6.5 搭建zabbix3.0相关的知识,希望对你有一定的参考价值。

一.搭建LAMP平台

注意zabbix3.0需要php5.4以上的版本

(1)安装依赖包

httpd和mysql安装过程省略

rpm -e httpd --nodeps

 

yum -y install mysql-devel gcc gcc-c++ autoconf httpd-manual mod_perl mod_auth_mysql mysql-connector-odbc libdbi-dbd-mysql net-snmp-devel curl-devel unixODBC-devel java-devel openldap openldap-devel ncurses-devel

 

2)安装源码包LAMP

php编译参数

./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/httpd/bin/apxs --with-mysql=/usr/local/mysql --with-openssl --enable-sockets --enable-sysvshm --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib-dir --with-libxml-dir=/usr --enable-xml --with-mhash --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-curl --with-gd --with-gettext --enable-bcmath --enable-opcache

 

cp php.ini-development  /etc/php.ini

 

 

建议用源码包安装PHP

 

 

 

修改php.ini  因为zabbix的运行环境要求,否则zabbix 的环境检测室无法通过的

 

 vim /etc/php.ini

440 max_execution_time = 300

449 max_input_time = 300

457 memory_limit = 128M

706 always_populate_raw_post_data = -1 #去掉注释

729 post_max_size = 16M

946 date.timezone = Asia/Shanghai    #启用并修改

1586 mbstring.func_overload = 2       #启用并修改

 

 

4.修改php配置文件(用sed修改上边的参数)

 

sed -i "[email protected];date.timezone [email protected] = Asia/[email protected]" /etc/php.ini

sed -i "[email protected]_execution_time = [email protected]_execution_time = [email protected]" /etc/php.ini
sed -i "[email protected]_max_size = [email protected]_max_size = [email protected]" /etc/php.ini

sed -i "[email protected]_input_time = [email protected]_input_time = [email protected]" /etc/php.ini

sed -i "[email protected]_limit = [email protected]_limit = [email protected]" /etc/php.ini

sed -i "[email protected];mbstring.func_overload = [email protected]_overload = [email protected]" /etc/php.ini

 

5、启动httpdmysql

/etc/init.d/httpd start

/etc/init.d/mysqld start

 

6、编译安装zabbix

useradd -s /sbin/nologin zabbix

mkdir /etc/zabbix /var/log/zabbix

chown -R zabbix.zabbix /var/log/zabbix/

 

更改系统时间,系统时间和北京时间一致

date 041211482017

tar xf zabbix-3.0.4.tar.gz  -C /usr/src/

cd /usr/src/zabbix-3.0.4/

 

./configure --prefix=/usr/local/zabbix --sysconfdir=/etc/zabbix/ \

--enable-server \

--enable-proxy\

 --enable-agent\

 --enable-ipv6\

 --with-mysql=/usr/bin/mysql_config\

 --with-net-snmp\

 --with-libcurl\

 --with-unixodbc\

 --with-ldap \

--enable-java

 

make && make install

 

 

复制启动脚本

cp misc/init.d/fedora/core/zabbix_* /etc/init.d/

编辑启动脚本,更改安装路径

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

 

7.修改zabbix的主配置文件

cd /etc/zabbix/

cp zabbix_server.conf zabbix_server.conf.origin

vim  zabbix_server.conf

39 LogFile=/var/log/zabbix/zabbix_server.log

87 DBName=zabbix

103 DBUser=zabbix

112  DBPassword=zabbix

120  DBSocket=/tmp/mysql.sock

128  DBPort=3306

77  DBHost=localhost

 

可以用sed修改

sed -i "[email protected][email protected][email protected]" /etc/zabbix/zabbix_server.conf
sed -i "[email protected]#[email protected][email protected]" /etc/zabbix/zabbix_server.conf
sed -i "[email protected]# [email protected][email protected]" /etc/zabbix/zabbix_server.conf
sed -i "[email protected] # DBSocket=/tmp/[email protected] DBSocket=/tmp/[email protected]" /etc/zabbix/zabbix_server.conf

sed -i "[email protected]# [email protected]=3306 @g" /etc/zabbix/zabbix_server.conf

sed -i "[email protected]# [email protected][email protected]" /etc/zabbix/zabbix_server.conf

 

cp zabbix_agentd.conf zabbix_agentd.conf.origin

编辑agentd.conf的配置文件

vim zabbix_agentd.conf

 LogFile=/var/log/zabbix/zabbix_agentd.log

 91 Server=127.0.0.1,192.168.3.10    #服务端IP

 132 ServerActive=192.168.3.10:10051   #服务端IP,固定端口

 264 Include=/etc/zabbix/zabbix_agentd.conf.d/     #自定义配置文件的路径

 280 UnsafeUserParameters=1   #自定义脚本功能,1为开启

 

8.导入数据库文件

cd /usr/src/zabbix-3.0.4/

mysqladmin -u root password ‘123123‘

 

登录mysql创建数据库,并且授权

mysql> create database zabbix character set utf8;

Query OK, 1 row affected (0.02 sec)

mysql> grant all on zabbix.* to ‘zabbix‘@localhost identified by ‘zabbix‘;

Query OK, 0 rows affected (0.03 sec)

mysql> flush privileges;        #刷新权限

Query OK, 0 rows affected (0.00 sec)

 

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

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

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

 

 

9、部署php页面

cd /usr/src/zabbix-3.0.4/

cp -rf frontends/php/ /usr/local/httpd/htdocs/zabbix/

chown -R apache:apache /usr/local/httpd/htdocs/zabbix/

 

 10、通过浏览器测试

http://192.168.3.10/zabbix/setup.php

 

 

 

 

 

以上是关于centos6.5 搭建zabbix3.0的主要内容,如果未能解决你的问题,请参考以下文章

[整理]Centos6.5 + hadoop2.6.4环境搭建

centos6.5搭建nginx

centos6.5上NFS服务器搭建!!!

centos6.5上搭建git2.3.0服务器

CentOS6.5 基础环境搭建 [个人整理-亲测可用]

CentOS6.5搭建LNMP