7.2 安装部署 Zabbix 3.0.4 详解
一、安装环境
1.1、环境准备
系统版本 | Zabbix版本 | Mariadb版本 |
CentOS Linux release 7.2.1511 (Core) | zabbix-3.0.4 | mariadb-5.5.50-1.el7_2.x86_64 |
1.2、安装基础环境
1
2
|
rpm
-
ivh http:
/
/
repo.zabbix.com
/
zabbix
/
3.0
/
rhel
/
7
/
x86_64
/
zabbix
-
release
-
3.0
-
1.el7
.noarch.rpm
yum install mysql
-
devel gcc net
-
snmp
-
devel curl
-
devel perl
-
DBI php
-
gd php
-
mysql php
-
bcmath php
-
mbstring php
-
xml
-
y
|
二、服务端安装
2.1 安装配置数据库
1
|
yum
-
y install mariadb
-
server
|
2.2 设置开机自启动
1
|
systemctl enable mariadb
|
2.3 启动数据库
1
|
systemctl start mariadb
|
2.4 初始化数据库
1
|
mysql_secure_installation
|
详细输出解析:
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
[root@zabbix
-
server src]
# mysql_secure_installation
/
usr
/
bin
/
mysql_secure_installation: line
379
: find_mysql_client: command
not
found
NOTE: RUNNING
ALL
PARTS OF THIS SCRIPT IS RECOMMENDED FOR
ALL
MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password
for
the root user. If you've just installed MariaDB,
and
you haven't
set
the root password yet, the password will be blank,
so you should just press enter here.
Enter current password
for
root (enter
for
none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set
root password? [Y
/
n] Y
New password:
#设置数据库root密码
Re
-
enter new password:
#再次输入
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created
for
them. This
is
intended only
for
testing,
and
to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y
/
n] Y
#删除匿名用户
... Success!
Normally, root should only be allowed to connect
from
'localhost'
. This
ensures that someone cannot guess at the root password
from
the network.
Disallow root login remotely? [Y
/
n] Y
#禁止root远程登陆数据库
... Success!
By default, MariaDB comes with a database named
'test'
that anyone can
access. This
is
also intended only
for
testing,
and
should be removed
before moving into a production environment.
Remove test database
and
access to it? [Y
/
n] Y
#删除test测试库
-
Dropping test database...
... Success!
-
Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that
all
changes made so far
will take effect immediately.
Reload
privilege tables now? [Y
/
n] Y
#刷新数据库表
... Success!
Cleaning up...
All
done! If you've completed
all
of the above steps, your MariaDB
installation should now be secure.
Thanks
for
using MariaDB!
|
2.5 创建zabbix数据库、用户并设置密码
1
2
|
mysql
-
uroot
-
p123456
-
e
"create database zabbix default character set utf8 collate utf8_bin;"
mysql
-
uroot
-
p123456
-
e
"grant all on zabbix.* to 'zabbix'@'%' identified by '123456';"
|
2.6 登陆测试
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
[root@zabbix
-
server src]
# mysql -uzabbix -p123456
Welcome to the MariaDB monitor. Commands end with ;
or
\g.
Your MariaDB connection
id
is
16
Server version:
5.5
.
50
-
MariaDB MariaDB Server
Copyright (c)
2000
,
2016
, , MariaDB Corporation Ab
and
others.
Type
'help;'
or
'\h'
for
help
.
Type
'\c'
to clear the current
input
statement.
MariaDB [(none)]> show databases;
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
| Database |
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
| information_schema |
| zabbix |
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
2
rows
in
set
(
0.00
sec)
MariaDB [(none)]> use zabbix
Database changed
MariaDB [zabbix]> show tables;
Empty
set
(
0.01
sec)
MariaDB [zabbix]> Bye
|
三、安装zabbix服务端
3.1 yum安装zabbix服务
1
|
yum
-
y install zabbix
-
server
-
mysql zabbix
-
web
-
mysql zabbix
-
get
|
3.2 导入数据表结构
1
2
|
cd
/
usr
/
share
/
doc
/
zabbix
-
server
-
mysql
-
3.0
.
4
/
zcat create.sql.gz | mysql
-
uzabbix
-
p123456 zabbix
|
3.3 备份并修改zabbix配置文件
配置数据库:
1
2
3
4
5
6
|
cp
/
etc
/
zabbix
/
zabbix_server.conf
/
etc
/
zabbix
/
zabbix_server.conf_$(date
+
%
F)
[root@zabbix
-
server ~]
# diff /etc/zabbix/zabbix_server.conf /etc/zabbix/zabbix_server.conf_2016-08-23
115c115
< DBPassword
=
123456
-
-
-
>
# DBPassword=
|
定义时区:
1
2
3
4
5
6
|
cp
/
etc
/
httpd
/
conf.d
/
zabbix.conf
/
etc
/
httpd
/
conf.d
/
zabbix.conf_$(date
+
%
F)
[root@zabbix
-
server ~]
# diff /etc/httpd/conf.d/zabbix.conf /etc/httpd/conf.d/zabbix.conf_2016-08-23
19c19
< php_value date.timezone Asia
/
Chongqing
-
-
-
>
# php_value date.timezone Europe/Riga
|
3.4 设置开机自启动,启动zabbix服务器端
1
2
|
systemctl enalble zabbix
-
server
systemctl restart zabbix
-
server
|
3.5 设置开机自启动,启动apache
1
2
|
systemctl enable httpd
systemctl start httpd
|
一些Zabbix相关教程集合:
四、web界面安装zabbix
4.1 访问地址http://192.168.0.125/zabbix/setup.php配置zabbix
注:下图中的所有配置必须都为ok才可以。
注:下图配置zabbix的一些数据库相关信息,按照自己的填写即可。
注:Name为别名设置,可填写
注:zabbix默认登录用户名为Admin(A为大写,),密码为zabbix。
注:下图进入登录界面
4.2 设置字体显示为中文
注:3.0.4默认的中文显示配置文件里面是开启的,无需重新设置,只需要如下图选择即可