​ zabbix搭建 ​

一、配置yum源安装lamp

  yum源的配置文件:


zabbix搭建_配置文件zabbix搭建_数据库_02


1 [base]
2 name=CentOS-$releasever - Base
3 baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
4 #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
5 gpgcheck=1
6 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
7
8 #released updates
9 [updates]
10 name=CentOS-$releasever - Updates
11 baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/
12 #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
13 gpgcheck=1
14 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
15
16 #additional packages that may be useful
17 [extras]
18 name=CentOS-$releasever - Extras
19 baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/
20 #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
21 gpgcheck=1
22 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
23
24 #additional packages that extend functionality of existing packages
25 [centosplus]
26 name=CentOS-$releasever - Plus
27 baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/
28 #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
29 gpgcheck=1
30 enabled=0
31 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

View Code

  安装lamp:数据库下面安装;一顿安装包yum安装去吧!

    yum install -y httpd php  php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt

 

二、下载zabbix-release安装包

   zabbix搭建_php_03

 安装zabbix-release

  zabbix搭建_数据库_04

 

 

 

    修改zabbix-repo配置文件(如下)


zabbix搭建_配置文件_05zabbix搭建_centos_06


1 [zabbix]
2 name=Zabbix Official Repository - $basearch
3 baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/$basearch/
4 enabled=1
5 gpgcheck=0
6 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
7
8 [zabbix-debuginfo]
9 name=Zabbix Official Repository debuginfo - $basearch
10 baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/$basearch/debuginfo/
11 enabled=0
12 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
13 gpgcheck=0
14
15 [zabbix-non-supported]
16 name=Zabbix Official Repository non-supported - $basearch
17 baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/non-supported/rhel/7/$basearch/
18 enabled=1
19 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
20 gpgcheck=0

View Code

  安装zabbix-server-mysql和zabbix-web-mysql

    yum install -y zabbix-server-mysql zabbix-web-mysql

 

二、下载安装数据库

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

  systemctl restart mariadb  启动数据库

  systemctl enable mariadb  开启自启数据库

  mysql_secure_installation  数据库初始化(一路回车,自己百度不详细说明)

  创建数据库并授权给zabbix用户

  zabbix搭建_数据库_07

 

 

  为数据库导入数据数据:

   zcat /usr/share/doc/zabbix-server-mysql-4.0.32/create.sql.gz | mysql zabbix

  注意:导入数据的时候注意数据库的版本;去查zabbix库有很多表则导入成功;

  修改zabbix配置文件: /etc/zabbix/zabbix_server.conf

 



1 LogFile=/var/log/zabbix/zabbix_server.log
2 LogFileSize=0
3 PidFile=/var/run/zabbix/zabbix_server.pid
4 SocketDir=/var/run/zabbix
5 DBHost=localhost
6 DBName=zabbix   ##数据库名称
7 DBUser=zabbix      ##数据库用户
8 DBPassword=zabbix123  ##数据库密码
9 SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
10 Timeout=4
11 AlertScriptsPath=/usr/lib/zabbix/alertscripts
12 ExternalScripts=/usr/lib/zabbix/externalscripts
13 LogSlowQueries=3000


  systemctl restart zabbix-server  启动zabbix

  systemctl enable zabbix-server  开机自启

  zabbix搭建_数据库_08

 

 

三、修改配置zabbix文件

  vim/etc/httpd/conf.d/zabbix.conf ;修改一下时区

  zabbix搭建_mysql_09

 

 

  systemctl restart httpd  启动httpd

  systemctl enable httpd  开机自启

  

  打开网页已经安装成功;httpd配置界面是因为安装了: zabbix-web-mysql

zabbix搭建_php_10

 

第二步:修改时区

zabbix搭建_数据库_11

 

 第三步:配置数据库

zabbix搭建_php_12

 

 下一步 下一步完成;默认账号:Admin  默认密码:zabbix

zabbix搭建_数据库_13

 

 登陆成功:

zabbix搭建_mysql_14