1、搭建之前确认一下Centos系统
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
[root@localhost ~]# cat /proc/version
Linux version 3.10.0-693.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) ) #1 SMP Tue Aug 22 21:09:27 UTC 2017
2、配置epel源足够,配置完成后可以将所有组件升级到最新
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
[root@localhost ~]# yum -y update
3、检查防火墙与selinux是否关闭
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
4、搭建lamp环境
[root@localhost ~]# yum install -y httpd mariadb-server mariadb php php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mhash
搭建完成后检查
[root@localhost ~]# rpm -aq | grep httpd
httpd-tools-2.4.6-90.el7.centos.x86_64
httpd-2.4.6-90.el7.centos.x86_64
[root@localhost ~]# rpm -aq | grep mariadb
mariadb-libs-5.5.64-1.el7.x86_64
mariadb-5.5.64-1.el7.x86_64
mariadb-server-5.5.64-1.el7.x86_64
[root@localhost ~]# rpm -aq | grep php
php-process-5.4.16-46.1.el7_7.x86_64
php-5.4.16-46.1.el7_7.x86_64
php-pear-1.9.4-21.el7.noarch
php-common-5.4.16-46.1.el7_7.x86_64
php-pdo-5.4.16-46.1.el7_7.x86_64
php-xml-5.4.16-46.1.el7_7.x86_64
php-odbc-5.4.16-46.1.el7_7.x86_64
php-mysql-5.4.16-46.1.el7_7.x86_64
php-ldap-5.4.16-46.1.el7_7.x86_64
php-cli-5.4.16-46.1.el7_7.x86_64
php-gd-5.4.16-46.1.el7_7.x86_64
php-xmlrpc-5.4.16-46.1.el7_7.x86_64
5、修改/etc/php.ini,修改时区为Asia/Shanghai
date.timezone = Asia/Shanghai
6、检查httpd环境,在/var/www/html/下编写phpinfo.php,启动服务,浏览器访问检查。
[root@localhost html]# cat phpinfo.php
<?php
phpinfo()
?>
7、初始化mariadb,并设置一个密码
[root@localhost html]# mysql_secure_installation
8、配置zabbix用户也可以登录数据库,下面的zabbix以及zabbix密码可以修改,也可以不修改,一旦修改需要在zabbix的配置文件中进行修改。
[root@localhost yum.repos.d]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
MariaDB [(none)]> create database zabbix;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all on zabbix.* to zabbix@localhost identified by 'zabbix';Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
9、检查zabbix的包
[root@localhost yum.repos.d]# yum list | grep zabbix
zabbix40.x86_64 4.0.16-1.el7 epel
zabbix40-agent.x86_64 4.0.16-1.el7 epel
zabbix40-dbfiles-mysql.noarch 4.0.16-1.el7 epel
zabbix40-dbfiles-pgsql.noarch 4.0.16-1.el7 epel
zabbix40-dbfiles-sqlite3.noarch 4.0.16-1.el7 epel
zabbix40-proxy.noarch 4.0.16-1.el7 epel
zabbix40-proxy-mysql.x86_64 4.0.16-1.el7 epel
zabbix40-proxy-pgsql.x86_64 4.0.16-1.el7 epel
zabbix40-proxy-sqlite3.x86_64 4.0.16-1.el7 epel
zabbix40-server.noarch 4.0.16-1.el7 epel
zabbix40-server-mysql.x86_64 4.0.16-1.el7 epel
zabbix40-server-pgsql.x86_64 4.0.16-1.el7 epel
zabbix40-web.noarch 4.0.16-1.el7 epel
zabbix40-web-mysql.noarch 4.0.16-1.el7 epel
zabbix40-web-pgsql.noarch 4.0.16-1.el7 epel
10、安装时一定要注意选择好版本,这里安装zabbix40,并且安装上自己的agent端。
[root@localhost yum.repos.d]# yum install zabbix40 zabbix40-server zabbix40-web zabbix40-web-mysql zabbix40-agent zabbix40-server-mysql zabbix40-dbfiles-mysql -y
11、配置mysql,在/etc/my.cnf中添加字符编码以及引擎。
[mysqld]
character-set-server=utf8
innodb_file_per_table=1
12、导入zabbix自带的三个表结构,必须按下图顺序导入,否则会报错。若路径不一样,自己搜一下即可。
[root@localhost zabbix]# cd /usr/share/zabbix-mysql/
[root@localhost zabbix-mysql]# ls
data.sql images.sql Makefile Makefile.am Makefile.in schema.sql
[root@localhost zabbix-mysql]# mysql -uzabbix -pzabbix zabbix < ./schema.sql
[root@localhost zabbix-mysql]# mysql -uzabbix -pzabbix zabbix < ./images.sql
[root@localhost zabbix-mysql]# mysql -uzabbix -pzabbix zabbix < ./data.sql
[root@localhost zabbix-mysql]# mysql -uzabbix -pzabbix zabbix -e 'show tables;'
+----------------------------+
| Tables_in_zabbix |
+----------------------------+
| acknowledges |
| actions |
| alerts |
13、配置连接数据库
[root@localhost zabbix-mysql]# grep -E -v "(^#|^$)" /etc/zabbix_server.conf
LogFile=/var/log/zabbixsrv/zabbix_server.log
LogFileSize=0
PidFile=/run/zabbixsrv/zabbix_server.pid
SocketDir=/var/lib/zabbixsrv/tmp
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix #配置这里
Timeout=4
AlertScriptsPath=/var/lib/zabbixsrv/alertscripts
ExternalScripts=/var/lib/zabbixsrv/externalscripts
LogSlowQueries=3000
TmpDir=/var/lib/zabbixsrv/tmp
SSLCertLocation=/var/lib/zabbixsrv/ssl/certs
SSLKeyLocation=/var/lib/zabbixsrv/ssl/keys
14、修改zabbix时区
[root@localhost zabbix-mysql]# vim /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/Shanghai
15、重启服务
[root@localhost zabbix-mysql]# systemctl restart zabbix-server
[root@localhost zabbix-mysql]# netstat -ntpl | grep 10051
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 24437/zabbix_server
下来在浏览器下安装
下面页面要保证所有的项都为OK
这里的端口不需要修改,0就代表3306.
默认账户名admin,密码zabbix.
更改语言。
zabbix-agent未启动.
所以现在进入后会是下面的界面:因为找不到10050端口。10050代表zabbix-agent端,10051代表zabbix-server.
启动zabbix-agent即可。
来源:CSDN
作者:闭上眼待琉璃
链接:https://blog.csdn.net/qq_41547105/article/details/104222168