0

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.

1 Answer 1

0

The error message "No alive nodes found in your cluster" typically indicates that Magento is unable to connect to your OpenSearch instance. Given your setup, there are a few areas to check and potentially adjust:

  1. Check OpenSearch Cluster Health: Ensure your OpenSearch cluster is up and running correctly. You can check the cluster health by running:

    curl -u admin:@Admin123root -XGET 'http://172.23.0.2:9200/_cluster/health?pretty'
    
  2. Verify OpenSearch Configuration: Ensure that your OpenSearch container is configured to accept connections and that it is correctly binding to the network interface. Since you're using Docker, make sure that the network settings are correct and that OpenSearch is reachable from the PHP container.

  3. Adjust Environment Variables: The discovery.seed_hosts and other configuration parameters might need to be adjusted. Since you are using a single-node setup, ensure the discovery.type is set to single-node.

  4. Network Configuration: Make sure that the php-apache container can resolve and reach opensearch1 on port 9200. You can test this by executing a command inside the php-apache container:

    docker exec -it php-apache bash
    curl -u admin:@Admin123root -XGET 'http://opensearch1:9200/_cluster/health?pretty'
    
  5. SSL Configuration: If you have SSL enabled in your OpenSearch setup, make sure your Magento configuration matches. For now, it looks like SSL is disabled ('ssl' => '0', 'ssl_verify' => '0'). Double-check that this is the case for your OpenSearch instance.

  6. OpenSearch Logs: Check the logs of your OpenSearch container to see if there are any errors or warnings:

    docker logs opensearch1
    
  7. Magento Configuration: Verify that your env.php configuration for OpenSearch is correct. Specifically, check the credentials and connection settings.

Here’s a consolidated approach:

  1. Check OpenSearch Availability: Ensure that OpenSearch is accessible from the PHP container:

    docker exec -it php-apache bash
    curl -u admin:@Admin123root -XGET 'http://opensearch1:9200/_cluster/health?pretty'
    
  2. Review OpenSearch Configuration: Ensure your docker-compose.yaml for OpenSearch is correct:

    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=@Admin123root
      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
      ports:
        - 9200:9200
        - 9600:9600
      networks:
        - magento_network
    
  3. Magento Configuration in env.php: Ensure the settings in env.php are correct and match your OpenSearch setup:

    'opensearch' => [
        'hostname' => 'opensearch1',
        'port' => '9200',
        'index_prefix' => '',
        'enable_auth' => '1',
        'username' => 'admin',
        'password' => '@Admin123root',
        'timeout' => '15',
        'ssl' => '0',
        'ssl_verify' => '0'
    ],
    
  4. OpenSearch Logs: Check OpenSearch logs for any connection issues:

    docker logs opensearch1
    

By following these steps, you should be able to diagnose and resolve the connection issue between Magento and OpenSearch. If the issue persists, please provide any relevant log entries or error messages for further assistance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.