设为首页 收藏本站
查看: 3725|回复: 0

[经验分享] CentOS 7.4 安装Zabbix 3.4

[复制链接]

尚未签到

发表于 2017-11-15 09:58:20 | 显示全部楼层 |阅读模式
一、安装环境



1 [iyunv@iyunv ~]# cat /etc/RedHat-release
2
3 CentOS Linux release 7.4.1708 (Core)
关闭防火墙



1 [iyunv@iyunv ~]# systemctl stop firewalld.service                 #关闭防火墙
2
3 [iyunv@iyunv ~]# systemctl disable firewalld.service               #开机不启动防火墙
4   
关闭selinux



1 [iyunv@iyunv ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config    #在/etc/selinux/config 把SELNUX=enforcing换成SELINUX=disabled
2
3 [iyunv@iyunv ~]# grep SELINUX=disabled /etc/selinux/config       #过滤刚刚换的disabled
4
5 SELINUX=disabled
6
7 [iyunv@iyunv ~]# setenforce 0                                #清空selinux的配置
8
9 setenforce: SELinux is disabled
二、数据库的安装及配置
  MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可。
  开发这个分支的原因是:甲骨文公司收购了MySQL后,有将MySQL闭源的潜在风险,因此社区采用分支的方式来避开这个风险。
  MariaDB的目的是完全兼容MySQL,包括API和命令行,使之能轻松成为MySQL的代替品。

安装mariadb



[iyunv@iyunv ~]# yum install mariadb-server mariadb –y
  已加载插件:fastestmirror, langpacks
  base                                                                                                                        


  中间省略安装过程
  已安装:
  mariadb.x86_64 1:5.5.56-2.el7                                         mariadb-server.x86_64 1:5.5.56-2.el7                                       
  作为依赖被安装:
  perl-DBD-MySQL.x86_64 0:4.023-5.el7                                                                                                               
  作为依赖被升级:
  mariadb-libs.x86_64 1:5.5.56-2.el7                                                                                                               
  完毕!

mariadb数据库的相关命令是:





1 [iyunv@iyunv ~]# systemctl start mariadb  #启动MariaDB
2
3 [iyunv@iyunv ~]# systemctl stop mariadb  #停止MariaDB
4
5 [iyunv@iyunv ~]# systemctl restart mariadb  #重启MariaDB
6
7 [iyunv@iyunv ~]# systemctl enable mariadb  #设置开机启动
三、Zabbix3.4安装及配置

安装zabbix3.4



1 [iyunv@iyunv ~]# rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-1.el7.centos.noarch.rpm
  获取http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-1.el7.centos.noarch.rpm
  准备中...                          ################################# [100%]
  正在升级/安装...
  1:zabbix-release-3.4-1.el7.centos  ################################# [100%]
[iyunv@iyunv ~]# yum install zabbix-server-mysql zabbix-web-mysql -y

  获取http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-1.el7.centos.noarch.rpm
  准备中...                          ################################# [100%]
  正在升级/安装...
  1:zabbix-release-3.4-1.el7.centos  ################################# [100%]



1 [iyunv@iyunv ~]# yum install zabbix-server-mysql zabbix-web-mysql -y
  已加载插件:fastestmirror, langpacks
  zabbix                                                                                                                       | 2.9 kB  00:00:00   
  zabbix-non-supported                                                                                                          |  951 B  00:00:00   
  zabbix/x86_64/primary_db                                                                                                     |  18 kB  00:00:00   
  zabbix-non-supported/x86_64/primary                                                                                          | 1.6 kB  00:00:00   
  Loading mirror speeds from cached hostfile
  * base: mirrors.aliyun.com
  * epel: mirrors.neusoft.edu.cn
  * extras: mirrors.aliyun.com
  * updates: mirrors.aliyun.com
  zabbix-non-supported                                                                                                                            4/4



安装省略中间过程

  已安装:
  zabbix-server-mysql.x86_64 0:3.4.1-1.el7                                  zabbix-web-mysql.noarch 0:3.4.1-1.el7                                 
  作为依赖被安装:
  OpenIPMI-libs.x86_64 0:2.0.19-15.el7          OpenIPMI-modalias.x86_64 0:2.0.19-15.el7            fping.x86_64 0:3.10-4.el7                  
  httpd.x86_64 0:2.4.6-67.el7.centos.2          httpd-tools.x86_64 0:2.4.6-67.el7.centos.2          iksemel.x86_64 0:1.4-6.el7                 
  libzip.x86_64 0:0.10.1-8.el7                  mailcap.noarch 0:2.1.41-2.el7                        php.x86_64 0:5.4.16-42.el7                 
  php-bcmath.x86_64 0:5.4.16-42.el7              php-cli.x86_64 0:5.4.16-42.el7                      php-common.x86_64 0:5.4.16-42.el7           
  php-gd.x86_64 0:5.4.16-42.el7                  php-ldap.x86_64 0:5.4.16-42.el7                      php-mbstring.x86_64 0:5.4.16-42.el7         
  php-mysql.x86_64 0:5.4.16-42.el7              php-pdo.x86_64 0:5.4.16-42.el7                      php-xml.x86_64 0:5.4.16-42.el7            
  t1lib.x86_64 0:5.1.2-14.el7                    unixODBC.x86_64 0:2.3.1-11.el7                      zabbix-web.noarch 0:3.4.1-1.el7            
  完毕!
[iyunv@iyunv ~]#


创建数据库



1 [iyunv@iyunv ~]# mysql -u root -p
2
3 Welcome to the MariaDB monitor.  Commands end with ; or \g.
4
5 Your MariaDB connection id is 2
6
7 Server version: 5.5.56-MariaDB MariaDB Server
8
9  
10
11 Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
12
13  
14
15 Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
16
17  
18
19 MariaDB [(none)]>
20
21 MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
22
23 Query OK, 1 row affected (0.00 sec)
24
25 MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
26
27 Query OK, 0 rows affected (0.08 sec)
28
29 MariaDB [(none)]> exit
30
31 Bye  
导入数据库



[iyunv@iyunv ~]# zcat /usr/share/doc/zabbix-server-mysql-3.4.1/create.sql.gz |mysql -uzabbix -pzabbix zabbix
配置数据库用户及密码



1 [iyunv@iyunv ~]# grep -n '^'[a-Z] /etc/zabbix/zabbix_server.conf
2
3 38:LogFile=/var/log/zabbix/zabbix_server.log
4
5 49:LogFileSize=0
6
7 72:PidFile=/var/run/zabbix/zabbix_server.pid
8
9 82:SocketDir=/var/run/zabbix
10
11 101:DBName=zabbix
12
13 117:DBUser=zabbix
14
15 316:SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
16
17 434:Timeout=4
18
19 476:AlertScriptsPath=/usr/lib/zabbix/alertscripts
20
21 486:ExternalScripts=/usr/lib/zabbix/externalscripts
22
23 522:LogSlowQueries=3000









[iyunv@iyunv ~]# vim /etc/zabbix/zabbix_server.conf              #修改配置文件
DSC0000.png



启动zabbix server并设置开机启动



1 [iyunv@iyunv ~]# systemctl start zabbix-server
2
3 [iyunv@iyunv ~]# systemctl enable zabbix-server
4   
编辑Zabbix前端PHP配置,更改时区



1 [iyunv@iyunv ~]# vim /etc/httpd/conf.d/zabbix.conf
DSC0001.png

  修改为亚洲上海
DSC0002.png

  保存并退出

SELinux配置



1 [iyunv@iyunv ~]# setsebool -P httpd_can_connect_zabbix on
2
3 setsebool:  SELinux is disabled.
4
5 [iyunv@iyunv ~]# setsebool -P httpd_can_cetwork_connect_db on
6
7 setsebool:  SELinux is disabled.
启动httpd并设置开机启动



1 [iyunv@iyunv ~]# systemctl start httpd           #启动httpd服务
2
3 [iyunv@iyunv ~]# systemctl enable httpd         #设置开机启动httpd服务
四、安装Zabbix Web

浏览器访问,并进行安装
  http://192.168.1.18/zabbix/
DSC0003.png

  点击next step
DSC0004.png

  点击 next step
DSC0005.png

  输入数据库的密码
  点击next step
DSC0006.png

  点击 next step
DSC0007.png

  确认信息没错以后
  点击 next step
DSC0008.png

  完成安装,会将在/etc/zabbix/web/zabbix.conf.php生成配置文件
  Congratulations! You have successfully installed Zabbix frontend.
  Configuration file "/etc/zabbix/web/zabbix.conf.php" created.



1 [iyunv@iyunv ~]# cat /etc/zabbix/web/zabbix.conf.php
2
3 <?php
4
5 // Zabbix GUI configuration file.
6
7 global $DB;
8
9  
10
11 $DB['TYPE']     = 'MYSQL';
12
13 $DB['SERVER']   = 'localhost';
14
15 $DB['PORT']     = '0';
16
17 $DB['DATABASE'] = 'zabbix';
18
19 $DB['USER']     = 'zabbix';
20
21 $DB['PASSWORD'] = 'zabbix';
22
23  
24
25 // Schema name. Used for IBM DB2 and PostgreSQL.
26
27 $DB['SCHEMA'] = '';
28
29  
30
31 $ZBX_SERVER      = 'localhost';
32
33 $ZBX_SERVER_PORT = '10051';
34
35 $ZBX_SERVER_NAME = 'Zabbix 监控平台';
36
37  
38
39 $IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
40
41 [iyunv@iyunv ~]#
  点击finish
DSC0009.png

  登录最新版Zabbix3.4 默认用户Admin 默认密码zabbix
  输入用户名和密码以后点击 sign in
DSC00010.png

DSC00011.png

  到此安装已经结束

五、zabbxi-agent安装及配置

安装zabbxi-agent



1 [iyunv@iyunv ~]# yum install zabbix-agent –y
2
3 已加载插件:fastestmirror, langpacks
4
5 Loading mirror speeds from cached hostfile
6
7  * base: mirrors.aliyun.com
8
9  * epel: mirrors.tuna.tsinghua.edu.cn
10
11  * extras: mirrors.aliyun.com
12
13  * updates: mirrors.aliyun.com
14
15 正在解决依赖关系
16
17 There are unfinished transactions remaining. You might consider running yum-complete-transaction, or "yum-complete-transaction --cleanup-only" and "yum history redo last", first to finish them. If those don't work you'll have to try removing/installing packages by hand (maybe package-cleanup can help).
18
19 --> 正在检查事务
20
21 ---> 软件包 zabbix-agent.x86_64.0.3.4.1-1.el7 将被 安装
22
23 --> 解决依赖关系完成
24
25  
26
27 依赖关系解决
28
29  
30
31 =====================================================================================================================================================
32
33  Package                               架构                            版本                                    源                               大小
34
35 =====================================================================================================================================================
36
37 正在安装:
38
39  zabbix-agent                          x86_64                          3.4.1-1.el7                             zabbix                          353 k
40
41  
42
43 事务概要
44
45 =====================================================================================================================================================
46
47 安装  1 软件包
48
49  
50
51 总下载量:353 k
52
53 安装大小:1.3 M
54
55 Downloading packages:
56
57 zabbix-agent-3.4.1-1.el7.x86_64.rpm                                                                                           | 353 kB  00:00:04   
58
59 Running transaction check
60
61 Running transaction test
62
63 Transaction test succeeded
64
65 Running transaction
66
67   正在安装    : zabbix-agent-3.4.1-1.el7.x86_64                                                                                                  1/1
68
69   验证中      : zabbix-agent-3.4.1-1.el7.x86_64                                                                                                  1/1
70
71  
72
73 已安装:
74
75   zabbix-agent.x86_64 0:3.4.1-1.el7                                                                                                                 
76
77  
78
79 完毕!
80
81  
配置zabbxi-agent



1 [iyunv@iyunv ~]# vim /etc/zabbix/zabbix_agentd.conf
  修改IP地址server IP地址
DSC00012.png

  输入IP地址
DSC00013.png

  修改serverActive IP地址
DSC00014.png

  输入IP地址
DSC00015.png


启动zabbxi-agent并设置开机启动
[iyunv@iyunv ~]# systemctl restart zabbix-agent.service

[iyunv@iyunv ~]# systemctl enable zabbix-agent.service


来源:cnblogs.com/it-hack  作者:it-hack

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-407165-1-1.html 上篇帖子: CentOS 5 全功能服务器搭建 下篇帖子: CentOS 7网络故障
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表