关于云计算:CentOS-7上如何搭建Zabbix40

30次阅读

共计 4426 个字符,预计需要花费 12 分钟才能阅读完成。

zabbix 介绍

Zabbix 是一个基于 WEB 界面的提供分布式系统监督以及网络监督性能的企业级的开源解决方案。它能监督各种网络参数,保障服务器零碎的平安经营;并提供灵便的告诉机制以让系统管理员疾速定位 / 解决存在的各种问题。

zabbix 软件组成

zabbix-server: 监控服务端 zabbix-agent: 监控客户端 zabbix-web: 监控网站服务 php: 解决动静申请 mysql: 数据库存储监控数据 zabbix: 负责收集 agent 信息汇总告知 zabbix-server

1. 敞开防火墙和 selinux

[root@zabbix ~]# setenforce 0
[root@zabbix ~]# sed -ri '/^SELINUX=/cSELINUX=disabled' /etc/sysconfig/selinux 
[root@zabbix ~]# systemctl stop firewalld ; systemctl disable firewalld

2. 增加 zabbix 源和 epel 源

[root@zabbix ~]# rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm ## 这里应用的是清华源
[root@zabbix ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo ## 增加 epel 源 

3. 装置 zabbix 和相干服务组件

[root@zabbix ~]# wget  https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/x86_64/{zabbix-server-mysql-4.0.20-1.el7.x86_64.rpm,zabbix-web-4.0.22-1.el7.noarch.rpm} ## 把这两个包先拿下来, 因为装置的时候网络问题会呈现装置超时
[root@zabbix ~]# yum install -y httpd php zabbix-server-mysql-4.0.20-1.el7.x86_64.rpm  zabbix-web-mysql ### 装置 zabbix 的服务程序和 web 程序
[root@zabbix ~]# yum install -y mariadb-server ## 装置数据库服务 

4. 批改 zabbix 配置文件

[root@zabbix ~]# sed -ri.bak '/# DBPassword=/cDBPassword=zabbix' /etc/zabbix/zabbix_server.conf ## 批改 zabbix 数据库明码为 zabbix
[root@zabbix ~]# sed -ri.bak 's/ #(.*)date.timezone.*/\1date.timezone Asia\/Shanghai/' /etc/httpd/conf.d/zabbix.conf ## 批改时区为国内 

5. 配置数据库服务

[root@zabbix ~]# systemctl start mariadb #启动数据库
[root@zabbix ~]# 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 current
password 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 MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] n
 ... skipping.

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!
[root@zabbix ~]# mysql -uroot -p ## 登录数据库
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 5.5.65-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; ## 创立 zabbix 数据库 
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix'; ## 创立数据库治理用户
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> quit
Bye
[root@zabbix ~]# zcat /usr/share/doc/zabbix-server-mysql-4.0.20/create.sql.gz  | mysql -uzabbix -pzabbix zabbix  ## 将数据表写入到 zabbix 库中 

6. 启动 zabbix 和相干服务

[root@zabbix ~]# systemctl start zabbix-server.service httpd mariadb.service
[root@zabbix ~]# systemctl enable zabbix-server.service httpd mariadb.service
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.

7. 登录 zabbix 的 web 界面, 进行初始化

初始化地址 http://172.16.210.56/zabbix/setup.php

点击 Next step

查看 php 的一些变量条件, 如果没有报错的信息能够点击 next step

填写好对应的数据库明码和帐号点击 Next step

设置主机和端口还有监控页面名字, 而后点击 Next step

确认信息. 而后点击 Next step

点击 Finish

帐号 Admin 明码 zabbix , 再点 Sign in

登录胜利。

8. 更改 zabbix 界面语言为中文

点击右上角的君子

抉择 Chinese

再点击 update

更改胜利!

福利:豆花同学为大家精心整顿了一份对于 linux 和 python 的学习材料大合集!有须要的小伙伴们,关注豆花集体公众号:python 头条!回复关键词“材料合集”即可收费支付!

正文完
 0