zabbix-4.4

安装部署


#配置zabbix官方仓库
[root@zabbix ~]# rpm -Uvh https://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm

#把官方源改为阿里云镜像源。 
#由于官方源是国外的镜像仓库,速度非常慢,改用阿里云的镜像仓库会非常快。只需在官方源的repo文件中修改URL即可。
[root@zabbix ~]# sed -i 's@http://repo.zabbix.com@https://mirrors.aliyun.com/zabbix@g' /etc/yum.repos.d/zabbix.repo

#安装
[root@zabbix ~]# yum install -y zabbix-server-mysql zabbix-web-mysql zabbix-agent zabbix-nginx-conf

#安装配置数据库。 数据库使用mysql和mariadb都可以,这里以二进制安装mysql-5.6.42为例
[root@zabbix ~]# wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.6.42-linux-glibc2.12-x86_64.tar.gz
[root@zabbix ~]# tar xf mysql-5.6.42-linux-glibc2.12-x86_64.tar.gz 
[root@zabbix ~]# mkdir /service
[root@zabbix ~]# mv mysql-5.6.42-linux-glibc2.12-x86_64 /service/mysql-5.6.42
[root@zabbix ~]# ln -s /service/mysql-5.6.42 /service/mysql
[root@zabbix ~]# useradd mysql -s /sbin/nologin -M
[root@zabbix ~]# cd /service/mysql/support-files/
[root@zabbix /service/mysql/support-files]# cp my-default.cnf /etc/my.cnf
cp: overwrite ‘/etc/my.cnf’? y
[root@zabbix /service/mysql/support-files]# cp mysql.server /etc/init.d/mysqld

[root@zabbix /service/mysql/support-files]# cd ../scripts/
[root@zabbix /service/mysql/scripts]# ./mysql_install_db --user=mysql --basedir=/service/mysql --datadir=/service/mysql/data

[root@zabbix ~]# cat /usr/lib/systemd/system/mysqld.service
[Unit]
Description=MySQL Server
Documentation=man:mysqld(8)
Documentation=https://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
[Service]
User=mysql
Group=mysql
ExecStart=/service/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf
LimitNOFILE = 5000

[root@zabbix ~]# systemctl daemon-reload

[root@zabbix ~]# vim /etc/init.d/mysqld
basedir=/service/mysql
datadir=/service/mysql/data
[root@zabbix ~]# systemctl start mysqld

[root@zabbix ~]# vim /etc/profile.d/mysql.sh 
export PATH=/service/mysql/bin:$PATH
[root@zabbix ~]# source /etc/profile

#创建密码
[root@zabbix ~]# mysqladmin -uroot password

#创建zabbix库
mysql> create database zabbix character set utf8 collate utf8_bin;

#导入SQL文件
[root@zabbix ~]# zcat /usr/share/doc/zabbix-server-mysql-4.4.10/create.sql.gz | mysql -uroot -p123 zabbix

#检查导入结果
mysql> show databases;
mysql> use zabbix;
mysql> show tables;

#创建用户
mysql> grant all on zabbix.* to zabbix@'localhost' identified by 'zabbix';

#编辑zabbix_server配置
[root@zzc ~]# vim /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix

#修改时区
[root@zabbix ~]# vim /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/Shanghai

#启动
[root@zabbix ~]# systemctl start zabbix-server httpd

#报错:
启动zabbix-server,使用netstat -lntp没有zabbix-server:10051端口,
systemctl status zabbix-server状态正常,
tail -f /var/log/zabbix/zabbix_server.log查看日志报错
  9665:20210424:104103.455 database is down: reconnecting in 10 seconds
  9665:20210424:104113.457 [Z3001] connection to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

#解决:
find查找mysql.sock文件位置,做软链接
[root@zabbix ~]# ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock


#监控页,字体乱码
在windows系统中,找到字体存放目录C:\Windows\Fonts,找一个自己喜欢的字体,我选择的是楷体
[root@zabbix ~]# cd /usr/share/zabbix
[root@zabbix /usr/share/zabbix]# ls
#查看有没有fonts目录,没有则创建
[root@zabbix /usr/share/zabbix]# mkdir fonts
#上传字体
[root@zabbix /usr/share/zabbix/fonts]# ls 
SIMKAI.TTF

#切换目录
[root@zabbix /usr/share/zabbix/fonts]# cd /etc/alternatives/
[root@zabbix /etc/alternatives]# ll
lrwxrwxrwx  1 root root 38 Apr 24 09:52 zabbix-web-font -> /usr/share/fonts/dejavu/DejaVuSans.ttf

#删除原有的,做软链接
[root@zabbix /etc/alternatives]# rm -rf zabbix-web-font
[root@zabbix /etc/alternatives]# ln -s /usr/share/zabbix/fonts/SIMKAI.TTF /etc/alternatives/zabbix-web-font

[root@zabbix /etc/alternatives]# systemctl restart zabbix-server

使用zabbix监控一台主机

主机IP服务
zabbix10.0.0.71zabbix-server
db0110.0.0.51zabbix-agent


#配置源并安装
[root@db01 ~]# rpm -Uvh https://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm
[root@db01 ~]# sed -i 's@http://repo.zabbix.com@https://mirrors.aliyun.com/zabbix@g' /etc/yum.repos.d/zabbix.repo
[root@db01 ~]# yum install -y zabbix-agent



[root@db01 ~]# vim /etc/zabbix/zabbix_agentd.conf
Server=127.0.0.1,10.0.0.71
ServerActive=127.0.0.1,10.0.0.71

[root@db01 ~]# systemctl start zabbix-agent
[root@db01 ~]# netstat -lntp
tcp6       0      0 :::10050                :::*                    LISTEN      8027/zabbix_agentd


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值