Centos6.5 安装Zabbix3.4
目录
@L_404_1@
操作环境:VMware Workstation
操作系统:Centos 6.5
目录
前言
编译安装
yum安装
zabbix深度了解
操作环境:VMware Workstation
操作系统:Centos 6.5
前言
最近在学习Zabbix,发现这个监控系统对于初学者还真是不好装,期间遇到了好多问题,去网上搜了好长时间,也看了好多博客,最后终于安装成功,故把详细命令和遇到的一些坑给总结一下。以下介绍两种安装方式,分别是编译安装和yum安装
编译安装
1、获取zabbix安装包
#可去下面地址中去获取最新版本的Zabbix安装包,建议用迅雷下载而不用wget获取(wget获取速度太慢了,迅雷下载后用rz上传到Centos系统中)
#https://sourceforge.net/projects/zabbix/files/latest/download?source=files
#由于更新原因,现在最新的版本已经不是3.4.3。有些命令在粘贴复制的时候需要自己手动改版本号
#解压
tar -zxvf zabbix-3.4.3.tar.gz
2、安装MysqL5.6,由于Centos6.5默认安装的版本是5.1的,故要先卸载再安装5.6版本的
yum remove MysqL*
引导MysqL5.6的yum源
#vim /etc/yum.repos.d/MysqL.repo
#写入一下内容
[MysqL56]
name=MysqL 5.6 Community Server
baseurl=http://repo.MysqL.com/yum/MysqL-5.6-community/el/6/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-MysqL
#vim /etc/pki/rpm-gpg/RPM-GPG-KEY-MysqL
#导入gpgcheck文件,去官网复制然后粘贴,由于内容太长这里就不列出来了
#(https://dev.MysqL.com/doc/refman/5.6/en/checking-gpg-signature.html)
安装MysqL5.6
yum install MysqL-community-server
若有报错:warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY
gpg --import /etc/pki/rpm-gpg/RPM*
rpm --import /etc/pki/rpm-gpg/RPM*
编辑MysqL的配置文件并添加一下内容
#vim my.cnf
[MysqLd]
innodb_file_per_table=1
3、安装PHP5.6和Apache服务
2018-04-12补充说明
今天我测试了一下下面安装的PHP56 yum源(rpm 安装的latest.rpm),有点问题,我看了生成的三个repo文件,里面的mirrolist都是https的,于是我进浏览器测试访问,结果访问失败,故我把三个repo文件里面的https全部替换为http,再次测试就成功了。yum源也可以正常访问。若是有出现此类情况的网友可以参照这种方法解决。
#获取yum源
rpm -ivh http://repo.webtatic.com/yum/el6/latest.rpm
#安装下列所有包
yum -y install httpd PHP56w PHP56w-gd PHP56w-MysqLnd PHP56w-bcmath PHP56w-mbstring PHP56w-xml PHP56w-ldap
#编辑PHP的ini文件(vim /etc/PHP.ini)并修改一下内容,注意date.timezone一定要写对,否则在配置完zabbix后,显示的界面全部报错
post_max_size = 16M
max_execution_time = 300
max_input_time = 300
date.timezone = Asia/Shanghai
always_populate_raw_post_data = -1
#配置/etc/httpd/conf/httpd.conf
DocumentRoot "/var/www/html/zabbix"
<Directory "/var/www/html/zabbix">
ServerName 127.0.0.1
DirectoryIndex index.html index.html.var index.PHP
#设置web前端
mkdir /var/www/html/zabbix
cp -a zabbix-3.4.3/frontends/PHP/ /var/www/html/zabbix
#设置apache的执行和所有者
chown -R apache:apache /var/www/html/zabbix
#赋予可执行权限
chmod +x /var/www/html/zabbix/conf/
4、创建zabbix用户和组
groupadd zabbix
useradd -g zabbix zabbix
5、编译并安装zabbix
cd zabbix-3.4.3/
./configure --enable-server --enable-agent --with-MysqL --enable-ipv6 --enable-java --with-net-snmp --with-libcurl --with-libxml2 --with-unixodbc --with-ssh2 --with-openipmi --with-openssl --prefix=/usr/local/zabbix
#可能会出现以下的报错信息,建议直接全部安装
yum install gcc* MysqL-devel libxml2-devel net-snmp* java* curl-devel -y
#(1)configure: error: in `/zabbix/zabbix-3.4.3':
#configure: error: no acceptable C compiler found in $PATH
yum install gcc* -y
#(2)configure: error: MysqL library not found
yum install MysqL-devel -y
#(3)configure: error: LIBXML2 library not found
yum install libxml2-devel -y
#(4)configure: error: Invalid Net-SNMP directory - unable to find net-snmp-config
yum install net-snmp* -y
#(5)configure: error: Unable to find "javac" executable in path
yum install java* -y
#在装java*的时候,我看到要安装1个多G的东西,于是我就改成了javac*,发现后来编译还是出错,所以还是老老实实装java*吧,虽然装的包有点多,但至少能编译成功啊!
#(6)configure: error: Curl library not found
yum install curl-devel -y
#以上是在编译的过程中可能会报错的信息及解决方法,当然也可能还有其它报错这里没列举出来,有问题找度娘,没毛病!
#编译成功会出现
***********************************************************
* Now run 'make install' *
* *
* Thank you for using Zabbix! *
* <http://www.zabbix.com> *
***********************************************************
make install
6、修改配置文件zabbix_server.conf
#vim /usr/local/zabbix/etc/zabbix_server.conf
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
7、添加Zabbix服务器和Zabbix代理启动脚本
cp zabbix-3.4.3/misc/init.d/fedora/core/zabbix_server /etc/init.d/zabbix_server
cp zabbix-3.4.3/misc/init.d/fedora/core/zabbix_agentd /etc/init.d/zabbix_agentd
#修改 /etc/init.d/zabbix_server /etc/init.d/zabbix_agentd的BASEDIR=/usr/local/为BASEDIR=/usr/local/zabbix
sed -i 's#BASEDIR=/usr/local/#BASEDIR=/usr/local/zabbix#g' /etc/init.d/zabbix_{server,agentd}
8、创建zabbix数据库并把导入一些sql表
#进入数据库,刚装的MysqL密码为空,直接回车就行
MysqL
MysqL>CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;
MysqL>GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@localhost IDENTIFIED BY 'zabbix';
MysqL>SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| MysqL |
| performance_schema |
| zabbix |
+--------------------+
4 rows in set (0.00 sec)
MysqL>use zabbix;
MysqL>source zabbix-3.4.3/database/MysqL/schema.sql;
MysqL>source zabbix-3.4.3/database/MysqL/images.sql;
MysqL>source zabbix-3.4.3/database/MysqL/data.sql;
MysqL>show tables;
+----------------------------+
| Tables_in_zabbix |
+----------------------------+
| acknowledges |
| actions |
| alerts |
| application_discovery |
| application_prototype |
| application_template |
| applications |
| auditlog |
| auditlog_details |
| autoreg_host |
| conditions |
| config |
| corr_condition |
| corr_condition_group |
| corr_condition_tag |
| corr_condition_tagpair |
| corr_condition_tagvalue |
| corr_operation |
| correlation |
| dashboard |
| dashboard_user |
| dashboard_usrgrp |
| dbversion |
| dchecks |
| dhosts |
| drules |
| dservices |
| escalations |
| event_recovery |
| event_tag |
| events |
| expressions |
| functions |
| globalmacro |
| globalvars |
| graph_discovery |
| graph_theme |
| graphs |
| graphs_items |
| group_discovery |
| group_prototype |
| groups |
| history |
| history_log |
| history_str |
| history_text |
| history_uint |
| host_discovery |
| host_inventory |
| hostmacro |
| hosts |
| hosts_groups |
| hosts_templates |
| housekeeper |
| httpstep |
| httpstep_field |
| httpstepitem |
| httptest |
| httptest_field |
| httptestitem |
| icon_map |
| icon_mapping |
| ids |
| images |
| interface |
| interface_discovery |
| item_application_prototype |
| item_condition |
| item_discovery |
| item_preproc |
| items |
| items_applications |
| maintenances |
| maintenances_groups |
| maintenances_hosts |
| maintenances_windows |
| mappings |
| media |
| media_type |
| opcommand |
| opcommand_grp |
| opcommand_hst |
| opconditions |
| operations |
| opgroup |
| opinventory |
| opmessage |
| opmessage_grp |
| opmessage_usr |
| optemplate |
| problem |
| problem_tag |
| profiles |
| proxy_autoreg_host |
| proxy_dhistory |
| proxy_history |
| regexps |
| rights |
| screen_user |
| screen_usrgrp |
| screens |
| screens_items |
| scripts |
| service_alarms |
| services |
| services_links |
| services_times |
| sessions |
| slides |
| slideshow_user |
| slideshow_usrgrp |
| slideshows |
| sysmap_element_trigger |
| sysmap_element_url |
| sysmap_shape |
| sysmap_url |
| sysmap_user |
| sysmap_usrgrp |
| sysmaps |
| sysmaps_elements |
| sysmaps_link_triggers |
| sysmaps_links |
| task |
| task_acknowledge |
| task_close_problem |
| task_remote_command |
| task_remote_command_result |
| timeperiods |
| trends |
| trends_uint |
| trigger_depends |
| trigger_discovery |
| trigger_tag |
| triggers |
| users |
| users_groups |
| usrgrp |
| valuemaps |
| widget |
| widget_field |
+----------------------------+
140 rows in set (0.00 sec)
MysqL>\q
9、启动所有服务,并设置开机自启
#启动Apache服务
service httpd start
#启用MysqL服务
service MysqLd start
/etc/init.d/zabbix_server start
/etc/init.d/zabbix_agentd start
#设置开机自启
chkconfig httpd on
chkconfig MysqLd on
chkconfig --add /etc/init.d/zabbix_server
chkconfig --add /etc/init.d/zabbix_agentd
chkconfig zabbix_server on
chkconfig zabbix_agentd on
#查看端口号80、3306、10050(zabbix_agentd)、10051(zabbix_server)是否监听
ss -tnul
/init.d/zabbix_agentdchkconfigzabbix_serveronchkconfigzabbix_agentdon#查看端口号80、3306、10050(zabbix_agentd)、10051(zabbix_server)是否监听ss-tnul123456789101112131415161718
10、浏览器访问zabbix页面并进行初始化
默认用户名:Admin
密码:zabbix
yum安装
1、引导zabbix3.4的yum源
rpm-ivhhttp://repo.zabbix.com/zabbix/3.4/rhel/6/x86_64/zabbix-release-3.4-1.el6.noarch.rpm1
2、安装MysqL5.6,由于Centos6.5默认安装的版本是5.1的,故要先卸载再安装5.6版本的
yumremoveMysqL*1
引导MysqL5.6的yum源
#vim/etc/yum.repos.d/MysqL.repo#写入一下内容[MysqL56] name=MysqL5.6CommunityServer baseurl=http://repo.MysqL.com/yum/MysqL-5.6-community/el/6/$basearch/enabled=1gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-MysqL#vim/etc/pki/rpm-gpg/RPM-GPG-KEY-MysqL#导入gpgcheck文件,去官网复制然后粘贴,由于内容太长这里就不列出来了#(https://dev.MysqL.com/doc/refman/5.6/en/checking-gpg-signature.html)123456789101112
安装MysqL5.6
yuminstallMysqL-community-server1
若有报错:warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY
gpg--import/etc/pki/rpm-gpg/RPM*rpm--import/etc/pki/rpm-gpg/RPM*12
#vimmy.cnf[MysqLd] innodb_file_per_table=11234
#进入数据库,刚装的MysqL密码为空,直接回车就行 MysqL MysqL>CREATEDATABASEzabbixCHARACTERSETutf8COLLATEutf8_bin; MysqL>GRANTALLPRIVILEGESONzabbix.*TOzabbix@localhostIDENTIFIEDBY'zabbix'; MysqL>SHOWDATABASES; +--------------------+ |Database| +--------------------+|information_schema||MysqL||performance_schema||zabbix|+--------------------+4rowsinset(0.00sec)1234567891011121314
3、安装PHP5.6和Apache服务
#获取yum源rpm-ivhhttp://repo.webtatic.com/yum/el6/latest.rpm#安装下列所有包yum-yinstallhttpdPHP56wPHP56w-gdPHP56w-MysqLndPHP56w-bcmathPHP56w-mbstringPHP56w-xmlPHP56w-ldap#编辑PHP的ini文件(vim/etc/PHP.ini)并修改一下内容,注意date.timezone一定要写对,否则在配置完zabbix后,显示的界面全部报错post_max_size=16M max_execution_time=300max_input_time=300date.timezone=Asia/Shanghai always_populate_raw_post_data=-1#配置/etc/httpd/conf/httpd.confDocumentRoot"/var/www/html/zabbix"<Directory"/var/www/html/zabbix"> ServerName127.0.0.1DirectoryIndexindex.htmlindex.html.varindex.PHP12345678910111213141516171819
4、创建zabbix用户和组
groupaddzabbix useradd-gzabbixzabbix12
5、yum安装zabbix
若一台服务器上即是zabbix_server又是zabbix_agent和web Server则需要安装以下程序包
yuminstallzabbixzabbix-agentzabbix-getzabbix-senderzabbix-serverzabbix-server-MysqLzabbix-webzabbix-web-MysqL-y1
若服务器是zabbix_server
yuminstallzabbixzabbix-getzabbix-serverzabbix-server-MysqLzabbix-sender-y1
若服务器是zabbix_agent
yuminstallzabbixzabbix-agentzabbix-getzabbix-sender-y1
若服务器是web Server
yuminstallzabbixzabbix-getzabbix-senderzabbix-webzabbix-web-MysqL-y1
6、往数据库中导入一些数据
cd/usr/share/doc/zabbix-server-MysqL-3.4.3/create/ #把下面三个表给导入zabbix数据库中 MysqLzabbix<schema.sqlMysqLzabbix<images.sqlMysqLzabbix<data.sql123456
7、修改/etc/zabbix/zabbix_server.conf 和 zabbix_agentd.conf
#若是本机DBHost=localhost#若不是本机DBHost=x.x.x.x#设置数据库用户名和密码,可自己在数据库中设置用户和密码DBUser=DBPassword=12345678
8、浏览器访问zabbix页面并进行初始化,详见上面步骤
总结:两种安装方法大同小异,核心思想还是一样的,就是在安装的时候可能会遇到很多坑,有报错又解决不了就找度娘吧,一般都能解决的!
END!
参考博客:
http://blog.csdn.net/mingjie1212/article/details/54619461
http://blog.csdn.net/mingjie1212/article/details/52704987
http://www.jb51.cc/article/p-buwmrulg-nx.html
zabbix深度了解
转载:https://blog.csdn.net/Mr_rsq/article/details/78457587
原文链接:https://www.f2er.com/centos/374189.html