searchusermenu
  • 发布文章
  • 消息中心
点赞
收藏
评论
分享
原创

zabbix+mysql监控服务器的搭建

2023-06-20 08:38:41
47
0

一、zabbix 安装

1. zabbix下载地址

http://repo.zabbix.com/zabbix

2. 安装zabbix server

rpm -Uvh https://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.e7.noarch.rpm

yum clean all

yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent zabbix-get zabbix-sender -y

 

3. 安装zabbix agent

zabbix server端必须要安装一个zabbix agent。

[root]# yum install zabbix-agent -y       

[root]# vi /etc/zabbix/zabbix_agentd.con f

PidFile=/run/zabbix/zabbix_server.pid     

LogFile=/var/log/zabbix/zabbix_agentd.log 

LogFileSize=0                             

Server=x.x.x.x                     

ServerActive=x.x.x.x:10051         

Hostname=zabbix-server                    

Include=/etc/zabbix/zabbix_agentd.d/*.conf

BufferSize=200                            

Timeout=30                            

 

二、MySQL安装

1.创建mysql文件夹

cd /usr/local

mkdir mysql

 

2.下载资源完整包,并上传到/usr/local/mysql

 

3.解压mysql下载包

tar -xvf mysql-8.0.26-1.el7.x86_64.rpm-bundle.tar

 

4.查询本地有没有已存在安装包和卸载

 

查询:rpm -qa | grep mariadb

卸载:rpm -e mariadb-libs-5.5.60-1.el7_5.x86_64 --nodeps

 

5. 安装顺序

rpm -ivh mysql-community-common-8.0.26-1.el7.x86_64.rpm        

rpm -ivh mysql-community-client-plugins-8.0.26-1.el7.x86_64.rpm

rpm -ivh mysql-community-libs-8.0.26-1.el7.x86_64.rpm         

rpm -ivh mysql-community-client-8.0.26-1.el7.x86_64.rpm       

rpm -ivh mysql-community-server-8.0.26-1.el7.x86_64.rpm       

rpm -ivh mysql-community-libs-compat-8.0.26-1.el7.x86_64.rpm  

 

6.开启mysql

systemctl start mysqld

 

7.查看数据库的初始密码,命令如下:

cat /var/log/mysqld.log | grep password(记录一下密码,修改要用

 

8.修改密码

登录:mysql -u root -p

修改:ALTER USER "USER"@"localhost" IDENTIFIED  BY "PASSWORD";

 

三、配置zabbix server

 

1.导入表,创建zabbix库、zabbix用户、导入zabbix数据

SQL> create database zabbix character set utf8 collate utf8_bin;     

SQL> create user 'USER'@'%' identified by 'PASSWORD';          

SQL> grant all privileges on zabbix.* to 'USER'@'%';               

[root]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix                                                   

 

2.配置zabbix-server连接mysql

[root]# vi /etc/zabbix/zabbix_server.conf

LogFile=/var/log/zabbix/zabbix_server.log

LogFileSize=0

PidFile=/run/zabbix/zabbix_server.pid (要和service里的路径一样

SocketDir=/var/run/zabbix

DBHost=localhost (这里,localhost还是127.0.0.1视情况而定

DBName=zabbix

DBUser=zabbix

DBPassword=PASSWORD

SNMPTrapperFile=/var/log/snmptrap/snmptrap.log

Timeout=4

AlertScriptsPath=/usr/lib/zabbix/alertscripts

ExternalScripts=/usr/lib/zabbix/externalscripts

LogSlowQueries=3000

 

3.启动zabbix server

[root]# systemctl start zabbix-server

[root]# systemctl enable zabbix-server

 

4.修改zabbix前端PHP配置

修改时区

[root]# vi /etc/httpd/conf.d/zabbix.conf

php_value date.timezone Asia/Shanghai

 

5.关闭firewall、selinux

systemctl stop firewalld.service

systemctl disable firewalld.service

vi /etc/selinux/config

将SELINUX改成disable(重启后生效)

 

6.启动httpd服务

[root]# vi /etc/httpd/conf

修改ServerName x.x.x.x:80 (同zabbix_agentd.conf中的server地址)

[root]# systemctl start httpd

[root]# systemctl enable httpd

 

7.登录zabbix web

http://x.x.x.x/zabbix    

初始:Admin/zabbix  

界面右上角 用户-修改密码为PASSWORD    语言改为中文。

 

四、web端配置

1.创建主机

配置--主机--创建主机

 

2.配置加密

配置--主机--选择一台主机--加密

共享密钥一致性:TEST

PSK:****************************************************

 

 

五、常见报错

1、mysql客户端连接失败:2059-Authentication plugin 'caching_sha2_password' can not be loaded: ...

解决方法:登录数据库后

use mysql

select user,host,plugin,authentication_string from user;

alter user 'USER'@'%' identified with mysql_native_password by 'PASSWORD';

 

2、zabbix web出现403错误。

vi /etc/httpd/conf

查看ServerName x.x.x.x:80有没有成功添加

 

3、登录时显示Unable to select configuration.

出现这个错误是数据库表导入失败。删除zabbix库和zabbix用户以后重新执行导入表,创建zabbix库、zabbix用户、导入zabbix数据

SQL> create database zabbix character set utf8 collate utf8_bin;     

SQL> create user 'USER'@'%' identified by 'PASSWORD';          

SQL> grant all privileges on zabbix.* to 'USER'@'%';               

[root]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix  (过程有一点长,不要中断)

 

 

0条评论
0 / 1000
z****n
2文章数
0粉丝数
z****n
2 文章 | 0 粉丝
z****n
2文章数
0粉丝数
z****n
2 文章 | 0 粉丝
原创

zabbix+mysql监控服务器的搭建

2023-06-20 08:38:41
47
0

一、zabbix 安装

1. zabbix下载地址

http://repo.zabbix.com/zabbix

2. 安装zabbix server

rpm -Uvh https://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.e7.noarch.rpm

yum clean all

yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent zabbix-get zabbix-sender -y

 

3. 安装zabbix agent

zabbix server端必须要安装一个zabbix agent。

[root]# yum install zabbix-agent -y       

[root]# vi /etc/zabbix/zabbix_agentd.con f

PidFile=/run/zabbix/zabbix_server.pid     

LogFile=/var/log/zabbix/zabbix_agentd.log 

LogFileSize=0                             

Server=x.x.x.x                     

ServerActive=x.x.x.x:10051         

Hostname=zabbix-server                    

Include=/etc/zabbix/zabbix_agentd.d/*.conf

BufferSize=200                            

Timeout=30                            

 

二、MySQL安装

1.创建mysql文件夹

cd /usr/local

mkdir mysql

 

2.下载资源完整包,并上传到/usr/local/mysql

 

3.解压mysql下载包

tar -xvf mysql-8.0.26-1.el7.x86_64.rpm-bundle.tar

 

4.查询本地有没有已存在安装包和卸载

 

查询:rpm -qa | grep mariadb

卸载:rpm -e mariadb-libs-5.5.60-1.el7_5.x86_64 --nodeps

 

5. 安装顺序

rpm -ivh mysql-community-common-8.0.26-1.el7.x86_64.rpm        

rpm -ivh mysql-community-client-plugins-8.0.26-1.el7.x86_64.rpm

rpm -ivh mysql-community-libs-8.0.26-1.el7.x86_64.rpm         

rpm -ivh mysql-community-client-8.0.26-1.el7.x86_64.rpm       

rpm -ivh mysql-community-server-8.0.26-1.el7.x86_64.rpm       

rpm -ivh mysql-community-libs-compat-8.0.26-1.el7.x86_64.rpm  

 

6.开启mysql

systemctl start mysqld

 

7.查看数据库的初始密码,命令如下:

cat /var/log/mysqld.log | grep password(记录一下密码,修改要用

 

8.修改密码

登录:mysql -u root -p

修改:ALTER USER "USER"@"localhost" IDENTIFIED  BY "PASSWORD";

 

三、配置zabbix server

 

1.导入表,创建zabbix库、zabbix用户、导入zabbix数据

SQL> create database zabbix character set utf8 collate utf8_bin;     

SQL> create user 'USER'@'%' identified by 'PASSWORD';          

SQL> grant all privileges on zabbix.* to 'USER'@'%';               

[root]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix                                                   

 

2.配置zabbix-server连接mysql

[root]# vi /etc/zabbix/zabbix_server.conf

LogFile=/var/log/zabbix/zabbix_server.log

LogFileSize=0

PidFile=/run/zabbix/zabbix_server.pid (要和service里的路径一样

SocketDir=/var/run/zabbix

DBHost=localhost (这里,localhost还是127.0.0.1视情况而定

DBName=zabbix

DBUser=zabbix

DBPassword=PASSWORD

SNMPTrapperFile=/var/log/snmptrap/snmptrap.log

Timeout=4

AlertScriptsPath=/usr/lib/zabbix/alertscripts

ExternalScripts=/usr/lib/zabbix/externalscripts

LogSlowQueries=3000

 

3.启动zabbix server

[root]# systemctl start zabbix-server

[root]# systemctl enable zabbix-server

 

4.修改zabbix前端PHP配置

修改时区

[root]# vi /etc/httpd/conf.d/zabbix.conf

php_value date.timezone Asia/Shanghai

 

5.关闭firewall、selinux

systemctl stop firewalld.service

systemctl disable firewalld.service

vi /etc/selinux/config

将SELINUX改成disable(重启后生效)

 

6.启动httpd服务

[root]# vi /etc/httpd/conf

修改ServerName x.x.x.x:80 (同zabbix_agentd.conf中的server地址)

[root]# systemctl start httpd

[root]# systemctl enable httpd

 

7.登录zabbix web

http://x.x.x.x/zabbix    

初始:Admin/zabbix  

界面右上角 用户-修改密码为PASSWORD    语言改为中文。

 

四、web端配置

1.创建主机

配置--主机--创建主机

 

2.配置加密

配置--主机--选择一台主机--加密

共享密钥一致性:TEST

PSK:****************************************************

 

 

五、常见报错

1、mysql客户端连接失败:2059-Authentication plugin 'caching_sha2_password' can not be loaded: ...

解决方法:登录数据库后

use mysql

select user,host,plugin,authentication_string from user;

alter user 'USER'@'%' identified with mysql_native_password by 'PASSWORD';

 

2、zabbix web出现403错误。

vi /etc/httpd/conf

查看ServerName x.x.x.x:80有没有成功添加

 

3、登录时显示Unable to select configuration.

出现这个错误是数据库表导入失败。删除zabbix库和zabbix用户以后重新执行导入表,创建zabbix库、zabbix用户、导入zabbix数据

SQL> create database zabbix character set utf8 collate utf8_bin;     

SQL> create user 'USER'@'%' identified by 'PASSWORD';          

SQL> grant all privileges on zabbix.* to 'USER'@'%';               

[root]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix  (过程有一点长,不要中断)

 

 

文章来自个人专栏
zabbix监控服务
2 文章 | 1 订阅
0条评论
0 / 1000
请输入你的评论
0
0