docker-compose部署单节点elasticsearch

docker-compose部署单节点elasticsearch,第1张

docker-compose部署单节点elasticsearch

1、编写docker-compose.yml文件

version: '3'
services:
  elasticsearch:
    image:  elasticsearch:6.8.8
    container_name: elasticsearch
    restart: always
    volumes:
      - ./data:/usr/share/elasticsearch/data:rw
      - ./conf/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
      - .//conf/jvm.options:/usr/share/elasticsearch/config/jvm.options
      - ./logs:/user/share/elasticsearch/logs:rw
    ports:
        - "9200:9200"
        - "9300:9300"
    environment:
        - discovery.type=single-node
        - TZ=Asia/Shanghai
  es-head:
    image: tobias74/elasticsearch-head:6
    container_name: es-head
    restart: always
    ports:
      - "9000:9100"

2、编写conf/elasticsearch.yml

bootstrap.memory_lock: false
cluster.name: "elasticSearch"
node.name: es
node.master: true
node.data: true
network.host: 0.0.0.0
http.port: 9200
path.logs: /usr/share/elasticsearch/logs
http.cors.enabled: true
http.cors.allow-origin: "*"
xpack.security.audit.enabled: true

3、编写 conf/jvm.options

-Djna.nosys=true

# turn off a JDK optimization that throws away stack traces for common
# exceptions because stack traces are important for debugging
-XX:-OmitStackTraceInFastThrow

# flags to configure Netty
-Dio.netty.noUnsafe=true
-Dio.netty.noKeySetOptimization=true
-Dio.netty.recycler.maxCapacityPerThread=0

# log4j 2
-Dlog4j.shutdownHookEnabled=false
-Dlog4j2.disable.jmx=true

-Djava.io.tmpdir=${ES_TMPDIR}

## heap dumps

# generate a heap dump when an allocation from the Java heap fails
# heap dumps are created in the working directory of the JVM
-XX:+HeapDumponOutOfMemoryError

# specify an alternative path for heap dumps; ensure the directory exists and
# has sufficient space
-XX:HeapDumpPath=data

# specify an alternative path for JVM fatal error logs
-XX:ErrorFile=logs/hs_err_pid%p.log

## JDK 8 GC logging

8:-XX:+PrintGCDetails
8:-XX:+PrintGCDateStamps
8:-XX:+PrintTenuringDistribution
8:-XX:+PrintGCApplicationStoppedTime
8:-Xloggc:logs/gc.log
8:-XX:+UseGCLogFileRotation
8:-XX:NumberOfGCLogFiles=32
8:-XX:GCLogFileSize=64m

# JDK 9+ GC logging
9-:-Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m
# due to internationalization enhancements in JDK 9 Elasticsearch need to set the provider to COMPAT otherwise
# time/date parsing will break in an incompatible way for some date patterns and locals
9-:-Djava.locale.providers=COMPAT

# temporary workaround for C2 bug with JDK 10 on hardware with AVX-512
10-:-XX:UseAVX=2

4、data目录设置普通权限

[root@ip-172-93-1-52 elasticsearch]# chown -R 744 data
[root@ip-172-93-1-52 elasticsearch]# chown -R  centos.centos data```

5、启动elasticsearch
```bash
[root@ip-172-93-1-52 elasticsearch]# docker-compose up -d
Creating network "elasticsearch_default" with the default driver
Creating es-head       ... done
Creating elasticsearch ... done

6、查看elasticsearch容器运行情况

[root@ip-172-93-1-52 elasticsearch]# docker-compose ps
    Name                   Command               State                       Ports                     
-------------------------------------------------------------------------------------------------------
elasticsearch   /usr/local/bin/docker-entr ...   Up      0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp
es-head         /bin/sh -c grunt server          Up      0.0.0.0:9000->9100/tcp

[root@ip-172-93-1-52 elasticsearch]# docker ps
ConTAINER ID   IMAGE                           COMMAND                  CREATED         STATUS         PORTS                                            NAMES
f9f4d28034e0   elasticsearch:6.8.8             "/usr/local/bin/dock…"   4 minutes ago   Up 4 minutes   0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp   elasticsearch
ff49ba66b4c3   tobias74/elasticsearch-head:6   "/bin/sh -c 'grunt s…"   4 minutes ago   Up 4 minutes   0.0.0.0:9000->9100/tcp                           es-head

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5698977.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存