参考博文:https://blog.csdn.net/qq_44895681/article/details/106209354
我是以多实例安装mysql5.7 的,安装方法请看我的博客;这里使用3307端口mysql,sock地址:/opt/data/3307/mysql.sock
安装完成后再进行以下操作:
1、安装zabbix源
rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm yum clean all
2、安装server与agent
安装失败多是网络不佳,多执行几次就好了。。。
yum install zabbix-server-mysql zabbix-agent -y
注意:
如果安装中报错:Delta RPMs disabled because /usr/bin/applydeltarpm not installed,则安装 deltarpm软件。
yum -y install deltarpm
3、安装Zabbix frontend
yum install centos-release-scl -y vim /etc/yum.repos.d/zabbix.repo [zabbix-frontend] ... enabled=1 ...
4、安装Zabbix前端包
yum install zabbix-web-mysql-scl zabbix-nginx-conf-scl -y
5、创建和初始化zabbix数据库
# mysql -uroot -pv,qZo#%?q0z* -S /opt/data/3307/mysql.sock
create database zabbix character set utf8 collate utf8_bin; create user zabbix@localhost identified by 'v,qZo#%?q0z*'; grant all privileges on zabbix.* to zabbix@localhost; quit;
6、导入zabbix数据
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -pv,qZo#%?q0z* zabbix -S /opt/data/3307/mysql.sock
7、配置zabbix文件
一共四个文件
/etc/zabbix/zabbix_server.conf DBPassword=v,qZo#%?q0z* /etc/opt/rh/rh-nginx116/nginx/conf.d/zabbix.conf # listen 80; # server_name example.com; 取消以上两行的注释 /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf listen.acl_users = apache,nginx 新增nginx ; php_value[date.timezone] = Europe/Riga 取消注释,并修改成Asia/Shanghai
这个文件内只保留一下内容,可以之间覆盖掉原有的 [root@db1 ~]# egrep -v '^$|#' /etc/opt/rh/rh-nginx116/nginx/nginx.conf user nginx; worker_processes auto; error_log /var/opt/rh/rh-nginx116/log/nginx/error.log; pid /var/opt/rh/rh-nginx116/run/nginx/nginx.pid; include /opt/rh/rh-nginx116/root/usr/share/nginx/modules/*.conf; events { worker_connections 1024; } http { 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/opt/rh/rh-nginx116/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/opt/rh/rh-nginx116/nginx/mime.types; default_type application/octet-stream; include /etc/opt/rh/rh-nginx116/nginx/conf.d/*.conf; }
8、修改php.ini
根据自己实际情况修改,默认是不要修改的。。。
安装zabbix之后注册输入mysql数值后报错:Error connecting to database: No such file or directory
把mysql.sock 通过软链接到一个指定位置。
mkdir /var/lib/mysql ln -s /opt/data/3307/mysql.sock /var/lib/mysql/mysql.sock 修改php.ini文件 [root@db1 ~]# vim /etc/opt/rh/rh-php72/php.ini 1119行 mysqli.default_socket = /var/lib/mysql/mysql.sock
9、启动zabbix及其组件服务
systemctl restart zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm systemctl enable zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm
10、web打开
在浏览器内输入IP地址,输入必要的信息
zabbix默认账号:Admin 密码:zabbix
11、图形显示框框问题
解决方法: 将本地电脑C:\windows\fonts\simkai.ttf拷贝到centos7下的/usr/share/zabbix/assets/fonts chmod 777 simkai.ttf vim /usr/share/zabbix/include/defines.inc.php define('ZBX_GRAPH_FONT_NAME', 'graphfont'); 修改为: define('ZBX_GRAPH_FONT_NAME', 'simkai');
12、被监控端安装agent
wget https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-agent2-5.0.4-1.el7.x86_64.rpm rpm -ivh zabbix-agent2-5.0.4-1.el7.x86_64.rpm
注意:(未实际测试)
如果下载的zabbix-agent 5.0安装包使用rpm
安装时提示“错误:依赖检测失败:libpcre.so.0()(64bit)
”,则可以使用zabbix 5.0 Yum源来安装zabbix-agent 5.0软件。
rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm yum clean all 使用Zabbix 5.0 Yum源文件安装zabbix-agent 5.0软件,并且将gpgcheck=1修改为gpgcheck=0,防止出现“获取GPG密钥失败”报错。 修改Zabbix 5.0 Yum源配置文件: [root@localhost ~]# sed -i "s/gpgcheck=1/gpgcheck=0/g" /etc/yum.repos.d/zabbix.repo [root@localhost ~]# cat /etc/yum.repos.d/zabbix.repo [zabbix] name=Zabbix Official Repository - $basearch baseurl=http://repo.zabbix.com/zabbix/5.0/rhel/7/$basearch/ enabled=1 gpgcheck=0 //修改gpgcheck=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591 [zabbix-frontend] name=Zabbix Official Repository frontend - $basearch baseurl=http://repo.zabbix.com/zabbix/5.0/rhel/7/$basearch/frontend enabled=1 gpgcheck=0 //修改gpgcheck=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591 [zabbix-debuginfo] name=Zabbix Official Repository debuginfo - $basearch baseurl=http://repo.zabbix.com/zabbix/5.0/rhel/7/$basearch/debuginfo/ enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591 gpgcheck=0 //修改gpgcheck=0 [zabbix-non-supported] name=Zabbix Official Repository non-supported - $basearch baseurl=http://repo.zabbix.com/non-supported/rhel/7/$basearch/ enabled=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX gpgcheck=0 //修改gpgcheck=0 [root@localhost ~]# yum -y install zabbix-agent //安装zabbix-agent 5.0软件 ... 已安装: zabbix-agent.x86_64 0:5.0.0-1.el7 完毕!
13、编辑agent配置文件(未实践)
[root@localhost ~]# vim /etc/zabbix/zabbix_agentd.conf 119 Server=127.0.0.1,192.168.2.128 //Zabbix-server地址,多个用","隔开 160 ServerActive=192.168.2.128 //主动检查本主机数据发送给Zabbix-server 171 #Hostname=Zabbix server 172 Hostname=192.168.2.129 //客户端IP地址 [root@localhost ~]# systemctl start zabbix-agent [root@localhost ~]# systemctl enable zabbix-agent [root@localhost ~]# ss -antulp | grep :10050 tcp LISTEN 0 128 *:10050 *:* users:(("zabbix_agentd",pid=3389,fd=4),("zabbix_agentd",pid=3388,fd=4),("zabbix_agentd",pid=3387,fd=4),("zabbix_agentd",pid=3386,fd=4),("zabbix_agentd",pid=3385,fd=4),("zabbix_agentd",pid=3384,fd=4)) tcp LISTEN 0 128 :::10050 :::* users:(("zabbix_agentd",pid=3389,fd=5),("zabbix_agentd",pid=3388,fd=5),("zabbix_agentd",pid=3387,fd=5),("zabbix_agentd",pid=3386,fd=5),("zabbix_agentd",pid=3385,fd=5),("zabbix_agentd",pid=3384,fd=5))