#一台虚拟机
hostname:Zabbix-server
ip:server_ip_address
[yuki@Zabbix-server tools]$ cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
[yuki@Zabbix-server tools]$ sudo firewall-cmd --state
running
[yuki@Zabbix-server tools]$ cat /etc/sysconfig/selinux
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=enforcing
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
---------------------------------------------------------------------------------------------------------------------------------------
[yuki@Zabbix-server tools]$ sudo systemctl stop firewalld.service
[yuki@Zabbix-server tools]$ sudo firewall-cmd --state
not running
[yuki@Zabbix-server tools]$ sudo setenforce 0 && sudo getenforce
[yuki@Zabbix-server tools]$ sudo sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/sysconfig/selinux
[yuki@Zabbix-server tools]$ sudo yum install -y httpd
[yuki@Zabbix-server tools]$ sudo rpm -qa|grep httpd
httpd-2.4.6-89.el7.centos.x86_64
httpd-tools-2.4.6-89.el7.centos.x86_64
[yuki@Zabbix-server tools]$ sudo systemctl enable httpd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[yuki@Zabbix-server tools]$ echo $?
0
[yuki@Zabbix-server tools]$ sudo systemctl start httpd && sudo echo $?
0
### 查看是否启动成功
[yuki@Zabbix-server tools]$ sudo systemctl status httpd.service
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: active (running) since 二 2019-05-07 11:20:50 CST; 2min 24s ago ###active (running)###
Docs: man:httpd(8)
man:apachectl(8)
Main PID: 18729 (httpd)
Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec"
CGroup: /system.slice/httpd.service
├─18729 /usr/sbin/httpd -DFOREGROUND
├─18730 /usr/sbin/httpd -DFOREGROUND
├─18731 /usr/sbin/httpd -DFOREGROUND
├─18732 /usr/sbin/httpd -DFOREGROUND
├─18733 /usr/sbin/httpd -DFOREGROUND
└─18734 /usr/sbin/httpd -DFOREGROUND
5月 07 11:20:50 Zabbix-server systemd[1]: Starting The Apache HTTP Server...
5月 07 11:20:50 Zabbix-server httpd[18729]: AH00557: httpd: apr_sockaddr_info_get() failed for Zabbix-server
5月 07 11:20:50 Zabbix-server httpd[18729]: AH00558: httpd: Could not reliably determine the server's fully qualified ...essage
5月 07 11:20:50 Zabbix-server systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.
### 通过端口号查看httpd服务是否启动成功
[yuki@Zabbix-server tools]$ sudo lsof -i:80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
httpd 18729 root 4u IPv6 51904 0t0 TCP *:http (LISTEN)
httpd 18730 apache 4u IPv6 51904 0t0 TCP *:http (LISTEN)
httpd 18731 apache 4u IPv6 51904 0t0 TCP *:http (LISTEN)
httpd 18732 apache 4u IPv6 51904 0t0 TCP *:http (LISTEN)
httpd 18733 apache 4u IPv6 51904 0t0 TCP *:http (LISTEN)
httpd 18734 apache 4u IPv6 51904 0t0 TCP *:http (LISTEN)
注意:因为7版本的mysql要收费,所以我们这里安装mariadb代替mysql
[yuki@Zabbix-server tools]$ sudo yum install -y mariadb mariadb-server
[yuki@Zabbix-server tools]$ sudo rpm -qa mariadb
mariadb-5.5.60-1.el7_5.x86_64
[yuki@Zabbix-server tools]$ sudo rpm -qa mariadb-server
mariadb-server-5.5.60-1.el7_5.x86_64
[yuki@Zabbix-server tools]$ sudo systemctl enable mariadb.service && sudo echo $?
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
0
[yuki@Zabbix-server tools]$ sudo systemctl start mariadb.service && echo $?
0
### 检查数据库是否启动成功
[yuki@Zabbix-server tools]$ sudo lsof -i:3306
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
mysqld 19065 mysql 13u IPv4 54342 0t0 TCP *:mysql (LISTEN)
[yuki@Zabbix-server tools]$ mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.60-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> select version();
+----------------+
| version() |
+----------------+
| 5.5.60-MariaDB |
+----------------+
1 row in set (0.00 sec)
MariaDB [(none)]> exit;
Bye
[yuki@Zabbix-server tools]$ sudo yum install -y php php-mysql
[yuki@Zabbix-server tools]$ echo $?
0
[yuki@Zabbix-server tools]$ sudo rpm -qa|grep php
php-cli-5.4.16-46.el7.x86_64
php-bcmath-5.4.16-46.el7.x86_64
php-ldap-5.4.16-46.el7.x86_64
php-pdo-5.4.16-46.el7.x86_64
php-5.4.16-46.el7.x86_64
php-mbstring-5.4.16-46.el7.x86_64
php-xml-5.4.16-46.el7.x86_64
php-gd-5.4.16-46.el7.x86_64
php-common-5.4.16-46.el7.x86_64
php-mysql-5.4.16-46.el7.x86_64
注意:zabbix-server也要监控自身,所以也要同时安装zabbix-agent
[yuki@Zabbix-server tools]$ cd /home/tools/
### 第一种下载安装rpm包的方法 ####
[yuki@Zabbix-server tools]$ sudo wget http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
[yuki@Zabbix-server tools]$ ll
总用量 875952
-rw-r--r--. 1 root root 13572 8月 28 2017 zabbix-release-3.4-2.el7.noarch.rpm
[yuki@Zabbix-server tools]$ sudo yum install -y zabbix-release-3.4-2.el7.noarch.rpm
[yuki@Zabbix-server tools]$ rpm -qa |grep zabbix
zabbix-release-3.4-2.el7.noarch
### 第二种下载安装rpm包的方法 ####
[yuki@Zabbix-server tools]$ sudo rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
获取http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
警告:/var/tmp/rpm-tmp.RJZaYd: 头V4 RSA/SHA512 Signature, 密钥 ID a14fe591: NOKEY
准备中... ################################# [100%]
软件包 zabbix-release-3.4-2.el7.noarch 已经安装
[yuki@Zabbix-server tools]$ sudo yum install -y zabbix-server-mysql zabbix-get zabbix-web zabbix-web-mysql zabbix-agent zabbix-sender
[yuki@Zabbix-server tools]$ sudo rpm -qa zabbix-server-mysql zabbix-get zabbix-web zabbix-web-mysql zabbix-agent zabbix-sender
zabbix-web-mysql-3.4.15-1.el7.noarch
zabbix-get-3.4.15-1.el7.x86_64
zabbix-web-3.4.15-1.el7.noarch
zabbix-server-mysql-3.4.15-1.el7.x86_64
zabbix-agent-3.4.15-1.el7.x86_64
zabbix-sender-3.4.15-1.el7.x86_64
[yuki@Zabbix-server tools]$ mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 5.5.60-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> exit
Bye
[yuki@Zabbix-server zabbix-server-mysql-3.4.15]$ sudo rpm -qa zabbix-server-mysql
zabbix-server-mysql-3.4.15-1.el7.x86_64
[yuki@Zabbix-server zabbix-server-mysql-3.4.15]$ cd /usr/share/doc/zabbix-server-mysql-3.4.15
[yuki@Zabbix-server zabbix-server-mysql-3.4.15]$ ll
总用量 2120
-rw-r--r--. 1 root root 98 11月 12 18:50 AUTHORS
-rw-r--r--. 1 root root 866545 11月 12 18:50 ChangeLog
-rw-r--r--. 1 root root 17990 11月 12 18:50 COPYING
-rw-r--r--. 1 root root 1267039 11月 12 18:54 create.sql.gz ### ###
-rw-r--r--. 1 root root 52 11月 12 18:50 NEWS
-rw-r--r--. 1 root root 1062 11月 12 18:50 README
### 解压sql文件
[yuki@Zabbix-server zabbix-server-mysql-3.4.15]$ sudo gunzip create.sql.gz ###使用gunzip命令
[yuki@Zabbix-server zabbix-server-mysql-3.4.15]$ ll
总用量 5756
-rw-r--r--. 1 root root 98 11月 12 18:50 AUTHORS
-rw-r--r--. 1 root root 866545 11月 12 18:50 ChangeLog
-rw-r--r--. 1 root root 17990 11月 12 18:50 COPYING
-rw-r--r--. 1 root root 4990625 11月 12 18:54 create.sql
-rw-r--r--. 1 root root 52 11月 12 18:50 NEWS
-rw-r--r--. 1 root root 1062 11月 12 18:50 README
### 对表进行导入
[yuki@Zabbix-server zabbix-server-mysql-3.4.15]$ mysql -uzabbix -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 5.5.60-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> use zabbix;
Database changed
MariaDB [zabbix]> source create.sql;
MariaDB [zabbix]> show tables;
MariaDB [zabbix]> exit;
[yuki@Zabbix-server ~]$ cd /etc/zabbix
[yuki@Zabbix-server zabbix]$ ll
总用量 28
drwxr-x---. 2 apache apache 32 5月 7 11:52 web
-rw-r--r--. 1 root root 10632 11月 12 18:55 zabbix_agentd.conf
drwxr-xr-x. 2 root root 37 5月 7 11:52 zabbix_agentd.d
-rw-r-----. 1 root zabbix 15527 11月 12 18:55 zabbix_server.conf #####
[yuki@Zabbix-server zabbix]$ sudo vi zabbix_server.conf
### 编辑之后的配置文件内容如下:
[yuki@Zabbix-server zabbix]$ sudo egrep -v "^$|^#" zabbix_server.conf
# Include=/usr/local/etc/zabbix_server.general.conf
# Include=/usr/local/etc/zabbix_server.conf.d/
# Include=/usr/local/etc/zabbix_server.conf.d/*.conf
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
SocketDir=/var/run/zabbix
DBHost=localhost ####
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
DBSocket=/var/lib/mysql/mysql.sock
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000
[yuki@Zabbix-server zabbix]$ sudo systemctl enable zabbix-server.service && echo $?
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.
0
[yuki@Zabbix-server zabbix]$ sudo systemctl start zabbix-server.service && echo $?
0
### 检查zabbix-server是否启动成功?注意:zabbix-server服务没有端口。
[yuki@Zabbix-server zabbix]$ sudo ps -ef |grep zabbix_server
注意:是过滤zabbix_server而不是zabbix-server
因为:在sudo systemctl start zabbix-server.service启动的时候,
实际上是调用的 /usr/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf 命令
[yuki@Zabbix-server zabbix]$ sudo systemctl enable zabbix-server.service && echo $?
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.
0
[yuki@Zabbix-server zabbix]$ cd /etc/httpd/conf.d
[yuki@Zabbix-server conf.d]$ ll
总用量 24
-rw-r--r--. 1 root root 2926 4月 24 21:45 autoindex.conf
-rw-r--r--. 1 root root 691 10月 31 2018 php.conf
-rw-r--r--. 1 root root 366 4月 24 21:46 README
-rw-r--r--. 1 root root 1252 4月 24 21:44 userdir.conf
-rw-r--r--. 1 root root 824 4月 24 21:44 welcome.conf
-rw-r--r--. 1 root root 870 7月 30 2018 zabbix.conf ###修改这个文件配置###
[yuki@Zabbix-server conf.d]$ cat /etc/httpd/conf.d/zabbix.conf
#
# Zabbix monitoring system php web frontend
#
Alias /zabbix /usr/share/zabbix
###zabbix-server安装路径####
Options FollowSymLinks
AllowOverride None
Require all granted
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 max_input_vars 10000
php_value always_populate_raw_post_data -1
# php_value date.timezone Europe/Riga
php_value date.timezone Asia/Shanghai ###配置时区###
Require all denied
Require all denied
Require all denied
Require all denied
[yuki@Zabbix-server conf.d]$ sudo systemctl restart httpd.service && echo $?
注意:Password是我们之前设置的数据库密码zabbix
登陆账户默认是Admin 密码是zabbix
中文乱码,如下图:
解决办法:从我们电脑win7(控制面板\所有控制面板项\字体)里面找到"黑体"(文件名:simhei.ttf),然后右键复制到桌面,再然后上传到zabbix-server服务器指定路径下面,具体步骤操作如下:
[yuki@Zabbix-server ~]# cd /usr/share/zabbix/fonts
[yuki@Zabbix-server fonts]# ll
总用量 0
lrwxrwxrwx. 1 root root 33 5月 7 11:52 graphfont.ttf -> /etc/alternatives/zabbix-web-font
[yuki@Zabbix-server fonts]# sudo cp graphfont.ttf graphfont.ttf_bak20190510 ##先备份,防止出错##
[yuki@Zabbix-server fonts]# ll
总用量 704
lrwxrwxrwx. 1 root root 33 5月 7 11:52 graphfont.ttf -> /etc/alternatives/zabbix-web-font
-rw-r--r--. 1 root root 720012 5月 10 10:55 graphfont.ttf_bak20190510
[yuki@Zabbix-server fonts]# sudo rz -y
rz waiting to receive.
Starting zmodem transfer. Press Ctrl+C to cancel.
Transferring simhei.ttf...
100% 9523 KB 9523 KB/sec 00:00:01 0 Errors
[yuki@Zabbix-server fonts]# ll
总用量 10228
lrwxrwxrwx. 1 root root 33 5月 7 11:52 graphfont.ttf -> /etc/alternatives/zabbix-web-font
-rw-r--r--. 1 root root 720012 5月 10 10:55 graphfont.ttf_bak20190510
-rw-r--r--. 1 root root 9751720 8月 22 2013 simhei.ttf
[yuki@Zabbix-server fonts]# sudo mv simhei.ttf graphfont.ttf
[yuki@Zabbix-server fonts]# ll
总用量 10228
-rw-r--r--. 1 root root 9751720 8月 22 2013 graphfont.ttf
-rw-r--r--. 1 root root 720012 5月 10 10:55 graphfont.ttf_bak20190510
###修改配置结束后再次重启zabbix-server服务
[yuki@Zabbix-server ~]$ sudo systemctl start zabbix-agent.service && echo $?
0
修改成功再次登录刷新页面就没有中文乱码了,如下图: