Zabbix安装部署

 

所有机器关闭防火墙和 selinux

setenforce 0 (修改配置文件关闭)
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config 
systemctl stop firewalld.service

Zabbix的安装

更新 yum 仓库

下载 yum 仓库

# yum -y install wget
[root@service ~]# wget http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm

安装 yum 仓库

[root@service ~]# rpm -ivh zabbix-release-4.2-1.el7.noarch.rpm

更新 yum 仓库

[root@service ~]# yum repolist 
Loaded plugins: fastestmirror, langpacks  
Loading mirror speeds from cached hostfile
zabbix-non-supported                                                      4/4
repo id                     repo name                                   status
base                        base                                         9,363
epel                        epel                                        11,349
zabbix/x86_64               Zabbix Official Repository - x86_64             80
zabbix-non-supported/x86_64 Zabbix Official Repository non-supported -       4
repolist: 20,796

安装 Zabbix

[root@service~]# yum -y install epel-release.noarch
[root@service~]# yum -y install zabbix-agent zabbix-get zabbix-sender zabbix-server-mysql zabbix-web zabbix-web-mysql
[root@service~]# yum-config-manager --enable rhel-7-server-optional-rpms

安装设置数据库:

创建 mariadb.repo

# vim /etc/yum.repos.d/mariadb.repo
写入以下内容:
[mariadb]
name = MariaDB 
baseurl = https://mirrors.ustc.edu.cn/mariadb/yum/10.4/centos7-amd64 
gpgkey=https://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB 
gpgcheck=1

yum 安装最新版本 mariadb

# yum install -y MariaDB-server MariaDB-client

修改配置文件

# vim /etc/my.cnf.d/server.cnf
    [mysqld]
    skip_name_resolve = ON          # 跳过主机名解析
    innodb_file_per_table = ON      # 开启独立表空间
    innodb_buffer_pool_size = 256M  # 缓存池大小
    max_connections = 2000          # 最大连接数
    log-bin = master-log            # 开启二进制日志

 重启数据库服务

# systemctl restart mariadb
# mysql_secure_installation

 创建数据库并授权账号

mysql> create database zabbix character set utf8mb4 collate utf8mb4_bin;
Query OK, 1 row affected (0.05 sec)

mysql>  create user zabbix@localhost identified by 'password';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql>  create user zabbix@localhost identified by 'Wyxbuke00.';
Query OK, 0 rows affected (0.02 sec)

mysql> grant all privileges on zabbix.* to zabbix@localhost;
Query OK, 0 rows affected (0.02 sec)

mysql> set global log_bin_trust_function_creators = 1;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> quit;
Bye

 导入 Zabbix 服务表

[root@service yum.repos.d]# zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -pWyxbuke00. zabbix
mysql: [Warning] Using a password on the command line interface can be insecure.

配置 server 端

  • 默认值为1,表示滚动。我们设为0则表示不滚动。当数据特别多的时候,我们也可以设置成为1,然后在 Maximum size of log file in MB 设置当数据文件最大到多少时会自动滚动。

[root@service yum.repos.d]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 8.0.36 MySQL Community Server - GPL

Copyright (c) 2000, 2024, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> set global log_bin_trust_function_creators = 0;
Query OK, 0 rows affected, 1 warning (0.01 sec)

mysql> quit;
Bye

 

数据库相关的设置

[root@service yum.repos.d]# vim  /etc/zabbix/zabbix_server.conf
    DBHost=192.168.142.139       #数据库对外的主机
    DBName=zabbix               #数据库名称
    DBUser=zbxuser              #数据库用户
    DBPassword=123456           #数据库密码
    DBPort=3306                 #数据库启动端口

 

启动服务

[root@service yum.repos.d]# systemctl restart zabbix-server zabbix-agent httpd php-fpm
[root@service yum.repos.d]# systemctl enable zabbix-server zabbix-agent httpd php-fpm
Created symlink /etc/systemd/system/multi-user.target.wants/zabbix-server.service → /usr/lib/systemd/system/zabbix-server.service.
Created symlink /etc/systemd/system/multi-user.target.wants/zabbix-agent.service → /usr/lib/systemd/system/zabbix-agent.service.
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
Created symlink /etc/systemd/system/multi-user.target.wants/php-fpm.service → /usr/lib/systemd/system/php-fpm.service.

 通过IP地址访问/zabbix

  • 12
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

元气满满的热码式

感谢您的支持!我会继续努力发布

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值