在线部署
环境:centos8
安装版本:zabbix6.0
sudo mv /etc/yum.repos.d/CentOS-* /tmp/
sudo curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo
sudo yum makecache
yum -y update
- 关闭防火墙,SELINUX
systemctl stop firewalld.service
systemctl disable firewalld.service
setenforce 0
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
systemctl status firewalld
systemctl status selinux-autorelabel
3. web 环境搭建(安装 LAMP)
yum -y install mariadb mariadb-server php php-mysqlnd httpd
4. 测试 Apache
先启动 http 服务
systemctl start httpd
[root@hello ~]# systemctl enable httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
[root@hello ~]# systemctl enable mariadb #开机启动
[root@hello ~]# systemctl start mariadb #开启数据库
[root@hello ~]# 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.
输入数据库 root 用户密码(默认为空,直接回车,若当时自己设的有,则输入),我这里设置的是有密码的
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.
You already have a root password set, so you can safely answer 'n'.
我在这里是在修改我原来的密码,看个人是否需要
Change the 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.
是否禁止 root 用户远程登陆? 否 (按回车跳过)
Disallow root login remotely? [Y/n]
... 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] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
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!
6. 创建 Zabbix 数据库及用户
[root@hello ~]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 28
Server version: 10.3.28-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.
建 zabbix 库,并设定 utf8 字符集
MariaDB [(none)]> create database zabbix character set utf8mb4 collate utf8mb4_bin;
Query OK, 1 row affected (0.001 sec)
授权 zabbix 用户给 zabbix 库权限并修改密码
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by '123456';
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> exit
退出数据库,再测试一下 zabbix 用户
[root@hello ~]# mysql -uzabbix -p123456 ##使用 zabbix 登录数据库
二、Server 端安装配置
1、安装 zabbix 仓库
rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/8/x86_64/zabbix-release-6.0-4.el8.noarch.rpm
2、清除缓存
dnf clean all
3、配置 zabbix.repo 文件仓库
[root@centos8 yum.repos.d]# cat zabbix.repo
[zabbix]
name=Zabbix Official Repository - $basearch
#baseurl=https://repo.zabbix.com/zabbix/6.0/rhel/8/$basearch/
baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/6.0/rhel/8/x86_64/ # zabbix 清华源
enabled=1
gpgcheck=1
gpgkey=
[zabbix-non-supported]
name=Zabbix Official Repository (non-supported) - $basearch
#baseurl=https://repo.zabbix.com/non-supported/rhel/8/$basearch/
baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/non-supported/rhel/8/x86_64/ # zabbix-non-supported 清华源
enabled=1
gpgkey=
gpgcheck=1
[zabbix-unstable]
name=Zabbix Official Repository (unstable) - $basearch
baseurl=https://repo.zabbix.com/zabbix/5.5/rhel/8/$basearch/
enabled=0
gpgcheck=1
gpgkey=
[root@centos8 yum.repos.d]#
4、配置 zabbix-agent2-plugins.repo 文件仓库
[root@centos8 yum.repos.d]# cat zabbix-agent2-plugins.repo
[zabbix-agent2-plugins]
name=Zabbix Official Repository (Agent2 Plugins) - $basearch
#baseurl=https://repo.zabbix.com/zabbix-agent2-plugins/1/rhel/8/$basearch/
baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix-agent2-plugins/1/rhel/8/x86_64/ # agent2 清华源
enabled=1
gpgkey=
gpgcheck=1
[root@centos8 yum.repos.d]#
安装 Zabbix server,Web 前端,agent
dnf install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent2 //注意这里安装的是 agent2
2. 配置数据库
2.1
配置 zabbix 之前,需先将其与数据库进行连接
初始数据导入数据库
zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p Zabbix
2.2
修改配置文件 vim /etc/zabbix/zabbix_server.conf ,添加 DBPassword=123456
##在文件的最后添加
NodeAddress=localhost:10051
AllowUnsupportedDBVersions=1
DBSocket=/var/lib/mysql/mysql.sock
2.3
更改时区
vim /etc/php-fpm.d/zabbix.conf
php_value[date.timezone] = Asia/Shanghai (有的话修改,没有添加)
1
2
2.4
最后,启动进程,并为它们设置开机自启。
systemctl restart zabbix-server zabbix-agent2 httpd php-fpm
systemctl enable zabbix-server zabbix-agent2 httpd php-fpm
3. Zabbix 访问测试
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于