zabbix的安装配置

ZABBIX服务端安装

zabbix服务器端需要LAMP环境,即linux、appache、mysql、php

linux:CentOS release 6.5

appache:2.2.15

mysql:5.6

php:5.6.13

zabbix:3.0.3



1、安装appache

CentOS6默认安装了appache,不需要重新安装

[root@oatest ~]# httpd -v

Server version: Apache/2.2.15 (Unix)

Server built:   Oct 19 2017 16:43:38

[root@oatest ~]# apachectl -v

Server version: Apache/2.2.15 (Unix)

Server built:   Oct 19 2017 16:43:38



2.安装PHP

Zabbix 3.0对PHP的要求最低为5.4,而CentOS6默认为5.3.3,完全不满足要求,故需要利用第三方源,将PHP升级到5.6,下载地址 http://cn2.php.net/distributions/php-5.6.13.tar.gz

[root@oatest ~]# cat /etc/issue

CentOS release 6.5 (Final)

[root@oatest ~]# rpm -qa|grep -i php

php-common-5.3.3-49.el6.x86_64

php-cli-5.3.3-49.el6.x86_64

php-5.3.3-49.el6.x86_64

[root@oatest ~]# rpm -e php-5.3.3-49.el6.x86_64

[root@oatest ~]# rpm -e php-cli-5.3.3-49.el6.x86_64

[root@oatest ~]# rpm -e php-common-5.3.3-49.el6.x86_64

[root@oatest ~]# cd /u01/software/

[root@oatest software]# tar -zxvf php-5.6.13.tar.gz

[root@oatest software]# cd php-5.6.13

[root@oatest php-5.6.13]# ./configure --prefix=/usr/local/php  --with-apxs2=/usr/local/apache/bin/apxs  --with-mysqli

--报错/usr/local/apache/bin/apxs: No such file or directoryconfigure

[root@oatest php-5.6.13]# find / -name apxs

--没有结果

[root@oatest php-5.6.13]# yum install -y httpd-devel

[root@oatest php-5.6.13]# find / -name apxs

--显示结果/usr/sbin/apxs

[root@oatest php-5.6.13]# ./configure --prefix=/usr/local/php  --with-apxs2=/usr/sbin/apxs  --with-mysqli

[root@oatest php-5.6.13]# make

--提示Don't forget to run 'make test'

--不需要运行这段make test

[root@oatest php-5.6.13]# make install

[root@oatest php-5.6.13]# php -version

[root@oatest php-5.6.13]# vi /etc/httpd/conf/httpd.conf

找到:

  AddType application/x-compress .Z

  AddType application/x-gzip .gz .tgz

在后面添加:

  AddType application/x-httpd-php .php #(使Apcche支持PHP)

  AddType application/x-httpd-php-source .php5 

[root@oatest php-5.6.13]# service httpd restart

--在/var/www/html/目录下建立一个文件index.php,内容如下

<?php

phpinfo();

?>

http://IP/index.php

查看appche是否可以正常显示php的内容

可以看到php.ini的路径,Configuration File (php.ini) Path /usr/local/php/lib


[root@oatest php-5.6.13]# cp php.ini-development  /usr/local/php/lib/php.ini

[root@oatest php-5.6.13]# vi /usr/local/php/lib/php.ini

新增如下

date.timezone = Asia/Shanghai

post_max_size = 32M

max_execution_time = 300

max_input_time = 300

always_populate_raw_post_data = -1



3.安装MySQL

MySQL建议使用5.6版本,CentOS6默认为5.1,不建议使用

[root@oatest ~]# cat /etc/issue

CentOS release 6.5 (Final)

[root@oatest ~]# rpm -qa|grep -i mysql

mysql-libs-5.1.71-1.el6.x86_64

[root@oatest ~]# rpm -e mysql-libs-5.1.71-1.el6.x86_64 --nodeps

[root@oatest ~]# cd /u01/software/

[root@oatest software]# rpm -ivh MySQL-client-5.6.10-1.rhel5.x86_64.rpm MySQL-server-5.6.10-1.rhel5.x86_64.rpm MySQL-devel-5.6.10-1.el6.x86_64.rpm MySQL-shared-5.6.10-1.el6.x86_64.rpm MySQL-shared-compat-5.6.10-1.el6.x86_64.rpm

--必须安装MySQL-devel,要不后面的zabbix安装的configure中会报错configure: error: MySQL library not found

--必须安装MySQL-shared,要不后面的zabbix安装的configure中会报错configure: error: Not found mysqlclient library

[root@oatest software]# service mysql start

[root@oatest software]# cat /root/.mysql_secret

# The random password set for the root user at Tue Aug 28 18:14:24 2018 (local time): kmRkDSXX

[root@oatest software]# mysql -u root -p

Enter password:输入上面的kmRkDSXX

mysql> SET PASSWORD = PASSWORD('123456');

mysql> CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;

mysql> GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@localhost IDENTIFIED BY 'zabbix';

mysql> flush privileges;



4.安装Zabbix

zabbix下载地址http://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/3.0.3/zabbix-3.0.3.tar.gz

[root@oatest ~]# cd /u01/software/

[root@oatest software]# useradd zabbix

[root@oatest software]# tar -zxvf zabbix-3.0.3.tar.gz

[root@oatest software]# cd zabbix-3.0.3

[root@oatest zabbix-3.0.3]# /usr/bin/mysql -uzabbix -pzabbix zabbix < database/mysql/schema.sql

[root@oatest zabbix-3.0.3]# /usr/bin/mysql -uzabbix -pzabbix zabbix < database/mysql/images.sql

[root@oatest zabbix-3.0.3]# /usr/bin/mysql -uzabbix -pzabbix zabbix < database/mysql/data.sql

[root@oatest zabbix-3.0.3]# ./configure --prefix=/usr/local/zabbix --sysconfdir=/etc/zabbix/ --enable-server --enable-agent --with-net-snmp --with-libcurl --with-mysql --with-libxml2 --with-ldap

--出现报错configure: error: Invalid Net-SNMP directory - unable to find net-snmp-config

--出现报错configure: error: Curl library not found

[root@oatest zabbix-3.0.3]# yum install net-snmp-devel

[root@oatest zabbix-3.0.3]# yum install curl-devel

[root@oatest zabbix-3.0.3]# ./configure --prefix=/usr/local/zabbix --sysconfdir=/etc/zabbix/ --enable-server --enable-agent --with-net-snmp --with-libcurl --with-mysql --with-libxml2

[root@oatest zabbix-3.0.3]# make install



5、zabbix和appache配置

[root@oatest zabbix-3.0.3]# vi /etc/zabbix/zabbix_server.conf

修改

DBPassword=zabbix

ListenIP=127.0.0.1,192.168.30.173

--此处192.168.30.173为zabbix server ip


[root@oatest zabbix-3.0.3]# ln -s /usr/local/zabbix/sbin/* /usr/sbin/

[root@oatest zabbix-3.0.3]# cp misc/init.d/fedora/core/zabbix_* /etc/init.d/

[root@oatest zabbix-3.0.3]# chmod +x /etc/init.d/zabbix_*

[root@oatest zabbix-3.0.3]# sed -i "s@BASEDIR=/usr/local@BASEDIR=/usr/local/zabbix@g" /etc/init.d/zabbix_server


[root@oatest zabbix-3.0.3]# vi /etc/httpd/conf/httpd.conf

ServerName 127.0.0.1

ServerName 192.168.30.173

DocumentRoot  "/var/www/html"


[root@oatest zabbix-3.0.3]# mkdir -p /var/www/html/zabbix

[root@oatest zabbix-3.0.3]# cp -r frontends/php/* /var/www/html/zabbix/

[root@oatest zabbix-3.0.3]# chown -R apache.apache /var/www/html/zabbix/

[root@oatest zabbix-3.0.3]# chkconfig zabbix_server on

[root@oatest zabbix-3.0.3]# service zabbix_server start

[root@oatest zabbix-3.0.3]# service httpd restart


编译php如果 make clean后重新make和make install,都需要重新配置一下/usr/local/php/lib/php.ini



6、zabbix的WEB页面配置

http://IP/zabbix/setup.php

登录用户/密码Admin/zabbix


遇到错误会有提示,比如PHP bcmath extension missing (PHP configuration parameter --enable-bcmath)

解决方法,make clean后重新make和make install编译php,加上参数--enable-bcmath


遇到如下错误的解决方法

先安装jpeg和freetype再make clean后重新make和make install编译php,加上参数--with-jpeg-dir --with-freetype-dir


PHP gd JPEG image support missing.

PHP gd FreeType support missing.

JPEG下载地址http://www.ijg.org/files/jpegsrc.v9b.tar.gz

FreeType下载地址https://sourceforge.net/projects/freetype/files/freetype2/2.6.5/freetype-2.6.5.tar.gz/download


[root@oatest zabbix-3.0.3]# cd /u01/software/

[root@oatest software]# tar -zxvf jpegsrc.v9b.tar.gz

[root@oatest software]# cd jpeg-9b/

[root@oatest jpeg-9b]# mkdir /usr/local/freetype

[root@oatest jpeg-9b]#./configure --prefix=/usr/local/jpeg --enable-shared

[root@oatest jpeg-9b]# make

[root@oatest jpeg-9b]# make install


[root@oatest jpeg-9b]# cd /u01/software/

[root@oatest software]# tar -zxvf freetype-2.6.5.tar.gz

[root@oatest software]# cd freetype-2.6.5

[root@oatest freetype-2.6.5]# mkdir /usr/local/freetype

[root@oatest freetype-2.6.5]# ./configure --prefix=/usr/local/freetype/

[root@oatest freetype-2.6.5]# make

[root@oatest freetype-2.6.5]# make install


[root@oatest freetype-2.6.5]# cd /u01/software/php-5.6.13

[root@oatest php-5.6.13]# ./configure --prefix=/usr/local/php  --with-apxs2=/usr/sbin/apxs  --with-mysqli --enable-bcmath --enable-mbstring --enable-sockets --with-gd --with-jpeg-dir --with-freetype-dir

[root@oatest php-5.6.13]# make clean

--必须清除原来的编译配置,重新编译php

[root@oatest php-5.6.13]# make

[root@oatest php-5.6.13]# make install

[root@oatest php-5.6.13]# cp php.ini-development /usr/local/php/lib/php.ini

[root@oatest php-5.6.13]# vi /usr/local/php/lib/php.ini

新增如下

date.timezone = Asia/Shanghai

post_max_size = 32M

max_execution_time = 300

max_input_time = 300

always_populate_raw_post_data = -1


Configure DB connection如下报错时

Error connecting to database: No such file or directory

ln -s /var/lib/mysql/mysql.sock /tmp/

vi /usr/local/php/lib/php.ini添加一行,如下:

mysqli.default_socket = /var/lib/mysql/mysql.sock


[root@oatest php-5.6.13]# service httpd restart






ZABBIX客户端安装

方法1:使用源码文件,即需要configure

安装客户端的时候,软件包和服务器端是同一个,只是 configure 的配置参数不同而已

useradd zabbix

tar -zxvf zabbix-3.0.3.tar.gz

cd zabbix-3.0.3

./configure --prefix=/usr --sysconfdir=/etc/zabbix  --enable-agent

make

make install

mkdir /var/log/zabbix

chown zabbix.zabbix /var/log/zabbix

cp misc/init.d/fedora/core/zabbix_agentd /etc/init.d/

chmod 755 /etc/init.d/zabbix_agentd

sed -i "s#BASEDIR=/usr/local#BASEDIR=/usr/#g"  /etc/init.d/zabbix_agentd


添加zabbix 到系统服务文件

vi /etc/services 

zabbix-agent 10050/tcp #ZabbixAgent 

zabbix-agent 10050/udp #ZabbixAgent 

zabbix-trapper 10051/tcp #ZabbixTrapper 

zabbix-trapper 10051/udp #ZabbixTrapper


vi /etc/zabbix/zabbix_agentd.conf

修改Server、ServerActive和Hostname


service zabbix_agentd start


服务端执行如下,返回值即可

/usr/local/zabbix/bin/zabbix_get -s 客户端IP -p 10050 -k "system.uptime"



方法2:直接使用二进制文件

1. tar -zxvf zabbix_agents_2.4.0.linux2_6.amd64.tar.gz

2. mkdir /etc/zabbix/

3. mv bin/zabbix_get /usr/bin/

4. mv bin/zabbix_sender /usr/bin/

5. mv sbin/zabbix_agent /usr/bin/

6. mv sbin/zabbix_agentd /usr/bin/

7. mv conf/zabbix_agentd.conf /etc/zabbix/

8. 修改zabbix_agentd.conf

Hostname=zabbix-client1 ###这里的hostname要与客户端的hostname一致,而且与监控主机中的名字一致!

ServerActive=192.168.254.153 ####zabbix server的ip

Server=192.168.254.153####zabbix server的ip

9. groupadd -r zabbix

useradd -g zabbix -s /sbin/nologin zabbix

10. zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf ####指定配置文件启动

11. ps –ef|grep zabbix

lsof -i:10050

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30126024/viewspace-2213289/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/30126024/viewspace-2213289/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值