centOS7部署安装zabbix5.0

参考

官网地址>> Download and install Zabbix 可参考版本及安装步骤

1、搭建LAMP环境

[root@test ~]# 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

2、查看软件版本

[root@test ~]# rpm -qa httpd mariadb php
mariadb-5.5.68-1.el7.x86_64
httpd-2.4.6-97.el7.centos.x86_64
php-5.4.16-48.el7.x86_64

3、启动、查看服务状态

[root@test ~]# systemctl restart mariadb
[root@test ~]# systemctl restart httpd
[root@test ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: active (running) since Thu 2021-03-18 10:24:57 EDT; 15s ago
     Docs: man:httpd(8)
           man:apachectl(8)
 Main PID: 524 (httpd)
   Status: "Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec"
    Tasks: 6
   CGroup: /system.slice/httpd.service
           ├─524 /usr/sbin/httpd -DFOREGROUND
           ├─526 /usr/sbin/httpd -DFOREGROUND
           ├─527 /usr/sbin/httpd -DFOREGROUND
           ├─528 /usr/sbin/httpd -DFOREGROUND
           ├─529 /usr/sbin/httpd -DFOREGROUND
           └─530 /usr/sbin/httpd -DFOREGROUND

Mar 18 10:24:46 test systemd[1]: Starting The Apache HTTP Server...
Mar 18 10:24:56 test httpd[524]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using... message
Mar 18 10:24:57 test systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.
[root@test ~]# systemctl status mariadb
● mariadb.service - MariaDB database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
   Active: active (running) since Thu 2021-03-18 10:24:34 EDT; 45s ago
  Process: 32714 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=0/SUCCESS)
  Process: 32630 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS)
 Main PID: 32713 (mysqld_safe)
    Tasks: 20
   CGroup: /system.slice/mariadb.service
           ├─  481 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/...
           └─32713 /bin/sh /usr/bin/mysqld_safe --basedir=/usr

Mar 18 10:24:32 test mariadb-prepare-db-dir[32630]: MySQL manual for more instructions.
Mar 18 10:24:32 test mariadb-prepare-db-dir[32630]: Please report any problems at http://mariadb.org/jira
Mar 18 10:24:32 test mariadb-prepare-db-dir[32630]: The latest information about MariaDB is available at http://mariadb.org/.
Mar 18 10:24:32 test mariadb-prepare-db-dir[32630]: You can find additional information about the MySQL part at:
Mar 18 10:24:32 test mariadb-prepare-db-dir[32630]: http://dev.mysql.com
Mar 18 10:24:32 test mariadb-prepare-db-dir[32630]: Consider joining MariaDB's strong and vibrant community:
Mar 18 10:24:32 test mariadb-prepare-db-dir[32630]: https://mariadb.org/get-involved/
Mar 18 10:24:32 test mysqld_safe[32713]: 210318 10:24:32 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
Mar 18 10:24:32 test mysqld_safe[32713]: 210318 10:24:32 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Mar 18 10:24:34 test systemd[1]: Started MariaDB database server.

4、搭建zabbix服务环境

[root@test ~]# cat /etc/redhat-release 
CentOS Linux release 7.7.1908 (Core)
[root@test ~]# yum -y install git //安装git下载工具 后面会用到
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 安装过程省略........
Installed:
  git.x86_64 0:1.8.3.1-23.el7_8                                                                                                         

Dependency Installed:
  perl-Error.noarch 1:0.17020-2.el7          perl-Git.noarch 0:1.8.3.1-23.el7_8          perl-TermReadKey.x86_64 0:2.30-20.el7         
Complete!
----------------------------------------------------------------------------
[root@test ~]# systemctl disable firewalld //开机自动关闭防火墙
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@test ~]# systemctl stop firewalld //临时停止防火墙
[root@test ~]# setenforce 0  //临时关闭selinux
[root@test ~]# vi /etc/sysconfig/selinux //进入配置文件修改SELINUX=disabled
[root@test ~]# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm //使用rpm下载zabbix安装包
Retrieving https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
warning: /var/tmp/rpm-tmp.ehC0Mh: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:zabbix-release-5.0-1.el7         ################################# [100%]
[root@test ~]# yum clean all 
Loaded plugins: fastestmirror, langpacks
Cleaning repos: base extras updates zabbix zabbix-non-supported
Cleaning up list of fastest mirrors
[root@test ~]# yum install -y zabbix-server-mysql zabbix-agent //开始安装客户端和服务端
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
安装过程省略......
installed:
  zabbix-agent.x86_64 0:5.0.9-1.el7                               zabbix-server-mysql.x86_64 0:5.0.9-1.el7                              
Dependency Installed:
  OpenIPMI.x86_64 0:2.0.27-1.el7         OpenIPMI-libs.x86_64 0:2.0.27-1.el7             OpenIPMI-modalias.x86_64 0:2.0.27-1.el7        
  fping.x86_64 0:3.10-1.el7              net-snmp-libs.x86_64 1:5.7.2-49.el7_9.1         unixODBC.x86_64 0:2.3.1-14.el7                 
Complete!
------------------------------------------------------------------------------
[root@test ~]# yum install centos-release-scl  //安装Zabbix frontend 启用RedHat软件包
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 此处省略安装过程......
Installed:
  zabbix-nginx-conf-scl.noarch 0:5.0.9-1.el7                                                                                             zabbix-web-mysql-scl.noarch 0:5.0.9-1.el7                                                                                            

Dependency Updated:
  policycoreutils.x86_64 0:2.5-34.el7                                                                                                                                                                                                                                         
Complete!
------------------------------------------------------------------------------
[root@test ~]# vi /etc/yum.repos.d/zabbix.repo
[zabbix-frontend]
name=Zabbix Official Repository frontend - $basearch
baseurl=http://repo.zabbix.com/zabbix/5.0/rhel/7/$basearch/frontend
enabled=1  //把0改成1即可
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE59
[root@test ~]# yum install zabbix-web-mysql-scl zabbix-nginx-conf-scl //安装web端

5、创建zabbix数据库

[root@test ~]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 5.5.68-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)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> create user zabbix@localhost identified by 'kuang@123456..';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> quit;

6、导入初始架构和数据,系统将提示您输入新创建的密码。

[root@test ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix 
Enter password: 

7、为Zabbix server配置数据库

[root@test ~]# vim /etc/zabbix/zabbix_server.conf
DBUser=zabbix

### Option: DBPassword
#       Database password.
#       Comment this line if no password is used.
#
# Mandatory: no
# Default:
DBPassword=kuang@123456.. //设置密码

8、修改nginx配置文件

[root@test ~]# vim /etc/opt/rh/rh-nginx116/nginx/conf.d/zabbix.conf 
......
2        listen          80;
3        server_name     10.10.12.252; //前面的注释去掉 加上IP
......

32 #               fastcgi_pass    unix:/var/opt/rh/rh-php72/run/php-fpm/zabbix.sock;
33                 fastcgi_pass    127.0.0.1:9000;

9、编辑php配置文件 /etc/opt/rh/rh-php72/php-fpm.d/zabbix.con

[root@test ~]# vim /etc/opt/rh/rh-php72/php.ini
383 max_execution_time = 300
393 max_input_time = 300
672 post_max_size = 16M
902 date.timezone = Asia/Shanghai  //修改这四点就好了

10、重启服务、设置开机自启

注:
如果nginx服务启动失败,就先停止HTTPD,详细检查fastcgi_pass是否加了注释的
[root@test ~]# systemctl restart zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm
[root@test ~]# systemctl enable zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm

11、永久关闭firewalld和selinux,关闭才能访问webzabbix

[root@test ~]# systemctl stop firewalld //停止防火墙
[root@test ~]# systemctl disable firewalld //开机自动关闭防火墙
[root@test ~]# vi /etc/sysconfig/selinux  //关闭selinux
....
SELINUX=disabled //把enforcing改成disabled
....

web访问zabbix

12、连接到新安装的Zabbix前端并安装:http://10.10.12.252

默认用户名Admin,密码zabbix

zabbix界面

默认是英文版,现在设置汉化

随后点击update更新

添加服务器监控

配置--创建主机群组--填写组名(例:workerP)--添加

配置--创建主机--主机名(例:workerP-1)--可见的名称(随便填)--IP地址(例:192.168.0.1要监控的服务器IP)--描述(可描述)--添加

模块选项 是linux系统就按照下图选吧

是win系统就选win snmp

最后选择添加就可以了

zabbix还有很多功能,待后续更新~~

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值