WD=/opt/opensearch mkdir -p $WD/{setup,data} cd $WD/setup cat << 'EOF' >docker-compose.yaml version: '3.7' services: opensearch-node1: image: opensearchproject/opensearch:${STACK_VER} container_name: opensearch-node1 networks: - opensearch-net ports: - 9200:9200 - 9600:9600 # required for Performance Analyzer volumes: # - type: volume # source: opensearch-data1 # target: /usr/share/opensearch/data #Copy from container - type: bind source: /opt/opensearch/data/ target: /usr/share/opensearch/data - type: bind source: /opt/opensearch/conf/opensearch.yml target: /usr/share/opensearch/config/opensearch.yml ulimits: memlock: soft: -1 hard: -1 nofile: soft: 65536 # maximum number of open files for the OpenSearch user, set to at least 65536 on modern systems hard: 65536 environment: - cluster.name=opensearch-cluster - node.name=opensearch-node1 - bootstrap.memory_lock=true # along with the memlock settings below, disables swapping - "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" # minimum and maximum Java heap size, recommend setting both to 50% of system RAM - "DISABLE_INSTALL_DEMO_CONFIG=true" # disables execution of install_demo_configuration.sh bundled with security plugin, which installs demo certificates and security configurations to OpenSearch - "DISABLE_SECURITY_PLUGIN=true" # disables security plugin entirely in OpenSearch by setting plugins.security.disabled: true in opensearch.yml - "discovery.type=single-node" # disables bootstrap checks that are enabled when network.host is set to a non-loopback address - 'TZ=${TZ}' - "indices.query.bool.max_clause_count=250000" opensearch-dashboards: image: opensearchproject/opensearch-dashboards:${STACK_VER} container_name: opensearch-dashboards networks: - opensearch-net ports: - 5601:5601 expose: - "5601" environment: - 'OPENSEARCH_HOSTS=["http://opensearch-node1:9200"]' - "DISABLE_SECURITY_DASHBOARDS_PLUGIN=true" # disables security dashboards plugin in OpenSearch Dashboards - 'TZ=${TZ}' #volumes: # opensearch-data1: networks: opensearch-net: EOF chmod +x docker-compose.yaml
cat <<'EOF'>opensearch.yml cluster.name: docker-cluster # Bind to all interfaces because we don't know what IP address Docker will assign to us. network.host: 0.0.0.0 # # minimum_master_nodes need to be explicitly set when bound on a public IP # # set to 1 to allow single node clusters # discovery.zen.minimum_master_nodes: 1 # Setting network.host to a non-loopback address enables the annoying bootstrap checks. "Single-node" mode disables them again. # discovery.type: single-node #http.cors.enabled : true #http.cors.allow-origin: "*" #http.cors.allow-methods: OPTIONS,HEAD,GET,POST,PUT,DELETE #http.cors.allow-headers: X-Requested-With,X-Auth-Token,Content-Type,Content-Length EOF chmod 777 opensearch.yml
cd $WD/setup cat << 'EOF'>.env TZ=America/Whitehorse STACK_VER=1.3.0 EOF chmod +x .env
WD=/opt/opensearch/setup cat << EOF >$WD/opensearch.service.setup.sh cat << EOL >/lib/systemd/system/opensearch.service [Unit] Description=opensearch_Docker Requires=docker.service network-online.target [Service] WorkingDirectory=/opt/opensearch/setup ExecStartPre=docker-compose pull Restart=on-abnormal ExecStart=/usr/bin/docker-compose --project-name opensearch --project-directory /opt/opensearch/setup -f /opt/opensearch/setup/docker-compose.yaml up --force-recreate ExecStop=/usr/bin/docker-compose --project-name opensearch --project-directory /opt/opensearch/setup -f /opt/opensearch/setup/docker-compose.yaml stop [Install] WantedBy=multi-user.target EOL systemctl enable opensearch systemctl restart opensearch systemctl status opensearch EOF chmod +x $WD/opensearch.service.setup.sh $WD/opensearch.service.setup.sh