部署zabbix

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6

源码下载地址

Download Zabbix sources

nginx: download

防火墙和selinux都需要关闭

1、部署监控服务器

1安装LNMP环境

Zabbix监控管理控制台需要通过Web页面展示出来并且还需要使用MySQL来存储数据因此需要先为Zabbix准备基础LNMP环境。

[root@zabbixserver ~]# yum -y install gcc pcre-devel  openssl-devel

[root@zabbixserver ~]# tar -xf nginx-1.12.2.tar.gz

[root@zabbixserver ~]# cd nginx-1.12.2

[root@zabbixserver nginx-1.12.2]# ./configure --with-http_ssl_module

[root@zabbixserver nginx-1.12.2]# make &&make install

[root@zabbixserver ~]# yum -y  install  php  php-mysql  php-fpm注意在centos8stream里没有php-mysql需要安装php-mysqlnd

[root@zabbixserver ~]# yum -y  install  mariadb  mariadb-devel  mariadb-server

2修改Nginx配置文件

配置Nginx支持PHP动态网站因为有大量PHP脚本需要执行因此还需要开启Nginx的各种fastcgi缓存加速PHP脚本的执行速度。

[root@zabbixserver ~]# vim /usr/local/nginx/conf/nginx.conf

… …

http{

… …

    fastcgi_buffers 816k;              #缓存php生成的页面内容8个16k

    fastcgi_buffer_size 32k;              #缓存php生产的头部信息32k

    fastcgi_connect_timeout 300;    #连接PHP的超时时间300

    fastcgi_send_timeout 300;             #发送请求的超时时间300

    fastcgi_read_timeout 300;            #读取请求的超时时间300

location ~\.php$ {

     root           html;

     fastcgi_pass   127.0.0.1:9000;

     fastcgi_index  index.php;

     include        fastcgi.conf;#[注意这里别出错]

}

… …

3启动服务

启动Nginx、PHP-FPM、MariaDB服务关闭SELinux与防火墙。

[root@zabbixserver ~]# systemctl start  mariadb        #启动服务

[root@zabbixserver ~]# systemctl start  php-fpm        #启动服务

[root@zabbixserver ~]# systemctl enable  mariadb        #设置开机自启

[root@zabbixserver ~]# systemctl enable  php-fpm        #设置开机自启

[root@zabbixserver ~]# /usr/local/nginx/sbin/nginx        #启动服务

[root@zabbixserver ~]# echo /usr/local/nginx/sbin/nginx  >>/etc/rc.local

[root@zabbixserver ~]# chmod +x /etc/rc.local

#通过rc.local设置开机自启

[root@zabbixserver ~]# firewall-cmd --set-default-zone=trusted

[root@zabbixserver ~]# setenforce 0

[root@zabbixserver ~]# sed -i '/SELINUX/s/enforcing/permissive/'/etc/selinux/config

 注意

在这里需要验证一下php是否正常启动了

ss -ntulp | grep php

如果没有输出则需要修改php-fpm的配置

[root@proxy etc]# vim /etc/php-fpm.d/www.conf

[www]

listen =127.0.0.1:9000            //PHP端口号

pm.max_children =32                //最大进程数量

pm.start_servers =15                //最小进程数量

2、部署监控服务器Zabbix Server

1源码安装Zabbix Server

多数源码包都是需要依赖包的zabbix也一样源码编译前需要先安装相关依赖包。

[root@zabbixserver ]# yum -y install  net-snmp-devel \

curl-devel autoconf libevent-devel

#安装相关依赖包

[root@zabbixserver]# tar -xf zabbix-3.4.4.tar.gz

[root@zabbixserver ]# cd zabbix-3.4.4/

[root@zabbixserver zabbix-3.4.4]# ./configure  --enable-server \

--enable-proxy --enable-agent --with-mysql=/usr/bin/mysql_config \

--with-net-snmp --with-libcurl

# --enable-server安装部署zabbix服务器端软件

# --enable-agent安装部署zabbix被监控端软件

# --enable-proxy安装部署zabbix代理相关软件

# --with-mysql指定mysql_config路径

# --with-net-snmp允许zabbix通过snmp协议监控其他设备如交换机、路由器等

# --with-libcurl安装相关curl库文件这样zabbix就可以通过curl连接http等服务测试被监控主机服务的状态

[root@zabbixserver zabbix-3.4.4]# make &&make install

2创建并初始化数据库root用户默认没有密码

[root@zabbixserver ~]# mysql

mysql>create database zabbix character set utf8;

#创建数据库数据库名称为zabbixcharacter set utf8是支持中文字符集

mysql>grant all on zabbix.*to zabbix@'localhost'identified by 'zabbix';

#创建可以访问数据库的账户与密码用户名是zabbix密码是zabbix

mysql>exit

#退出数据库

[root@zabbixserver ~]# cd zabbix-3.4.4/database/mysql/

[root@zabbixserver mysql]# mysql -uzabbix -pzabbix zabbix <schema.sql

[root@zabbixserver mysql]# mysql -uzabbix -pzabbix zabbix <images.sql

[root@zabbixserver mysql]# mysql -uzabbix -pzabbix zabbix <data.sql

#刚刚创建是空数据库zabbix源码包目录下有提前准备好的数据

#使用mysql导入这些数据即可注意导入顺序

如果导入有如下问题

[root@zabbix mysql]# mysql -uzabbix -pzabbix zabbix < schema.sql ERROR 1118 (42000) at line 1244: Row size too large (> 8126). Changing some columns to TEXT or BLOB may help. In current row format, BLOB prefix of 0 bytes is stored inline.

修改my.cnf文件添加或修改以下参数[root@zabbix mysql]# ls /etc/my.cnf

innodb_file_per_table=1

innodb_file_format=Barracuda

innodb_strict_mode=0

 

#-u指定数据库用户名-p指定数据库密码

如何测试

[root@zabbixserver ~]# mysql -uzabbix -pzabbix -h localhost zabbix

#-u指定用户名-p指定密码-h指定服务器IP最后的zabbix是数据库名称

#使用zabbix账户密码为zabbix连接localhost服务器上面的zabbix数据库

mysql>show tables;

#查看有没有数据表

mysql>exit

#退出数据库

 

3修改zabbix_server配置并启动监控服务

修改Zabbix_server配置文件设置数据库相关参数启动Zabbix_server服务

[root@zabbixserver ~]# vim /usr/local/etc/zabbix_server.conf

DBHost=localhost

# 85行定义哪台主机为数据库主机localhost为本机

DBName=zabbix

#95行设置数据库名称

DBUser=zabbix

#111行设置数据库账户

DBPassword=zabbix

#119行设置数据库密码

LogFile=/tmp/zabbix_server.log    

#38行日志的位置排错使用该行仅查看即可

AllowUnsupportedDBVersions=1

 

[root@zabbixserver ~]# useradd -s /sbin/nologin zabbix

#服务不允许以root身份启动不创建用户无法启动服务用户不需要登录系统

#创建zabbix用户才可以以zabbix用户的身份启动服务

#启动服务后可以通过ps aux查看进程是以什么用户的身份启动的

 

通过创建service文件管理zabbix服务。

[root@zabbixserver ~]# vim /usr/lib/systemd/system/zabbix_server.service

[Unit]

Description=zabbix server

After=network.target remote-fs.target nss-lookup.target

[Service]

Type=forking

PIDFile=/tmp/zabbix_server.pid

ExecStart=/usr/local/sbin/zabbix_server

ExecStop=/bin/kill $MAINPID

[Install]

WantedBy=multi-user.target

[root@zabbixserver ~]# systemctl  enable  zabbix_server  --now

[root@zabbixserver ~]# ss -ntulp |grep zabbix_server     #确认连接状态端口10051

tcp LISTEN 0128*:10051*:*users:(("zabbix_server",pid=23275,fd=4),("zabbix_server",pid=23274,fd=4)

4) 修改Zabbix_agent配置文件启动Zabbix_agent服务

[root@zabbixserver ~]# vim /usr/local/etc/zabbix_agentd.conf

Server=127.0.0.1,192.168.2.5            #93行允许哪些主机监控本机

ServerActive=127.0.0.1,192.168.2.5        #134行允许哪些主机通过主动模式监控本机

Hostname=zabbix_server                #145行设置本机主机名名称可以任意

LogFile=/tmp/zabbix_agentd.log            #设置日志文件不需要修改

UnsafeUserParameters=1                #280行是否允许自定义监控传参

编写zabbix_agentd的service文件通过systemd管理服务。

[root@zabbixserver ~]#  vim /usr/lib/systemd/system/zabbix_agentd.service

[Unit]

Description=zabbix agent

After=network.target remote-fs.target nss-lookup.target

[Service]

Type=forking

PIDFile=/tmp/zabbix_agentd.pid

ExecStart=/usr/local/sbin/zabbix_agentd

ExecStop=/bin/kill $MAINPID

[Install]

WantedBy=multi-user.target

[root@zabbixserver ~]# systemctl enable  zabbix_agentd   --now

[root@zabbixserver ~]# ss -ntulp |grep zabbix_agentd   #查看端口信息为10050

tcp    LISTEN     0128*:10050*:*users:(("zabbix_agentd",pid=23505,fd=4),("zabbix_agentd",pid=23504,fd=4)

5)上线Zabbix的Web页面

[root@zabbixserver ~]# cd zabbix-3.4.4/frontends/php/

[root@zabbixserver php]# cp -r */usr/local/nginx/html/

[root@zabbixserver php]# chown -R  apache.apache /usr/local/nginx/html/

#这里修改所有者使用:或者.都可以。

#修改权限的原因如下

#php-fpm的账户是apache后面我们需要让php-fpm对网站目录具有读写操作

#而/usr/local/nginx/html默认是root所有仅root具有写权限php-fpm无写权限

浏览器访问Zabbix_server服务器的Web页面

火狐浏览器访问【 firefox http://192.168.2.5/index.php

#第一次访问初始化PHP页面会检查计算机环境是否满足要求如果不满足会给出修改建议

#默认会提示PHP的配置不满足环境要求需要修改PHP配置文件

根据错误提示安装依赖、修改PHP配置文件满足Zabbix_server的环境要求。

[root@zabbixserver ~]# yum -y install  php-gd  php-xml

[root@zabbixserver ~]# yum -y install  php-bcmath  php-mbstring

[root@zabbixserver ~]# vim /etc/php.ini

date.timezone =Asia/Shanghai                #878行设置时区

max_execution_time =300                    #384行最大执行时间秒

post_max_size =32M                        #672行POST数据最大容量

max_input_time =300                        #394行服务器接收数据的时间限制

[root@zabbixserver ~]# systemctl restart php-fpm

3、部署被监控主机Zabbix Agent

1源码安装Zabbix agent软件

在2.100和2.200做相同操作以web1为例。

[root@web1 ~]# useradd -s /sbin/nologin  zabbix

[root@web1 ~]# yum -y install gcc pcre-devel autoconf

[root@web1 ~]# tar -xf zabbix-3.4.4.tar.gz

[root@web1 ~]# cd zabbix-3.4.4/

[root@web1 zabbix-3.4.4]# ./configure --enable-agent

[root@web1 zabbix-3.4.4]# make &&make install

2修改agent配置文件启动Agent

[root@web1 ~]# vim /usr/local/etc/zabbix_agentd.conf

Server=127.0.0.1,192.168.2.5                #93行谁可以监控本机被动监控模式

ServerActive=127.0.0.1,192.168.2.5            #134行谁可以监控本机主动监控模式

Hostname=web1                                    #145行被监控端自己的主机名

EnableRemoteCommands=1    

#69行监控异常后是否允许服务器远程过来执行命令如重启某个服务

UnsafeUserParameters=1                    #280行是否允许自定义key传参

[root@web1 ~]# firewall-cmd --set-default-zone=trusted

[root@web1 ~]# sed -'/SELINUX/s/enforcing/permissive/'/etc/selinux/config

[root@web1 ~]# setenforce 0

[root@web1 ~]# vim /usr/lib/systemd/system/zabbix_agentd.service

[Unit]

Description=zabbix agent

After=network.target remote-fs.target nss-lookup.target

[Service]

Type=forking

PIDFile=/tmp/zabbix_agentd.pid

ExecStart=/usr/local/sbin/zabbix_agentd

ExecStop=/bin/kill $MAINPID

[Install]

WantedBy=multi-user.target

[root@web1 ~]# systemctl enable  zabbix_agentd   --now

#启动服务器并设置开机自启动

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6

“部署zabbix” 的相关文章

好玩的docker项目,盒子刷的海思nas,挂载外接硬盘。qb种子

玩法思路(5条消息) 群晖qb下载,tr辅种_屿兮的博客-CSDN博客_群晖辅种 qbittorrent简介及设置_哔哩哔哩_bilibili qb下载器下载...

【Linux】vim最基本指令,如何做到复制粘贴之类的功能?

进行代码的编写在Linux当然可以用nano但是这个基本上学到后面都不会有人用vim之前称为vi是一个很好用但是不太适合初学者的软件你可以在自己的服务器上打出vim这个指令如果成功跳转一个界面就代表你的服务器已经内置vim如果没有就 yum install -y vim 安装一下就好...

怎么使用Vue.js全选指令实现多选框的全选操作 - web开发

这篇“怎么使用Vue.js全选指令实现多选框的全选操作”文章的知识点大部分人都不太理解,所以小编给大家总结了以下内容,内容详细,步骤清晰,具有一定的借鉴价值,希望大家阅读完这篇文章能有所收获,下面我们一起来看看这篇“怎么使用Vue.js全选指令实现多选框的全选操作”文...

Ubuntu

关闭 ubuntu System program problem detected每次开机都出现:System program problem detected很麻烦,关闭方法:vim /etc/default/apport# set this to 0 to disable apport, or...

直接保理与间接保理_保理与反向保理的区别

依债务人付款对象不同,保理分为直接保理与间接保理。  直接保理(direct factoring):指根据保理合同或转让通知,债务人直接向保理商支付已转让的应收账款的保理。  间接保理(indirect factoring):指债务人直接向原债权人...

pydev debugger: process 10341 is connecting无法debu如何解决 - 开发技术

这篇文章主要介绍了pydev debugger: process 10341 is connecting无法debu如何解决的相关知识,内容详细易懂,操作简单快捷,具有一定借鉴价值,相信大家阅读完这篇pydev&nbs...