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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
[root@Zabbix_Server Tools]
# tar zxvf zabbix-3.0.4.tar.gz
[root@Zabbix_Server Tools]
# cd zabbix-3.0.4/database/mysql/
[root@Zabbix_Server mysql]
# ls
data.sql images.sql schema.sql
[root@Zabbix_Server mysql]
# mysql -u root -pZabbix
mysql> create database zabbix character
set
utf8;
#创建数据库zabbix,并且数据库编码使用utf8
Query OK, 1 row affected (0.00 sec)
mysql> insert into mysql.user(Host,User,Password) values(
'localhost'
,
'zabbix'
,password(
'zabbix'
));
ERROR 1364 (HY000): Field
'ssl_cipher'
doesn't have a default value
mysql> quit;
[root@Zabbix_Server mysql]
# vim /app/mysql/my.cnf
#sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 指定了严格模式,为了安全,严格模式禁止通过insert 这种形式直接修改mysql库中的user表进行添加新用户
sql_mode=NO_ENGINE_SUBSTITUTION
#将配置文件中的STRICT_TRANS_TABLES删掉
[root@Zabbix_Server mysql]
# service mysqld restart
[root@Zabbix_Server mysql]
# mysql -u root -pZabbix
mysql> insert into mysql.user(Host,User,Password) values(
'localhost'
,
'zabbix'
,password(
'zabbix'
));
#新建账户zabbix,密码zabbix
Query OK, 1 row affected, 3 warnings (0.00 sec)
mysql> flush privileges;
#刷新系统授权表
Query OK, 0 rows affected (0.00 sec)
mysql> grant all on zabbix.* to
'zabbix'
@
'localhost'
identified by
'zabbix'
with grant option;
#允许账户zabbix能从本机连接到数据库zabbix
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> use zabbix;
#进入数据库,按照顺序进行导入,否则会出错。
Database changed
mysql>
source
/usr/local/Tools/zabbix-3
.0.4
/database/mysql/schema
.sql
...
Query OK, 0 rows affected (0.05 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql>
source
/usr/local/Tools/zabbix-3
.0.4
/database/mysql/images
.sql
...
Query OK, 1 row affected (0.01 sec)
mysql>
source
/usr/local/Tools/zabbix-3
.0.4
/database/mysql/data
.sql
...
Query OK, 1 row affected (0.00 sec)
Query OK, 0 rows affected (0.01 sec)
mysql>
exit
;
Bye
[root@Zabbix_Server mysql]
# ln -s /usr/lib64/mysql/libmysqlclient.so.16.0.0 /usr/lib64/mysql/libmysqlclient.so #32位系统为/usr/lib/mysql,注意系统版本同,文件版本可能不一样,这里是16.0.0
[root@Zabbix_Server mysql]
# ln -s /usr/lib64/mysql/libmysqlclient_r.so.16.0.0 /usr/lib64/mysql/libmysqlclient_r.so
[root@Zabbix_Server mysql]
# cd /usr/local/Tools/zabbix-3.0.4
[root@Zabbix_Server zabbix-3.0.4]
# groupadd zabbix
[root@Zabbix_Server zabbix-3.0.4]
# useradd -g zabbix zabbix -s /sbin/nologin
[root@Zabbix_Server zabbix-3.0.4]
# yum -y install mysql-devel mysql-community-devel unixODBC-devel libssh2-devel OpenIPMI-devel net-snmp-devel curl-devel net-snmp-libs net-snmp-utils
[root@Zabbix_Server zabbix-3.0.4]
# chkconfig snmpd on
[root@Zabbix_Server zabbix-3.0.4]
# ./configure --prefix=/app/zabbix --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 --with-unixodbc --with-ssh2 --with-openipmi --with-openssl
[root@Zabbix_Server zabbix-3.0.4]
# make && make install (注意如果报错,请安装相应的模块)
[root@Zabbix_Server zabbix-3.0.4]
# cp /usr/local/Tools/zabbix-3.0.4/misc/init.d/fedora/core/zabbix_server /etc/rc.d/init.d/zabbix_server
[root@Zabbix_Server zabbix-3.0.4]
# cp /usr/local/Tools/zabbix-3.0.4/misc/init.d/fedora/core/zabbix_agentd /etc/rc.d/init.d/zabbix_agentd
[root@Zabbix_Server zabbix-3.0.4]
# chmod +x /etc/rc.d/init.d/zabbix_*
[root@Zabbix_Server zabbix-3.0.4]
# chkconfig zabbix_server on
[root@Zabbix_Server zabbix-3.0.4]
# chkconfig zabbix_agentd on
[root@Zabbix_Server zabbix-3.0.4]
# vim /etc/rc.d/init.d/zabbix_server
BASEDIR=
/app/zabbix
[root@Zabbix_Server zabbix-3.0.4]
# vim /etc/rc.d/init.d/zabbix_agentd
BASEDIR=
/app/zabbix
[root@Zabbix_Server zabbix-3.0.4]
# cp /app/zabbix/etc/zabbix_server.conf{,bak}
[root@Zabbix_Server zabbix-3.0.4]
# ln -s /app/zabbix/sbin/* /usr/local/sbin/
[root@Zabbix_Server zabbix-3.0.4]
# ln -s /app/zabbix/bin/* /usr/local/bin/
[root@Zabbix_Server zabbix-3.0.4]
# vim /app/zabbix/etc/zabbix_server.conf
LogFile=
/app/zabbix/logs/zabbix_server
.log
PidFile=
/app/zabbix/pid/zabbix_server
.pid
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
ListenIP=localhost
CacheSize=1024M
#根据服务器性能修改,太小后面会报out of memory
AlertScriptsPath=
/app/zabbix/alertscripts
#zabbix运行脚本存放目录
[root@Zabbix_Server zabbix-3.0.4]
# cp /app/zabbix/etc/zabbix_agentd.conf{,bak}
[root@Zabbix_Server zabbix-3.0.4]
# vim /app/zabbix/etc/zabbix_agentd.conf
LogFile=
/app/zabbix/logs/zabbix_agentd
.log
Include=
/app/zabbix/etc/zabbix_agentd
.conf.d/
UnsafeUserParameters=1
#启用自定义key
[root@Zabbix_Server zabbix-3.0.4]
# mkdir -p /app/zabbix/logs
[root@Zabbix_Server zabbix-3.0.4]
# touch /app/zabbix/logs/zabbix_agentd.log
[root@Zabbix_Server zabbix-3.0.4]
# touch /app/zabbix/logs/zabbix_server.log
[root@Zabbix_Server zabbix-3.0.4]
# mkdir /app/zabbix/pid
[root@Zabbix_Server zabbix-3.0.4]
# touch /app/zabbix/pid/zabbix_server.pid
[root@Zabbix_Server zabbix-3.0.4]
# chmod 766 /app/zabbix/pid/*
[root@Zabbix_Server zabbix-3.0.4]
# chmod 766 /app/zabbix/logs/*
|
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
|
[root@Zabbix_Server zabbix-3.0.4]
# rm -rf /app/nginx/html/*
[root@Zabbix_Server zabbix-3.0.4]
# cp -r /usr/local/Tools/zabbix-3.0.4/frontends/php/* /app/nginx/html/
[root@Zabbix_Server zabbix-3.0.4]
# chown www.www -R /app/nginx/html/
[root@Zabbix_Server zabbix-3.0.4]
# service zabbix_agentd start
[root@Zabbix_Server zabbix-3.0.4]
# service zabbix_agentd start
[root@Zabbix_Server zabbix-3.0.4]
# tail /app/zabbix/logs/zabbix_server.log
21858:20160906:072015.723 Ez Texting notifications: YES
21858:20160906:072015.724 ODBC: YES
21858:20160906:072015.724 SSH2 support: YES
21858:20160906:072015.724 IPv6 support: YES
21858:20160906:072015.724 TLS support: YES
21858:20160906:072015.724 ******************************
21858:20160906:072015.724 using configuration
file
:
/app/zabbix/etc/zabbix_server
.conf
21858:20160906:072015.730 current database version (mandatory
/optional
): 03000000
/03000000
21858:20160906:072015.730 required mandatory version: 03000000
21858:20160906:072015.735 listener failed: cannot resolve address [[localhost]:10051]: [-2] Name or service not known
[root@Zabbix_Server zabbix-3.0.4]
# vim /app/zabbix/etc/zabbix_server.conf
#ListenIP=localhost
ListenIP=127.0.0.1
[root@Zabbix_Server logs]
# service zabbix_server start
[root@Zabbix_Server logs]
# netstat -ntlp |grep zabbix
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 22490
/zabbix_agentd
tcp 0 0 127.0.0.1:10051 0.0.0.0:* LISTEN 22419
/zabbix_server
tcp 0 0 :::10050 :::* LISTEN 22490
/zabbix_agentd
[root@Zabbix_Server logs]
#
|
1
2
3
4
5
6
7
8
9
|
[root@Zabbix_Server zabbix-3.0.4]
# cp /app/php/etc/php.ini{,bak}
[root@Zabbix_Server zabbix-3.0.4]
# vim /app/php/etc/php.ini
post_max_size = 16M
max_execution_time = 300
max_input_time = 300
[root@Zabbix_Server zabbix-3.0.4]
# cp /app/php/etc/php-fpm.conf{,bak}
[root@Zabbix_Server zabbix-3.0.4]
# vim /app/php/etc/php-fpm.conf
request_terminate_timeout = 300
[root@Zabbix_Server zabbix-3.0.4]
# service php-fpm restart
|
1
2
3
|
[root@Zabbix_Server conf]
# vim /app/php/etc/php.ini
always_populate_raw_post_data = -1
[root@Zabbix_Server conf]
# service php-fpm restart
|
1
2
3
4
5
6
7
8
9
|
[root@Zabbix_Server ~]
# /app/zabbix/bin/zabbix_get -V
zabbix_get (Zabbix) 3.0.4
Revision 61185 15 July 2016, compilation
time
: Sep 5 2016 14:28:41
Copyright (C) 2016 Zabbix SIA
License GPLv2+: GNU GPL version 2 or later This is
free
software: you are
free
to change and redistribute it according to
the license. There is NO WARRANTY, to the extent permitted by law.
[root@Zabbix_Server ~]
#
|