GVKun编程网logo

centos7+docker+elasticsearch 安装记录 + 踩坑(centos7上安装docker)

5

本文将介绍centos7+docker+elasticsearch安装记录+踩坑的详细情况,特别是关于centos7上安装docker的相关信息。我们将通过案例分析、数据研究等多种方式,帮助您更全面地

本文将介绍centos7+docker+elasticsearch 安装记录 + 踩坑的详细情况,特别是关于centos7上安装docker的相关信息。我们将通过案例分析、数据研究等多种方式,帮助您更全面地了解这个主题,同时也将涉及一些关于(centos7)安装elasticsearch6.4.2、CentOS-Docker安装Elasticsearch(单点)、CentOS6.5安装elasticsearch-5.5.1以及elasticsearch-sql插件安装、centos7 elasticsearch集群安装的知识。

本文目录一览:

centos7+docker+elasticsearch 安装记录 + 踩坑(centos7上安装docker)

centos7+docker+elasticsearch 安装记录 + 踩坑(centos7上安装docker)

版本:

  cenos7 :3.10.0-957.21.3.el7.x86_64  (内核需>=3.10 才可以安装)

  docker: yum 安装版本为 1.13.1

  elasticsearch: 6.8.5

安装:

  网上的安装步骤很多,主要参考这篇文章 https://juejin.im/post/5ca0d12c518825550b35be6d,大致说一下不同点

  1. 此文是内网环境,需外网访问参看下文异常处理 3、4
  2. 注意应用 docker logs containerid  命令查看 docker 日志,分析错误原因
  3. 安装 es-head:  
  • docker pull mobz/elasticsearch-head:5
  • docker run -d -p 9100:9100 docker.io/mobz/elasticsearch-head:5
  • ps: 注意提前开 9100 端口
  • oh shit, 没想到这个官方镜像是有 bug 的,由于 es6.0 + 修改了检测 contenttype 的机制,而 es-head5 没有手动设置 content-type,造成所有查询都报 406.  目前 es-head5 已经修复了这个 bug,但是官方 docker 镜像没有同步修复。建议不要安装 docker 版本 https://github.com/mobz/elasticsearch-head/issues/361

  4.zipkin 设置存储方式为 es 时,查看 docker 日志有报错,启动命令为:

  

docker run -d  -p 9411:9411 \
           -e "STORAGE_TYPE=elasticsearch" \
           -e "ES_HOSTS=http://x.x.x.x:9200" \
           -e "ES_INDEX=zipkin" \
           -e "ES_INDEX_SHARDS=1" \
           -e "ES_INDEX_REPLICAS=1" \
           openzipkin/zipkin

  发现只要加上 STORAGE_TYPE=elasticsearch,就在 zipkin 中无数据,去掉就可以正常写入数据

  改为 zipkin-slim 后正常写入 zipkin 和 es (上面命令最后一行改为 openzipkin/zipkin-slim)

  ps:zipkin-slim 只能连接 es,不能连接 mysql

 

启动

  

es启动:
docker run -e xpack.security.enabled=true -e xpack.security.transport.ssl.enabled=true -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -d -p 9200:9200 -p 9300:9300 -v /dockerdata/es/config/master.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /dockerdata/es/master:/usr/share/elasticsearch/data --name es-master elasticsearch:6.8.5

ps:master.yml
cluster.name: elasticsearch-cluster
node.name: master
network.bind_host: 0.0.0.0
network.publish_host: x.x.x.x
network.host: 0.0.0.0
http.port: 9200
transport.tcp.port: 9300
http.cors.enabled: true
http.cors.allow-origin: "*"
node.master: true
node.data: true
discovery.zen.ping.unicast.hosts: ["x.x.x.x:9300","x.x.x.x:9301"]
http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type

最后一行为添加xpack后运行head插件访问使用,访问时http://x.x.x.x:9100/?auth_user=elastic&auth_password=123456

head启动:
定位到head目录后 nohup npm run start &
            disown (不加disown的话,node进程会在shell断开后结束)
没有使用docker版本的原因是官方docker镜像没有同步git主版本,所以存在一个bug:所有接口调用都报406错误,原因是es新版更新了请求机制,需要指定content-type

zipkin启动:
docker run -d -p 9411:9411 \
-e "STORAGE_TYPE=elasticsearch" \
-e "ES_HOSTS=http://x.x.x.x:9200" \
-e "ES_INDEX=zipkin" \
-e "ES_INDEX_SHARDS=1" \
-e "ES_INDEX_REPLICAS=1" \
-e "ES_USERNAME=elastic" \
-e "ES_PASSWORD=123456" \
openzipkin/zipkin-slim


kibana启动:
//docker run --link es-master:elasticsearch -p 5601:5601 --name kibana -d kibana:6.8.5
docker run -l es-master:elasticsearch -p 5601:5601 -v /dockerdata/es/kibana/config/kibana.yml:/usr/share/kibana/config/kibana.yml -d kibana:6.8.5

ps:kibana.yml

server.name: kibana
server.host: "0"
elasticsearch.url: http://x.x.x.x:9200
xpack.monitoring.ui.container.elasticsearch.enabled: true
elasticsearch.username: "kibana"
elasticsearch.password: "123456"



修改xpack默认用户名密码:
docker exec -it ''containerid'' bash
进入 /usr/share/elasticsearch/bin 输入 elasticsearch-setup-passwords interactive
然后依次修改所有账户密码

 

异常处理:

  1. 启动容器时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen   解决:重启 docker 后再启动容器
  2. max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144] 解决:/etc/sysctl.conf   ,vm.max_map_count=262144  (大于等于此数字)
  3. 无法外网访问:修改 config/master.yml/slave.yml 中的 network.host: 0.0.0.0 (我有两个节点,所以修改两个配置文件;如果非 docker 环境,直接修改 elasticsearch.yml)
  4. 外网依然访问不了,可能是防火墙没有开放端口,防火墙和端口相关命令参看 https://blog.csdn.net/u011846257/article/details/54707864

 

ps: es 工具 https://github.com/elastic/curator

 

(centos7)安装elasticsearch6.4.2

(centos7)安装elasticsearch6.4.2

(centos7)安装elasticsearch6.4.2

环境

centos7 虚拟机

java 1.8

步骤

  1. 下载
    https://www.elastic.co/downloads/elasticsearch

  2. 解压安装
    解压后,移动到 /usr/local/elasticsearch (个人习惯)

  3. 修改配置
    /usr/local/elaticsearch/configelasticsearch.yml 文件中 可配置 访问权限,默认是只能在本机访问,其他机子都不能访问,就算开了防火墙都不行,里面可配置 port 默认是 9200。 如果只有本地可以访问,尝试修改配置文件 elasticsearch.yml 中network.host(注意配置文件格式不是以 # 开头的要空一格, : 后要空一格)
    network.host: 0.0.0.0

  4. 启动服务
    我的虚拟机报了一系列的错误,首先是,默认不允许使用root用户去启动,这个你可以有两种解决办法:1. 老实用其他非root 用户去启动es 2.修改配置,是其能使用root 启动
    其中错误的问题,详细的错误问题,可以查看这篇博客https://www.jianshu.com/p/4c6f9361565b
    基本上解决了我的问题。

    根据上面的博文,总结一下解决办法。
    ERROR: bootstrap checks failed

    1. vi /etc/security/limits.conf 
      添加如下内容:
       soft nofile 65536
       hard nofile 131072
       soft nproc 2048
       hard nproc 4096
      
    2. vi /etc/security/limits.d/90-nproc.conf 
      修改文件内容为
      soft nproc 2048
      
    3. vi /etc/sysctl.conf 
      添加下面配置:
      vm.max_map_count=655360
      
    4. 执行 sysctl -p

    5. 重启es

    max file descriptors [65535] for elasticsearch process likely too low, increase to at least [65536]

    1. 执行下面命令

      ulimit -n 65536
      

参考文献

https://www.jianshu.com/p/4c6f9361565b

本文同步分享在 博客"suveng"(CSDN)。
如有侵权,请联系 support@oschina.cn 删除。
本文参与“OSC源创计划”,欢迎正在阅读的你也加入,一起分享。

CentOS-Docker安装Elasticsearch(单点)

CentOS-Docker安装Elasticsearch(单点)

下载镜像

$ docker pull elasticsearch:7.6.0

运行镜像

$ docker run --restart=always --name elasticsearch -d -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:7.6.0

安装kibana

$ docker run --restart=unless-stopped --name kibana --link elasticsearch:elasticsearch -d -p 5601:5601 kibana:7.6.0

安装elasticsearch-head

$ docker run --restart=unless-stopped --name es-head --link elasticsearch:elasticsearch -d -p 9100:9100 mobz/elasticsearch-head:5

处理跨域

进入容器内部
$ docker exec -it elasticsearch bash

修改配置文件(追加设置)

$ vi config/elasticsearch.yml

http.cors.enabled: true
http.cors.allow-origin: "*"

 

安装分词插件(可选)

进入容器内部
$ docker exec -it elasticsearch bash

安装IK分词

$ ./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.6.0/elasticsearch-analysis-ik-7.6.0.zip

安装拼音分词

$ ./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-pinyin/releases/download/v7.6.0/elasticsearch-analysis-pinyin-7.6.0.zip

安装结巴分词(非官方支持)

参考: https://github.com/sing1ee/elasticsearch-jieba-plugin

 

退出容器,重启es

$ docker restart elasticsearch

 

ES测试地址

http://localhost:9200

watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=

 

es-head测试地址

http://localhost:9100

watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=

解决es-head查询报错

$ docker cp es-head:/usr/src/app/_site/vendor.js /home/

编辑vendor.js两处

6886行
contentType: "application/x-www-form-urlencoded
改成
contentType: "application/json;charset=UTF-8"

7574行
var inspectData = s.contentType === "application/x-www-form-urlencoded" &&
改成
var inspectData = s.contentType === "application/json;charset=UTF-8" &&

$ docker cp /home/vendor.js es-head:/usr/src/app/_site/

$ docker restart es-head

CentOS6.5安装elasticsearch-5.5.1以及elasticsearch-sql插件安装

CentOS6.5安装elasticsearch-5.5.1以及elasticsearch-sql插件安装

  • 首先下载

elasticsearch包下载地址:点击跳转官网

  • 上传到服务器并且解压.

  • 修改配置文件 elasticsearch.yml (其他根据需要配置)

#集群名称
cluster.name: myes
#节点名字
node.name: myes01
#数据位置
path.data: /usr/java/elk/elasticsearch-5.5.1/espath/data
#日志位置
path.logs: /usr/java/elk/elasticsearch-5.5.1/espath/logs
#本机IP
network.host: 192.168.80.123
#可以选取的节点(如果是多台就["lijie","lijie1","lijie2"])但是必须是基数个
discovery.zen.ping.unicast.hosts: ["lijie"]

#这两个配置是支持跨域访问用的
http.cors.allow-origin: "/.*/"
http.cors.enabled: true
  • 启动es
/usr/java/elk/elasticsearch-5.5.1/bin/elasticsearch -d

报错:

Elasticsearch requires at least Java 8 but your Java version from /usr/java/jdk1.7.0_79/bin/java does not meet this requirement

解决:
最低只支持JDK1.8,换成JDK8就行

  • 启动失败,查看日志,es和solr一样不允许用root用户启动,切换一个用户即可:
[WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [myes01] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
    at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:127) ~[elasticsearch-5.5.1.jar:5.5.1]
    at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:114) ~[elasticsearch-5.5.1.jar:5.5.1]
    at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:67) ~[elasticsearch-5.5.1.jar:5.5.1]
    at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:122) ~[elasticsearch-5.5.1.jar:5.5.1]
    at org.elasticsearch.cli.Command.main(Command.java:88) ~[elasticsearch-5.5.1.jar:5.5.1]
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:91) ~[elasticsearch-5.5.1.jar:5.5.1]
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:84) ~[elasticsearch-5.5.1.jar:5.5.1]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
    at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:106) ~[elasticsearch-5.5.1.jar:5.5.1]
    at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:194) ~[elasticsearch-5.5.1.jar:5.5.1]
    at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:351) ~[elasticsearch-5.5.1.jar:5.5.1]
    at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:123) ~[elasticsearch-5.5.1.jar:5.5.1]
  • 启动失败,查看日志:
java.lang.UnsupportedOperationException: seccomp unavailable: requires kernel 3.5+ with CONfig_SECCOMP and CONfig_SECCOMP_FILTER compiled in
    at org.elasticsearch.bootstrap.SystemCallFilter.linuxImpl(SystemCallFilter.java:350) ~[elasticsearch-5.5.1.jar:5.5.1]
    at org.elasticsearch.bootstrap.SystemCallFilter.init(SystemCallFilter.java:638) ~[elasticsearch-5.5.1.jar:5.5.1]
    at org.elasticsearch.bootstrap.JNANatives.tryInstallSystemCallFilter(JNANatives.java:245) [elasticsearch-5.5.1.jar:5.5.1]
    at org.elasticsearch.bootstrap.Natives.tryInstallSystemCallFilter(Natives.java:113) [elasticsearch-5.5.1.jar:5.5.1]
    at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:111) [elasticsearch-5.5.1.jar:5.5.1]
    at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:194) [elasticsearch-5.5.1.jar:5.5.1]
    at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:351) [elasticsearch-5.5.1.jar:5.5.1]
    at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:123) [elasticsearch-5.5.1.jar:5.5.1]
    at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:114) [elasticsearch-5.5.1.jar:5.5.1]
    at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:67) [elasticsearch-5.5.1.jar:5.5.1]
    at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:122) [elasticsearch-5.5.1.jar:5.5.1]
    at org.elasticsearch.cli.Command.main(Command.java:88) [elasticsearch-5.5.1.jar:5.5.1]
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:91) [elasticsearch-5.5.1.jar:5.5.1]
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:84) [elasticsearch-5.5.1.jar:5.5.1]

查看内核版本:

[root@lijie ~]# cat /proc/version
Linux version 2.6.32-431.el6.x86_64 (mockbuild@c6b8.bsys.dev.centos.org) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) ) #1 SMP Fri Nov 22 03:15:09 UTC 2013

问题:
linux的内核版本过低

  • 升级linux内核

首先导入publicKey:

rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org

然后执行

rpm -Uvh http://www.elrepo.org/elrepo-release-6-8.el6.elrepo.noarch.rpm

安装kmod-r8168

yum install -y kmod-r8168

然后:

yum --enablerepo=elrepo-kernel install kernel-lt -y

然后:

vi /etc/grub.conf
#将第一个default的值改为0  -> default=0

然后重启:

reboot

重启后再查看内核版本:

[root@lijie ~]# cat /proc/version
Linux version 3.10.107-1.el6.elrepo.x86_64 (mockbuild@Build64R6) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC) ) #1 SMP Tue Jun 27 10:57:54 EDT 2017

重新启动,还是报错,查看日志文件:

错误内容如下:

bootstrap checks Failed
[1]: max file descriptors [4096] for elasticsearch process is too low,increase to at least [65536]
[2]: max number of threads [1024] for user [hadoop] is too low,increase to at least [2048]
[3]: max virtual memory areas vm.max_map_count [65530] is too low,increase to at least [262144]
  • 三个错误的解决方案:

其中[1]: max file descriptors [4096] for elasticsearch process is too low,increase to at least [65536]
解决方法:

#用root用户执行
vi /etc/security/limits.conf 

#添加
* soft    nofile  65536
* hard    nofile  131072

其中[2]: max number of threads [1024] for user [hadoop] is too low,increase to at least [2048]
解决方法:

#用root用户执行
vi /etc/security/limits.d/90-nproc.conf 

#修改
*          soft    nproc     10242048

其中[3]: max virtual memory areas vm.max_map_count [65530] is too low,increase to at least [262144]
解决方法:

#用root用户执行
vi /etc/sysctl.conf 

#添加一条配置:
vm.max_map_count=262144

#然后执行:
sysctl -p

解决上面的错误之后重启elasticsearch
/usr/java/elk/elasticsearch-5.5.1/bin/elasticsearch -d

注意事项: 用root用户做完上面的修改后再切回普通用户,这样上面的配置才能生效,不然还是会报错

查看日志:

[2017-08-10T13:38:32,471][INFO ][o.e.t.TransportService ] [myes01] publish_address {192.168.80.123:9300},bound_addresses {192.168.80.123:9300}
[2017-08-10T13:38:32,574][INFO ][o.e.b.BootstrapChecks ] [myes01] bound or publishing to a non-loopback or non-link-local address,enforcing bootstrap checks
[2017-08-10T13:38:33,245][WARN ][o.e.m.j.JvmGcMonitorService] [myes01] [gc][2] overhead,spent [625ms] collecting in the last [1s]
[2017-08-10T13:38:36,327][INFO ][o.e.c.s.ClusterService ] [myes01] new_master {myes01}{4B84juCUSKqRiddNlMOuCw}{sBOoIcHPTZmCt5O3olccrg}{192.168.80.123}{192.168.80.123:9300},reason: zen-disco-elected-as-master ([0] nodes joined)
[2017-08-10T13:38:36,444][INFO ][o.e.g.GatewayService ] [myes01] recovered [0] indices into cluster_state
[2017-08-10T13:38:36,446][INFO ][o.e.h.n.Netty4HttpServerTransport] [myes01] publish_address {192.168.80.123:9200},bound_addresses {192.168.80.123:9200}
[2017-08-10T13:38:36,446][INFO ][o.e.n.Node ] [myes01] started

终于启动成功!

  • 查看http://192.168.80.123:9200/

返回:

{
  "name" : "myes01","cluster_name" : "myes","cluster_uuid" : "N74wJcOMTAGkyANd9_qpvA","version" : { "number" : "5.5.1","build_hash" : "19c13d0","build_date" : "2017-07-18T20:44:24.823Z","build_snapshot" : false,"lucene_version" : "6.6.0" },"tagline" : "You KNow,for Search" }

安装特别简单,就是新版本的安装可能会遇到上述的问题.

安装sql插件(详见 :https://github.com/NLPchina/elasticsearch-sql/):

[hadoop@lijie elasticsearch-5.5.1]$ ./bin/elasticsearch-plugin install https://github.com/NLPchina/elasticsearch-sql/releases/download/5.5.1.0/elasticsearch-sql-5.5.1.0.zip

[hadoop@lijie site-server]$ wget https://github.com/NLPchina/elasticsearch-sql/releases/download/5.4.1.0/es-sql-site-standalone.zip

[hadoop@lijie site-server]$ unzip es-sql-site-standalone.zip

下载nodejs(http://nodejs.cn/download/):

上传解压:
[root@lijie nodejs]# xz -d node-v8.7.0-linux-x64.tar.xz
[root@lijie nodejs]# tar -xvf node-v8.7.0-linux-x64.tar 

然后创建软链接:
[root@lijie node-v8.7.0-linux-x64]# ln -s /usr/nodejs/node-v8.7.0-linux-x64/bin/npm /usr/local/bin/ 


[root@lijie node-v8.7.0-linux-x64]# ln -s /usr/nodejs/node-v8.7.0-linux-x64/bin/node /usr/local/bin/ 

[root@lijie node-v8.7.0-linux-x64]# node -v
v8.7.0

在site-server目录下:

[hadoop@lijie site-server]$ npm install express --save

[hadoop@lijie site-server]$ node node-server.js

最后重启es并且查询:

#访问
http://192.168.80.123:9200/_sql?sql=select * from school where score > 90

centos7 elasticsearch集群安装

centos7 elasticsearch集群安装

1.安装Java环境

tar -zxvf jdk-8u60-linux-x64.tar.gz -C /usr/local/
vim /etc/profile
export JAVA_HOME=/usr/local/jdk1.8.0_60 export PATH=$JAVA_HOME/bin:$PATH export CLAsspATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
source /etc/profile
java -version

2.下载安装包

https://www.elastic.co/cn/downloads/past-releases#elasticsearch
elasticsearch-7.6.1-linux-x86_64.tar.gz

3.修改系统参数,内核参数

vim /etc/security/limits.conf
`

  • soft nofile 65536
  • hard nofile 131072
  • soft nproc 65536
  • hard nproc 131072`

vim /etc/sysctl.conf
echo "vm.max_map_count=262144" >> /etc/sysctl.conf
加载系统参数
sysctl -p

4.创建elasticsearch 安装目录 添加用户 配置目录权限

mkdir -pv /data/es
mkdir -pv /data/es/data
mkdir -pv /data/es/logs

创建用户组
groupadd es
创建用户 es
useradd es -g es -p 123456
授权
chown -R es.es /data/es

5.开始安装(单机配置)

上传安装包到/opt下
tar -zxvf elasticsearch-7.6.1-linux-x86_64.tar.gz -C /data/es
编辑elasticsearch.yml
vim /data/es/elasticsearch-7.6.1/config/elasticsearch.yml
'设定es集群名称 【注】集群
cluster.name: my-es
设置es当前节点名称,用于区分不同节点 【注】集群
node.name: master
修改数据目录
path.data: /data/es/data/
日志目录位置
path.logs: /data/es/logs/
监听访问地址为任意网段
network.host: 0.0.0.0
服务监听端口
http.port: 9200'
配置jvm参数
按照夫妻配置调整Java虚拟机内存,在config\jvm.options配置文件中调整内存大小 。其中,xms参数表示堆空间的初始值,Xmx参数表示堆空间的最大值,应该把最小和最大JVM堆设置成相同的值
vim /data/es/elasticsearch-7.6.1/config/jvm.options


启动es
【注】启动es需要普通用户
su - es
进入到启动文件目录下
cd /data/es/elasticsearch-7.6.1/bin/
启动
nohup ./elasticsearch &
后台运行
./bin/elasticsearch –d
以root用户查看9200端口是否开启


浏览器访问 需要将CentOS防火墙关闭或者在防火墙开启9200端口

6.集群配置

拷贝/data/es目录下的elasticsearch-7.6.1安装包2个(【注】单台服务器集群)
cp -r elasticsearch-7.6.1 elasticsearch-7.6.1-01
cp -r elasticsearch-7.6.1 elasticsearch-7.6.1-02
修改elasticsearch.yml 01配置文件
集群名称
cluster.name: lg-es
节点名称
node.name: master
是不是有资格主节点
node.master: true
是否存储数据
node.data: true
最大集群节点数
node.max_local_storage_nodes: 2
ip地址
network.host: 0.0.0.0
外部访问端口
http.port: 9200
内部节点之间沟通端口
transport.tcp.port: 9300
es7.x 之后新增的配置,节点发现
discovery.seed_hosts: ["172.16.80.25:9300", "172.16.80.26:9300"]
es7.x 之后新增的配置,初始化一个新的集群时需要此配置来选举master
cluster.initial_master_nodes: ["master", "node1"]
数据和存储路径
path.data: /data/es/data
path.logs: /data/es/logs

修改elasticsearch.yml 02配置文件
集群名称
cluster.name: lg-es
节点名称
node.name: node1
是不是有资格主节点
node.master: true
是否存储数据
node.data: true
最大集群节点数
node.max_local_storage_nodes: 2
ip地址
network.host: 0.0.0.0
外部访问端口
http.port: 9200
内部节点之间沟通端口
transport.tcp.port: 9300
es7.x 之后新增的配置,节点发现
discovery.seed_hosts: ["172.16.80.25:9300", "172.16.80.26:9300"]
es7.x 之后新增的配置,初始化一个新的集群时需要此配置来选举master
cluster.initial_master_nodes: ["master", "node1"]
数据和存储路径
path.data: /data/es/data
path.logs: /data/es/logs

每个节点配置jvm参数
vim /data/es/elasticsearch-7.6.1/config/jvm.options


启动es
【注】启动es需要普通用户
su - es
进入到启动文件目录下
cd /data/es/elasticsearch-7.6.1/bin/
启动
nohup ./elasticsearch &
后台运行
./bin/elasticsearch –d
启动成功访问
访问集群状态信息 http://172.16.80.25:9200/_cat/health?v 成功

关于centos7+docker+elasticsearch 安装记录 + 踩坑centos7上安装docker的介绍现已完结,谢谢您的耐心阅读,如果想了解更多关于(centos7)安装elasticsearch6.4.2、CentOS-Docker安装Elasticsearch(单点)、CentOS6.5安装elasticsearch-5.5.1以及elasticsearch-sql插件安装、centos7 elasticsearch集群安装的相关知识,请在本站寻找。

本文标签: