麒麟系统V10 SP2 编译安装 Zabbix 6.0.8 + MySQL 8.0.30 + PHP 7.4.30
这篇文章虽然比较长,但是代码块比较完整,没有在其他系统上测试过。
编译并安装fping
fping官网http://www.fping.org/
wget http://www.fping.org/dist/fping-5.0.tar.gz
mkdir -p /usr/local/fping/
tar -zxvf fping-5.0.tar.gz -C /usr/local/fping/
cd /usr/local/fping/fping-5.0
./configure –prefix=/usr/local/fping –enable-ipv4 –enable-ipv6
进行安装
ln -s /usr/local/fping/sbin/fping /usr/sbin/fping
chmod u+s /usr/local/fping/sbin/fping
MySQL
下载MySQL 源码包解压
wget https://cdn.mysql.com/archives/mysql-8.0/mysql-8.0.30-linux-glibc2.17-x86_64-minimal.tar.xz
tar -Jxvf mysql-8.0.30-linux-glibc2.17-x86_64-minimal.tar.xz -C /usr/local/
mv /usr/local/mysql-8.0.30-linux-glibc2.17-x86_64-minimal /usr/local/mysql
创建MySQL用户和用户组
组添加mysql
useradd -M -g mysql -s /sbin/nologin mysql
创建MySQL目录并授权
#创建MySQL数据目录
mkdir -p /数据/mysql
#创建MySQL日志目录
mkdir -p /var/log/mysql
chown mysql:mysql -R /data/mysql
chown mysql:mysql -R /var/log/mysql
环境变量
vim /etc/配置文件
导出路径=/usr/local/mysql/bin:$PATH
源/etc/profile
创建my.cnf配置文件
vim /etc/my.cnf
[服务器]
[mysqld]
数据目录=/data/mysql
basedir=/usr/local/mysql 的
套接字=/data/mysql/mysql.sock
日志错误=/var/log/mysql/mysql.log
最大连接数=1000
连接超时=60
等待超时=600
交互超时=600
锁等待超时=3600
跳过名称解析=1
跳过外部锁=1
open_files_limit=65535
Explicit_default_for_timestamp=1
慢查询日志=1
throw_query_log_file=/var/log/mysql/slow.log
通用日志=1
通用日志文件=/var/log/mysql/sql_row.log
key_buffer_size=1M
读取缓冲区大小=4M
read_rnd_buffer_size=2M
表_open_cache=1024
表定义缓存=1024
表_open_cache_instances=64
线程缓存大小=512
排序缓冲区大小=16M
join_buffer_size=64M
Bulk_insert_buffer_size=64M
tmp_table_size=64M
最大堆表大小=776M
符号链接=0
最大允许数据包=512M
绑定地址=0.0.0.0
innodb_file_per_table=1
innodb_buffer_pool_size=1G
innodb_buffer_pool_instances=8
innodb_buffer_pool_load_at_startup=1
innodb_buffer_pool_dump_at_shutdown=1
innodb_log_file_size=1G
innodb_log_buffer_size=32M
innodb_log_files_in_group=2
innodb_flush_log_at_trx_commit=0
innodb_lock_wait_timeout=600
innodb_autoinc_lock_mode=2
innodb_doublewrite=关闭
innodb_thread_concurrency=16
innodb_flush_method=O_DIRECT
innodb_io_capacity=2000
innodb_io_capacity_max=4000
innodb_write_io_threads=32
innodb_read_io_threads=16
innodb_purge_threads=4
innodb_page_cleaners=4
innodb_open_files=65535
innodb_max_dirty_pages_pct=50
innodb_lru_scan_Depth=4000
innodb_status_file=1
innodb_change_buffer_max_size=50
innodb_open_files=10000
open_files_limit=10000
[客户]
套接字=/data/mysql/mysql.sock
初始化 数据库
mysqld –defaults-file=/etc/my.cnf –user=mysql –initialize
启动zabbix 服务
启动脚本
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/
初始化日志
触摸/var/log/mysql.log
chown mysql.mysql /var/log/mysql.log
启动服务
/etc/init.d/mysql.server启动
重置root密码
使用初始化密码登录MySQL后,只能更改密码。您无法使用以下命令更改密码:
#初始密码为
grep \’密码\’ /var/log/mysql/mysql.log
mysql-uroot-p
更改密码
修改由“q1w2E#R$”标识的用户“root”@“localhost”。
闪存权限。
创建zabbix数据库,创建用户并授权
#登录数据库
mysql -uroot -pq1w2E#R$
#创建zabbix数据库
创建mysql数据库zabbix字符集utf8mb4排序规则utf8mb4_bin;
#创建zabbix用户
mysql 创建了由“password”标识的用户“zabbix”@“%”。
#允许访问本地主机
mysql 将zabbix.* 上的所有权限授予\’zabbix\’@\’%\’。
#刷新策略
mysqlflush 权限。
更新用户账户密码的存储方式,默认使用caching_sha2_password
mysql ALTER USER \’root\’@\’localhost\’ 通过mysql_native_password BY \’password\’ 进行识别;
mysql ALTER USER \’zabbix\’@\’%\’ 通过mysql_native_password BY \’password\’ 进行识别;
mysql 退出
Zabbix 编译安装
创建zabbix用户组
groupadd –系统zabbix
useradd –system -g zabbix -d /usr/lib/zabbix -s /sbin/nologin -c \’Zabbix监控系统\’ zabbix
创建用户家目录
mkdir -m u=rwx,g=rwx,o=-p /usr/lib/zabbix
chown zabbix:zabbix /usr/lib/zabbix
安装依赖环境
yum install gcc libxml2 libxml2-devel net-snmp net-snmp-devel OpenIPMI OpenIPMI-devel libevent libevent-develcurlcurl-devel -y
安装UNIX ODBC
下载unixODBC 和unixODBC-devel 包。
yum install -y unixODBC unixODBC-devel
下载zabbix6.0.8源码包
wget https://cdn.zabbix.com/zabbix/sources/stable/6.0/zabbix-6.0.8.tar.gz
tar -zvxf zabbix-6.0.8.tar.gz -C /opt cd /opt/zabbix-6.0.8/
导入zabbix数据库
系统将要求您输入密码。上面设置的zabbix密码是“password”。
cd 数据库/mysql
mysql -uzabbix -p zabbix schema.sql
mysql -uzabbix -p zabbix image.sql
mysql -uzabbix -p zabbix data.sql
编译安装zabbix
cd /opt/zabbix-6.0.8/
./configure –prefix=/usr/local/zabbix –enable-server \\
–enable-agent –with-mysql –enable-ipv6 –with-net-snmp \\
–with-libcurl –with-libxml2 –with-openipmi –with-unixodbc
安装
创建链接文件
ln -s /usr/local/mysql/lib/libmysqlclient.so.21 /usr/lib64/
#设置环境变量
echo \’导出LD_LIBRARY_PATH=/usr/local/mysql/lib:$LD_LIBRARY_PATH\’ /etc/profile
源/etc/profile
#手动执行不需要执行(不需要执行)
/usr/local/zabbix/sbin/zabbix_server -c /usr/local/zabbix/etc/zabbix_server.conf
#停止批次
pkill -f zabbix_server
ZabbIx Server 配置文件
#您还需要修改配置文件以匹配下面显示的配置文件/usr/local/zabbix/etc/zabbix_server.conf
[root@kylin02 sbin]#
egrep -v \’*#|^$\’ /usr/local/zabbix/etc/zabbix_server.conf
LogFile=/usr/local/zabbix/zabbix_server.log
数据库主机=127.0.0.1
数据库名称=zabbix
数据库用户=zabbix
DB密码=密码
超时=4
日志慢查询=3000
允许的路线=1
用户=root
统计允许IP=127.0.0.1
配置系统服务
创建 zabbix-server.service 文件并写入内容
cat EOL /etc/systemd/system/zabbix-server.service
[单元]
描述=Zabbix 服务器
之后=网络.目标
[服务]
类型=叉子
环境=\’LD_LIBRARY_PATH=/usr/local/mysql/lib\’
ExecStart=/usr/local/zabbix/sbin/zabbix_server -c /usr/local/zabbix/etc/zabbix_server.conf
PIDFile=/usr/local/zabbix/var/run/zabbix_server.pid
超时开始秒=180
重新启动=失败时
[安装]
WantedBy=多用户.Target
停产
#更改配置文件
vim /usr/local/zabbix/etc/zabbix_server.conf
#更改以下参数设置
PidFile=/usr/local/zabbix/var/run/zabbix_server.pid
#创建目录并授予权限
mkdir -p /usr/local/zabbix/var/run
chown root:root /usr/local/zabbix/var/run
chmod 755 /usr/local/zabbix/var/run
重新加载 systemd 配置以应用新的服务文件
重新加载systemctl 守护进程
启动 Zabbix Server 服务
systemctl 启动zabbix-server
设置 Zabbix Server 服务在系统启动时自动启动
使用systemctl启用zabbix服务器
检查 Zabbix Server 服务状态
systemctl 状态zabbix-server
PHP 编译安装
安装PHP依赖环境
yum -y 安装libtool sqlite-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel readline readline-devel libxslt libxslt-devel
yum 安装openldap openldap-devel -y
拷贝和链接所需必要文件
cp -frp /usr/lib64/libldap* /usr/lib/
ln -s /usr/lib64/liblber.so /usr/lib/lib
安装oniguruma-6.9.4
wget https://github.com/kkos/oniguruma/archive/v6.9.4.tar.gz -O oniguruma-6.9.4.tar.gz
tar -xvf oniguruma-6.9.4.tar.gz
CD Oniguruma-6.9.4/
./autogen.sh ./configure –prefix=/usr –libdir=/lib64
进行安装
安装libmcrypt
wget https://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
tar xf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure –prefix=/usr/local/libmcrypt
进行安装
编译安装PHP
下载php7.4源文件
光盘/选择
wget –timeout=7200 https://www.php.net/distributions/php-7.4.30.tar.gz
tar -xvf php-7.4.30.tar.gz
cd /opt/php-7.4.30
#安装一些缺失的模块
百胜安装php-gd -y
yum install -y zlib-devel
编辑PHP的配置项(直接运行下面代码块)
LDFLAGS=\’-L/usr/lib64 -lz\’ LIBS=\’-llber\’ ./configure –prefix=/usr/local/php \\
–with-config-file-path=/usr/local/php/etc \\
–enable-fpm –with-fpm-user=nginx –with-fpm-group=nginx \\
–enable-inline-optimization –disable-debug –disable-rpath \\
–enable-shared –enable-soap –with-xmlrpc \\
–with-openssl –with-mhash –with-sqlite3 \\
–with-zlib –enable-bcmath –with-iconv –with-bz2 \\
–enable-calendar –with-curl –with-cdb –enable-dom \\
–enable-exif –enable-fileinfo –enable-filter \\
–enable-ftp –with-openssl-dir –with-zlib-dir \\
–enable-gd –with-jpeg –with-freetype –with-png \\
–enable-gd-jis-conv –with-gettext –with-gmp –with-mhash \\
–enable-json –enable-mbstring –enable-mbregex \\
–enable-pdo –with-mysqli=mysqlnd –with-pdo-mysql=mysqlnd \\
–with-zlib-dir –with-pdo-sqlite –with-readline –enable-session \\
–enable-shmop –enable-simplexml –enable-sockets –enable-sysvmsg \\
–enable-sysvsem –enable-sysvshm –with-xsl –with-ldap –with-ldap-sasl=/usr/lib64 \\
–enable-mysqlnd-compression-support –with-pear \\
–enable-opcache –disable-fileinfo
编译安装
使-j 3
安装
PHP环境变量
echo \’导出PATH=$PATH:/usr/local/php/bin\’ /etc/profile
源/etc/profile
#检查所需模块
php -m | grep -E \’zlib|gd|ldap\’
拷贝PHP配置文件
cp /opt/php-7.4.30/php.ini-生产/usr/local/php/etc/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
ln -s /usr/local/php/etc//etc/php
修改 /usr/local/php/etc/php-fpm.conf 运行用户和组改为nginx
添加nginx 组
useradd -g nginx nginx
chown nginx.nginx /usr/local/php/etc/php-fpm.conf
chown -R nginx.nginx /etc/php
查看PHP 安装模块
php-m
启动php-fpm
启动php-fpm
/usr/local/php/sbin/php-fpm
#相关命令
#显示进程
ps aux | php-fpm
#restartphp-fpm
杀死-USR2 303081
终止php-fpm
杀死-INT 303081
启动php-fpm
/usr/local/php/sbin/php-fpm
部署Nginx
安装Nginx所需依赖环境
百胜安装GC
c-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel -y
编译安装Nginx
下载Nginx 源码包
wget -c http://nginx.org/download/nginx-1.20.1.tar.gz
tar -zxvf nginx-1.20.1.tar.gz -C /opt
cd /opt/nginx-1.20.1/
编译配置
./configure \\
–with-file-aio –with-ipv6 –with-http_ssl_module \\
–with-http_v2_module –with-http_realip_module \\
–with-http_addition_module –with-http_sub_module \\
–with-http_dav_module –with-http_flv_module \\
–with-http_mp4_module –with-http_gunzip_module \\
–with-http_gzip_static_module –with-http_random_index_module \\
–with-http_secure_link_module –with-http_degradation_module \\
–with-http_slice_module –with-http_perl_module=dynamic \\
–with-http_auth_request_module –with-mail=dynamic \\
–with-mail_ssl_module –with-pcre –with-pcre-jit \\
–with-stream=dynamic –with-stream_ssl_module –with-debug
编译安装
make && make install
启动Nginx
进入安装目录,启动服务器
cd /usr/local/nginx
进入sbin
cd sbin
启动
./nginx -c /usr/local/nginx/conf/nginx.conf
#相关命令,如果方法不了zabbix,就重启nginx试试
查看进程
ps -ef | grep nginx
快速停止(快速关闭所有连接)
/usr/local/nginx/sbin/nginx -s stop
优雅停止(完成当前连接再停止)
/usr/local/nginx/sbin/nginx -s quit
启动
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
优雅重启(重新加载配置文件)
/usr/local/nginx/sbin/nginx -s reload
配置nginx开机启动
vim /usr/lib/systemd/system/nginx.service
[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx reload
ExecStop=/usr/local/nginx/sbin/nginx quit
PrivateTmp=true
[Install]
WantedBy=multi-user.target
创建软链接
ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx
Nginx 配置文件(删除原有的内容)
vim /usr/local/nginx/conf/nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm index.php;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \\.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_buffer_size 32k;
fastcgi_buffers 10240 32k;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
}
重新加载配置文件
/usr/local/nginx/sbin/nginx -s reload
拷贝Zabbix 前端UI文件
mkdir -p /usr/local/nginx/html/zabbix
chown nginx:nginx /usr/local/nginx/html/zabbix
cp -r /opt/zabbix-6.0.8/ui/* /usr/local/nginx/html/zabbix
Zabbix Web Install
访问 http://ip/zabbix/setup.php
http://192.142.8.93/zabbix/setup.php
报错处理
安装freetype
wget https://download.savannah.gnu.org/releases/freetype/freetype-2.9.tar.gz
tar -zxvf freetype-2.9.tar.gz
cd freetype-2.9
./configure –prefix=/user/local/freetype
make && make install
安装libjpeg
wget http://www.ijg.org/files/jpegsrc.v9d.tar.gz
tar -zxvf jpegsrc.v9d.tar.gz
cd jpeg-9d
./configure –prefix=/user/local/libjpeg –enable-shared
make && make install
安装gd扩展
cd /opt/php-7.4.30/ext/gd/
phpize
./configure –with-php-config=/usr/local/php/bin/php-config –with-jpeg=/user/local/libjpeg –with-freetype=/user/local/freetype
make && make install
php 参数调整(不需要删除原来的,直接添加)
vim /usr/local/php/etc/php.ini
max_execution_time = 300
max_input_time = 300
memory_limit = 128M
post_max_size = 16M
upload_max_filesize = 2M
date.timezone = Asia/Shanghai
重启php-fpm
终止php-fpm
ps aux | grep php-fpm
kill -INT 303081
启动php-fpm
/usr/local/php/sbin/php-fpm
至此:刷新,会发现问题已解决
下一步
下一步
下一步
下一步
根据提示操作:下载上传配置到目录:/usr/local/nginx/html/zabbix/conf
完成:
agent不用编译安装
上传安装包zabbix-agent-6.0.22-release1.el8.x86_64.rpm
wget https://repo.zabbix.com/zabbix/6.0/rhel/8/x86_64/zabbix-agent-6.0.22-release1.el8.x86_64.rpm
rpm -ivh zabbix-agent-6.0.22-release1.el8.x86_64.rpm
编辑,把这三个参数改一下
“`bash
vi /etc/zabbix/zabbix_agentd.conf
Server=127.0.0.1
#ServerActive=127.0.0.1 注释掉
Hostname=192.168.9.181
重启agent
systemctl restart zabbix-agent
** Zabbix 6.0 UI 中文乱码处理**
在Windows 系统中找到 C:\\Windows\\Fonts 中的楷体(常规)字体, 上传到/usr/local/nginx/html/zabbix/assets/fonts 目录下
cp DejaVuSans.ttf DejaVuSans.ttf.bak
mv simkai.ttf DejaVuSans.ttf
chmod 755 DejaVuSans.ttf
参考链接
https://cloud.tencent.com/developer/article/2168923
#以上关于zabbix安装步骤的相关内容来源网络仅供参考,相关信息请以官方公告为准!
原创文章,作者:CSDN,如若转载,请注明出处:https://www.sudun.com/ask/93995.html