docker compose部署opensearch集群

docker compose 配置

假设有两台电脑

A电脑的ip为192.168.1.100

B电脑的ip为192.168.1.103

A电脑的docker compose 配置

bash 复制代码
version: '3'

services:
      
  opensearch:
    image: opensearchproject/opensearch:2.1.0
    container_name: opensearch-node-1
    environment:
      - cluster.name=opensearch-cluster
      - node.name=opensearch-node-1
      - network.publish_host=192.168.1.100
      - discovery.seed_hosts=192.168.1.100,192.168.1.103
      - cluster.initial_cluster_manager_nodes=192.168.1.100,192.168.1.103
      - bootstrap.memory_lock=true
      - "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m"
      - DISABLE_INSTALL_DEMO_CONFIG=true
      - DISABLE_SECURITY_PLUGIN=true
    ulimits:
      memlock:
        soft: -1
        hard: -1
      nofile:
        soft: 65536
        hard: 65536
    ports:
      - "9200:9200"
      - "9300:9300"
    volumes:
      - opensearch-data:/usr/share/opensearch/data
      - opensearch-config:/usr/share/opensearch/config

volumes:
  opensearch-data:
  opensearch-config:

B电脑的docker compose 配置

bash 复制代码
version: '3'

services:
      
  opensearch:
    image: opensearchproject/opensearch:2.1.0
    container_name: opensearch-node-3
    environment:
      - cluster.name=opensearch-cluster
      - node.name=opensearch-node-3
      - network.publish_host=192.168.1.103
      - discovery.seed_hosts=192.168.1.100,192.168.1.103
      - cluster.initial_cluster_manager_nodes=192.168.1.100,192.168.1.103
      - bootstrap.memory_lock=true
      - "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m"
      - DISABLE_INSTALL_DEMO_CONFIG=true
      - DISABLE_SECURITY_PLUGIN=true
    ulimits:
      memlock:
        soft: -1
        hard: -1
      nofile:
        soft: 65536
        hard: 65536
    ports:
      - "9200:9200"
      - "9300:9300"
    volumes:
      - opensearch-data:/usr/share/opensearch/data
      - opensearch-config:/usr/share/opensearch/config

volumes:
  opensearch-data:
  opensearch-config:

设置内存

临时

bash 复制代码
sysctl -w vm.max_map_count=262144

永久

Disable memory paging and swapping performance on the host to improve performance.

禁用主机上的内存分页和交换性能以提高性能。

ps:这个看情况,内存大的话,也可以关掉

bash 复制代码
sudo swapoff -a

Increase the number of memory maps available to OpenSearch.

增加OpenSearch可用的内存映射数量。

bash 复制代码
# Edit the sysctl config file
sudo vi /etc/sysctl.conf

# Add a line to define the desired value
# or change the value if the key exists,
# and then save your changes.
vm.max_map_count=262144

# Reload the kernel parameters using sysctl
sudo sysctl -p

# Verify that the change was applied by checking the value
cat /proc/sys/vm/max_map_count

两边同时启动

bash 复制代码
docker compose up -d

nginx设置集群

bash 复制代码
    server {
        listen       9200;
        location / {
            proxy_pass http://opensearch/;
			proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header X-Forwarded-Port $server_port;
            proxy_set_header X-Forwarded-Host $http_host;

        }
    }
	upstream opensearch {
		server 192.168.1.100:9200;
		server 192.168.1.103:9200;
	}

参考

https://www.cnblogs.com/lz0925/p/12011026.html

https://opensearch.org/docs/latest/install-and-configure/install-opensearch/docker/

相关推荐
意疏12 小时前
【Linux 篇】Docker 的容器之海与镜像之岛:于 Linux 系统内探索容器化的奇妙航行
linux·docker
墨鸦_Cormorant12 小时前
使用docker快速部署Nginx、Redis、MySQL、Tomcat以及制作镜像
redis·nginx·docker
Code_Artist12 小时前
Docker镜像加速解决方案:配置HTTP代理,让Docker学会科学上网!
docker·云原生·容器
wanmei00214 小时前
Dockerfile复制目录进入镜像里
docker
inter_peng14 小时前
[Docker-显示所有容器IP] 显示docker-compose.yml中所有容器IP的方法
tcp/ip·docker·eureka
Linux运维日记14 小时前
k8s1.31版本最新版本集群使用容器镜像仓库Harbor
linux·docker·云原生·容器·kubernetes
一名路过的小码农16 小时前
ceph 18.2.4二次开发,docker镜像制作
ceph·docker·容器
xiangshangdemayi18 小时前
Windows环境GeoServer打包Docker极速入门
windows·docker·容器·geoserver·打包·数据挂载
程序员JerrySUN19 小时前
熟悉的 Docker,陌生的 Podman
linux·docker·容器·系统架构·podman
gobeyye20 小时前
Docker 用法详解
运维·docker·容器