zabbix基础之安装
1.zabbix是一款开源监控工具,可监控对象众多,使用者较多。下面我们来安装zabbix在安装zabbix之前,提前部署好LAMP或者LNMP。
zabbix可以在官网中获取,地址:http://www.zabbix.com/download
zabbix官网为我们提供了三种安装方式:
(1)源码编译安装
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# tar -zxvf zabbix-3.2.1.tar.gz
同时安装server和agent,并支持将数据放入mysql数据中,可使用类似如下配置命令:
./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-ssh2
如果仅安装server,并支持将数据放入mysql数据中,可使用类似如下配置命令:
./configure --enable-server --with-mysql --with-net-snmp --with-libcurl
如果仅安装proxy,并支持将数据放入mysql数据中,可使用类似如下配置命令:
./configure --prefix=/usr --enable-proxy --with-net-snmp --with-mysql --with-ssh2
如果仅安装agent,可使用类似如下配置命令:
./configure --enable-agent
而后编译安装zabbix即可:
# make
# make install
(2)配置yum源安装
1
2
3
4
5
# rpm -ivh http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpm
Retrieving http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpm
warning: /var/tmp/rpm-tmp.QBkmAF: Header V4 DSA/SHA1 Signature, key ID 79ea5ed4: NOKEY
Preparing... ###########################################
1:zabbix-release ###########################################
1
2
3
4
5
6
# yum clean all
已加载插件:fastestmirror, langpacks
正在清理软件源: base extras updates zabbix zabbix-non-supported
Cleaning up everything
Cleaning up list of fastest mirrors
# yum makecache
(3)rpm包下载安装
2.配置zabbix-database,以mysql为例,可使用mysql和pgsql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
MariaDB [(none)]> create database zabbix character set utf8;
MariaDB [(none)]> grant all on zabbix.* to 'zbxuser'@'localhost' identified by 'zbxpass';
MariaDB [(none)]> grant all on zabbix.* to 'zbxuser'@'192.168.%.%' identified by 'zbxpass';
MariaDB [(none)]> flush privileges;
#连接测试
# mysql -uzbxuser -hlocalhost -p
Enter password:
Welcome to the MariaDB monitor.Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 5.5.50-MariaDB MariaDB Server
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> \q
Bye
3.安装zabbix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# yum install zabbix zabbix-agent zabbix-get zabbix-sender zabbix-server zabbix-server-mysql zabbix-web zabbix-web-mysql
在httpd中生成zabbix-web的配置文件
# cd /etc/zabbix/
# ls
webzabbix_agentd.confzabbix_agentd.dzabbix_server.conf
# service httpd start
Starting httpd:
# ls /etc/httpd/conf.d
php.confREADMEwelcome.confzabbix.conf #有了zabbix.conf这个文件
将zabbix导入数据库
# cd /usr/share/doc/zabbix-server-mysql-2.4.8/
# cd create/
# mysql zabbix < schema.sql #注意导入顺序
# mysql zabbix < images.sql
# mysql zabbix < data.sql
# 如果仅为proxy创建数据库,只导入schema.sql即可
4.配置zabbix-server
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# vim /etc/zabbix/zabbix_server.conf
### Option: DBHost
# Database host name.
# If set to localhost, socket is used for MySQL.
# If set to empty string, socket is used for PostgreSQL.
#
# Mandatory: no
# Default:
# DBHost=localhost
DBHost=192.168.3.8 #填写连接的数据库服务器,默认是本机
### Option: DBUser
# Database user. Ignored for SQLite.
#
# Mandatory: no
# Default:
# DBUser=
DBUser=zabbix
### Option: DBPassword
# Database password. Ignored for SQLite.
# Comment this line if no password is used.
#
# Mandatory: no
# Default:
# DBUser=
DBUser=zbxuser #填写数据库用户名
### Option: DBPassword
# Database password. Ignored for SQLite.
# Comment this line if no password is used.
#
# Mandatory: no
# Default:
# DBPassword=
DBPassword=zbxpass #填写数据库密码
其余常用修改选项
ListenIP=localhost #数据库ip地址
AlertScriptsPath=/usr/local/zabbix/share/zabbix/alertscripts #zabbix运行脚本存放目录
5.修改PHP时区
1
2
# vim /etc/php.ini
date.timezone = 'Asia/Chongqing' #修改时区为重庆
页:
[1]