zabbix 安装配置详解
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了zabbix 安装配置详解相关的知识,希望对你有一定的参考价值。
一.zabbix架构
1.zabbix的架构图:
2.zabbix的逻辑架构图
3.zabbix 服务器进程图
二.zabbix安装
这里以两台机器为示例做介绍:
192.168.10.153(数据库)
192.168.10.154(服务器)
zabbix 安装有两种方法:(这里我们采取yum 安装的方式)
(1).编译安装:
同时安装server和agent,并支持将数据放入mysql数据库中,可使用类似如下配置命令:
./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl
如果仅安装server,并支持将数据库加入mysql数据中,可使用类似如下配置命令:
./configure --enable-server --with-mysql --with-net-snmp
如果仅安装proxy,并支持将数据放入mysql数据中,可使用类似如下配置命令:
./configure --prefix=/usr enable-proxy --with-net-snmp --with-mysql --with-ssh2
如果仅安装agent,可使用类似如下配置命令:
./configure --enable-agent
而后编译安装zabbix即可:
make install
(2).yum安装:
下面我们来安装zabbix:
1.安装server端只需要安装下面的几个包(比较新的版本,2.4.8)
zabbix-server-2.4.8-1.el6.x86_64.rpm zabbix-web-mysql-2.4.8-1.el6.noarch.rpm
zabbix-2.4.8-1.el6.x86_64.rpm zabbix-server-mysql-2.4.8-1.el6.x86_64.rpm
zabbix-get-2.4.8-1.el6.x86_64.rpm zabbix-web-2.4.8-1.el6.noarch.rpm
2.关闭selinux
vim /etc/selinux/config
SELINUX=disabled
setenforce 0
3.关闭防火墙
service iptables stop
chkconfig iptables off
4.安装使用zabbix官方的yum源
[[email protected] ~]# rpm -ivhzabbix-release-2.4-1.el6.noarch.rpm
warning:zabbix-release-2.4-1.el6.noarch.rpm: Header V4 DSA/SHA1 Signature, key ID79ea5ed4: NOKEY
Preparing... ########################################### [100%]
1:zabbix-release ########################################### [100%]
5.配好zabbix的yum源以后,我们来看看yum源里的zabbix版本(需要安装的包已用蓝色标注出来了)
[[email protected] src]# yum list|grep zabbix
zabbix-release.noarch 2.4-1.el6 installed
fping.x86_64 2.4b2-16.el6 zabbix-non-supported
iksemel.x86_64 1.4-2.el6 zabbix-non-supported
iksemel-devel.x86_64 1.4-2.el6 zabbix-non-supported
iksemel-utils.x86_64 1.4-2.el6 zabbix-non-supported
libssh2.x86_64 1.4.2-2.el6 zabbix-non-supported
libssh2-devel.x86_64 1.4.2-2.el6 zabbix-non-supported
libssh2-docs.x86_64 1.2.2-7.el6 zabbix-non-supported
libssh2-docs.noarch 1.4.2-2.el6 zabbix-non-supported
2.72-2.el6 zabbix-non-supported
snmptt.noarch 1.4-1.el6 zabbix-non-supported
zabbix.x86_64 2.4.8-1.el6 zabbix
zabbix-agent.x86_64 2.4.8-1.el6 zabbix
zabbix-get.x86_64 2.4.8-1.el6 zabbix
zabbix-java-gateway.x86_64
2.4.8-1.el6 zabbix
zabbix-proxy.x86_64 2.4.8-1.el6 zabbix
zabbix-proxy-mysql.x86_64
2.4.8-1.el6 zabbix
zabbix-proxy-pgsql.x86_64
2.4.8-1.el6 zabbix
zabbix-proxy-sqlite3.x86_64
2.4.8-1.el6 zabbix
zabbix-sender.x86_64 2.4.8-1.el6 zabbix
zabbix-server-mysql.x86_64
2.4.8-1.el6 zabbix
zabbix-server-pgsql.x86_64
2.4.8-1.el6 zabbix
zabbix-web.noarch 2.4.8-1.el6 zabbix
zabbix-web-japanese.noarch
2.4.8-1.el6 zabbix
zabbix-web-mysql.noarch
2.4.8-1.el6 zabbix
zabbix-web-pgsql.noarch
2.4.8-1.el6 zabbix
注意:/etc/yum.repos.d下面要有两个文件
CentOS-Base.repo zabbix.repo
不然安装的时候要报依赖性的错误
6.使用yum 安装软件
yum -y install zabbix.x86_64 zabbix-get.x86_64 zabbix-sender.x86_64 zabbix-server-mysql.x86_64 zabbix-web.noarch zabbix-web-mysql.noarch
7.初始化数据库,在192.168.10.154(服务器)上
查看数据库脚本位置。
[[email protected] ~]# rpm -ql zabbix-server-mysql.x86_64 0:2.4.8-1.el6
/usr/share/doc/zabbix-server-mysql-2.4.8/create/data.sql
/usr/share/doc/zabbix-server-mysql-2.4.8/create/images.sql
/usr/share/doc/zabbix-server-mysql-2.4.8/create/schema.sql
8.在客户端192.168.10.153(数据库)的机器上,设置mysql的权限:
先给安装好的mysql数据库设置密码并赋予权限
mysql> use mysql
Reading tableinformation for completion of table and column names
You can turn off thisfeature to get a quicker startup with -A
Database changed
mysql> update userset password=password("huaxia") where user=‘root‘;
Query OK, 3 rowsaffected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0
mysql> flushprivileges;
Query OK, 0 rowsaffected (0.00 sec)
mysql> quit
Bye
mysql> GRANT ALLPRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘huaxia‘ WITH GRANT OPTION;#赋予所有IP地址都可以连接的权限
Query OK, 0 rowsaffected (0.00 sec)
mysql> flushprivileges;
Query OK, 0 rowsaffected (0.00 sec)
mysql> quit
Bye
9.在服务器端192.168.10.154(服务器)的机器上安装mysql
yum install mysql
10.在客户端192.168.10.153(数据库)的机器上,创建数据库zabbix
mysql> CREATE DATABASE zabbix;
Query OK, 1 row affected (0.01 sec)
11.在服务器端192.168.10.154(服务器)的机器上,导入sql文件,
[[email protected] ~]# mysql -uroot -phuaxia -h192.168.10.153 zabbix </usr/share/doc/zabbix-server-mysql-2.4.8/create/schema.sql
12.在客户端192.168.10.153(数据库)的机器上,查看刚才导入的sql文件。
mysql> use zabbix;
Reading tableinformation for completion of table and column names
You can turn off thisfeature to get a quicker startup with -A
Database changed
mysql> show tables;#如下面所示说明导入数据库成功。
+-----------------------+
|Tables_in_zabbix |
+-----------------------+
| acknowledges |
| actions |
| alerts |
|application_template |
| applications |
| auditlog |
|auditlog_details |
| autoreg_host |
| conditions |
| config |
| dbversion |
| dchecks |
| dhosts |
| drules |
| dservices |
| escalations |
| 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 |
| httpstepitem |
| httptest |
| httptestitem |
| icon_map |
| icon_mapping |
| ids |
| images |
| interface |
|interface_discovery |
| item_condition |
| item_discovery |
| items |
|items_applications |
| maintenances |
|maintenances_groups |
|maintenances_hosts |
|maintenances_windows |
| mappings |
| media |
| media_type |
| opcommand |
| opcommand_grp |
| opcommand_hst |
| opconditions |
| operations |
| opgroup |
| opmessage |
| opmessage_grp |
| opmessage_usr |
| optemplate |
| profiles |
|proxy_autoreg_host |
| proxy_dhistory |
| proxy_history |
| regexps |
| rights |
| screens |
| screens_items |
| scripts |
| service_alarms |
| services |
| services_links |
| services_times |
| sessions |
| slides |
| slideshows |
| sysmap_element_url |
| sysmap_url |
| sysmaps |
|sysmaps_elements |
|sysmaps_link_triggers |
| sysmaps_links |
| timeperiods |
| trends |
| trends_uint |
| trigger_depends |
|trigger_discovery |
| triggers |
| user_history |
| users |
| users_groups |
| usrgrp |
| valuemaps |
+-----------------------+
104 rows in set (0.00sec)
13.在服务器端192.168.10.154(服务器)的机器上,
再导入下面所示的两个sql文件
[[email protected] ~]# mysql -uroot -phuaxia -h192.168.10.153 zabbix </usr/share/doc/zabbix-server-mysql-2.4.8/create/images.sql
[[email protected] ~]# mysql -uroot -phuaxia -h192.168.10.153 zabbix < /usr/share/doc/zabbix-server-mysql-2.4.8/create/data.sql
14.在客户端192.168.10.153(数据库)的机器上,授权zbxuser访问zabbix数据库。
mysql> GRANT ALL onzabbix.* TO ‘zbxuser‘@‘%‘ IDENTIFIED BY ‘huaxia‘;
Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
15.在服务器端192.168.10.154(服务器)的机器上配置zabbix_server。
[[email protected] ~]# cd /etc/zabbix/
[[email protected] zabbix]# ls
web zabbix_server.conf
[[email protected] zabbix]# ls web
maintenance.inc.php
vim zabbix_server.conf
改下,把配置文件的参数改为以下所示
DBHost=192.168.10.153#数据库服务器IP地址
DBUser=zbxuser#刚才在数据库里设置的zabbix数据库用户。
DBPassword=huaxia#刚才数据库里设置的密码。
16.在服务器端192.168.10.154(服务器)的机器上启动zabbix_server。
[[email protected] zabbix]# ls /etc/rc.d/init.d#查看启动脚本
abrt-ccpp bluetooth haldaemon killall NetworkManager psacct rpcsvcgssd spice-vdagentd ypbind
abrtd certmonger halt lvm2-lvmetad nfs quota_nld rsyslog sshd zabbix-server
abrt-oops cpuspeed htcacheclean lvm2-monitor nfslock rdisc sandbox sssd
acpid crond httpd mdmonitor ntpd restorecond saslauthd sysstat
atd cups &nbs 以上是关于zabbix 安装配置详解的主要内容,如果未能解决你的问题,请参考以下文章