如何进行zabbix的安装配置,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。
我们提供的服务有:网站建设、成都网站设计、微信公众号开发、网站优化、网站认证、泗阳ssl等。为成百上千家企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的泗阳网站制作公司
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,内容如下
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
看完上述内容,你们掌握如何进行zabbix的安装配置的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注创新互联行业资讯频道,感谢各位的阅读!
本文名称:如何进行zabbix的安装配置
分享URL:http://scyingshan.cn/article/peiiih.html