Centos6.5 安装Zabbix3.4
目录
操作环境: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.gz2、安装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.6yum install mysql-community-server若有报错:warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEYgpg --import /etc/pki/rpm-gpg/RPM*rpm --import /etc/pki/rpm-gpg/RPM*编辑mysql的配置文件并添加一下内容#vim my.cnf[mysqld]innodb_file_per_table=13、安装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 = 16Mmax_execution_time = 300max_input_time = 300date.timezone = Asia/Shanghaialways_populate_raw_post_data = -1#配置/etc/httpd/conf/httpd.confDocumentRoot "/var/www/html/zabbix"<Directory "/var/www/html/zabbix">ServerName 127.0.0.1DirectoryIndex index.html index.html.var index.php#设置web前端mkdir /var/www/html/zabbixcp -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 zabbixuseradd -g zabbix zabbix5、编译并安装zabbixcd 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 $PATHyum install gcc* -y#(2)configure: error: MySQL library not foundyum install mysql-devel -y#(3)configure: error: LIBXML2 library not foundyum install libxml2-devel -y#(4)configure: error: Invalid Net-SNMP directory - unable to find net-snmp-configyum install net-snmp* -y#(5)configure: error: Unable to find "javac" executable in pathyum install java* -y#在装java*的时候,我看到要安装1个多G的东西,于是我就改成了javac*,发现后来编译还是出错,所以还是老老实实装java*吧,虽然装的包有点多,但至少能编译成功啊!#(6)configure: error: Curl library not foundyum install curl-devel -y#以上是在编译的过程中可能会报错的信息及解决方法,当然也可能还有其它报错这里没列举出来,有问题找度娘,没毛病!#编译成功会出现************************************************************ Now run 'make install' ** ** Thank you for using Zabbix! ** <http://www.zabbix.com> ************************************************************make install6、修改配置文件zabbix_server.conf#vim /usr/local/zabbix/etc/zabbix_server.confDBName=zabbixDBUser=zabbixDBPassword=zabbix7、添加Zabbix服务器和Zabbix代理启动脚本cp zabbix-3.4.3/misc/init.d/fedora/core/zabbix_server /etc/init.d/zabbix_servercp 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/zabbixsed -i 's#BASEDIR=/usr/local/#BASEDIR=/usr/local/zabbix#g' /etc/init.d/zabbix_{server,agentd}8、创建zabbix数据库并把导入一些sql表#进入数据库,刚装的mysql密码为空,直接回车就行mysqlmysql>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>\q9、启动所有服务,并设置开机自启#启动Apache服务service httpd start#启用mysql服务service mysqld start/etc/init.d/zabbix_server start/etc/init.d/zabbix_agentd start#设置开机自启chkconfig httpd onchkconfig mysqld onchkconfig --add /etc/init.d/zabbix_serverchkconfig --add /etc/init.d/zabbix_agentdchkconfig zabbix_server onchkconfig zabbix_agentd on#查看端口号80、3306、10050(zabbix_agentd)、10051(zabbix_server)是否监听ss -tnul
/init.d/zabbix_agentdchkconfig zabbix_server onchkconfig zabbix_agentd on#查看端口号80、3306、10050(zabbix_agentd)、10051(zabbix_server)是否监听ss -tnul123456789101112131415161718
10、浏览器访问zabbix页面并进行初始化
默认用户名:Admin
密码:zabbixyum安装
1、引导zabbix3.4的yum源
rpm -ivh http://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版本的
yum remove mysql*1
引导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)123456789101112
安装mysql5.6
yum install mysql-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
编辑mysql的配置文件并添加一下内容
#vim my.cnf[mysqld]innodb_file_per_table=11234
创建zabbix数据库并把导入一些sql表
#进入数据库,刚装的mysql密码为空,直接回车就行mysqlmysql>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)1234567891011121314
3、安装php5.6和Apache服务
#获取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 = 16Mmax_execution_time = 300max_input_time = 300date.timezone = Asia/Shanghaialways_populate_raw_post_data = -1#配置/etc/httpd/conf/httpd.confDocumentRoot "/var/www/html/zabbix"ServerName 127.0.0.1DirectoryIndex index.html index.html.var index.php12345678910111213141516171819
4、创建zabbix用户和组
groupadd zabbixuseradd -g zabbix zabbix12
5、yum安装zabbix
若一台服务器上即是zabbix_server又是zabbix_agent和web Server则需要安装以下程序包
yum install zabbix zabbix-agent zabbix-get zabbix-sender zabbix-server zabbix-server-mysql zabbix-web zabbix-web-mysql -y1
若服务器是zabbix_server
yum install zabbix zabbix-get zabbix-server zabbix-server-mysql zabbix-sender -y1
若服务器是zabbix_agent
yum install zabbix zabbix-agent zabbix-get zabbix-sender -y1
若服务器是web Server
yum install zabbix zabbix-get zabbix-sender zabbix-web zabbix-web-mysql -y1
6、往数据库中导入一些数据
cd /usr/share/doc/zabbix-server-mysql-3.4.3/create/#把下面三个表给导入zabbix数据库中mysql zabbix < schema.sqlmysql zabbix < images.sqlmysql zabbix < data.sql123456
7、修改/etc/zabbix/zabbix_server.conf 和 zabbix_agentd.conf
#若是本机DBHost=localhost#若不是本机DBHost=x.x.x.x#设置数据库用户名和密码,可自己在数据库中设置用户和密码DBUser=DBPassword=12345678
8、浏览器访问zabbix页面并进行初始化,详见上面步骤
总结:两种安装方法大同小异,核心思想还是一样的,就是在安装的时候可能会遇到很多坑,有报错又解决不了就找度娘吧,一般都能解决的!
END!
参考博客:
zabbix深度了解
转载:https://blog.csdn.net/Mr_rsq/article/details/78457587