CentOS   发布时间:2022-04-02  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了centos6.5安装zabbix3.0大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

一、Centos 6.5 下的Zabbix Server安装   上篇文章记录的是centos 7 下安装zabbix ,很简单。但是6.5上面没有可用的源直接安装zabbix,所以需要从别处下载。感谢itnihao团队的制作。 二、基础环境   zabbix server:系统:阿里云 centos6.5    4核8G   zabbix agent:系统:阿里云 centos6.5    4

一、Centos 6.5 下的Zabbix Server安装

  上篇文章记录的是centos 7 下安装zabbix ,很简单。但是6.5上面没有可用的源直接安装zabbix,所以需要从别处下载。感谢itnihao团队的制作。

二、基础环境

  zabbix server:系统:阿里云 centos6.5    4核8G

  zabbix agent:系统:阿里云 centos6.5    4核8G

三、安装步骤:

 zabbix需要MysqL5.6以上版本,删除旧的版本

下载MysqL5.6版本

[[email protected] /]# rpm -ivh http://dev.MysqL.com/get/MysqL-community-release-el6-5.noarch.rpm [[email protected] /]# yum -y install MysqL-server [[email protected] /]# yum list installed | grep MysqL MysqL-community-client.x86_64 5.6.32-2.el6 @MysqL56-community MysqL-community-common.x86_64 5.6.32-2.el6 @MysqL56-community MysqL-community-libs.x86_64 5.6.32-2.el6 @MysqL56-community MysqL-community-release.noarch MysqL-community-server.x86_64 5.6.32-2.el6 @MysqL56-community 修改MysqL配置文件/etc/my.cnf,在[MysqLd]中添加innodb_file_per_table=1
[[email protected] /]# vim /etc/my.cnf innodb_file_per_table=1 [[email protected] /]# /etc/init.d/MysqLd start 这是强烈建议安全数据库和指定的“根”的帐户密码,删除匿名登录等。它是按照指令后MysqL安全安装完成。 [email protected] /]# MysqL_secure_installation 登陆数据库 [[email protected] /]# MysqL -u root -p #这里的root密码为123456 MysqL> CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin; Query OK,@R_675_2643@ted (0.06 seC) MysqL> GRANT ALL PRIVILEGES ON zabbix.* TO [email protected] IDENTIFIED BY ‘zabbixpass‘; Query OK,0 rows affected (0.02 seC) MysqL> show databases; +--------------------+ | Database | +--------------------+ | information_scheR_983_11845@a | | MysqL | | perfoRMANce_scheR_983_11845@a | | zabbix | +--------------------+ 4 rows in set (0.03 seC) MysqL>

centos6.5安装zabbix3.0

安装PHP5.3.3 

Zabbix 3需要PHP是至少5.4或更高版本。我们的CentOS 6.5库跟PHP 5.3.3因此我们需要安装一个新的。

[[email protected] /]# rpm -ivh http://repo.webtatic.com/yum/el6/latest.rpm

安装所需要的包

[[email protected] /]# yum -y install httpd PHP56w PHP56w-gd PHP56w-MysqL PHP56w-bcmath PHP56w-mbString PHP56w-xml PHP56w-ldap

 修改PHP配置

centos6.5安装zabbix3.0

[[email protected] /]# vim /etc/PHP.ini 
post_max_size = 16M
max_execution_time = 300
max_input_time = 300
date.timezone = Asia/Shanghai
always_populate_raw_post_data = -1

centos6.5安装zabbix3.0

修改apache配置

centos6.5安装zabbix3.0

[[email protected] /]# vim /etc/httpd/conf/httpd.conf
ServerName 127.0.0.1
DirectoryIndex index.html index.html.var index.PHP
启动apache
[[email protected] /]# /etc/init.d/httpd start
StarTing httpd:                                            [  OK  ]
在iptables上开放80端口
[[email protected] /]# iptables -I INPUT -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
[[email protected] /]# /etc/init.d/iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[  OK  ]
[[email protected] /]# cat /etc/sysconfig/iptables
# Generated by iptables-save v1.4.7 on Mon Aug 29 21:58:54 2016
*filter
:INPUT ACCEPT [0:0]
:FOR@R_944_10225@ ACCEPT [0:0]
:OUTPUT ACCEPT [67:6921]
-A INPUT -p tcp -m tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT 
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT 
-A INPUT -p icmp -j ACCEPT 
-A INPUT -i lo -j ACCEPT 
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT 
-A INPUT -j REjeCT --reject-with icmp-host-prohibited 
-A FOR@R_944_10225@ -j REjeCT --reject-with icmp-host-prohibited 
COMMIT
# Completed on Mon Aug 29 21:58:54 2016
[[email protected] /]# 

centos6.5安装zabbix3.0

创建zabbix用户

[[email protected] /]# groupadd zabbix
[[email protected] /]# useradd -g zabbix zabbix

 依赖包安装

[[email protected] MysqL]# yum -y install gcc MysqL-community-devel libxml2-devel unixodbc-devel net-snmp-devel libcurl-devel libssh2-devel OpenIPMI-devel openssl-devel openldap-devel
 

下载zabbix安装包、解压

centos6.5安装zabbix3.0

用于上传下载文件(由于直接在虚拟机里下载较慢、在此直接下载到本地主机用lrzsz上传至虚拟机)
[[email protected] /]# yum -y install lrzsz
zabbix3.0.4下载地址
[[email protected] /]# wget http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.0.4/zabbix-3.0.4.tar.gz
解压到当前目录根
[[email protected] /]# tar -zxvf zabbix-3.0.4.tar.gz 
 
[[email protected] /]# cd zabbix-3.0.4/database/MysqL/
[[email protected] MysqL]# ls
data.sql  images.sql  scheR_983_11845@a.sql
[[email protected] MysqL]# MysqL -uroot -hlocalhost -p zabbix < scheR_983_11845@a.sql 
Enter password:     #这里的root密码为123456
[[email protected] MysqL]# MysqL -uroot -hlocalhost -p zabbix < images.sql 
Enter password: 
[[email protected] MysqL]# MysqL -uroot -hlocalhost -p zabbix < data.sql 
Enter password: 

centos6.5安装zabbix3.0

安装zabbix

centos6.5安装zabbix3.0

[[email protected] MysqL]# cd /usr/local/zabbix-3.0.4
编译
[[email protected] zabbix-3.0.4]# ./configure --enable-server --enable-agent --with-MysqL --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 --with-unixodbc --with-ssh2 --with-openipmi --with-openssl --prefix=/usr/local/zabbix
安装
[[email protected] zabbix-3.0.4]# make && make install
[[email protected] zabbix-3.0.4]# echo $?
0

centos6.5安装zabbix3.0

修改zabbix_server的配置

[[email protected] etc]# vim /usr/local/zabbix/etc/zabbix_server.conf
DBName=zabbix
DBUser=zabbix
DBpassword=zabbixpass

 创建一个新的web前端文件

[[email protected] conf]# mkdir /var/www/html/zabbix
移动源到刚才创建目录下
[[email protected] conf]#cd /usr/local/zabbix-3.0.4/frontends/PHP/
[[email protected] PHP]# cp -a . /var/www/html/zabbix/

 设置Apache作为Web用户接口文件的所有者

[@L_674_143@ PHP]# chown -R apache:apache /var/www/html/zabbix

 添加权限给Zabbix Web界面执行文件

[[email protected] PHP]# chmod +x /var/www/html/zabbix/conf/

 添加Zabbix服务器和Zabbix代理启动脚本

[[email protected] PHP]# cp /usr/local/zabbix-3.0.4/misc/init.d/fedora/core/zabbix_server /etc/init.d/zabbix_server
[[email protected] PHP]# cp /usr/local/zabbix-3.0.4/misc/init.d/fedora/core/zabbix_agentd /etc/init.d/zabbix_agentd

 添加Zabbix服务器和Zabbix代理服务

centos6.5安装zabbix3.0

[[email protected] PHP]# chkconfig --add /etc/init.d/zabbix_server
[[email protected] PHP]# chkconfig --add /etc/init.d/zabbix_agentd
[[email protected] PHP]# chkconfig httpd on
[[email protected] PHP]# chkconfig MysqLd on
[[email protected] PHP]# chkconfig zabbix_server on
[@L_874_172@ PHP]# chkconfig zabbix_agentd on

centos6.5安装zabbix3.0

 启动zabbix_server

centos6.5安装zabbix3.0

[[email protected] PHP]# /etc/init.d/zabbix_server start    #报错
StarTing zabbix_server:  /etc/init.d/functions: line 546: /usr/local/sbin/zabbix_server: No such file or directory
                                                           [Failed]
 
[[email protected] PHP]# vim /etc/init.d/zabbix_server
BASEDIR=/usr/local/zabbix     #更改下路径

 
[[email protected] PHP]# /etc/init.d/zabbix_server start
StarTing zabbix_server:                                    [  OK  ]
 
[[email protected] PHP]# vim /etc/init.d/zabbix_agentd
BASEDIR=/usr/local/zabbix    #更改下路径

 
[[email protected] PHP]# /etc/init.d/zabbix_agentd start
StarTing zabbix_agentd:                                    [  OK  ]

centos6.5安装zabbix3.0

 

web界面安装

apache首页

centos6.5安装zabbix3.0

 
 
 

 

zabbix  web安装界面

centos6.5安装zabbix3.0

centos6.5安装zabbix3.0

centos6.5安装zabbix3.0

centos6.5安装zabbix3.0

centos6.5安装zabbix3.0

centos6.5安装zabbix3.0

Username:Admin
password :zabbix

centos6.5安装zabbix3.0

安装完成

 

centos6.5安装zabbix3.0

 

@R_753_9382@出现的报错排查

登陆首页报错

centos6.5安装zabbix3.0

上面@L_98_197@zabbix_server服务未运行、到服务端检查zabbix_server是否运行
[ [email protected] PHP]# /etc/init.d/zabbix_server status
zabbix_server (pid 2952) is running...
[ [email protected] PHP]# netstat -anpt | grep zabbix      #zabbix_server没有运行
tcp        0      0 0.0.0.0:10050               0.0.0.0:*                   LISTEN      2275/zabbix_agentd  
tcp        0      0 :::10050                    :::*                        LISTEN      2275/zabbix_agentd
查看zabbix的进程
[ [email protected] PHP]#ps aux | grep zabbix
zabbix    2275  0.0  0.1  77020  1396 ?        S    23:02   0:00 /usr/local/zabbix/sbin/zabbix_agentd
zabbix    2280  0.0  0.1  77020  1384 ?        S    23:02   0:01 /usr/local/zabbix/sbin/zabbix_agentd: collector [idle 1 sec]
zabbix    2281  0.0  0.1  77020  1968 ?        S    23:02   0:00 /usr/local/zabbix/sbin/zabbix_agentd: listener #1 [waiTing for connection]
zabbix    2282  0.0  0.1  77020  1968 ?        S    23:02   0:00 /usr/local/zabbix/sbin/zabbix_agentd: listener #2 [waiTing for connection]
zabbix    2283  0.0  0.1  77020  1968 ?        S    23:02   0:00 /usr/local/zabbix/sbin/zabbix_agentd: listener #3 [waiTing for connection]
zabbix    2284  0.0  0.2  77032  2080 ?        S    23:02   0:00 /usr/local/zabbix/sbin/zabbix_agentd: active checks #1 [idle 1 sec]
zabbix    2952  0.0  0.2 154964  2816 ?        S    23:26   0:00 /usr/local/zabbix/sbin/zabbix_server
root      2981  0.0  0.0 103216   780 pts/0    S+   23:28   0:00 grep zabbix
杀死这个进程
[ [email protected] PHP]#kill 2952
[ [email protected] PHP]# kill 2952
[ [email protected] PHP]# kill 2952
-bash: kill: (2952) - 没有那个进程
 
在此确认zabbix_server这个进程是否存在
[ [email protected] PHP]#ps aux | grep zabbix
zabbix    2275  0.0  0.1  77020  1396 ?        S    23:02   0:00 /usr/local/zabbix/sbin/zabbix_agentd
zabbix    2280  0.0  0.1  77020  1384 ?        S    23:02   0:01 /usr/local/zabbix/sbin/zabbix_agentd: collector [idle 1 sec]
zabbix    2281  0.0  0.1  77020  1968 ?        S    23:02   0:00 /usr/local/zabbix/sbin/zabbix_agentd: listener #1 [waiTing for connection]
zabbix    2282  0.0  0.1  77020  1968 ?        S    23:02   0:00 /usr/local/zabbix/sbin/zabbix_agentd: listener #2 [waiTing for connection]
zabbix    2283  0.0  0.1  77020  1968 ?        S    23:02   0:00 /usr/local/zabbix/sbin/zabbix_agentd: listener #3 [waiTing for connection]
zabbix    2284  0.0  0.2  77032  2080 ?        S    23:02   0:00 /usr/local/zabbix/sbin/zabbix_agentd: active checks #1 [idle 1 sec]
root      2992  0.0  0.0 103216   780 pts/0    S+   23:30   0:00 grep zabbix
 
 
查看zabbix_server日志
[ [email protected] PHP]# find / -name zabbix_server.log   #使用find命令找到zabbix_server日志的位置
/tmp/zabbix_server.log
[ [email protected] PHP]# cat /tmp/zabbix_server.log 

 

centos6.5安装zabbix3.0

发现 访问被拒绝 没有密码
我们再去检查下zabbix_server.conf 密码配置那行检查下
[ [email protected] PHP]#cd /usr/local/zabbix/
[ [email protected] zabbix]# ls
bin  etc  lib  sbin  share
[ [email protected] zabbix]# cd etc/
[ [email protected] etc]# ls
zabbix_agentd.conf    zabbix_server.conf
zabbix_agentd.conf.d  zabbix_server.conf.d
[ [email protected] etc]# vim zabbix_server.conf
DBpassword=zabbixpass     #查找密码是否设置

centos6.5安装zabbix3.0

 
发现vim zabbix_server.conf 中并没有配置DBpassword=zabbixpass
我们在这里添加上DBpassword=zabbixpass
启动zabbix_server服务
[ [email protected] etc]# /etc/init.d/zabbix_server start
[ @L_618_225@ etc]# netstat -anpt | grep zabbix    #确认服务是否启动
tcp        0      0 0.0.0.0:10050               0.0.0.0:*                   LISTEN      2275/zabbix_agentd  
tcp        0      0 0.0.0.0:10051               0.0.0.0:*                   LISTEN      3148/zabbix_server  
tcp        0      0 :::10050                    :::*                        LISTEN      2275/zabbix_agentd  
tcp        0      0 :::10051                    :::*                        LISTEN      3148/zabbix_server  
再去查看下日志
[ [email protected] etc]# cat /tmp/zabbix_server.log
已经没有了拒绝访问的报错在最后以行发现本地主机没有被检测

centos6.5安装zabbix3.0

再去zabbix web页面查看下是否正常

centos6.5安装zabbix3.0

web页面显示正常了
 
之前报错的原因 查看了下 history  发现原来是在配置zabbix_server.conf的时候修改的是
[ [email protected] etc]# history

 

centos6.5安装zabbix3.0

到上面那个操作错误的目录查看下
[ [email protected] etc]# cd /zabbix-3.0.4
[ [email protected] zabbix-3.0.4]# cd conf/
[ [email protected] conf]# ls
zabbix_agentd  zabbix_agentd.conf  zabbix_agentd.win.conf  zabbix_proxy.conf  zabbix_server.con

centos6.5安装zabbix3.0

 
查看下zabbix_server.conf这个文件确实是否是这里的问题

centos6.5安装zabbix3.0

 
错误:是之前修改配置文件所导致的 
 
把web页面改为中文
 

centos6.5安装zabbix3.0

centos6.5安装zabbix3.0

centos6.5安装zabbix3.0

centos6.5安装zabbix3.0

centos6.5安装zabbix3.0

centos6.5安装zabbix3.0

到这里已经把本机加入监控了
到日志里查看下
[ [email protected] etc]# cat /tmp/zabbix_server.log 

 

centos6.5安装zabbix3.0

@H_301_543@

大佬总结

以上是大佬教程为你收集整理的centos6.5安装zabbix3.0全部内容,希望文章能够帮你解决centos6.5安装zabbix3.0所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。