Zabbix监控 文章目录 Zabbix监控一、zabbix6.0部署1、部署zabbix 6.0版本(nginx+php+zabbix)1、nginx配置2、php配置3、mariadb配置
zabbix 6.0后 版本后 对php版本至少7.2+
2G2核
zabbix-server服务端安装
# 1、nginx配置[root@Centos7 conf.d]# cat << EOF > /etc/yum.repos.d/nginx.repo[nginx-stable]name=nginx stable repobaseurl=Http://nginx.org/packages/centos/7/\$basearch/gpGCheck=1enabled=1gpgkey=https://nginx.org/keys/nginx_signing.keymodule_hotfixes=trueEOF[root@centos7 conf.d]# yum install -y nginx[root@centos7 conf.d]# vim /etc/nginx/conf.d/default.conf server { listen 80; server_name localhost; # 默认使用localhost(如果使用域名,修改在本地hosts解析) root /app/zbx; # 需要创建好该目录,否则报错Not Found location / { index index.php; } location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }}# 2、检查安装结果rpm -qa |egrep 'nginx'# 3、检查nginx配置[root@centos7 conf.d]# nginx -t
# 1、php配置[root@centos7 conf.d]# cat << EOF > /etc/yum.repos.d/php.repo[php-WEBtatic]name = PHP Repositorybaseurl = http://us-east.repo.webtatic.com/yum/el7/x86_64/gpgcheck = 0EOF[root@centos7 conf.d]# yum -y install php71w php71w-cli php71w-common php71w-devel php71w-embedded php71w-gd php71w-mcrypt php71w-mbstring php71w-pdo php71w-xml php71w-fpm php71w-Mysqlnd php71w-opcache php71w-pecl-memcached php71w-pecl-Redis php71w-pecl-mongoDB[root@centos7 ~]# sed -ri '/^(user|group)/s#apache#nginx#g' /etc/php-fpm.d/www.conf[root@centos7 ~]# vim /etc/php.inipost_max_size = 16Mmax_execution_time = 300max_input_time = 300date.timezone = Asia/Shanghai# 2、进行检查[root@centos7 ~]# egrep '^(user|group)' /etc/php-fpm.d/www.confuser = nginxgroup = nginx[root@centos7 ~]# rpm -qa |grep 'nginx|php'x# 3、创建目录测试文件[root@centos7 ~]# mkdir -p /app/zbx[root@centos7 ~]# vim /app/zbx/info.php <?phpphpinfo();?># 4、启动nginx+php[root@centos7 ~]# systemctl enable nginx php-fpm && systemctl start nginx php-fp# 5、验证结果
# 1、mariadb配置[root@centos7 ~]# vim /etc/yum.repos.d/mariadb.repo[mariadb]name = MariaDBbaseurl = https://mirrors.aliyun.com/mariadb/yum/10.5/centos7-amd64/gpgkey=https://mirrors.aliyun.com/mariadb/yum/RPM-GPG-KEY-MariaDBgpgcheck=1enabled=1[root@centos7 ~]# yum install -y mariadb-server# 2、进行检查[root@centos7 ~]# rpm -qa |grep -i mariadb# 3、启动服务[root@centos7 ~]# systemctl enable mariadb && systemctl start mariadb# 4、查看[root@centos7 ~]# netstat -lntp tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 1871/php- 854/rpcbind tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1874/nginx: master tcp6 0 0 :::3306 :::* LISTEN 2181/mariadbd # 5、基本配置数据库初始化 mysql_secure_installation 仅1次。 Enter current passWord for root (enter for none): 回车 Switch to unix_Socket authentication [Y/n] 输入n Change the root password? [Y/n] 输入Y 设置root密码 Remove anonymous users? [Y/n] 输入Y Disallow root login remotely? [Y/n] 输入Y Remove test database and access to it? [Y/n] 输入Y Reload privilege tables now? [Y/n] 输入Y Thanks for using MariaDB! 表示完成 [root@centos7 ~]# mysql -uroot -p1、创建数据库要指定字符集create database zabbix charset utf8 collate utf8_bin;2、创建zabbix用户grant all on zabbix.* to 'zabbix'@'localhost' identified by 'zabbix' ; #如果数据库与zbx,php不在一起#grant all on zabbix.* to 'zabbix'@'172.16.1.%' identified by 'zabbix' ;# 3、刷新配置flush privileges;
zabbix官网 www.zabbix.com
# 1、安装包下载[root@centos7 zabbix]# wget https://cdn.zabbix.com/zabbix/sources/stable/6.0/zabbix-6.0.0.tar.gz# 2、创建zabbix用户[root@centos7 zabbix]# useradd -M -s /sbin/nologin zabbix# 3、下载依赖包(有些依赖是通过现在下载的包的依赖关系同步下载下来的)[root@centos7 zabbix]# yum -y install libevent-devel net-snmp-devel libxml2-devel libcurl-devel gcc gcc-c++ make pcre pcre-devel openssl openssl-devel zlib zlib-devel# 4、编译安装[root@centos7 zabbix]# ./configure --prefix=/usr/local/zabbix --enable-server --enable-proxy --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2 按提示编译安装make install,或先make一下再make install都行,make install的过程中会自动make# mkdir /usr/local/zabbix/log # 可以随便指定目录# chown -R zabbix:zabbix /usr/local/zabbix/# 5、修改配置文件安装完成后,找到zabbix_server的配置文件,可查看./configure产生的配置列表或用find工具全局查找也行修改其中一下内容[root@centos7 zabbix]# vi /usr/local/zabbix/etc/zabbix_server.confLogFile=/usr/local/zabbix/log/zabbix_server.log #日志文件地址,目录没有需要创建并授权DBHost=localhost #数据库地址DBName=zabbix #数据库名DBUser=zabbix #数据库用户名DBPassword=123456 #数据库密码DBSocket=/var/lib/mysql/mysql.sock #数据库sock文件路径DBPort=3306 #数据库端口Timeout=30AlertScriptsPath=/usr/local/zabbix/alertscripts #告警脚本存放位置ExternalScripts=/usr/local/zabbix/externalscripts #告警脚本存放位置LogSlowQueries=3000Include=/usr/local/zabbix/etc/zabbix_server.conf.d[root@centos7 zabbix-server-mysql-6.*]# zcat create.sql.gz | mysql -uroot -p'123456' zabbix[root@centos7 ~]# ll-rw-r--r-- 1 root root 21471836 11月 19 00:03 zabbix-6.0.0.tar (提前下载好,下载方式见下文)drwxr-xr-x 13 1000 1000 4096 11月 2 16:54 zabbix-6.0.0# 7、文件授权[root@centos7 ~]# ll-rw-r--r-- 1 root root 21471836 11月 19 00:03 zabbix-5.0.29.tar (提前下载好,下载方式见下文)drwxr-xr-x 13 1000 1000 4096 11月 2 16:54 zabbix-5.0.29[root@centos7 ~]# cp -r zabbix-6.0.0/ui[root@centos7 zabbix-server-mysql-6.*]# zcat create.sql.gz | mysql -uroot -p'123456' zabbix[root@centos7 ~]# ll-rw-r--r-- 1 root root 21471836 11月 19 00:03 zabbix-6.0.0.tar (提前下载好,下载方式见下文)drwxr-xr-x 13 1000 1000 4096 11月 2 16:54 zabbix-6.0.0[root@centos7 ~]# cp -r zabbix-5.0.29/ui[root@centos7 zabbix-server-mysql-5.*]# zcat create.sql.gz | mysql -uroot -p'123456' zabbix# 9、修改zabbix配置文件1、修改zabbix.conf文件[root@centos7 ~]# egrep '^DB' /etc/zabbix/zabbix_server.confDBHost=localhostDBName=zabbixDBUser=zabbixDBPassword=1234562、zabbix.conf完整操作[root@centos7 ~]# egrep '^[a-Z]' /etc/zabbix/zabbix_server.confLogFile=/var/log/zabbix/zabbix_server.logLogFileSize=0PidFile=/var/run/zabbix/zabbix_server.pidSocketDir=/var/run/zabbixDBHost=localhostDBName=zabbixDBUser=zabbixDBPassword=123456SNMPTrapperFile=/var/log/snmptrap/snmptrap.logTimeout=4AlertScriptsPath=/usr/lib/zabbix/alertscriptsExternalScripts=/usr/lib/zabbix/externalscriptsLogSlowQueries=3000StatsAllowedIP=127.0.0.13、文件授权[root@centos7 ~]# ll-rw-r--r-- 1 root root 21471836 11月 19 00:03 zabbix-5.0.29.tar (提前下载好,下载方式见下文)drwxr-xr-x 13 1000 1000 4096 11月 2 16:54 zabbix-5.0.29[root@centos7 ~]# cp -r zabbix-5.0.29/uicreate.sql.gz | mysql -uzabbix -p zabbix# 3、Zabbix server配置数据库[root@centos7 ~]# grep '^DBPa' /etc/zabbix/zabbix_server.conf DBPassword=123456# 4、启动服务[root@centos7 conf]# systemctl restart zabbix-server zabbix-agent
来源地址:https://blog.csdn.net/mm970919/article/details/127932002
--结束END--
本文标题: 全网监控 nginx 部署 zabbix6.0
本文链接: https://lsjlt.com/news/416998.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0