标签: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源
[root@192 ~]# 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版本(需要安装的包已用蓝色标注出来了)
[root@192 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(服务器)上
查看数据库脚本位置。
[root@192 ~]# 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文件,
[root@192 ~]# 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文件
[root@192 ~]# mysql -uroot -phuaxia -h192.168.10.153 zabbix </usr/share/doc/zabbix-server-mysql-2.4.8/create/images.sql
[root@192 ~]# 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。
[root@192 ~]# cd /etc/zabbix/
[root@192 zabbix]# ls
web zabbix_server.conf
[root@192 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。
[root@192 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 ip6tables messagebus ntpdate rngd single udev-post
auditd dnsmasq iptables netconsole oddjobd rpcbind smartd wdaemon
autofs firstboot irqbalance netfs portreserve rpcgssd snmpd winbind
blk-availability functions kdump network postfix rpcidmapd snmptrapd wpa_supplicant
[root@192 zabbix]#service zabbix-server start#启动服务
Starting Zabbixserver: [确定]
[root@192 zabbix]# ss-tnlp#查看zabbix启动的进程数,看到zabbix启动在10051端口上。
LISTEN 0 128 :::10051 :::* users:(("zabbix_server",7273,5),("zabbix_server",7274,5),("zabbix_server",7275,5),("zabbix_server",7276,5),("zabbix_server",7277,5),("zabbix_server",7278,5),("zabbix_server",7279,5),("zabbix_server",7280,5),("zabbix_server",7281,5),("zabbix_server",7282,5),("zabbix_server",7283,5),("zabbix_server",7284,5),("zabbix_server",7285,5),("zabbix_server",7286,5),("zabbix_server",7287,5),("zabbix_server",7288,5),("zabbix_server",7289,5),("zabbix_server",7290,5),("zabbix_server",7291,5),("zabbix_server",7292,5),("zabbix_server",7293,5),("zabbix_server",7294,5),("zabbix_server",7295,5),("zabbix_server",7296,5),("zabbix_server",7297,5),("zabbix_server",7298,5),("zabbix_server",7299,5))
LISTEN 0 128 *:10051 *:* users:(("zabbix_server",7273,4),("zabbix_server",7274,4),("zabbix_server",7275,4),("zabbix_server",7276,4),("zabbix_server",7277,4),("zabbix_server",7278,4),("zabbix_server",7279,4),("zabbix_server",7280,4),("zabbix_server",7281,4),("zabbix_server",7282,4),("zabbix_server",7283,4),("zabbix_server",7284,4),("zabbix_server",7285,4),("zabbix_server",7286,4),("zabbix_server",7287,4),("zabbix_server",7288,4),("zabbix_server",7289,4),("zabbix_server",7290,4),("zabbix_server",7291,4),("zabbix_server",7292,4),("zabbix_server",7293,4),("zabbix_server",7294,4),("zabbix_server",7295,4),("zabbix_server",7296,4),("zabbix_server",7297,4),("zabbix_server",7298,4),("zabbix_server",7299,4))
17.在服务器端192.168.10.154(服务器)的机器上查看web接口配置。
注意:配置一般不用改
[root@192 zabbix]# ls /etc/httpd/conf.d/
mod_dnssd.conf php.conf README welcome.conf zabbix.conf
[root@192 zabbix]# cd /etc/httpd/
[root@192 httpd]# ls
conf conf.d logs modules run
[root@192 httpd]# cd conf.d/
[root@192 conf.d]# ls
mod_dnssd.conf php.conf README welcome.conf zabbix.conf
[root@192 conf.d]# cat zabbix.conf
Alias /zabbix /usr/share/zabbix#定义访问别名
<Directory"/usr/share/zabbix">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
<IfModule mod_php5.c>
php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
# php_value date.timezone Europe/Riga
</IfModule>
</Directory>
18.在服务器端192.168.10.154(服务器)的机器上,启动http服务。
[root@192 ~]# service httpd start
正在启动 httpd: [确定]
[root@192 ~]# ss -tnlp
LISTEN 0 128 :::80#80端口处于监听状态 :::* users:(("httpd",7492,4),("httpd",7495,4),("httpd",7496,4),("httpd",7497,4),("httpd",7498,4),("httpd",7499,4),("httpd",7500,4),("httpd",7501,4),("httpd",7502,4))
19.在服务器端192.168.10.154(服务器)的机器上,访问zabbix,在浏览器中输入网址http://192.168.10.154/zabbix,会出现如下图所示的界面。注意:主机防火墙这里要关闭,或者放开对80端口的访问权限。
vim /etc/php.ini#默认安装php的配置文件路径
date.timezone= Asia/Shanghai#修改时区
[root@192 ~]# service httpd restart#
重启httpd服务
停止 httpd: [确定]
正在启动 httpd: [确定]
再重新检查下,说明配置正确,如下图:
填入默认的用户名"admin",默认密码"zabbix"登录。
显示如下图所示的界面:
证明安装已经成功!接下来的大多数的工作,都是在这个WEB接口上配置的。
本文出自 “服务器运维” 博客,请务必保留此出处http://shamereedwine.blog.51cto.com/5476890/1776759
标签:zabbix安装
原文地址:http://shamereedwine.blog.51cto.com/5476890/1776759