-
Zabbix环境准备
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
[[email protected] ~]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core) [[email protected] ~]# uname -r
3.10.0-693.5.2.el7.x86_64[[email protected] ~]# getenforce
Disabled[[email protected] ~]# systemctl stop firewalld
Failed to stop firewalld.service: Unit firewalld.service not loaded.[[email protected] ~]# ifconfig eth0|awk -F '[ :]+' 'NR==2{print $3}'
192.168.56.11[[email protected] ~]# hostname
linux-node1[[email protected] ~]# yum install -y ntpdate
[[email protected] ~]# ntpdate time1.aliyun.com
[[email protected] ~]# crontab -e
*/5 * * * * /usr/sbin/ntpdate time1.aliyun.com &>/dev/null
|
2.Zabbix安装
|
1
2
3
4
5
6
7
|
Zabbix存储配置包以及yum配置文件[[email protected] ~]# rpm -ivh http://mirrors.aliyun.com/zabbix/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
[[email protected] ~]# yum list |grep zabbix
Zabbix程序包安装,以及MySQL、Zabbix-agent[[email protected] ~]# yum install -y zabbix-server-mysql zabbix-web-mysql mariadb-server zabbix-agent
|
3.初始化数据库
|
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
|
创建Zabbix数据库以及用户[[email protected] ~]# systemctl start mariadb
[[email protected] ~]# mysql_secure_installation
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 currentpassword 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 MariaDBroot user without the proper authorisation.Set root password? [Y/n] Y
New password: 123456Re-enter new password: 123456Password updated successfully!Reloading privilege tables.. ... Success!
[[email protected] ~]# mysql -uroot -p
Enter password: 123456Welcome to the MariaDB monitor. Commands end with ; or \g.Your MariaDB connection id is 10
Server version: 10.1.20-MariaDB MariaDB ServerCopyright (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)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)Query OK, 0 rows affected (0.00 sec)MariaDB [(none)]> flush privileges;Query OK, 0 rows affected (0.00 sec)MariaDB [(none)]> quit;Bye导入初始模式和数据:[[email protected] ~]# zcat /usr/share/doc/zabbix-server-mysql-3.0.13/create.sql.gz |mysql -uzabbix -p zabbix
Enter password: zabbix[[email protected] ~]# mysql -uroot -p123456 -e "use zabbix;show tables;"
+----------------------------+| Tables_in_zabbix |+----------------------------+| acknowledges || actions || alerts || application_discovery || application_prototype || application_template || applications || auditlog || auditlog_details || autoreg_host || conditions || config ||...... |+----------------------------+ |
4.Zabbix服务器进程启动
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
在Zabbix_server.conf编辑数据库配置[[email protected] ~]# grep ^[a-Z] /etc/zabbix/zabbix_server.conf
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0PidFile=/var/run/zabbix/zabbix_server.pid
DBHost=localhostDBName=zabbixDBUser=zabbixDBPassword=zabbixSNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000启动Zabbix服务器进程[[email protected] ~]# systemctl enable zabbix-server#默认端口为10051
[[email protected] ~]# systemctl start zabbix-server
|
5.编辑Zabbix前端PHP配置
|
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
|
Apache的配置文件/etc/httpd/conf.d/zabbix.conf,取消注释,设置正确的时区:Asia/Shanghai
[[email protected] ~]# vim /etc/httpd/conf.d/zabbix.conf
php_value max_execution_time 300php_value memory_limit 128Mphp_value post_max_size 16Mphp_value upload_max_filesize 2Mphp_value max_input_time 300php_value always_populate_raw_post_data -1php_value date.timezone Asia/Shanghai
通过改变配置文件启动Apache Web服务器[[email protected] ~]# vim /etc/httpd/conf/httpd.conf
Severname 127.0.0.1:80[[email protected] ~]# systemctl enable httpd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[[email protected] ~]# systemctl start httpd.service
[[email protected] ~]# netstat -lntp
Active Internet connections (only servers)Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 863/sshd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2085/master tcp6 0 0 :::80 :::* LISTEN 21955/httpd tcp6 0 0 :::22 :::* LISTEN 863/sshd tcp6 0 0 ::1:25 :::* LISTEN 2085/master tcp6 0 0 :::3306 :::* LISTEN 21820/mysqld
|
6.Zabbix的web安装
step1:
在浏览器中,打开Zabbix URL:http:// <server_ip_or_name> / zabbix
step2:
确保满足所有软件的先决条件。
step3:
输入连接到数据库的详细信息。Zabbix数据库必须已经创建。
step4:
输入Zabbix服务器的详细信息。
step5:
查看设置摘要。
step6:
完成安装,会在/etc/zabbix/web/zabbix.conf.php生成配置文件
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
当数据库遇到瓶劲,在进行数据库拆分的时候,需要修改配置文件/etc/zabbix/web/zabbix.conf.php,指向新的数据库地址。
[[email protected] ~]# vim /etc/zabbix/web/zabbix.conf.php
<?php// Zabbix GUI configuration file.
global $DB;$DB['TYPE'] = 'MYSQL';
$DB['SERVER'] = 'localhost';
$DB['PORT'] = '0';
$DB['DATABASE'] = 'zabbix';
$DB['USER'] = 'zabbix';
$DB['PASSWORD'] = 'zabbix';
// Schema name. Used for IBM DB2 and PostgreSQL.
$DB['SCHEMA'] = '';
$ZBX_SERVER = 'localhost';
$ZBX_SERVER_PORT = '10051';
$ZBX_SERVER_NAME = '';
$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG; |
step8:
Zabbix前端准备就绪!默认的用户名是Admin,密码zabbix。
本文转自 IT_外卖小哥 51CTO博客,原文链接:http://blog.51cto.com/jinlong/2050947