CnentOS6.5安装zabbix2.2
准备工作:
准备两台服务器:
1:192.168.6.141 安装zabbix-server—服务端和zabbix-database端以及zabbix-web端
2:192.168.6.135 安装zabbix-agent端
注意:先关闭iptables和seliunx
关闭防火墙:
[root@localhost ~]# chkconfig iptables off
关闭seliunx:
切换到、etc/seliunx下,编辑文件config,注释掉#SELINUX=enforcing,加上SELINUX=disabled
复制代码 [root@localhost ~]# cd /etc/selinux/ [root@localhost selinux]# vi config # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. #SELINUX=enforcing SELINUX=disabled # SELINUXTYPE= can take one of these two values: # targeted - Targeted processes are protected, # mls - Multi Level Security protection. SELINUXTYPE=targeted
一、首先安装数据库
选择mysql作为zabbix-database
1:安装mysql并启动mysql服务
[root@localhost ~]# yum install mysql mysql-server -y
[root@localhost ~]# service mysqld start
修改mysql的初始密码并测试登陆mysql:
[root@localhost ~]# mysqladmin -uroot password root [root@localhost ~]# mysql -uroot -proot -e 'show databases;' +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | test | +--------------------+
为zabbix创建数据库,数据库名为zabbix,并给予zabbixuser所有权限并且zabbixuser用户的密码为zabbix
[root@localhost selinux]# mysql -uroot -proot Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.1.73 Source distribution Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | test | +--------------------+ 3 rows in set (0.00 sec) mysql> create database zabbix; Query OK, 1 row affected (0.00 sec) mysql> grant all privileges on zabbix.* to zabbixuser@localhost identified by 'zabbix'; Query OK, 0 rows affected (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | test | | zabbix | +--------------------+ 4 rows in set (0.00 sec) mysql> \q Bye
数据库完成安装。
二、安装zabbix
我们首先安装一个wget;
[root@localhost selinux]# yum install wget -y
配置yum源
有三个源,根据自己的需求自行安装
http://repo.zabbix.com/zabbix/2.0/rhel/6/x86_64/zabbix-release-2.0-1.el6.noarch.rpm
http://mirrors.aliyun.com/zabbix/zabbix/2.2/rhel/6/x86_64/zabbix-release-2.2-1.el6.noarch.rpm
http://mirrors.aliyun.com/zabbix/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpm
下载rpm源
[root@localhost ~]# wget http://mirrors.aliyun.com/zabbix/zabbix/2.2/rhel/6/x86_64/zabbix-release-2.2-1.el6.noarch.rpm --2017-06-06 00:54:06-- http://mirrors.aliyun.com/zabbix/zabbix/2.2/rhel/6/x86_64/zabbix-release-2.2-1.el6.noarch.rpm 正在解析主机 mirrors.aliyun.com... 112.124.140.210, 115.28.122.210 正在连接 mirrors.aliyun.com|112.124.140.210|:80... 已连接。 已发出 HTTP 请求,正在等待回应... 200 OK 长度:11256 (11K) [application/x-redhat-package-manager] 正在保存至: “zabbix-release-2.2-1.el6.noarch.rpm” 100%[=========================================================================================================================================================================>] 11,256 --.-K/s in 0s 2017-06-06 00:54:06 (32.1 MB/s) - 已保存 “zabbix-release-2.2-1.el6.noarch.rpm” [11256/11256]) [root@localhost ~]# ls anaconda-ks.cfg install.log install.log.syslog zabbix-release-2.2-1.el6.noarch.rpm [root@localhost ~]#
安装rpm源
[root@localhost ~]# rpm -ivh http://mirrors.aliyun.com/zabbix/zabbix/2.2/rhel/6/x86_64/zabbix-release-2.2-1.el6.noarch.rpm Retrieving http://mirrors.aliyun.com/zabbix/zabbix/2.2/rhel/6/x86_64/zabbix-release-2.2-1.el6.noarch.rpm warning: /var/tmp/rpm-tmp.277IjT: Header V4 DSA/SHA1 Signature, key ID 79ea5ed4: NOKEY Preparing... ########################################### [100%] 1:zabbix-release ########################################### [100%] [root@localhost ~]#
配置完成之后安装zabbix
[root@localhost ~]# yum install zabbix zabbix-server zabbix-server-mysql zabbix-web zabbix-web-mysql zabbix-get
出现一下,表示安装完成
ependency Installed: OpenIPMI-libs.x86_64 0:2.0.16-14.el6 apr.x86_64 0:1.3.9-5.el6_2 apr-util.x86_64 0:1.3.9-3.el6_0.1 apr-util-ldap.x86_64 0:1.3.9-3.el6_0.1 dejavu-fonts-common.noarch 0:2.33-1.el6 dejavu-sans-fonts.noarch 0:2.33-1.el6 fontpackages-filesystem.noarch 0:1.41-1.1.el6 fping.x86_64 0:2.4b2-16.el6 freetype.x86_64 0:2.3.11-17.el6 gnutls.x86_64 0:2.12.23-21.el6 httpd.x86_64 0:2.2.15-59.el6.centos httpd-tools.x86_64 0:2.2.15-59.el6.centos iksemel.x86_64 0:1.4-2.el6 libX11.x86_64 0:1.6.4-3.el6 libX11-common.noarch 0:1.6.4-3.el6 libXau.x86_64 0:1.0.6-4.el6 libXpm.x86_64 0:3.5.10-2.el6 libjpeg-turbo.x86_64 0:1.2.1-3.el6_5 libpng.x86_64 2:1.2.49-2.el6_7 libtool-ltdl.x86_64 0:2.2.6-15.5.el6 libxcb.x86_64 0:1.12-4.el6 libxslt.x86_64 0:1.1.26-2.el6_3.1 lm_sensors-libs.x86_64 0:3.1.1-17.el6 mailcap.noarch 0:2.1.31-2.el6 net-snmp.x86_64 1:5.5-60.el6 net-snmp-libs.x86_64 1:5.5-60.el6 php.x86_64 0:5.3.3-49.el6 php-bcmath.x86_64 0:5.3.3-49.el6 php-cli.x86_64 0:5.3.3-49.el6 php-common.x86_64 0:5.3.3-49.el6 php-gd.x86_64 0:5.3.3-49.el6 php-mbstring.x86_64 0:5.3.3-49.el6 php-mysql.x86_64 0:5.3.3-49.el6 php-pdo.x86_64 0:5.3.3-49.el6 php-xml.x86_64 0:5.3.3-49.el6 unixODBC.x86_64 0:2.2.14-14.el6 Complete!
三、安装完成之后,我们将zabbix的数据表导入到zabbix数据库中
切换到如下mulu
[root@localhost create]# cd /usr/share/doc/zabbix-server-mysql-2.2.18/create
[root@localhost create]# ls
data.sql images.sql schema.sql
导入并查看是否导入成功
[root@localhost create]# mysql -uroot -proot zabbix <schema.sql [root@localhost create]# mysql -uroot -proot zabbix <images.sql [root@localhost create]# mysql -uroot -proot zabbix <data.sql [root@localhost create]# mysql -uroot -proot Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 8 Server version: 5.1.73 Source distribution Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> use zabbix; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> show tables;
则表示导入成功
四、修改zabbix的配置文件
[root@localhost /]# cd /etc/zabbix/
[root@localhost zabbix]# ls
web zabbix_server.conf
[root@localhost zabbix]# vi zabbix_server.conf
修改以下内容
DBHost=localhost
DBName=zabbix
DBUser=zabbixuser
DBPassword=zabbix
DBPort=3306
重启zabbix-server
查看是否连接成功
[root@localhost zabbix]# service zabbix-server restart Shutting down Zabbix server: [确定] Starting Zabbix server: [确定] [root@localhost zabbix]# ss -tnl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 :::22 :::* LISTEN 0 128 *:22 *:* LISTEN 0 100 ::1:25 :::* LISTEN 0 100 127.0.0.1:25 *:* LISTEN 0 128 :::10051 :::* LISTEN 0 128 *:10051 *:* LISTEN 0 50 *:3306
zabbix的默认监听端口10051,必须存在
启动http服务
[root@localhost zabbix]# service httpd start
正在启动 httpd:httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName
[确定]
开启防火墙端口和关闭seliunx
[root@localhost zabbix]# setenforce 0 [root@localhost zabbix]# iptables -I INPUT -p tcp --dport 80 -j ACCEPT [root@localhost zabbix]# iptables -I INPUT -p tcp --dport 3306 -j ACCEPT [root@localhost zabbix]# iptables -I INPUT -p tcp --dport 10051 -j ACCEPT [root@localhost zabbix]# service iptables save iptables:将防火墙规则保存到 /etc/sysconfig/iptables:[确定] [root@localhost zabbix]# service zabbix-server restart Shutting down Zabbix server: [确定] Starting Zabbix server: [确定] 复制代码
然后访问192.168.6.141/zabbix出现如下界面则表示安装成功
可能会遇到的错误:时间timezone
修改php.ini文件,找到timezone = 见前边的注释去掉,在后边加上Asia/Shanghai即可
[root@localhost ~]# vi /etc/php.ini
然后重启HTTP服务就好了
[root@localhost ~]# service httpd restart
五、在192.168.6.135上安装zabbix-agent
安装zabbix的yum源如上一样
[root@localhost ~]# yum install zabbix zabbix-agent zabbix-sender -y
安装完成之后修改zabbix-agent的配置文件
[root@localhost ~]# vi /etc/zabbix/zabbix_agentd.conf
Server=192.168.6.141
启动服务设置为开机启动项
[root@localhost ~]# service zabbix-agent start Starting Zabbix agent: [确定] [root@localhost ~]# chkconfig zabbix-agent on [root@localhost ~]# ss -tnl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 :::22 :::* LISTEN 0 128 *:22 *:* LISTEN 0 100 ::1:25 :::* LISTEN 0 100 127.0.0.1:25 *:* LISTEN 0 128 :::10050 :::* LISTEN 0 128 *:10050