当前位置: 首页 > article >正文

LNMP+Zabbix安装部署(Zabbix6.0 Lnmp+Zabbix Installation and Deployment)

LNMP+Zabbix安装部署(Zabbix6.0)

简介

LNMP(Linux + Nginx + MySQL + PHP)是一种流行的Web服务器架构,广泛用于搭建高性能的网站和应用程序。Zabbix 是一个开源的监控软件,可以用来监控网络、服务器和应用程序的性能和健康状态。将 Zabbix 集成到 LNMP 架构中可以提供全面的监控解决方案。下面将介绍如何在一个 LNMP 环境中安装和部署 Zabbix。

安装环境:

系统:centos7.0

nginx版本:1.20

php版本:php7.2.34

mysql版本:mysql8.0.30

zabbix版本:zabbix6.0.1

1、zabbix server端安装    

1.1、关闭系统防火墙    

systemctl stop firewalld.service

systemctl disable firewalld.service

firewall-cmd --state

sed -i '/^SELINUX=.*/c SELINUX=disabled' /etc/selinux/config

sed -i 's/^SELINUXTYPE=.*/SELINUXTYPE=disabled/g' /etc/selinux/config

grep --color=auto '^SELINUX' /etc/selinux/config

setenforce 0

1.2、mysql部署    

wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.30-1.el7.x86_64.rpm-bundle.tar    

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

rpm -ivh mysql-community-* --force --nodeps

mkdir -p /data/mysql

chown mysql:mysql /data/mysql

           vim /etc/my.cnf

[mysqld]

datadir=/data/mysql

socket=/var/lib/mysql/mysql.sock    

log-error=/var/log/mysqld.log

pid-file=/var/run/mysqld/mysqld.pid

character-set-server=utf8mb4

collation-server=utf8mb4_general_ci

port=3306

lower_case_table_names=1

max_connections=4096

           启动数据库:

yum -y install libaio

systemctl enable mysqld    

systemctl start mysqld

           获取密码登录mysql:

cat /var/log/mysqld.log | grep password

mysql -uroot -pkegsOfDBY9?K

set global validate_password.policy=0;

set global validate_password.length=6;

set global validate_password.mixed_case_count=0;

alter user 'root'@'localhost' identified by 'abc123';

create database zabbix character set utf8 collate utf8_bin;

create user 'zabbix'@'localhost' identified with mysql_native_password by 'abc123';

grant all privileges on zabbix.* to 'zabbix'@'localhost';

flush privileges;

1.3、nginx部署    

rpm -Uvh http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-1.20.0-1.el7.ngx.x86_64.rpm

mkdir /data/nginx

mv /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.bak

      vim /etc/nginx/nginx.conf

user  nginx;

worker_processes  auto;

error_log  /var/log/nginx/error.log notice;

pid        /var/run/nginx.pid;

               events {

    worker_connections  1024;

}

           http {

    include       /etc/nginx/mime.types;

    default_type  application/octet-stream;

           

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '

                      '$status $body_bytes_sent "$http_referer" '

                      '"$http_user_agent" "$http_x_forwarded_for"';

               access_log  /var/log/nginx/access.log  main;

    sendfile        on;

    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    server {

      listen       80;

      server_name  localhost;

      root         /data/nginx;

      location / {

        index  index.php index.html index.htm;

      }

      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;

      }

    }

}

           systemctl enable nginx

systemctl start nginx

systemctl status nginx

netstat -ntlp |grep 80

1.4、PHP部署    

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo    

yum -y install epel-release

wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

yum -y install gcc gcc-c++ php72w-cli php72w-fpm php72w-gd php72w-mbstring php72w-bcmath php72w-xml php72w-ldap php72w-mysqlnd

sed -i "s/max_execution_time = 30/max_execution_time = 300/g" /etc/php.ini

sed -i "s/max_input_time = 60/max_input_time = 300/g" /etc/php.ini

sed -i "s/post_max_size = 8M/post_max_size = 16M/g" /etc/php.ini

cd /data/nginx/

vim index.php

<?phpphpinfo();?>

systemctl enable php-fpm

systemctl start php-fpm

netstat -ntlp |grep 9000

           使用浏览器验证一下Nginx和PHP:

1.5、zabbix-server部署    

groupadd zabbix

useradd -g zabbix -M -s /sbin/nologin zabbix

wget https://cdn.zabbix.com/zabbix/sources/stable/6.0/zabbix-6.0.1.tar.gz    

tar -xf zabbix-6.0.1.tar.gz

cd zabbix-6.0.1/

yum -y install  mysql-devel pcre-devel openssl-devel zlib-devel libxml2-devel net-snmp-devel net-snmp libssh2-devel OpenIPMI-devel libevent-devel openldap-devel libcurl-devel

./configure --sysconfdir=/etc/zabbix --enable-server --with-mysql --with-net-snmp --with-libxml2 --with-ssh2 --with-openipmi --with-zlib --with-libpthread --with-libevent --with-openssl --with-ldap --with-libcurl --with-libpcre

make install

vim /etc/zabbix/zabbix_server.conf

ListenPort=10051

LogFile=/tmp/zabbix_server.log

DBHost=localhost

DBName=zabbix

DBUser=zabbix

DBPassword=abc123

Timeout=4

LogSlowQueries=3000

StatsAllowedIP=127.0.0.1

#向数据库中导入zabbix的库表及数据(注意导入的顺序)

mysql -uzabbix -pabc123 zabbix < /root/zabbix-6.0.1/database/mysql/schema.sql

mysql -uzabbix -pabc123 zabbix < /root/zabbix-6.0.1/database/mysql/images.sql

mysql -uzabbix -pabc123 zabbix < /root/zabbix-6.0.1/database/mysql/data.sql

           #移动zabbix前端页面到网站根目录

cp -rf /root/zabbix-6.0.1/ui/* /data/nginx/

vim /usr/lib/systemd/system/zabbix-server.service

[Unit]

Description=Zabbix Server with MySQL DB

After=syslog.target network.target mysqld.service    

[Service]

Type=simple

ExecStart=/usr/local/sbin/zabbix_server -f

User=zabbix

[Install]

WantedBy=multi-user.target

           #重新加载system文件

systemctl daemon-reload

systemctl enable zabbix-server

systemctl start zabbix-server

1.6、Web端初始化    

1)、输入IP直接跳转至zabbix网页端

2)、这里已经调整过PHP的配置文件,如果还有问题的可以编辑/etc/php.ini ,调整对应字段的值即可    

3)、配置DB连接

4)、这里自定义Zabbix主机名称即可    

5)、安装

cp /data/nginx/conf/zabbix.conf.php.example /data/nginx/conf/zabbix.conf.php

chown zabbix:zabbix /data/nginx/conf/zabbix.conf.php    

vim /data/nginx/conf/zabbix.conf.php

#只修改PASSWORD的密码

$DB['PASSWORD']                 = 'abc123';

默认账号密码:Admin zabbix

1.7、解决zabbix 6.0 中文乱码问题    

将window的C:\Windows\Fonts路径下将楷体的ttf文件复制到linux的 /data/web/assets/fonts 目录下

#替换配置文件中的默认字体

sed -i 's/DejaVuSans/simkai/g' /data/nginx/include/defines.inc.php

zabbix不支持主机名中存在中文字符的,要让zabbix主机名支持中文,需要修改zabbix的php配置文件

vim /data/nginx/include/defines.inc.php

#将下面的字段(大概在1198 行)

define('ZBX_PREG_INTERNAL_NAMES', '([0-9a-zA-Z_\. \-]+)');

改成

define('ZBX_PREG_INTERNAL_NAMES', '([0-9a-zA-Z_\. \-\x{80}-\x{ff}]+)');

重启zabbix-server:

systemctl restart zabbix-server

2、zabbix agent端安装    

rpm -ivh https://mirrors.aliyun.com/zabbix/zabbix/6.0/rhel/7/x86_64/zabbix-agent-6.0.1-1.el7.x86_64.rpm?spm=a2c6h.25603864.0.0.4a7e7a10tEvrPp --nodeps

rpm -ivh http://mirror.centos.org/centos/7/os/x86_64/Packages/pcre2-10.23-2.el7.x86_64.rpm

vim /etc/zabbix/zabbix_agentd.conf

PidFile=/var/run/zabbix/zabbix_agentd.pid    

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

LogFileSize=0

Server=192.168.52.20

ServerActive=127.0.0.1

Hostname=Zabbix server

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

启动Zabbix-agent服务:

systemctl start zabbix-agent

systemctl status zabbix-agent       


http://www.kler.cn/a/552036.html

相关文章:

  • 六、k8s:pv和pvc
  • Python 基础-使用dict和set
  • 胶囊网络动态路由算法:突破CNN空间局限性的数学原理与工程实践
  • Unity合批处理优化内存序列帧播放动画
  • spring的核心配置
  • 图数据库Neo4j面试内容整理-Neo4j的性能
  • HashSet 的底层原理(简单易懂)
  • deepseek蓝耘云端智能助手:让AI成为你专属的智慧助理
  • Git 使用指南:避免使用 merge 的完整流程
  • Jenkins 给任务分配 节点(Node)、设置工作空间目录
  • 大数据组件(四)快速入门实时数据湖存储系统Apache Paimon(1)
  • 华为交换机堆叠技术简介配置
  • 生成艺术与审美图灵测试:当算法成为艺术创作者
  • 路由基础 | 路由引入实验 | 不同路由引入方式存在的问题
  • 探秘Transformer系列之(3)---数据处理
  • 力扣-二叉树-98 验证二叉搜索树
  • 【Linux】在 ubuntu 18.04 arm 容器中安装ROS环境
  • 反向代理模块kd
  • 基于ARM的人脸识别系统的研究
  • Next.js【详解】获取数据(访问接口)