docker安装ElasticSearch集群

2023-05-17 11:54:19阅读 6评论 0

机器基础设置

#修改文件
sudo vim /etc/sysctl.conf

#添加参数
vm.max_map_count = 262144

#重新加载/etc/sysctl.conf配置
sysctl -p

目录准备

├── config
│   ├── es00
│   │   └── elasticsearch.yml
│   ├── es01
│   │   └── elasticsearch.yml
│   ├── es02
│   │   └── elasticsearch.yml
│   ├── es03
│   │   └── elasticsearch.yml
│   ├── es04
│   │   └── elasticsearch.yml
│   └── es05
│       └── elasticsearch.yml
├── data
│   ├── es00
│   ├── es01
│   ├── es02
│   ├── es03
│   ├── es04
│   └── es05
├── docker-compose.yml
└── logs
│   ├── es00
│   ├── es01
│   ├── es02
│   ├── es03
│   ├── es04
│   └── es05

docker-compose.yml内容

version: '2'
services:
  cerebro:
    image: lmenezes/cerebro:0.8.4
    container_name: cerebro
    ports:
      - "9000:9000"
    command:
      - -Dhosts.0.host=http://es01:9201
    networks:
      - esnet
  kibana:
    image: kibana:7.3.0
    container_name: kibana
    environment:
      - ELASTICSEARCH_HOSTS=http://es01:9201
      # 需要将Kibana配置文件中的小写转换成大写,然后这个才能用于变量,才能被设置到
      - I18N_LOCALE=zh-CN
      - xpack.monitoring.ui.container.elasticsearch.enabled=false
    ports:
      - 5601:5601
    networks:
      - esnet
  es00:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.3.0
    container_name: es00
    restart: always
    environment:
      - "ES_JAVA_OPTS=-Xms256m -Xmx256m"
      - "ES_JAVA_OPTS=-Des.insecure.allow.root=true"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - ./data/es00:/usr/share/elasticsearch/data
      - ./config/es00/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
      - ./logs/es00:/usr/share/elasticsearch/logs
    ports:
      - 9200:9200
      - 9300:9300
    networks:
      - esnet
  es01:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.3.0
    container_name: es01
    restart: always
    environment:
      - "ES_JAVA_OPTS=-Xms256m -Xmx256m"
      - "ES_JAVA_OPTS=-Des.insecure.allow.root=true"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - ./data/es01:/usr/share/elasticsearch/data
      - ./config/es01/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
      - ./logs/es01:/usr/share/elasticsearch/logs
    ports:
      - 9201:9201
      - 9301:9301
    networks:
      - esnet
  es02:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.3.0
    container_name: es02
    restart: always
    environment:
      - "ES_JAVA_OPTS=-Xms256m -Xmx256m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - ./data/es02:/usr/share/elasticsearch/data
      - ./config/es02/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
      - ./logs/es02:/usr/share/elasticsearch/logs
    depends_on:
      - es01
    networks:
      - esnet
    ports:
      - 9202:9202
      - 9302:9302
  es03:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.3.0
    container_name: es03
    restart: always
    environment:
      - "ES_JAVA_OPTS=-Xms256m -Xmx256m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - ./data/es03:/usr/share/elasticsearch/data
      - ./config/es03/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
      - ./logs/es03:/usr/share/elasticsearch/logs
    depends_on:
      - es01
    networks:
      - esnet
    ports:
      - 9203:9203
      - 9303:9303
  es04:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.3.0
    container_name: es04
    restart: always
    environment:
      - "ES_JAVA_OPTS=-Xms256m -Xmx256m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - ./data/es04:/usr/share/elasticsearch/data
      - ./config/es04/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
      - ./logs/es04:/usr/share/elasticsearch/logs
    depends_on:
      - es01
    networks:
      - esnet
    ports:
      - 9204:9204
      - 9304:9304
  es05:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.3.0
    container_name: es05
    restart: always
    environment:
      - "ES_JAVA_OPTS=-Xms256m -Xmx256m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - ./data/es05:/usr/share/elasticsearch/data
      - ./config/es05/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
      - ./logs/es05:/usr/share/elasticsearch/logs
    depends_on:
      - es01
    networks:
      - esnet
    ports:
      - 9205:9205
      - 9305:9305

networks:
  esnet:

配置文件elasticsearch.yml内容

config/es00/elasticsearch.yml

cluster.name: es-cluster
node.name: es00
node.master: true
node.data: false
path.data: /usr/share/elasticsearch/data
path.logs: /usr/share/elasticsearch/logs
bootstrap.memory_lock: true
network.host: 0.0.0.0
http.port: 9200
# transport.tcp.port: [9300,9302,9303,9304,9305]
# discovery.zen.ping.unicast.hosts: ["es01","es02","es03","es04","es05"]
cluster.initial_master_nodes: ["es00","es01"]
discovery.seed_hosts: ["es00","es01"]

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

xpack.security.enabled: false
xpack.security.transport.ssl.enabled: false

config/es01/elasticsearch.yml

cluster.name: es-cluster
node.name: es01
node.master: true
node.data: false
path.data: /usr/share/elasticsearch/data
path.logs: /usr/share/elasticsearch/logs
bootstrap.memory_lock: true
network.host: 0.0.0.0
http.port: 9201
# transport.tcp.port: [9300,9302,9303,9304,9305]
# discovery.zen.ping.unicast.hosts: ["es01","es02","es03","es04","es05"]
cluster.initial_master_nodes: ["es00","es01"]
discovery.seed_hosts: ["es00","es01"]

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

xpack.security.enabled: false
xpack.security.transport.ssl.enabled: false

config/es02/elasticsearch.yml

cluster.name: es-cluster
node.name: es02
node.master: false
node.data: true
path.data: /usr/share/elasticsearch/data
path.logs: /usr/share/elasticsearch/logs
bootstrap.memory_lock: true
network.host: 0.0.0.0
http.port: 9202
# transport.tcp.port: [9300,9302,9303,9304,9305]
# discovery.zen.ping.unicast.hosts: ["es01","es02","es03","es04","es05"]
cluster.initial_master_nodes: ["es00","es01"]
discovery.seed_hosts: ["es00","es01"]

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

xpack.security.enabled: false
xpack.security.transport.ssl.enabled: false

config/es03/elasticsearch.yml

cluster.name: es-cluster
node.name: es03
node.master: false
node.data: true
path.data: /usr/share/elasticsearch/data
path.logs: /usr/share/elasticsearch/logs
bootstrap.memory_lock: true
network.host: 0.0.0.0
http.port: 9203
# transport.tcp.port: [9300,9302,9303,9304,9305]
# discovery.zen.ping.unicast.hosts: ["es01","es02","es03","es04","es05"]
cluster.initial_master_nodes: ["es00","es01"]
discovery.seed_hosts: ["es00","es01"]

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

xpack.security.enabled: false
xpack.security.transport.ssl.enabled: false

config/es04/elasticsearch.yml

cluster.name: es-cluster
node.name: es04
node.master: false
node.data: true
path.data: /usr/share/elasticsearch/data
path.logs: /usr/share/elasticsearch/logs
bootstrap.memory_lock: true
network.host: 0.0.0.0
http.port: 9204
# transport.tcp.port: [9300,9302,9303,9304,9305]
# discovery.zen.ping.unicast.hosts: ["es01","es02","es03","es04","es05"]
cluster.initial_master_nodes: ["es00","es01"]
discovery.seed_hosts: ["es00","es01"]

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

xpack.security.enabled: false
xpack.security.transport.ssl.enabled: false

config/es05/elasticsearch.yml

cluster.name: es-cluster
node.name: es05
node.master: false
node.data: true
path.data: /usr/share/elasticsearch/data
path.logs: /usr/share/elasticsearch/logs
bootstrap.memory_lock: true
network.host: 0.0.0.0
http.port: 9205
# transport.tcp.port: [9300,9302,9303,9304,9305]
# discovery.zen.ping.unicast.hosts: ["es01","es02","es03","es04","es05"]
cluster.initial_master_nodes: ["es00","es01"]
discovery.seed_hosts: ["es00","es01"]

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

xpack.security.enabled: false
xpack.security.transport.ssl.enabled: false

还没有评论,来说两句吧