文章目录
- 环境
- 一、zabbix 5.0 部署
- 1、安装yum源
- 2、安装相关软件
- 3、数据库安装和配置
- mariaDB数据库
- mysql57数据库
- 安装mysql
- 万能卸载mysql代码:
- 启动mysql并初始化
- 4、数据表导入
- 5、修改配置,启动服务
- 6、配置 web GUI
- 7、浏览器访问
- 注意数据加密的选项不要勾
- 8、配置agent端
- Install and configure Zabbix for your platform
- a. Install Zabbix repository
- b. Install Zabbix agent
- c. set configure file
- d. Start Zabbix agent process
- 开始使用Zabbix
- d. Start Zabbix agent process
- 开始使用Zabbix
- 自我补充
- zabbix的监控模式
环境
系统 | ip | zabbix版本 | 主机名 |
---|---|---|---|
centos7 | 192.168.249.141 | 5.0 | zabbix-server |
ceneto7 | 192.168.249.148 | 5.0 | zabbix-agent |
一、zabbix 5.0 部署
zabbix 5.0版本为长期支持版本,安装方式封装成都更高,web ui更加细致,喜人,本篇记录zabbix5.0安装细节
官方部署文档,同样简单好用
1、安装yum源
[root@zabbix-server ~]# yum install -y https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
[root@zabbix-server ~]# yum clean all
[root@zabbix-server ~]# yum makecache fast
2、安装相关软件
# 这里我们安装了比较多的包
[root@zabbix-server ~]# yum -y install zabbix-agent zabbix-get zabbix-sender zabbix-server-mysql
3、数据库安装和配置
mariaDB数据库
[root@zabbix-server ~]# 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
# 安装
[root@zabbix-server ~]# yum install MariaDB-server MariaDB-client
# 修改配置文件
[root@zabbix-server ~]# 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 #开启二进制日志
# 启动数据库
[root@zabbix-server ~]# systemctl restart mariadb
# 进入数据库进行数据初始化
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin; # 创建zabbix数据库
MariaDB [(none)]> grant all on zabbix.* to 'zabbix'@'%' identified by 'keer'; # 注意授权网段
MariaDB [(none)]> flush privileges; # 刷新授权
mysql57数据库
安装mysql
rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-11.noarch.rpm
更改5.7
vim /etc/yum.repos.d/mysql-community.repo
yum -y install mysql-server
万能卸载mysql代码:
systemctl stop mysqld mariadb &>/dev/null ;pkill -9 mysql ; userdel -r -f mysql; rm -rf /var/lib/mysql* /etc/my* /var/log/mysql* ; echo “mysql已删除”
启动mysql并初始化
systemctl start mysqld && passwd=
grep password /var/log/mysqld.log | awk 'END{ print $NF} '
&& mysqladmin -p"$passwd" password ‘Qwer@123…’;
在数据库执行
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql>CREATE USER ‘zabbix’@‘%’ IDENTIFIED BY ‘your_password’;
mysql>GRANT ALL PRIVILEGES ON zabbix.* TO ‘zabbix’@‘%’ WITH GRANT OPTION;
mysql> set global log_bin_trust_function_creators = 1;
mysql> quit;
4、数据表导入
# 让我们来看一下zabbix-server-mysql 这个包为我们安装了哪些内容
[root@zabbix-server ~]# rpm -ql zabbix-server-mysql
/etc/logrotate.d/zabbix-server
/etc/zabbix/zabbix_server.conf
/usr/lib/systemd/system/zabbix-server.service
/usr/lib/tmpfiles.d/zabbix-server.conf
/usr/lib/zabbix/alertscripts
/usr/lib/zabbix/externalscripts
/usr/sbin/zabbix_server_mysql
/usr/share/doc/zabbix-server-mysql-5.0.10
/usr/share/doc/zabbix-server-mysql-5.0.10/AUTHORS
/usr/share/doc/zabbix-server-mysql-5.0.10/COPYING
/usr/share/doc/zabbix-server-mysql-5.0.10/ChangeLog
/usr/share/doc/zabbix-server-mysql-5.0.10/NEWS
/usr/share/doc/zabbix-server-mysql-5.0.10/README
/usr/share/doc/zabbix-server-mysql-5.0.10/create.sql.gz # 这个就是初始化数据库的包
/usr/share/doc/zabbix-server-mysql-5.0.10/double.sql
/usr/share/man/man8/zabbix_server.8.gz
/var/log/zabbix
/var/run/zabbix
[root@zabbix-server ~]# zcat /usr/share/doc/zabbix-server-mysql-5.0.42/create.sql.gz | mysql -uzabbix -p zabbix
mysql -uroot -p'密码' 进入mysql
mysql> set global log_bin_trust_function_creators = 0;
mysql> quit; #将这条配置关闭后,退出mysql
5、修改配置,启动服务
[root@zabbix-server ~]# cd /etc/zabbix
[root@zabbix-server zabbix]# ls
web zabbix_agentd.conf zabbix_agentd.d zabbix_server.conf
[root@zabbix-server zabbix]# cp zabbix_server.conf{,.bak} # 备份配置文件
[root@zabbix-server zabbix]# vim zabbix_server.conf # 修改一下内容,其他配置可以参考4.4文档
ListenPort=10051 #默认监听端口
SourceIP=192.168.249.141 #发采样数据请求的IP
DBHost=192.168.249.141 #数据库对外的主机
DBName=zabbix #数据库名称
DBUser=zabbix #数据库用户
DBPassword=keer #数据库密码
DBPort=3306 #数据库启动端口
# 开启服务并检查
[root@zabbix-server zabbix]# systemctl start zabbix-server.service
[root@zabbix-master zabbix]# ss -nutl |grep 10051
tcp LISTEN 0 128 *:10051 *:*
tcp LISTEN 0 128 :::10051 :::*
6、配置 web GUI
[root@zabbix-server ~]# vim /etc/yum.repos.d/zabbix.repo
[zabbix-frontend] # 将这个软件源设置为启动
...
enabled=1
# 这是5.0的新特性,将nginx和php进行了封装,这里安装后我们就可以直接使用了
[root@zabbix-server ~]# yum install centos-release-scl
[root@zabbix-server ~]# yum install zabbix-web-mysql-scl zabbix-nginx-conf-scl
# php 位置: /etc/opt/rh/rh-php72
# nginx位置:/etc/opt/rh/rh-nginx116
# 修改php-fpm服务启动用户和时区
[root@zabbix-server ~]# vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
[zabbix]
user = nginx
group = nginx
listen = /var/opt/rh/rh-php72/run/php-fpm/zabbix.sock
listen.acl_users = nginx
listen.allowed_clients = 127.0.0.1
php_value[date.timezone] = Asia/Shanghai
[root@zabbix-server ~]#vim /etc/opt/rh/rh-php72/php-fpm.d/www.conf #修改配置文件
user = nginx
group = nginx #将其中的这两个参数改为nginx
[root@zabbix-server ~]# chown .nginx /var/opt/rh/rh-php72/lib/php/session/
[root@zabbix-server ~]# chown nginx.nginx -R /etc/zabbix/web/
[root@zabbix-server ~]# vim /etc/opt/rh/rh-nginx116/nginx/nginx.conf
server {
# listen 80 default_server;
# listen [::]:80 default_server;
server_name _;
root /opt/rh/rh-nginx116/root/usr/share/nginx/html; #将server模块中的两个监听80端口参数注释
# 启动服务
[root@zabbix-server ~]# systemctl restart zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm
[root@zabbix-server ~]# systemctl enable zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm
7、浏览器访问
http://192.168.249.141
注意数据加密的选项不要勾
8、配置agent端
[root@zabbix-agent ~]# yum install zabbix-agent zabbix-sender -y
-
Install and configure Zabbix for your platform
a. Install Zabbix repository
# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm# yum clean all
b. Install Zabbix agent
# yum install zabbix-agent
c. set configure file
# vim /etc/zabbix/zabbix_agentd.conf
d. Start Zabbix agent process
Start Zabbix agent process and make it start at system boot.
# systemctl restart zabbix-agent
# systemctl enable zabbix-agent
-
开始使用Zabbix
268927994)]
[外链图片转存中…(img-T3a6lOE6-1715268927994)]
d. Start Zabbix agent process
Start Zabbix agent process and make it start at system boot.
# systemctl restart zabbix-agent
# systemctl enable zabbix-agent
自我补充
zabbix的监控模式
参照物:agent
比如我问我同桌,你今天吃饭了吗,他就得回答,所以他是被动的
被动模式:server端向agent端请求获取监控项配置的相关数据,agent端响应,并将数据发送给server端
主动模式:agent端主动向server请求与自己相关监控配置,主动将server配置的监控项的相关数据发送给server端
自己解决问题真的很酷,嘿嘿,今天开心,