6.2.4版本安装
建议打包成docker容器
docker run -d -p 18082:80 -p 3309:3306 --name zabbix18082 --privileged=true -v /data/docker_var/zabbix18082soft:/zabbix18082soft eeb6ee3f44bd /usr/sbin/init
zabbix编译插件安装
yum -y install openssl-devel gcc libevent-devel libcurl-devel libxml2-devel net-snmp-devel OpenIPMI OpenIPMI-devel
查询系统默认已安装数据组件
rpm -qa |grep mysql
rpm -qa |grep mariadb
卸载
rpm -e xxx --nodeps
下载yum依赖
yum install -y libaio
yum -y install numactl
yum -y install net-tools
下载安装包
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-community-client-plugins-8.0.30-1.el7.x86_64.rpm
安装
rpm -ivh mysql-community-client-plugins-8.0.30-1.el7.x86_64.rpm
rpm -ivh mysql-community-common-8.0.30-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.30-1.el7.x86_64.rpm
rpm -ivh mysql-community-devel-8.0.30-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.30-1.el7.x86_64.rpm
rpm -ivh mysql-community-icu-data-files-8.0.30-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-compat-8.0.30-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.30-1.el7.x86_64.rpm
vi /etc/my.cnf配置文件
[client]
port=3306
socket=/tmp/mysql/mysql.sock
[mysqld]
port=3306
user=mysql
socket=/tmp/mysql/mysql.sock
basedir=/data/mysql
datadir=/data/mysql/data
log-error=error.log
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
max_connections = 4096
transaction_isolation = READ-COMMITTED
character-set-server = utf8mb4
#collation-server = utf8mb4_general_ci
collation-server = utf8mb4_bin
lower_case_table_names = 1
#生产环境注释
skip-grant-tables
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
[mysqld_safe]
log-error=/tmp/mysql/log/mysqld.log
pid-file=/tmp/mysql/run/mysqld/mysqld.pid
#log-error=/var/log/mysqld.log
#pid-file=/var/run/mysqld/mysqld.pid
#my.ini配置文件中更改允许的最大错误连接数
max_connect_errors = 8000
初始化mysql配置
groupadd mysql
useradd -g mysql mysql -s /sbin/nologin -M
mkdir -p /tmp/mysql/log
touch /tmp/mysql/log/mysqld.log
chown -R mysql:mysql /tmp/mysql
chown -R mysql:mysql /data/mysql
chmod -R 755 /tmp/mysql /data/mysql
systemctl start mysqld
修改mysql初始密码
ln -s /data/mysql/bin/mysql /usr/bin
mysql -u root -p
use mysql;
update user set authentication_string='' where user='root';
flush privileges;
vi /etc/my.cnf
注释 skip-grant-tables
systemctl restart mysqld 重启mysql
mysql -u root -p (空密码登陆)
alter user 'root'@'localhost' identified by '123456';
use mysql;
update user set host='%' where user='root';
flush privileges;
如果zabbix存储的mysql使用其他服务器的,需要下载mysql客户端
yum -y install mysql-devel
yum -y install mysql
选择源码安装
添加用户
groupadd --system zabbix
useradd --system -g zabbix -d /usr/lib/zabbix -s /sbin/nologin -c "Zabbix Monitoring System" zabbix
sql脚本创建
创建zabbix库
shell> mysql -uroot -p<password>
mysql> create database zabbix character set utf8mb4 collate utf8mb4_bin;
mysql> create user 'zabbix'@'%' identified by '<password>';
mysql> grant all privileges on zabbix.* to 'zabbix'@'%';
mysql> SET GLOBAL log_bin_trust_function_creators = 1;
mysql> quit;
导入库
shell> cd database/mysql
shell> mysql -uzabbix -p<password> zabbix < schema.sql
# stop here if you are creating database for Zabbix proxy
shell> mysql -uzabbix -p<password> zabbix < images.sql
shell> mysql -uzabbix -p<password> zabbix < data.sql
关闭log_bin_trust_function_creators
shell> mysql -uroot -p<password>
mysql> SET GLOBAL log_bin_trust_function_creators = 0;
mysql> quit;
编译安装
yum install gcc
./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 --with-openipmi --disable-dependency-tracking
make install
如果使用外部mysql
./configure --enable-server --enable-agent --with-mysql=/usr/bin/mysql_config --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 --with-openipmi --disable-dependency-tracking
修改配置文件,位置/usr/local/etc/zabbix_server.conf
vim zabbix_server.conf
DBHost=127.0.0.1
DBName=zabbix
DBUser=zabbix
DBPassword=123456
DBPort=3306
agent配置文件位置
/usr/local/etc/zabbix_agentd.conf
配置服务管理脚本
cp /data/zabbix-6.2.4/misc/init.d/fedora/core5/zabbix_server /etc/init.d/
cp /data/zabbix-6.2.4/misc/init.d/fedora/core5/zabbix_agentd /etc/init.d/
修改脚本中的路径
vim /etc/init.d/zabbix_server
vim /etc/init.d/zabbix_agentd
启动服务
service zabbix_server start
service zabbix_agentd start
安装Zabbix Web组件
安装php74
php仓库下载配置
https://computingforgeeks.com/how-to-install-php-7-4-on-centos-7/
参考文章
yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum -y install yum-utils
yum-config-manager --enable remi-php74
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum install httpd php74-php php74-php-cli php74-php-common php74-php-gd php74-php-ldap php74-php-mbstring php74-php-mysqlnd php74-php-xml php74-php-bcmath mod_php74-php -y
将 Zabbix 源码包中的 PHP 文件复制到 httpd 的根目录下
cp -r /root/zabbix-6.2.0/ui /var/www/html
chown -R apache.apache /var/www
配置允许php连接
vi /etc/httpd/conf/httpd.conf
开启rewrite功能
LoadModule rewrite_module modules/mod_rewrite.so
修改 php 的配置文件
vim /etc/opt/remi/php74/php.ini
max_execution_time = 300
max_input_time = 300
memory_limit = 128M
post_max_size = 500M
upload_max_filesize = 500M
date.timezone = Asia/Shanghai
修改
/var/www/html/zabbix/conf/zabbix.conf.php文件
配置数据库账号密码
启动httpd服务
/usr/sbin/apachectl start
http://IP/zabbix
进入Zabbix的登录界面,默认的用户名为Admin,密码为zabbix,管理员权限。
zabbix启动失败
查看/tmp/zabbix_server.log文件日志
切换mysql配置
如果数据库要使用外部的,zabbix_server.conf文件配置改为外部数据库的
监控mysql数据库
确保zabbix所在的数据库能执行mysql和mysqladmin命令
创建.my.cnf文件在/var/lib/zabbix目录下,该目录没有的话就创建一个
修改/usr/local/zabbix/etc/zabbix_agentd.conf文件,使agent能找到template_db_mysql.conf配置文件
修改
Include=/data/zabbix-6.2.4/conf/zabbix_agentd/template_db_mysql.conf
添加template_db_mysql.conf文件
复制userparameter_mysql.conf为template_db_mysql.conf文件,不知道位置的话搜索一下该文件,一般在conf/zabbix_agentd目录下
如果.my.cnf没有生效则要自动手动修改命令,因为文件自带的没有用户名和密码,会导致ping失败
创建.my.cnf在/var/lib/zabbix目录下
[client]
user='zbx_monitor'
password='<password>'
生效.my.cnf
在mysqladmin之前添加HOME
创建数据库监控用户在被监控的数据库上
CREATE USER 'zbx_monitor'@'%' IDENTIFIED BY '<password>';
GRANT REPLICATION CLIENT,PROCESS,SHOW DATABASES,SHOW VIEW ON *.* TO 'zbx_monitor'@'%';
重启agent
创建host,如果已有host可以不用创建
模板选择mysql by zabbix agent
如果想自己配置连接的用户名和密码,点击mysql by zabbix agent,添加macros的用户名和密码
修改key,返回正常则表示打通了
监听elastic集群
模板搜索elastic
复制模板,方便适用于不同的环境
host添加该模板
修改模板macros
修改url值,因为ELASTICSEARCH.HOST是自己添加的值,所以需要修改一下配置
状态都显示为enabled时,代表成功了
监控seata
开启metrics
#Metrics configuration, only for the server
metrics.enabled=true
metrics.registryType=compact
metrics.exporterList=prometheus
metrics.exporterPrometheusPort=9898
然后访问ip:9898/metrics即可看到返回了
再通过http检测这个url就能监控到了