Elastic Stack之ElasticSearch分布式集群二进制方式部署
作者:尹正杰
版权声明:原创作品,谢绝转载!否则将追究法律责任。
想必大家都知道ELK其实就是Elasticsearch+Logstash+Kibanna。其中的Logstash由于收集日志很占用资源,官方引入了一个新的组建叫做Beats。它以后可能会渠道Logstash,因为Beats是比Logstash更轻量级的日志收集工具。于此同时,该公司还引入了X-pack插件(需要单独安装),可以在安全审计,权限控制,机器学习,实时监控,数据导出(用于离线分享,支持PDF,CSV等格式)以及图形分析等功能。当然,如果可以的话,你可以使用Elastic Cloud公有云的或者自建Elastic Cloud Enterpriose私有云版本。因此ELK是一个比较古老的名字,该公司将ELK更名为“Elastic Stack”。
一.官方网址介绍
1>.Elasticsearch官方地址(https://www.elastic.co/cn/)
2>.下载Elstic公司的相关产品(https://www.elastic.co/cn/downloads)
二.下载相应的软件
1>.下载Elasticsearch(下载地址:https://www.elastic.co/downloads/elasticsearch)
2>.下载Kibana(下载地址:https://www.elastic.co/downloads/kibana)
3>.下载X-Pack软件
默认情况下,安装Elasticsearch时会安装X-Pack。官方介绍了通过命令行安装X-Pack插件,地址链接:https://www.elastic.co/downloads/x-pack。
我们从上图可以看出,X-Pack的版本是6.2.4版本对吧,如果你非要拿到X-pack这个软件包的话,官方也提供了相应的链接地址:https://www.elastic.co/guide/en/elasticsearch/reference/6.2/installing-xpack-es.html。如下图所示:
三.安装ElasticSearch
1>.安装JDK
我们知道ES是使用java语言编写的,因此我们需要安装对应的jdk。推荐安装jdk1.8及以上版本(1.7版本官方以及不支持维护了,推荐使用openjdk,官方版本的jdk是收费的!)安装步骤可以参考我之前部署jdk版本的方式:https://www.cnblogs.com/yinzhengjie/p/10226567.html。
[root@node101 bin]# -openjdk.x86_64Loaded plugins: fastestmirrorLoading mirror speeds from cached hostfile * base: mirrors.tuna.tsinghua.edu.cn * extras: mirrors.tuna.tsinghua.edu.cn * updates: mirrors.tuna.tsinghua.edu.cnResolving Dependencies--> Running transaction check---> Package java--openjdk.x86_64 :.el7_6 will be installed--> Processing Dependency: java--openjdk-headless(x86-) = :.el7_6 :java--openjdk-.el7_6.x86_64--> Processing Dependency: xorg-x11-fonts-Type1 :java--openjdk-.el7_6.x86_64--> Processing Dependency: libpng15.so.(PNG15_0)(64bit) :java--openjdk-.el7_6.x86_64--> Processing Dependency: libjvm.so(SUNWprivate_1.)(64bit) :java--openjdk-.el7_6.x86_64--> Processing Dependency: libjpeg.so.(LIBJPEG_6.)(64bit) :java--openjdk-.el7_6.x86_64--> Processing Dependency: libjava.so(SUNWprivate_1.)(64bit) :java--openjdk-.el7_6.x86_64--> Processing Dependency: fontconfig(x86-) :java--openjdk-.el7_6.x86_64--> Processing Dependency: libpng15.so.()(64bit) :java--openjdk-.el7_6.x86_64--> Processing Dependency: libjvm.so()(64bit) :java--openjdk-.el7_6.x86_64--> Processing Dependency: libjpeg.so.()(64bit) :java--openjdk-.el7_6.x86_64--> Processing Dependency: libjava.so()(64bit) :java--openjdk-.el7_6.x86_64--> Processing Dependency: libgif.so.()(64bit) :java--openjdk-.el7_6.x86_64--> Processing Dependency: libXtst.so.()(64bit) :java--openjdk-.el7_6.x86_64--> Processing Dependency: libXrender.so.()(64bit) :java--openjdk-.el7_6.x86_64--> Processing Dependency: libXi.so.()(64bit) :java--openjdk-.el7_6.x86_64--> Processing Dependency: libXext.so.()(64bit) :java--openjdk-.el7_6.x86_64--> Processing Dependency: libXcomposite.so.()(64bit) :java--openjdk-.el7_6.x86_64--> Processing Dependency: libX11.so.()(64bit) :java--openjdk-.el7_6.x86_64--> Running transaction check---> Package fontconfig.x86_64 :-4.3.el7 will be installed--> Processing Dependency: freetype >= -4.3.el7.x86_64--> Processing Dependency: fontpackages-filesystem -4.3.el7.x86_64--> Processing Dependency: dejavu-sans-fonts -4.3.el7.x86_64---> Package giflib.x86_64 :-.el7 will be installed--> Processing Dependency: libSM.so.()(64bit) -.el7.x86_64--> Processing Dependency: libICE.so.()(64bit) -.el7.x86_64---> Package java--openjdk-headless.x86_64 :.el7_6 will be installed--> Processing Dependency: tzdata-java >= 2015d :java--openjdk-headless-.el7_6.x86_64--> Processing Dependency: nss-softokn(x86-) >= :java--openjdk-headless-.el7_6.x86_64--> Processing Dependency: nss(x86-) >= :java--openjdk-headless-.el7_6.x86_64--> Processing Dependency: copy-jdk-configs >= :java--openjdk-headless-.el7_6.x86_64--> Processing Dependency: chkconfig >= :java--openjdk-headless-.el7_6.x86_64--> Processing Dependency: chkconfig >= :java--openjdk-headless-.el7_6.x86_64--> Processing Dependency: lksctp-tools(x86-) :java--openjdk-headless-.el7_6.x86_64--> Processing Dependency: jpackage-utils :java--openjdk-headless-.el7_6.x86_64---> Package libX11.x86_64 :-.el7 will be installed--> Processing Dependency: libX11-common >= -.el7 -.el7.x86_64--> Processing Dependency: libxcb.so.()(64bit) -.el7.x86_64---> Package libXcomposite.x86_64 :-4.1.el7 will be installed---> Package libXext.x86_64 :-.el7 will be installed---> Package libXi.x86_64 :-.el7 will be installed---> Package libXrender.x86_64 :-.el7 will be installed---> Package libXtst.x86_64 :-.el7 will be installed---> Package libjpeg-turbo.x86_64 :-.el7 will be installed---> Package libpng.x86_64 :-.el7_2 will be installed---> Package xorg-x11-fonts-Type1.noarch :.el7 will be installed--> Processing Dependency: ttmkfdir .el7.noarch--> Processing Dependency: ttmkfdir .el7.noarch--> Processing Dependency: mkfontdir .el7.noarch--> Processing Dependency: mkfontdir .el7.noarch--> Running transaction check---> Package chkconfig.x86_64 :-.el7 will be updated---> Package chkconfig.x86_64 :-.el7 will be an update---> Package copy-jdk-configs.noarch :.el7_5 will be installed---> Package dejavu-sans-fonts.noarch :.el7 will be installed--> Processing Dependency: dejavu-fonts-common = .el7 .el7.noarch---> Package fontpackages-filesystem.noarch :.el7 will be installed---> Package freetype.x86_64 :-.el7 will be updated---> Package freetype.x86_64 :.el7 will be an update---> Package javapackages-tools.noarch :-.el7 will be installed--> Processing Dependency: python-javapackages = -.el7 -.el7.noarch--> Processing Dependency: libxslt -.el7.noarch---> Package libICE.x86_64 :-.el7 will be installed---> Package libSM.x86_64 :-.el7 will be installed---> Package libX11-common.noarch :-.el7 will be installed---> Package libxcb.x86_64 :.el7 will be installed--> Processing Dependency: libXau.so.()(64bit) .el7.x86_64---> Package lksctp-tools.x86_64 :-.el7 will be installed---> Package nss.x86_64 :-.el7 will be updated--> Processing Dependency: nss = -.el7 -.el7.x86_64--> Processing Dependency: nss(x86-) = -.el7 -.el7.x86_64---> Package nss.x86_64 :-.el7_5 will be an update--> Processing Dependency: nss-util >= - -.el7_5.x86_64--> Processing Dependency: nspr >= -.el7_5.x86_64--> Processing Dependency: nss-pem(x86-) -.el7_5.x86_64--> Processing Dependency: libnssutil3.so(NSSUTIL_3.)(64bit) -.el7_5.x86_64--> Processing Dependency: libnssutil3.so(NSSUTIL_3.)(64bit) -.el7_5.x86_64--> Processing Dependency: libnssutil3.so(NSSUTIL_3.)(64bit) -.el7_5.x86_64---> Package nss-softokn.x86_64 :.el7_1 will be updated---> Package nss-softokn.x86_64 :-.el7_5 will be an update--> Processing Dependency: nss-softokn-freebl(x86-) >= -.el7_5 -.el7_5.x86_64---> Package ttmkfdir.x86_64 :-.el7 will be installed---> Package tzdata-java.noarch :2018i-.el7 will be installed---> Package xorg-x11-font-utils.x86_64 :.el7 will be installed--> Processing Dependency: libfontenc.so.()(64bit) :xorg-x11-font-utils-.el7.x86_64--> Running transaction check---> Package dejavu-fonts-common.noarch :.el7 will be installed---> Package libXau.x86_64 :-2.1.el7 will be installed---> Package libfontenc.x86_64 :-.el7 will be installed---> Package libxslt.x86_64 :-.el7 will be installed---> Package nspr.x86_64 :-.el7_1 will be updated---> Package nspr.x86_64 :-.el7_5 will be an update---> Package nss-pem.x86_64 :-.el7 will be installed---> Package nss-softokn-freebl.x86_64 :.el7_1 will be updated---> Package nss-softokn-freebl.x86_64 :-.el7_5 will be an update---> Package nss-sysinit.x86_64 :-.el7 will be updated---> Package nss-sysinit.x86_64 :-.el7_5 will be an update---> Package nss-tools.x86_64 :-.el7 will be updated---> Package nss-tools.x86_64 :-.el7_5 will be an update---> Package nss-util.x86_64 :-.el7_1 will be updated---> Package nss-util.x86_64 :-.el7_5 will be an update---> Package python-javapackages.noarch :-.el7 will be installed--> Processing Dependency: python-lxml -.el7.noarch--> Running transaction check---> Package python-lxml.x86_64 :-.el7 will be installed--> Finished Dependency ResolutionDependencies Resolved============================================================================================================================================================================= Package Arch Version Repository Size=============================================================================================================================================================================Installing: java--openjdk x86_64 :.el7_6 updates kInstalling for dependencies: copy-jdk-configs noarch .el7_5 base k dejavu-fonts-common noarch .el7 base k dejavu-sans-fonts noarch .el7 base 1.4 M fontconfig x86_64 - k fontpackages-filesystem noarch .el7 base 9.9 k giflib x86_64 -.el7 base k java--openjdk-headless x86_64 :.el7_6 updates M javapackages-tools noarch -.el7 base k libICE x86_64 -.el7 base k libSM x86_64 -.el7 base k libX11 x86_64 -.el7 base k libX11-common noarch -.el7 base k libXau x86_64 - k libXcomposite x86_64 - k libXext x86_64 -.el7 base k libXi x86_64 -.el7 base k libXrender x86_64 -.el7 base k libXtst x86_64 -.el7 base k libfontenc x86_64 -.el7 base k libjpeg-turbo x86_64 -.el7 base k libpng x86_64 :-.el7_2 base k libxcb x86_64 .el7 base k libxslt x86_64 -.el7 base k lksctp-tools x86_64 -.el7 base k nss-pem x86_64 -.el7 base k python-javapackages noarch -.el7 base k python-lxml x86_64 -.el7 base k ttmkfdir x86_64 -.el7 base k tzdata-java noarch 2018i-.el7 updates k xorg-x11-font-utils x86_64 :.el7 base k xorg-x11-fonts-Type1 noarch .el7 base kUpdating for dependencies: chkconfig x86_64 -.el7 base k freetype x86_64 .el7 base k nspr x86_64 -.el7_5 base k nss x86_64 -.el7_5 base k nss-softokn x86_64 -.el7_5 base k nss-softokn-freebl x86_64 -.el7_5 base k nss-sysinit x86_64 -.el7_5 base k nss-tools x86_64 -.el7_5 base k nss-util x86_64 -.el7_5 base kTransaction Summary=============================================================================================================================================================================Install Package (+ Dependent packages)Upgrade ( Dependent packages)Total download size: MDownloading packages:Delta RPMs disabled because /usr/bin/applydeltarpm not installed.(/): dejavu-fonts-common-.el7.noarch.rpm | kB ::(/): fontpackages-filesystem-.el7.noarch.rpm | ::(/): copy-jdk-configs-.el7_5.noarch.rpm | kB ::(/): freetype-.el7.x86_64.rpm | kB ::(/): java--openjdk-.el7_6.x86_64.rpm | kB ::(/): chkconfig--.el7.x86_64.rpm | kB ::(/): giflib--.el7.x86_64.rpm | kB ::(/): javapackages-tools--.el7.noarch.rpm | kB ::(/): libSM--.el7.x86_64.rpm | kB ::(/): libX11--.el7.x86_64.rpm | kB ::(/): dejavu-sans-fonts-.el7.noarch.rpm | ::(/): libX11-common--.el7.noarch.rpm | kB ::(/): libXau-- kB ::(/): fontconfig-- kB ::(/): libXi--.el7.x86_64.rpm | kB ::(/): libXcomposite-- kB ::(/): libXtst--.el7.x86_64.rpm | kB ::(/): libXrender--.el7.x86_64.rpm | kB ::(/): libICE--.el7.x86_64.rpm | kB ::(/): libpng--.el7_2.x86_64.rpm | kB ::(/): libfontenc--.el7.x86_64.rpm | kB ::(/): libxcb-.el7.x86_64.rpm | kB ::(/): libjpeg-turbo--.el7.x86_64.rpm | kB ::(/): lksctp-tools--.el7.x86_64.rpm | kB ::(/): nspr--.el7_5.x86_64.rpm | kB ::(/): libxslt--.el7.x86_64.rpm | kB ::(/): nss--.el7_5.x86_64.rpm | kB ::(/): nss-softokn-freebl--.el7_5.x86_64.rpm | kB ::(/): nss-sysinit--.el7_5.x86_64.rpm | kB ::(/): nss-pem--.el7.x86_64.rpm | kB ::(/): libXext--.el7.x86_64.rpm | kB ::(/): python-javapackages--.el7.noarch.rpm | kB ::(/): nss-tools--.el7_5.x86_64.rpm | kB ::(/): nss-softokn--.el7_5.x86_64.rpm | kB ::(/): ttmkfdir--.el7.x86_64.rpm | kB ::(/): tzdata-java-2018i-.el7.noarch.rpm | kB ::(/): xorg-x11-font-utils-.el7.x86_64.rpm | kB ::(/): nss-util--.el7_5.x86_64.rpm | kB ::(/): python-lxml--.el7.x86_64.rpm | kB ::(/): xorg-x11-fonts-Type1-.el7.noarch.rpm | kB ::(/): java--openjdk-headless-.el7_6.x86_64.rpm | MB ::-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------Total MB ::Running transaction checkRunning transaction testTransaction test succeededRunning transaction Updating : nspr--.el7_5.x86_64 / Updating : nss-util--.el7_5.x86_64 / Updating : chkconfig--.el7.x86_64 / Installing : libxslt--.el7.x86_64 / Installing : libjpeg-turbo--.el7.x86_64 / Installing : fontpackages-filesystem-.el7.noarch / Installing : libICE--.el7.x86_64 / Installing : :libpng--.el7_2.x86_64 / Updating : freetype-.el7.x86_64 / Installing : ttmkfdir--.el7.x86_64 / Installing : libSM--.el7.x86_64 / Installing : dejavu-fonts-common-.el7.noarch / Installing : dejavu-sans-fonts-.el7.noarch / Installing : fontconfig--/ Installing : python-lxml--.el7.x86_64 / Installing : python-javapackages--.el7.noarch / Installing : javapackages-tools--.el7.noarch / Updating : nss-softokn-freebl--.el7_5.x86_64 / Updating : nss-softokn--.el7_5.x86_64 / Installing : nss-pem--.el7.x86_64 / Updating : nss-sysinit--.el7_5.x86_64 / Updating : nss--.el7_5.x86_64 / Installing : libfontenc--.el7.x86_64 / Installing : :xorg-x11-font-utils-.el7.x86_64 / Installing : xorg-x11-fonts-Type1-.el7.noarch / Installing : libX11-common--.el7.noarch / Installing : libXau--/ Installing : libxcb-.el7.x86_64 / Installing : libX11--.el7.x86_64 / Installing : libXext--.el7.x86_64 / Installing : libXi--.el7.x86_64 / Installing : libXtst--.el7.x86_64 / Installing : giflib--.el7.x86_64 / Installing : libXrender--.el7.x86_64 / Installing : libXcomposite--/ Installing : lksctp-tools--.el7.x86_64 / Installing : copy-jdk-configs-.el7_5.noarch / Installing : tzdata-java-2018i-.el7.noarch / Installing : :java--openjdk-headless-.el7_6.x86_64 / Installing : :java--openjdk-.el7_6.x86_64 / Updating : nss-tools--.el7_5.x86_64 / Cleanup : nss-tools--.el7.x86_64 / Cleanup : nss-sysinit--.el7.x86_64 / Cleanup : nss--.el7.x86_64 / Cleanup : nss-softokn-.el7_1.x86_64 / Cleanup : nss-util--.el7_1.x86_64 / Cleanup : nspr--.el7_1.x86_64 / Cleanup : nss-softokn-freebl-.el7_1.x86_64 / Cleanup : chkconfig--.el7.x86_64 / Cleanup : freetype--.el7.x86_64 / Verifying : libXext--.el7.x86_64 / Verifying : libXi--.el7.x86_64 / Verifying : fontconfig--/ Verifying : :libpng--.el7_2.x86_64 / Verifying : giflib--.el7.x86_64 / Verifying : libXrender--.el7.x86_64 / Verifying : python-lxml--.el7.x86_64 / Verifying : tzdata-java-2018i-.el7.noarch / Verifying : libICE--.el7.x86_64 / Verifying : nss--.el7_5.x86_64 / Verifying : fontpackages-filesystem-.el7.noarch / Verifying : ttmkfdir--.el7.x86_64 / Verifying : freetype-.el7.x86_64 / Verifying : nss-util--.el7_5.x86_64 / Verifying : copy-jdk-configs-.el7_5.noarch / Verifying : python-javapackages--.el7.noarch / Verifying : nss-pem--.el7.x86_64 / Verifying : dejavu-fonts-common-.el7.noarch / Verifying : libXcomposite--/ Verifying : libXtst--.el7.x86_64 / Verifying : libxcb-.el7.x86_64 / Verifying : libjpeg-turbo--.el7.x86_64 / Verifying : lksctp-tools--.el7.x86_64 / Verifying : xorg-x11-fonts-Type1-.el7.noarch / Verifying : libxslt--.el7.x86_64 / Verifying : libX11--.el7.x86_64 / Verifying : :java--openjdk-.el7_6.x86_64 / Verifying : dejavu-sans-fonts-.el7.noarch / Verifying : nss-tools--.el7_5.x86_64 / Verifying : javapackages-tools--.el7.noarch / Verifying : :java--openjdk-headless-.el7_6.x86_64 / Verifying : nss-sysinit--.el7_5.x86_64 / Verifying : libXau--/ Verifying : nss-softokn-freebl--.el7_5.x86_64 / Verifying : libSM--.el7.x86_64 / Verifying : nspr--.el7_5.x86_64 / Verifying : libX11-common--.el7.noarch / Verifying : :xorg-x11-font-utils-.el7.x86_64 / Verifying : chkconfig--.el7.x86_64 / Verifying : libfontenc--.el7.x86_64 / Verifying : nss-softokn--.el7_5.x86_64 / Verifying : freetype--.el7.x86_64 / Verifying : nss-tools--.el7.x86_64 / Verifying : nss-softokn-.el7_1.x86_64 / Verifying : nss--.el7.x86_64 / Verifying : nss-sysinit--.el7.x86_64 / Verifying : chkconfig--.el7.x86_64 / Verifying : nss-softokn-freebl-.el7_1.x86_64 / Verifying : nspr--.el7_1.x86_64 / Verifying : nss-util--.el7_1.x86_64 / Installed: java--openjdk.x86_64 :.el7_6 Dependency Installed: copy-jdk-configs.noarch :.el7_5 dejavu-fonts-common.noarch :.el7 dejavu-sans-fonts.noarch :.el7 fontconfig.x86_64 :-:.el7 giflib.x86_64 :-.el7 java--openjdk-headless.x86_64 :.el7_6 javapackages-tools.noarch :-.el7 libICE.x86_64 :-.el7 libSM.x86_64 :-.el7 libX11.x86_64 :-.el7 libX11-common.noarch :-.el7 libXau.x86_64 :-:-:-.el7 libXi.x86_64 :-.el7 libXrender.x86_64 :-.el7 libXtst.x86_64 :-.el7 libfontenc.x86_64 :-.el7 libjpeg-turbo.x86_64 :-.el7 libpng.x86_64 :-.el7_2 libxcb.x86_64 :.el7 libxslt.x86_64 :-.el7 lksctp-tools.x86_64 :-.el7 nss-pem.x86_64 :-.el7 python-javapackages.noarch :-.el7 python-lxml.x86_64 :-.el7 ttmkfdir.x86_64 :-.el7 tzdata-java.noarch :2018i-.el7 xorg-x11-font-utils.x86_64 :.el7 xorg-x11-fonts-Type1.noarch :.el7 Dependency Updated: chkconfig.x86_64 :-.el7 freetype.x86_64 :.el7 nspr.x86_64 :-.el7_5 nss.x86_64 :-.el7_5 nss-softokn.x86_64 :-.el7_5 nss-softokn-freebl.x86_64 :-.el7_5 nss-sysinit.x86_64 :-.el7_5 nss-tools.x86_64 :-.el7_5 nss-util.x86_64 :-.el7_5 Complete![root@node101 bin]#
安装JRE环境([root@node101 bin]# yum -y install java-1.8.0-openjdk.x86_64)
[root@node101 bin]# -openjdk-devel.x86_64Loaded plugins: fastestmirrorLoading mirror speeds from cached hostfile * base: mirrors.tuna.tsinghua.edu.cn * extras: mirrors.tuna.tsinghua.edu.cn * updates: mirrors.tuna.tsinghua.edu.cnResolving Dependencies--> Running transaction check---> Package java--openjdk-devel.x86_64 :.el7_6 will be installed--> Finished Dependency ResolutionDependencies Resolved============================================================================================================================================================================= Package Arch Version Repository Size=============================================================================================================================================================================Installing: java--openjdk-devel x86_64 :.el7_6 updates 9.8 MTransaction Summary=============================================================================================================================================================================Install PackageTotal download size: 9.8 MInstalled size: MDownloading packages:java--openjdk-devel-.el7_6.x86_64.rpm | ::Running transaction checkRunning transaction testTransaction test succeededRunning transaction Installing : :java--openjdk-devel-.el7_6.x86_64 / Verifying : :java--openjdk-devel-.el7_6.x86_64 / Installed: java--openjdk-devel.x86_64 :.el7_6 Complete![root@node101 bin]#
安装devel开发环境([root@node101 bin]# yum -y install java-1.8.0-openjdk-devel.x86_64 )
2>.创建下载目录和存放软件的目录
[root@node101 ~]# mkdir -pv /yinzhengjie/download #用于存放下载文件的目录mkdir: created directory ‘/yinzhengjie’mkdir: created directory ‘/yinzhengjie/download’[root@node101 ~]#[root@node101 ~]# mkdir -pv /yinzhengjie/softwares #用于安装软件的目录mkdir: created directory ‘/yinzhengjie/softwares’[root@node101 ~]#[root@node101 ~]#
2>.下载ElasticSearch软件
[root@node101 ~]# cd /yinzhengjie/download/[root@node101 download]#[root@node101 download]# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.5.4.tar.gz[root@node101 download]#[root@node101 download]# ll -htotal 109M-rw-r--r--. root root 109M Jan : elasticsearch-.tar.gz[root@node101 download]#
3>.解压tar包到制定存放软件到路径(目录结构说明)
[root@node101 download]# .tar.gz -C /yinzhengjie/softwares/[root@node101 download]#[root@node101 download]# ll /yinzhengjie/softwares/elasticsearch-/totaldrwxr-xr-x. root root Jan : bindrwxr-xr-x. root root Dec : config #存放ES配置文件,包括JVM参数配置也放在这里,大家可以使用ls名称查看,根据文件名称估计大家也明白了的十之八九了。drwxr-xr-x. root root Dec : lib #这里是存放依赖库文件,基本上都是一些jar包-rw-r--r--. root root Dec : LICENSE.txtdrwxr-xr-x. root root Dec : logs #存放日志的目录drwxr-xr-x. root root Dec : modules #ES的一些核心功能都是以模块的形式存放-rw-r--r--. root root Dec : NOTICE.txtdrwxr-xr-x. root root Dec : plugins #这里是存放ES第三方的一些插件信息-rw-r--r--. root root Dec : README.textile[root@node101 download]#[root@node101 download]#
4>.修改ES到配置文件(下面的配置基本我使用的是主机名,因此我们需要提前在“/etc/hosts”作相应的解析操作)
[root@node101 ~]# /config/elasticsearch.yml /yinzhengjie/softwares/elasticsearch-/config/elasticsearch.yml.`date +%F `[root@node101 ~]#[root@node101 ~]# /config/elasticsearch.yml#cluster.name: my-application[root@node101 ~]#[root@node101 ~]# /config/elasticsearch.yml[root@node101 ~]#[root@node101 ~]# /config/elasticsearch.ymlcluster.name: yinzhengjie-elasticsearch[root@node101 ~]#[root@node101 ~]# /config/elasticsearch.yml#node.name: node-[root@node101 ~]#[root@node101 ~]# /config/elasticsearch.yml[root@node101 ~]#[root@node101 ~]# /config/elasticsearch.ymlnode.name: node101.yinzhengjie.org.cn[root@node101 ~]#[root@node101 ~]# /config/elasticsearch.yml#network.host: 192.168.0.1[root@node101 ~]#[root@node101 ~]# /config/elasticsearch.yml[root@node101 ~]#[root@node101 ~]# /config/elasticsearch.ymlnetwork.host: node101.yinzhengjie.org.cn[root@node101 ~]#[root@node101 ~]#
以上修改,只是单机部署所需要修改上面配置的参数即可,如果有集群的话,应该还需要修改一个参数,具体修改内容如下:
[root@node101 ~]# /config/elasticsearch.yml | egrep -v "^#|^$"cluster.name: yinzhengjie-elasticsearch #自定义当前节点所属集群的名称。node.name: node101.yinzhengjie.org.cn #自定义节点的名称。path.data: /yinzhengjie/softwares/elasticsearch-/data #自定义存放数据的目录。path.logs: /yinzhengjie/softwares/elasticsearch-/logs #自定义存放日志的目录。network.host: node101.yinzhengjie.org.cn #服务启动时绑定的IP地址,默认是loacalhost。discovery.zen.ping.unicast.hosts: ["node101.yinzhengjie.org.cn:9300", "node102.yinzhengjie.org.cn:9300","node103.yinzhengjie.org.cn:9300"] #这里是集群的各个节点的IP地址,一定别忘记把端口加上哟!因为不加端口,可能有各别节点检测不到到情况![root@node101 ~]#
5>.启动ES
[root@node101 download]# sysctl -q vm.max_map_count #调大虚拟内存映射vm.max_map_count =[root@node101 download]#[root@node101 download]# ulimit -u #调大用户可以开启的最大进程数量[root@node101 download]#[root@node101 download]# id yinzhengjie #你可以使用useradd命令创建出来一个普通用户uid=(yinzhengjie) gid=(yinzhengjie) (yinzhengjie),(wheel)[root@node101 download]#[root@node101 download]# / #将ES整个目录授权给一个普通用户[root@node101 download]#[root@node101 download]# cd /yinzhengjie/softwares/elasticsearch-/bin/ #进入到ES到脚本目录[root@node101 bin]#[root@node101 bin]# su yinzhengjie #切换到普通用户,因为ES默认是不支持以root身份运行哟![yinzhengjie@node101 bin]$[yinzhengjie@node101 bin]$ ./elasticsearch #启动ES
上面的启动方式是没有配置环境变量,我们可以将ES的bin路径加入到系统到PATH中,这样我们在任意一个位置都可以执行ES的相关命令啦~
[root@node101 bin]# echo "#Add by yinzhengjie" >> /etc/profile[root@node101 bin]#[root@node101 bin]# echo "export PATH=$PATH:/yinzhengjie/softwares/elasticsearch-6.5.4/bin" >> /etc/profile[root@node101 bin]#[root@node101 bin]# /etc/profile#Add by yinzhengjieexport PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/yinzhengjie/softwares/elasticsearch-/bin[root@node101 bin]#[root@node101 bin]# source /etc/profile #一般情况下,我不建议大家将环境变量配置在“~/.bash_profile”中,将环境变量定义在全局生效,目的就是为了切换用户时,我们配置的环境变量依旧有效![root@node101 bin]#[root@node101 ~]# su yinzhengjie[yinzhengjie@node101 root]$
[yinzhengjie@node101 root]$ elasticsearch &[][yinzhengjie@node101 root]$[yinzhengjie@node101 root]$ [--22T04::,][INFO ][o.e.e.NodeEnvironment ] [node105.yinzhengjie.org.cn] using [] data paths, mounts [[/ (rootfs)]], net usable_space [.5gb], net total_space [49gb], types [rootfs][--22T04::,][INFO ][o.e.e.NodeEnvironment ] [node105.yinzhengjie.org.cn] heap size [.3mb], compressed ordinary object pointers [true][--22T04::,][INFO ][o.e.n.Node ] [node105.yinzhengjie.org.cn] node name [node105.yinzhengjie.org.cn], node ID [5Xyf16x8SNaMa_29D7452Q][--22T04::,][INFO ][o.e.n.Node ] [node105.yinzhengjie.org.cn] version[], pid[], build[default/--17T21::.758843Z], OS[Linux/-.el7.x86_64/amd64], JVM[Oracle Corporation/OpenJDK -Bit Server VM/1.8.0_191/25.191-b12][--22T04::,][INFO ][o.e.n.Node ] [node105.yinzhengjie.org.cn] JVM arguments [-Xms1g, -Xmx1g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=, -XX:+UseCMSInitiatingOccupancyOnly, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=, -Djna.nosys=, -Dlog4j.shutdownHookEnabled=, -XX:GCLogFileSize=64m, -Des.path.home=/yinzhengjie/softwares/elasticsearch-, -Des.path.conf=/yinzhengjie/softwares/elasticsearch-/config, -Des.distribution.flavor=default, -Des.distribution.type=tar][--22T04::,][INFO ][o.e.p.PluginsService ] [node105.yinzhengjie.org.cn] loaded module [aggs-matrix-stats][--22T04::,][INFO ][o.e.p.PluginsService ] [node105.yinzhengjie.org.cn] loaded module [analysis-common][--22T04::,][INFO ][o.e.p.PluginsService ] [node105.yinzhengjie.org.cn] loaded module [ingest-common][--22T04::,][INFO ][o.e.p.PluginsService ] [node105.yinzhengjie.org.cn] loaded module [lang-expression][--22T04::,][INFO ][o.e.p.PluginsService ] [node105.yinzhengjie.org.cn] loaded module [lang-mustache][--22T04::,][INFO ][o.e.p.PluginsService ] [node105.yinzhengjie.org.cn] loaded module [lang-painless][--22T04::,][INFO ][o.e.p.PluginsService ] [node105.yinzhengjie.org.cn] loaded module [mapper-extras][--22T04::,][INFO ][o.e.p.PluginsService ] [node105.yinzhengjie.org.cn] loaded module [parent-join][--22T04::,][INFO ][o.e.p.PluginsService ] [node105.yinzhengjie.org.cn] loaded module [percolator][--22T04::,][INFO ][o.e.p.PluginsService ] [node105.yinzhengjie.org.cn] loaded module [rank-eval][--22T04::,][INFO ][o.e.p.PluginsService ] [node105.yinzhengjie.org.cn] loaded module [reindex][--22T04::,][INFO ][o.e.p.PluginsService ] [node105.yinzhengjie.org.cn] loaded module [repository-url][--22T04::,][INFO ][o.e.p.PluginsService ] [node105.yinzhengjie.org.cn] loaded module [transport-netty4][--22T04::,][INFO ][o.e.p.PluginsService ] [node105.yinzhengjie.org.cn] loaded module [tribe][--22T04::,][INFO ][o.e.p.PluginsService ] [node105.yinzhengjie.org.cn] loaded module [x-pack-ccr][--22T04::,][INFO ][o.e.p.PluginsService ] [node105.yinzhengjie.org.cn] loaded module [x-pack-core][--22T04::,][INFO ][o.e.p.PluginsService ] [node105.yinzhengjie.org.cn] loaded module [x-pack-deprecation][--22T04::,][INFO ][o.e.p.PluginsService ] [node105.yinzhengjie.org.cn] loaded module [x-pack-graph][--22T04::,][INFO ][o.e.p.PluginsService ] [node105.yinzhengjie.org.cn] loaded module [x-pack-logstash][--22T04::,][INFO ][o.e.p.PluginsService ] [node105.yinzhengjie.org.cn] loaded module [x-pack-ml][--22T04::,][INFO ][o.e.p.PluginsService ] [node105.yinzhengjie.org.cn] loaded module [x-pack-monitoring][--22T04::,][INFO ][o.e.p.PluginsService ] [node105.yinzhengjie.org.cn] loaded module [x-pack-rollup][--22T04::,][INFO ][o.e.p.PluginsService ] [node105.yinzhengjie.org.cn] loaded module [x-pack-security][--22T04::,][INFO ][o.e.p.PluginsService ] [node105.yinzhengjie.org.cn] loaded module [x-pack-sql][--22T04::,][INFO ][o.e.p.PluginsService ] [node105.yinzhengjie.org.cn] loaded module [x-pack-upgrade][--22T04::,][INFO ][o.e.p.PluginsService ] [node105.yinzhengjie.org.cn] loaded module [x-pack-watcher][--22T04::,][INFO ][o.e.p.PluginsService ] [node105.yinzhengjie.org.cn] no plugins loaded[--22T04::,][INFO ][o.e.x.s.a.s.FileRolesStore] [node105.yinzhengjie.org.cn] parsed [] roles from /config/roles.yml][--22T04::,][INFO ][o.e.x.m.j.p.l.CppLogMessageHandler] [node105.yinzhengjie.org.cn] [controller/] [Main.] controller ( bit): Version (Build b616085ef32393) Copyright (c) Elasticsearch BV[--22T04::,][DEBUG][o.e.a.ActionModule ] [node105.yinzhengjie.org.cn] Using REST wrapper from plugin org.elasticsearch.xpack.security.Security[--22T04::,][INFO ][o.e.d.DiscoveryModule ] [node105.yinzhengjie.org.cn] using discovery type [zen] and host providers [settings][--22T04::,][INFO ][o.e.n.Node ] [node105.yinzhengjie.org.cn] initialized[--22T04::,][INFO ][o.e.n.Node ] [node105.yinzhengjie.org.cn] starting ...[--22T04::,][INFO ][o.e.t.TransportService ] [node105.yinzhengjie.org.cn] publish_address {}, bound_addresses {}[--22T04::,][INFO ][o.e.b.BootstrapChecks ] [node105.yinzhengjie.org.cn] bound or publishing to a non-loopback address, enforcing bootstrap checks[--22T04::,][INFO ][o.e.c.s.MasterService ] [node105.yinzhengjie.org.cn] zen-disco-elected-as-master ([] nodes joined), reason: new_master {node105.yinzhengjie.org.cn}{5Xyf16x8SNaMa_29D7452Q}{o8lotI6GSg2kQtrFkHf9Eg}{node105.yinzhengjie.org.cn}{}{ml.machine_memory=, xpack.installed=, ml.enabled=true}[--22T04::,][INFO ][o.e.c.s.ClusterApplierService] [node105.yinzhengjie.org.cn] new_master {node105.yinzhengjie.org.cn}{5Xyf16x8SNaMa_29D7452Q}{o8lotI6GSg2kQtrFkHf9Eg}{node105.yinzhengjie.org.cn}{}{ml.machine_memory=, xpack.installed=, ml.enabled=}{ml.machine_memory=, xpack.installed=, ml.enabled=] source [zen-disco-elected-as-master ([] nodes joined)]])[--22T04::,][INFO ][o.e.x.s.t.n.SecurityNetty4HttpServerTransport] [node105.yinzhengjie.org.cn] publish_address {}, bound_addresses {}[--22T04::,][INFO ][o.e.n.Node ] [node105.yinzhengjie.org.cn] started[--22T04::,][WARN ][o.e.x.s.a.s.m.NativeRoleMappingStore] [node105.yinzhengjie.org.cn] Failed to clear cache for realms [[]][--22T04::,][INFO ][o.e.l.LicenseService ] [node105.yinzhengjie.org.cn] license [c7460796--404e-9b75-6dcb4e6992fe] mode [basic] - valid[--22T04::,][INFO ][o.e.g.GatewayService ] [node105.yinzhengjie.org.cn] recovered [] indices into cluster_state
[yinzhengjie@node101 root]$ elasticsearch & #后台启动ES,当然输出信息大家可以直接丢弃在Linux的回收站(/dev/null),如果刚刚部署ES建议大家不要这么干,因为输出信息有助于我们排错!
6>.启动ES报错汇总
解决方案:
根据报错提示信息,是由于咱们的默认配置未能达到ES的要求,因此启动失败了,我们按照其要求,修改Linux系统对应的配置文件,于此同时,我还做了一些其他的优化参数。
[root@node101 ~]# cat /etc/security/limits.conf |egrep -v '^#|^$'* soft nofile* hard nofile* soft nproc* hard nproc unlimited* soft memlock unlimited* hard memlock unlimited[root@node101 ~]#
修改用户的资源限制([root@node101 ~]# cat /etc/security/limits.conf |egrep -v ‘^#|^$’ )
[root@node101 ~]# cat /etc/sysctl.conf | egrep -v '^#|^$'net.ipv6.conf.all.disable_ipv6 =vm.dirty_ratio =vm.dirty_background_ratio =vm.swappiness =net.core.wmem_default =net.core.rmem_default =net.ipv4.tcp_wmem =net.ipv4.tcp_rmem =net.ipv4.tcp_window_scaling =net.ipv4.tcp_max_syn_backlog =net.core.netdev_max_backlog =vm.max_map_count =[root@node101 ~]#
修改Linux的内核配置([root@node101 ~]# cat /etc/sysctl.conf | egrep -v ‘^#|^$’)
7>.访问ES的RESTFUL API接口
由于ES是基于http协议的,因此我们可以通过浏览器访问,当然我们也可以使用curl命令来模拟浏览器。
[root@node101 ~]# systemctl status firewalld● firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled) Active: active (running) since Mon -- :: EST; 17h ago Main PID: (firewalld) CGroup: /system.slice/firewalld.service └─ /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopidJan :: node101.yinzhengjie.org.cn systemd[]: Starting firewalld - dynamic firewall daemon...Jan :: node101.yinzhengjie.org.cn systemd[]: Started firewalld - dynamic firewall daemon.[root@node101 ~]#[root@node101 ~]#[root@node101 ~]# systemctl stop firewalld[root@node101 ~]#[root@node101 ~]# systemctl disable firewalldRemoved symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.[root@node101 ~]#
关闭防火墙([root@node101 ~]# systemctl stop firewalld )
关闭防火墙后,我们再次访问WebUI,如下图所示:
上面是查看某个节点是否工作正常,如果想要查看整个集群的所有节点信息,我们可以在浏览器输入:http://node101.yinzhengjie.org.cn:9200/_cat/nodes。
当然我们也可以通过curl命令来模拟http请求,详情请参考:https://www.cnblogs.com/yinzhengjie/p/10226567.html。
8>.等待集群每个节点都启动成功后,我们任意选取一个节点在9300端口进行抓包(部署过程重复上述的2~6步骤)
[root@node101 ~]# yum -y install tcpdumpLoaded plugins: fastestmirrorbase | ::extras | ::updates | ::Loading mirror speeds from cached hostfile * base: mirrors.tuna.tsinghua.edu.cn * extras: mirrors.tuna.tsinghua.edu.cn * updates: mirrors.tuna.tsinghua.edu.cnResolving Dependencies--> Running transaction check---> Package tcpdump.x86_64 :-.el7 will be installed--> Processing Dependency: libpcap >= :- :tcpdump--.el7.x86_64--> Processing Dependency: libcrypto.so.(OPENSSL_1.:tcpdump--.el7.x86_64--> Running transaction check---> Package libpcap.x86_64 :-.el7 will be updated---> Package libpcap.x86_64 :-.el7 will be an update---> Package openssl-libs.x86_64 :.el7. will be updated--> Processing Dependency: openssl-libs(x86-) = :.el7. :openssl-.el7..x86_64---> Package openssl-libs.x86_64 :.el7 will be an update--> Running transaction check---> Package openssl.x86_64 :.el7. will be updated---> Package openssl.x86_64 :.el7 will be an update--> Finished Dependency ResolutionDependencies Resolved================================================================================================================================= Package Arch Version Repository Size=================================================================================================================================Installing: tcpdump x86_64 :-.el7 base kUpdating for dependencies: libpcap x86_64 :-.el7 base k openssl x86_64 :.el7 base k openssl-libs x86_64 :.el7 base 1.2 MTransaction Summary=================================================================================================================================Install PackageUpgrade ( Dependent packages)Total download size: 2.2 MDownloading packages:Delta RPMs disabled because /usr/bin/applydeltarpm not installed.(/): libpcap--.el7.x86_64.rpm | kB ::(/): openssl-.el7.x86_64.rpm | kB ::(/): openssl-libs-.el7.x86_64.rpm | ::(/): tcpdump--.el7.x86_64.rpm | kB ::---------------------------------------------------------------------------------------------------------------------------------Total kB/s | ::Running transaction checkRunning transaction testTransaction test succeededRunning transaction Updating : :openssl-libs-.el7.x86_64 / Updating : :libpcap--.el7.x86_64 / Installing : :tcpdump--.el7.x86_64 / Updating : :openssl-.el7.x86_64 / Cleanup : :openssl-.el7..x86_64 / Cleanup : :openssl-libs-.el7..x86_64 / Cleanup : :libpcap--.el7.x86_64 / Verifying : :openssl-libs-.el7.x86_64 / Verifying : :tcpdump--.el7.x86_64 / Verifying : :openssl-.el7.x86_64 / Verifying : :libpcap--.el7.x86_64 / Verifying : :openssl-libs-.el7..x86_64 / Verifying : :libpcap--.el7.x86_64 / Verifying : :openssl-.el7..x86_64 / Installed: tcpdump.x86_64 :-.el7 Dependency Updated: libpcap.x86_64 :-.el7 openssl.x86_64 :.el7 openssl-libs.x86_64 :.el7 Complete![root@node101 ~]#
安装Linux的网络分析工具([root@node101 ~]# yum -y install tcpdump)
[root@node101 ~]# tcpdump -i eth0 -nn tcp porttcpdump: verbose output suppressed, use -v or -vv for full protocol decodelistening on eth0, link-type EN10MB (Ethernet), capture size bytes:: > : Flags [P.], :, ack , win , options [nop,nop,TS val ecr ], length:: > : Flags [P.], :, ack , win , options [nop,nop,TS val ecr ], length:: > : Flags [.], ack , win , options [nop,nop,TS val ecr ], length:: > : Flags [P.], :, ack , win , options [nop,nop,TS val ecr ], length:: > : Flags [P.], :, ack , win , options [nop,nop,TS val ecr ], length:: > : Flags [.], ack , win , options [nop,nop,TS val ecr ], length:: > : Flags [P.], :, ack , win , options [nop,nop,TS val ecr ], length:: > : Flags [P.], :, ack , win , options [nop,nop,TS val ecr ], length:: > : Flags [.], ack , win , options [nop,nop,TS val ecr ], length:: > : Flags [P.], :, ack , win , options [nop,nop,TS val ecr ], length:: > : Flags [P.], :, ack , win , options [nop,nop,TS val ecr ], length:: > : Flags [.], ack , win , options [nop,nop,TS val ecr ], length:: > : Flags [P.], :, ack , win , options [nop,nop,TS val ecr ], length:: > : Flags [P.], :, ack , win , options [nop,nop,TS val ecr ], length:: > : Flags [.], ack , win , options [nop,nop,TS val ecr ], length:: > : Flags [P.], :, ack , win , options [nop,nop,TS val ecr ], length:: > : Flags [P.], :, ack , win , options [nop,nop,TS val ecr ], length:: > : Flags [.], ack , win , options [nop,nop,TS val ecr ], length:: > : Flags [P.], :, ack , win , options [nop,nop,TS val ecr ], length:: > : Flags [P.], :, ack , win , options [nop,nop,TS val ecr ], length:: > : Flags [.], ack , win , options [nop,nop,TS val ecr ], length:: > : Flags [P.], :, ack , win , options [nop,nop,TS val ecr ], length:: > : Flags [P.], :, ack , win , options [nop,nop,TS val ecr ], length:: > : Flags [.], ack , win , options [nop,nop,TS val ecr ], length:: > : Flags [P.], :, ack , win , options [nop,nop,TS val ecr ], length:: > : Flags [P.], :, ack , win , options [nop,nop,TS val ecr ], length:: > : Flags [.], ack , win , options [nop,nop,TS val ecr ], length:: > : Flags [P.], :, ack , win , options [nop,nop,TS val ecr ], length:: > : Flags [P.], :, ack , win , options [nop,nop,TS val ecr ], length:: > : Flags [.], ack , win , options [nop,nop,TS val ecr ], length:: > : Flags [P.], :, ack , win , options [nop,nop,TS val ecr ], length:: > : Flags [P.], :, ack , win , options [nop,nop,TS val ecr ], length:: > : Flags [.], ack , win , options [nop,nop,TS val ecr ], length:: > : Flags [P.], :, ack , win , options [nop,nop,TS val ecr ], length:: > : Flags [P.], :, ack , win , options [nop,nop,TS val ecr ], length:: > : Flags [.], ack , win , options [nop,nop,TS val ecr ], length^C packets captured packets received by filter packets dropped by kernel[root@node101 ~]#
进行抓包分析,我们只看9300端口,发现3个节点有数据在交互([root@node101 ~]# tcpdump -i eth0 -nn tcp port 9300)