zabbix4.0搭建(yum 安装)

参考文档:https://www.zabbix.com/documentation/4.0/manual/installation/install_from_packages/rhel_centos

目录:

  1. 配置yum源、时间同步
  2. zabbix4.0LTS 安装
  3. 安装mysql
  4. 配置httpd服务
  5. zabbix网页安装
  6. 配置zabbix server配置文件,并启动zabbix-server服务
  7. 在zabbix-server上安装zabbix-agent

配置yum源、时间同步

# 使用阿里yum源
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

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

yum install -y ntpdate

echo '* * * * * /usr/sbin/ntpdate ntp1.aliyun.com &>/dev/null' >> /var/spool/cron/root

# 查看crontab
crontab -l

zabbix4.0LTS 安装

# 安装zabbix yum源
[root@localhost ~]# rpm -ivh http://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm

[root@localhost ~]# rpm -ql zabbix-release-4.0-1.el7.noarch
/etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
/etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
/etc/yum.repos.d/zabbix.repo
/usr/share/doc/zabbix-release-4.0
/usr/share/doc/zabbix-release-4.0/GPL

# 修改为阿里yum源
[root@localhost ~]# vim /etc/yum.repos.d/zabbix.repo

# 文件内容
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=http://mirrors.aliyun.com/zabbix/zabbix/4.0/rhel/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/zabbix/RPM-GPG-KEY-ZABBIX-A14FE591

[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch 
baseurl=http://mirrors.aliyun.com/zabbix/non-supported/rhel/7/$basearch/
enabled=1
gpgkey=http://mirrors.aliyun.com/zabbix/RPM-GPG-KEY-ZABBIX
gpgcheck=1


# 使用yum安装
yum install zabbix-server-mysql zabbix-web-mysql -y

回到目录

安装mysql

# 安装数据库
yum install -y mariadb-server

# 开机自启动
[root@localhost ~]# systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@localhost ~]# systemctl start mariadb


# 数据库初始化
mysql_secure_installation

# 输入更改好的root密码
[root@localhost ~]# mysql -uroot -p
Enter password: 


# 进入数据库,创建数据库,使用utf8编码
create database zabbix character set utf8 collate utf8_bin;

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

# 刷新
flush privileges;

# 退出
quit

[root@localhost yum.repos.d]# rpm -ql zabbix-server-mysql-4.0.10-1.el7.x86_64
/etc/logrotate.d/zabbix-server
/etc/zabbix/zabbix_server.conf
/usr/lib/systemd/system/zabbix-server.service
/usr/lib/tmpfiles.d/zabbix-server.conf
/usr/lib/zabbix/alertscripts
/usr/lib/zabbix/externalscripts
/usr/sbin/zabbix_server_mysql
/usr/share/doc/zabbix-server-mysql-4.0.10
/usr/share/doc/zabbix-server-mysql-4.0.10/AUTHORS
/usr/share/doc/zabbix-server-mysql-4.0.10/COPYING
/usr/share/doc/zabbix-server-mysql-4.0.10/ChangeLog
/usr/share/doc/zabbix-server-mysql-4.0.10/NEWS
/usr/share/doc/zabbix-server-mysql-4.0.10/README
/usr/share/doc/zabbix-server-mysql-4.0.10/create.sql.gz
/usr/share/man/man8/zabbix_server.8.gz
/var/log/zabbix
/var/run/zabbix

# 执行zabbix创建sql,创建zabbix相关数据库
zcat /usr/share/doc/zabbix-server-mysql-4.0.10/create.sql.gz | mysql -uzabbix -pzabbix用户密码 zabbix

配置httpd服务

[root@localhost ~]# vim /etc/httpd/conf/httpd.conf

# 修改参数
ServerName 127.0.0.1:80

# Time zone for PHP is not set (configuration parameter "date.timezone").
更改php.ini配置文件的设置,去掉date.timezone的注释,将时区改为Asia/Shanghai

[root@localhost ~]# vim /etc/php.ini
 878 date.timezone = Asia/Shanghai

[root@localhost ~]# vi /etc/httpd/conf.d/zabbix.conf
20 php_value date.timezone Asia/Shanghai

[root@localhost ~]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@localhost ~]# systemctl start httpd

回到目录

zabbix网页安装

在chrome浏览器中 http://[IP]/zabbix/setup.php

zabbix4.0搭建(yum 安装)_第1张图片
zabbix4.0搭建(yum 安装)_第2张图片
zabbix4.0搭建(yum 安装)_第3张图片
zabbix4.0搭建(yum 安装)_第4张图片
继续点击下一步,直到结束安装

注:数据库分离 修改此配置文件 /etc/zabbix/web/zabbix.conf.php
登录界面默认用户: Admin (区分大小写) 密码: zabbix

回到目录

配置zabbix server配置文件,并启动zabbix-server服务

[root@localhost ~]# vim /etc/zabbix/zabbix_server.conf
124 DBPassword=zabbix用户的数据库密码

# 开机自启动zabbix-server服务
[root@localhost ~]# systemctl enable zabbix-server

# 如遇报错 kernel: zabbix_server[62454]: segfault at 18 ip 00007f7887562c00 sp 00007fff94590f68 error 4 in libpthread-2.17.so[7f7887559000+16000]
Centos7 中 gnutls.x86_64 (gnutls.x86_64 3.3.8-14.el7_2 ) 版本过高,需要降级 3.1.18-8.el7(1.20)
# 3.1.18-8.el7(1.20)下载地址
http://rpm.pbone.net/index.php3/stat/4/idpl/27382700/dir/scientific_linux_7/com/gnutls-3.1.18-8.el7.x86_64.rpm.html/

wget ftp://ftp.pbone.net/mirror/ftp.scientificlinux.org/linux/scientific/7.0/x86_64/os/Packages/gnutls-3.1.18-8.el7.x86_64.rpm

[root@localhost ~]# rpm -Uvh --force  gnutls-3.1.18-8.el7.x86_64.rpm 
[root@localhost ~]# systemctl restart zabbix-server

在zabbix-server上安装zabbix-agent

# wget agent二进制包
[root@localhost ~]# wget https://mirrors.aliyun.com/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-agent-4.0.9-3.el7.x86_64.rpm
# 安装
[root@localhost ~]# rpm -ivh zabbix-agent-4.0.9-3.el7.x86_64.rpm 

[root@localhost ~]# vim /etc/zabbix/zabbix_agentd.conf
# 允许那些ip、域名的主机能从agent获取信息
 98 Server=127.0.0.1

# agent主动模式配置参数
139 ServerActive=127.0.0.1

# 默认都为参数指定,如果要保证agent主机名唯一,可以把这个参数注释
150 Hostname=Zabbix server

[root@localhost ~]# systemctl enable zabbix-agent
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
[root@localhost ~]# systemctl start zabbix-agent

# 使用此命令、避免等待时间
zabbix_server -R config_cache_reload

agent添加完成图
zabbix4.0搭建(yum 安装)_第5张图片
回到目录

你可能感兴趣的:(监控)