Skip to content

At setup:install …OpenSearch. No alive nodes found in your cluster

The stack is ok.
LAMP and Opensearch are running well.

Below a ping to the opensearch host:

root@HPCOREI5:~/magento# ping 172.23.0.2
PING 172.23.0.2 (172.23.0.2) 56(84) bytes of data.
64 bytes from 172.23.0.2: icmp_seq=1 ttl=64 time=1.57 ms
64 bytes from 172.23.0.2: icmp_seq=2 ttl=64 time=0.091 ms
64 bytes from 172.23.0.2: icmp_seq=3 ttl=64 time=0.066 ms

but, at the magento setup:install step

In SearchConfig.php line 81:
Could not validate a connection to the OpenSearch. No alive nodes found in your cluster

here’s my docker-compose.yaml file:

version: '3.8'

services:
   opensearch1:
    image: opensearchproject/opensearch:2.12.0
    container_name: opensearch1
    environment:
      - discovery.type=single-node
      - cluster.name=opensearch-cluster 
      - plugins.security.disabled=false
      - node.name=opensearch1 
      - discovery.seed_hosts=opensearch1 
      - bootstrap.memory_lock=true 
      - "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" 
      - OPENSEARCH_INITIAL_ADMIN_PASSWORD=${OPENSEARCH_INITIAL_ADMIN_PASSWORD}
    ulimits:
      memlock:
        soft: -1 
        hard: -1
      nofile:
        soft: 65536 
        hard: 65536
    volumes:
      - ./certs:/usr/share/opensearch/config/certs
      - opensearch_logs:/usr/share/opensearch/logs/opensearch-cluster.log
      - opensearch_data1:/usr/share/opensearch/data # Creates volume called opensearch_data1 and mounts it to the container
    ports:
      - 9200:9200
      - 9600:9600
    networks:
      - magento_network 

  opensearch-dashboards:
    image: opensearchproject/opensearch-dashboards:2.12.0 # Make sure the version of opensearch-dashboards matches the version of opensearch installed on other nodes
    container_name: opensearch-dashboards
    ports:
      - 5601:5601 
    expose:
    - "5601" 
    environment:
      OPENSEARCH_HOSTS: '["https://opensearch1:9200"]' 
    networks:
      - magento_network
  php-apache:
    image: webdevops/php-apache:8.2
    container_name: php-apache
    depends_on:
      - mysql
      - opensearch1
    ports:
      - "8080:80"
    volumes:
      - ./:/app
    environment:
      - WEB_DOCUMENT_ROOT=/app/pub
      - PHP_DISPLAY_ERRORS=1
      - PHP_ERROR_REPORTING=E_ALL
      - PHP_MEMORY_LIMIT=512M
      - MYSQL_HOST=mysql
      - MYSQL_PORT=3306
      - MYSQL_DATABASE=magento2
      - MYSQL_USER=magento2
      - MYSQL_PASSWORD=magento2
    networks:
      - magento_network

  mysql:
    image: mysql:8.0
    container_name: magento_mysql
    environment:
      MYSQL_ROOT_PASSWORD: magento2
      MYSQL_DATABASE: magento2
      MYSQL_USER: magento2
      MYSQL_PASSWORD: magento2
    ports:
      - "3306:3306"
    volumes:
      - mysql_data:/var/lib/mysql
    networks:
      - magento_network

volumes:
  opensearch_data1:
  mysql_data:

networks:
  magento_network:
    driver: bridge

And here’s is my env.php file:

'opensearch' => [
        'hostname' => 'opensearch1',
        'port' => '9200',
        'index_prefix' => '',
        'enable_auth' => '1',
        'username' => 'admin',
        'password' => '@Admin123root',
        'timeout' => '15',
        'ssl' => '0',
        'ssl_verify' => '0'
    ],

Any insights will be appreciate.