安装zabbix

如果安装中出现需要php-bcmath和php-mbstring
1.操作系统版本

[root@aws zabbix]# cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 7.4 (Maipo)

2.在安装zabbix的时候报错( 红色是执行的语句), 如下:

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

--> Finished Dependency Resolution
Error: Package: zabbix-web-3.4.7-1.el7.noarch (zabbix)
           Requires: php-bcmath
Error: Package: zabbix-web-3.4.7-1.el7.noarch (zabbix)
           Requires: php-mbstring
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

3.这两个模块的yum源比较少,在网上发现163的yum源包含它们,那么就需要替换yum源,步骤如下:

a.进入yum源目录

cd /etc/yum.repos.d

b.执行

[root@aws yum.repos.d]# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo

c.因为我目前是redhat7,所以要编辑这个文件,黑色加粗斜体是我改的,屏蔽3行,增加3行

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever - Base - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
#baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/
baseurl=http://mirrors.163.com/centos/7/os/x86_64/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever - Updates - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
#baseurl=http://mirrors.163.com/centos/$releasever/updates/$basearch/
baseurl=http://mirrors.163.com/centos/7/updates/x86_64/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
#baseurl=http://mirrors.163.com/centos/$releasever/extras/$basearch/
baseurl=http://mirrors.163.com/centos/7/extras/x86_64/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - 163.com
#baseurl=http://mirrors.163.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

4.清除和创建 yum缓存

yum clean all yum makecache

5.再次执行安装zabbix

安装步骤
一,关闭selinux和iptables

[root@localhost ~]# systemctl stop firewalld.service
[root@localhost ~]# setenforce 0

二,安装Zabbix rpm包仓库

[root@localhost ~]# rpm -vhi http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm

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

[root@localhost ~]# yum install -y zabbix-server-mysql zabbix-web-mysql

四,安装并且启动mysql5.6及初始化数据库信息

[root@localhost ~]# rpm -ivh http://repo.mysql.com/yum/mysql-5.6-community/el/6/x86_64/mysql-community-release-el6-5.noarch.rpm
[root@localhost ~]# yum install -y mysql-community-server
[root@localhost ~]# systemctl start mysqld
[root@localhost ~]# /sbin/chkconfig mysqld on #开机启动

#初始化数据库信息

[root@localhost ~]# mysql_secure_installation 
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we’ll need the current
password for the root user. If you’ve just installed MySQL, and
you haven’t set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n] y
New password:
Re-enter new password:
Sorry, passwords do not match.
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables…
… Success!
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y
… Success!
Normally, root should only be allowed to connect from ‘localhost’. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y
… Success!
By default, MySQL comes with a database named ‘test’ that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y

Dropping test database…
ERROR 1008 (HY000) at line 1: Can’t drop database ‘test’; database doesn’t exist
… Failed! Not critical, keep moving…
Removing privileges on test database…
… Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
… Success!
All done! If you’ve completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!
五,创建zabbix数据库,创建zabbix账号
[root@localhost ~]# mysql -uroot -p
mysql> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)

mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix123456'; #注意后面密码带引号
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> Ctrl-C – exit!

六,导入默认的zabbix数据库信息

[root@localhost ~]# cd /usr/share/doc/zabbix-server-mysql-3.0.24/
[root@localhost zabbix-server-mysql-3.0.24]# zcat /usr/share/doc/zabbix-server-mysql-3.0.24/create.sql.gz | mysql zabbix -uzabbix -pzabbix123456

七,修改zabbix_server.conf的配置文件`


[root@localhost ~]# vi /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix123456

八,修改配置文件/etc/httpd/conf.d/zabbix.conf,时区改成 Asia/Shanghai

[root@localhost ~]# vi /etc/httpd/conf.d/zabbix.conf
php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
php_value always_populate_raw_post_data -1
php_value date.timezone Asia/Shanghai
九,启动apache/zabbix-server服务并设置为开机启动
[root@localhost ~]# systemctl start httpd
[root@localhost ~]# systemctl enable httpd
[root@localhost ~]# systemctl start zabbix-server
[root@localhost ~]# systemctl enable zabbix-server

十,安装apache也就是httpd服务
直接yum安装

[yuki@Zabbix-server tools]$ sudo yum install -y httpd
[yuki@Zabbix-server tools]$ sudo  rpm -qa|grep httpd
httpd-2.4.6-89.el7.centos.x86_64
httpd-tools-2.4.6-89.el7.centos.x86_64

设置httpd服务开机自启动

[yuki@Zabbix-server tools]$ sudo systemctl enable httpd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[yuki@Zabbix-server tools]$ echo $?
0

启动http

[yuki@Zabbix-server tools]$ sudo systemctl start httpd && sudo echo $?
0

### 查看是否启动成功
[yuki@Zabbix-server tools]$ sudo systemctl status httpd.service
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: active (running) since 二 2019-05-07 11:20:50 CST; 2min 24s ago   ###active (running)###
     Docs: man:httpd(8)
           man:apachectl(8)
 Main PID: 18729 (httpd)
   Status: "Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec"
   CGroup: /system.slice/httpd.service
           ├─18729 /usr/sbin/httpd -DFOREGROUND
           ├─18730 /usr/sbin/httpd -DFOREGROUND
           ├─18731 /usr/sbin/httpd -DFOREGROUND
           ├─18732 /usr/sbin/httpd -DFOREGROUND
           ├─18733 /usr/sbin/httpd -DFOREGROUND
           └─18734 /usr/sbin/httpd -DFOREGROUND

5月 07 11:20:50 Zabbix-server systemd[1]: Starting The Apache HTTP Server...
5月 07 11:20:50 Zabbix-server httpd[18729]: AH00557: httpd: apr_sockaddr_info_get() failed for Zabbix-server
5月 07 11:20:50 Zabbix-server httpd[18729]: AH00558: httpd: Could not reliably determine the server's fully qualified ...essage
5月 07 11:20:50 Zabbix-server systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.

### 通过端口号查看httpd服务是否启动成功
[yuki@Zabbix-server tools]$ sudo lsof -i:80
COMMAND   PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
httpd   18729   root    4u  IPv6  51904      0t0  TCP *:http (LISTEN)
httpd   18730 apache    4u  IPv6  51904      0t0  TCP *:http (LISTEN)
httpd   18731 apache    4u  IPv6  51904      0t0  TCP *:http (LISTEN)
httpd   18732 apache    4u  IPv6  51904      0t0  TCP *:http (LISTEN)
httpd   18733 apache    4u  IPv6  51904      0t0  TCP *:http (LISTEN)
httpd   18734 apache    4u  IPv6  51904      0t0  TCP *:http (LISTEN)

十一,安装php环境

[yuki@Zabbix-server tools]$ sudo yum install -y php php-mysql
[yuki@Zabbix-server tools]$ echo $?
0
[yuki@Zabbix-server tools]$ sudo rpm -qa|grep php
php-cli-5.4.16-46.el7.x86_64
php-bcmath-5.4.16-46.el7.x86_64
php-ldap-5.4.16-46.el7.x86_64
php-pdo-5.4.16-46.el7.x86_64
php-5.4.16-46.el7.x86_64
php-mbstring-5.4.16-46.el7.x86_64
php-xml-5.4.16-46.el7.x86_64
php-gd-5.4.16-46.el7.x86_64
php-common-5.4.16-46.el7.x86_64
php-mysql-5.4.16-46.el7.x86_64

十二,访问网站,例如:http://本机IP/zabbix,如下图所示:
在这里插入图片描述

yum安装zabbix-server,启动失败,提示:zabbix-server.service never wrote its PID file. Failing…

  [root@CentOS7x64 ~]# systemctl restart zabbix-server

  Job for zabbix-server.service failed because a configured resource limit was exceeded.

  See "systemctl status zabbix-server.service" and "journalctl -xe" for details.

 

  解决方法:

  [root@CentOS7x64 ~]# getenforce

  Enforcing

  [root@CentOS7x64 ~]# setenforce 0

  [root@CentOS7x64 ~]# getenforce

  Permissive

  启动zabbix-server 成功
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值