I configured redis master-slave-sentinel environment using docker-compose.
and I completed it and tested it.
but, in my spring boot application, I wrote a redis sentinel config code.
below spring config class.
#Configuration
#EnableRedisRepositories
public class RedisConfig {
#Bean
public RedisConnectionFactory redisConnectionFactory(){
RedisSentinelConfiguration redisSentinelConfiguration = new RedisSentinelConfiguration()
.master("redis-master")
.sentinel("localhost",26379)
.sentinel("localhost",26380)
.sentinel("localhost",26381);
LettuceConnectionFactory lettuceConnectionFactory = new LettuceConnectionFactory(redisSentinelConfiguration);
return lettuceConnectionFactory;
}
}
and then I did run application, then problem occured.
enter image description here
I think there are some docker-compose network configs....
I want to know why it was...
If you guys know, .. please let me know about it.
↓ redis master-slave-sentinel config docker-compose.yml code.
version: '3.9'
services:
redis-master:
hostname: redis-master
container_name: redis-master
image: bitnami/redis:6.2.6
environment:
- REDIS_REPLICATION_MODE=master
- ALLOW_EMPTY_PASSWORD=yes
volumes:
- ./master/backup:/freelog/backup
networks:
- net-redis
ports:
- 6379:6379
# slave1 : bitnami/redis:6.2.6
redis-slave-1:
hostname: redis-slave-1
container_name: redis-slave-1
image: bitnami/redis:6.2.6
environment:
- REDIS_REPLICATION_MODE=slave
- REDIS_MASTER_HOST=redis-master
- ALLOW_EMPTY_PASSWORD=yes
ports:
- 6480:6379
volumes:
- ./slave1/backup:/freelog/backup
networks:
- net-redis
depends_on:
- redis-master
# slave2 : bitnami/redis:6.2.6
redis-slave-2:
hostname: redis-slave-2
container_name: redis-slave-2
image: bitnami/redis:6.2.6
environment:
- REDIS_REPLICATION_MODE=slave
- REDIS_MASTER_HOST=redis-master
- ALLOW_EMPTY_PASSWORD=yes
ports:
- 6481:6379
networks:
- net-redis
volumes:
- ./slave2/backup:/freelog/backup
depends_on:
- redis-master
- redis-slave-1
# slave3 : bitnami/redis:6.2.6
redis-slave-3:
hostname: redis-slave-3
container_name: redis-slave-3
image: bitnami/redis:6.2.6
environment:
- REDIS_REPLICATION_MODE=slave
- REDIS_MASTER_HOST=redis-master
- ALLOW_EMPTY_PASSWORD=yes
ports:
- 6482:6379
volumes:
- ./slave3/backup:/freelog/backup
networks:
- net-redis
depends_on:
- redis-master
- redis-slave-2
# sentinel1 : bitnami/redis-sentinel:6.2.6
redis-sentinel-1:
hostname: redis-sentinel-1
container_name: redis-sentinel-1
image: bitnami/redis-sentinel:6.2.6
environment:
- REDIS_SENTINEL_DOWN_AFTER_MILLISECONDS=3000
- REDIS_SENTINEL_FAILOVER_TIMEOUT=60000
- REDIS_MASTER_HOST=redis-master
- REDIS_MASTER_PORT_NUMBER=6379
- REDIS_MASTER_SET=master-name
- REDIS_SENTINEL_QUORUM=2
# - REDIS_SENTINEL_PASSWORD=170anwkd!
depends_on:
- redis-master
- redis-slave-1
- redis-slave-2
- redis-slave-3
ports:
- 26379:26379
networks:
- net-redis
volumes:
- ./sentinel1/backup:/freelog/backup
redis-sentinel-2:
hostname: redis-sentinel-2
container_name: redis-sentinel-2
image: bitnami/redis-sentinel:6.2.6
environment:
- REDIS_SENTINEL_DOWN_AFTER_MILLISECONDS=3000
- REDIS_SENTINEL_FAILOVER_TIMEOUT=60000
- REDIS_MASTER_HOST=redis-master
- REDIS_MASTER_PORT_NUMBER=6379
- REDIS_MASTER_SET=master-name
- REDIS_SENTINEL_QUORUM=2
# - REDIS_SENTINEL_PASSWORD=170anwkd!
depends_on:
- redis-master
- redis-slave-1
- redis-slave-2
- redis-slave-3
ports:
- 26380:26379
networks:
- net-redis
volumes:
- ./sentinel2/backup:/freelog/backup
# sentinel3 : bitnami/redis-sentinel:6.2.6
redis-sentinel-3:
hostname: redis-sentinel-3
container_name: redis-sentinel-3
image: bitnami/redis-sentinel:6.2.6
environment:
- REDIS_SENTINEL_DOWN_AFTER_MILLISECONDS=3000
- REDIS_SENTINEL_FAILOVER_TIMEOUT=60000
- REDIS_MASTER_HOST=redis-master
- REDIS_MASTER_PORT_NUMBER=6379
- REDIS_MASTER_SET=master-name
- REDIS_SENTINEL_QUORUM=2
# - REDIS_SENTINEL_PASSWORD=170anwkd!
depends_on:
- redis-master
- redis-slave-1
- redis-slave-2
- redis-slave-3
ports:
- 26381:26379
networks:
- net-redis
volumes:
- ./sentinel3/backup:/freelog/backup
networks:
net-redis:
driver: bridge
Related
I have a 3 node ElasticSearch (7.14.2) with docker that is used by Web App with Python ElasticSearch library (elasticsearch==7.15.0).
I connect with:
connection = Elasticsearch(
[cnt_params],
max_retries=100,
retry_on_timeout=True,
timeout=700,
request_timeout=800,
)
if connection.ping():
return connection
else:
return None
Everything runs normal but sometimes after the App is idle for a few days or hours the ping() returns False, then If I try again the ping returns True. It is like if ElasticSearch goes to sleep.
Here is my docker-compose.yml
version: '3'
services:
fsmysql_20211019:
image: mysql:8.0.26
command: --default-authentication-plugin=mysql_native_password
container_name: fs_mysql_20211019
cap_add:
- SYS_NICE
environment:
MYSQL_ROOT_PASSWORD: some_pass
volumes:
- /opt/my_app/mysql/data:/var/lib/mysql
- /opt/my_app/mysql/conf:/etc/mysql
networks:
fsnet:
ipv4_address: 192.169.1.5
fses20211019n01:
image: docker.elastic.co/elasticsearch/elasticsearch:7.14.2
container_name: fses20211019n01
environment:
- network.host=192.169.1.1
- node.name=fses20211019n01
- cluster.name=fs-es-cluster
- discovery.seed_hosts=fses20211019n02,fses20211019n03
- cluster.initial_master_nodes=fses20211019n01,fses20211019n02,fses20211019n03
- bootstrap.memory_lock=true
- xpack.security.enabled=false
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- /opt/my_app/elasticsearch/esdata:/usr/share/elasticsearch/data
networks:
fsnet:
ipv4_address: 192.169.1.1
fses20211019n02:
image: docker.elastic.co/elasticsearch/elasticsearch:7.14.2
container_name: fses20211019n02
environment:
- network.host=192.169.1.2
- node.name=fses20211019n02
- cluster.name=fs-es-cluster
- discovery.seed_hosts=fses20211019n01,fses20211019n03
- cluster.initial_master_nodes=fses20211019n01,fses20211019n02,fses20211019n03
- bootstrap.memory_lock=true
- xpack.security.enabled=false
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- /opt/my_app/elasticsearch/esdata2:/usr/share/elasticsearch/data
networks:
fsnet:
ipv4_address: 192.169.1.2
fses20211019n03:
image: docker.elastic.co/elasticsearch/elasticsearch:7.14.2
container_name: fses20211019n03
environment:
- network.host=192.169.1.3
- node.name=fses20211019n03
- cluster.name=fs-es-cluster
- discovery.seed_hosts=fses20211019n01,fses20211019n02
- cluster.initial_master_nodes=fses20211019n01,fses20211019n02,fses20211019n03
- bootstrap.memory_lock=true
- xpack.security.enabled=false
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- /opt/my_app/elasticsearch/esdata3:/usr/share/elasticsearch/data
networks:
fsnet:
ipv4_address: 192.169.1.3
fsfluentd_20211019:
image: qlands/fluentd:v1.14-1
container_name: fs_fluentd_20211019
environment:
WAIT_HOSTS: 192.169.1.1:9200, 192.169.1.4:5900
WAIT_HOSTS_TIMEOUT: 3200
volumes:
- /opt/my_app/log:/opt/formshare_log
- /opt/my_app/fluentd:/fluentd/etc/
networks:
fsnet:
ipv4_address: 192.169.1.6
formshare_20211019:
image: qlands/formshare2:20211019
container_name: formshare_20211019
environment:
MYSQL_HOST_NAME: 192.169.1.5
MYSQL_USER_NAME: root
MYSQL_USER_PASSWORD: some_pass
FORMSHARE_ADMIN_USER: admin
FORMSHARE_ADMIN_EMAIL: info#me.com
FORMSHARE_ADMIN_PASSWORD: some_pass
ELASTIC_SEARCH_HOST: 192.169.1.1
ELASTIC_SEARCH_PORT: 9200
FORMSHARE_HOST: 192.169.1.4
FORMSHARE_PORT: 5900
FORWARDED_ALLOW_IP: localhost
CONFIGURE_FLUENT: "true"
WAIT_HOSTS: 192.169.1.1:9200, 192.169.1.5:3306
WAIT_HOSTS_TIMEOUT: 1200
volumes:
- /opt/my_app/repository:/opt/formshare_repository
- /opt/my_app/log:/opt/formshare_log
- /opt/my_app/celery:/opt/formshare_celery
- /opt/my_app/config:/opt/formshare_config
- /opt/my_app/fluentd:/opt/formshare_fluentd
- /opt/my_app/plugins:/opt/formshare_plugins
- /opt/my_app/mosquitto:/etc/mosquitto/conf.d/
- /opt/tomcat/webapps:/opt/formshare_odata_webapps
ports:
- 5900:5900
- 9001:9001
networks:
fsnet:
ipv4_address: 192.169.1.4
networks:
fsnet:
ipam:
driver: default
config:
- subnet: 192.169.0.0/16
This was reported before here: https://discuss.elastic.co/t/does-elasticsearch-go-to-sleep-when-there-are-no-requests-for-a-couple-of-hours/231632 But no indication of what might cause it.
Any idea is appreciated.
Is it possible to run a docker-compose.yml file without having access to the environment variables (on windows)? I have docker desktop installed successfully. Below is the docker-compose.yml.
Best,
---
version: '3.8'
services:
zookeeper:
image: confluentinc/cp-zookeeper:5.5.1
hostname: zookeeper
container_name: zookeeper
ports:
- "2181:2181"
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
broker:
image: confluentinc/cp-server:5.5.1
hostname: broker
container_name: broker
depends_on:
- zookeeper
ports:
- "9092:9092"
- "9101:9101"
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: 'zookeeper:2181'
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://broker:29092,PLAINTEXT_HOST://localhost:9092
KAFKA_METRIC_REPORTERS: io.confluent.metrics.reporter.ConfluentMetricsReporter
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
KAFKA_CONFLUENT_LICENSE_TOPIC_REPLICATION_FACTOR: 1
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
KAFKA_JMX_PORT: 9101
CONFLUENT_METRICS_REPORTER_BOOTSTRAP_SERVERS: broker:29092
CONFLUENT_METRICS_REPORTER_ZOOKEEPER_CONNECT: zookeeper:2181
CONFLUENT_METRICS_REPORTER_TOPIC_REPLICAS: 1
CONFLUENT_METRICS_ENABLE: 'true'
CONFLUENT_SUPPORT_CUSTOMER_ID: 'anonymous'
schema-registry:
image: confluentinc/cp-schema-registry:5.5.1
hostname: schema-registry
container_name: schema-registry
depends_on:
- zookeeper
- broker
ports:
- "8081:8081"
environment:
SCHEMA_REGISTRY_HOST_NAME: schema-registry
SCHEMA_REGISTRY_KAFKASTORE_CONNECTION_URL: 'zookeeper:2181'
connect:
image: cnfldemos/cp-server-connect-datagen:0.3.2-5.5.0
hostname: connect
container_name: connect
depends_on:
- zookeeper
- broker
- schema-registry
ports:
- "8083:8083"
environment:
CONNECT_BOOTSTRAP_SERVERS: 'broker:29092'
CONNECT_REST_ADVERTISED_HOST_NAME: connect
CONNECT_REST_PORT: 8083
CONNECT_GROUP_ID: compose-connect-group
CONNECT_CONFIG_STORAGE_TOPIC: docker-connect-configs
CONNECT_CONFIG_STORAGE_REPLICATION_FACTOR: 1
CONNECT_OFFSET_FLUSH_INTERVAL_MS: 10000
CONNECT_OFFSET_STORAGE_TOPIC: docker-connect-offsets
CONNECT_OFFSET_STORAGE_REPLICATION_FACTOR: 1
CONNECT_STATUS_STORAGE_TOPIC: docker-connect-status
CONNECT_STATUS_STORAGE_REPLICATION_FACTOR: 1
CONNECT_KEY_CONVERTER: org.apache.kafka.connect.storage.StringConverter
CONNECT_VALUE_CONVERTER: io.confluent.connect.avro.AvroConverter
CONNECT_VALUE_CONVERTER_SCHEMA_REGISTRY_URL: http://schema-registry:8081
CONNECT_INTERNAL_KEY_CONVERTER: "org.apache.kafka.connect.json.JsonConverter"
CONNECT_INTERNAL_VALUE_CONVERTER: "org.apache.kafka.connect.json.JsonConverter"
CONNECT_ZOOKEEPER_CONNECT: 'zookeeper:2181'
# CLASSPATH required due to CC-2422
CLASSPATH: /usr/share/java/monitoring-interceptors/monitoring-interceptors-5.5.1.jar
CONNECT_PRODUCER_INTERCEPTOR_CLASSES: "io.confluent.monitoring.clients.interceptor.MonitoringProducerInterceptor"
CONNECT_CONSUMER_INTERCEPTOR_CLASSES: "io.confluent.monitoring.clients.interceptor.MonitoringConsumerInterceptor"
CONNECT_PLUGIN_PATH: "/usr/share/java,/usr/share/confluent-hub-components"
CONNECT_LOG4J_LOGGERS: org.apache.zookeeper=ERROR,org.I0Itec.zkclient=ERROR,org.reflections=ERROR
control-center:
image: confluentinc/cp-enterprise-control-center:5.5.1
hostname: control-center
container_name: control-center
depends_on:
- zookeeper
- broker
- schema-registry
- connect
- ksqldb-server
ports:
- "9021:9021"
environment:
CONTROL_CENTER_BOOTSTRAP_SERVERS: 'broker:29092'
CONTROL_CENTER_ZOOKEEPER_CONNECT: 'zookeeper:2181'
CONTROL_CENTER_CONNECT_CLUSTER: 'connect:8083'
CONTROL_CENTER_KSQL_KSQLDB1_URL: "http://ksqldb-server:8088"
CONTROL_CENTER_KSQL_KSQLDB1_ADVERTISED_URL: "http://localhost:8088"
CONTROL_CENTER_SCHEMA_REGISTRY_URL: "http://schema-registry:8081"
CONTROL_CENTER_REPLICATION_FACTOR: 1
CONTROL_CENTER_INTERNAL_TOPICS_PARTITIONS: 1
CONTROL_CENTER_MONITORING_INTERCEPTOR_TOPIC_PARTITIONS: 1
CONFLUENT_METRICS_TOPIC_REPLICATION: 1
PORT: 9021
ksqldb-server:
image: confluentinc/cp-ksqldb-server:5.5.1
hostname: ksqldb-server
container_name: ksqldb-server
depends_on:
- broker
- connect
ports:
- "8088:8088"
environment:
KSQL_CONFIG_DIR: "/etc/ksql"
KSQL_BOOTSTRAP_SERVERS: "broker:29092"
KSQL_HOST_NAME: ksqldb-server
KSQL_LISTENERS: "http://0.0.0.0:8088"
KSQL_CACHE_MAX_BYTES_BUFFERING: 0
KSQL_KSQL_SCHEMA_REGISTRY_URL: "http://schema-registry:8081"
KSQL_PRODUCER_INTERCEPTOR_CLASSES: "io.confluent.monitoring.clients.interceptor.MonitoringProducerInterceptor"
KSQL_CONSUMER_INTERCEPTOR_CLASSES: "io.confluent.monitoring.clients.interceptor.MonitoringConsumerInterceptor"
KSQL_KSQL_CONNECT_URL: "http://connect:8083"
ksqldb-cli:
image: confluentinc/cp-ksqldb-cli:5.5.1
container_name: ksqldb-cli
depends_on:
- broker
- connect
- ksqldb-server
entrypoint: /bin/sh
tty: true
ksql-datagen:
image: confluentinc/ksqldb-examples:5.5.1
hostname: ksql-datagen
container_name: ksql-datagen
depends_on:
- ksqldb-server
- broker
- schema-registry
- connect
command: "bash -c 'echo Waiting for Kafka to be ready... &&
cub kafka-ready -b broker:29092 1 40 &&
echo Waiting for Confluent Schema Registry to be ready... &&
cub sr-ready schema-registry 8081 40 &&
echo Waiting a few seconds for topic creation to finish... &&
sleep 11 &&
tail -f /dev/null'"
environment:
KSQL_CONFIG_DIR: "/etc/ksql"
STREAMS_BOOTSTRAP_SERVERS: broker:29092
STREAMS_SCHEMA_REGISTRY_HOST: schema-registry
STREAMS_SCHEMA_REGISTRY_PORT: 8081
rest-proxy:
image: confluentinc/cp-kafka-rest:5.5.1
depends_on:
- zookeeper
- broker
- schema-registry
ports:
- 8082:8082
hostname: rest-proxy
container_name: rest-proxy
environment:
KAFKA_REST_HOST_NAME: rest-proxy
KAFKA_REST_BOOTSTRAP_SERVERS: 'broker:29092'
KAFKA_REST_LISTENERS: "http://0.0.0.0:8082"
KAFKA_REST_SCHEMA_REGISTRY_URL: 'http://schema-registry:8081'
Hi have the following docker-compose file with several services including ElasticSearch with two nodes:
version: '3'
services:
CO_MYSQL:
image: mysql:8.0.23
container_name: CO_MYSQL
environment:
MYSQL_ROOT_PASSWORD: 72EkBqCs!
volumes:
- /opt/cropontology/mysql/data:/var/lib/mysql
ports:
- 3306:3306
networks:
- CO_Network
CO_MONGO:
image: mongo:3.6.8
container_name: CO_MONGO
volumes:
- /opt/cropontology/mongo/data:/data/db
ports:
- 27017:27017
networks:
- CO_Network
CO_NEO4J:
image: neo4j:4.1.2
container_name: CO_NEO4J
volumes:
- /opt/cropontology/neo4j/data:/data
- /opt/cropontology/neo4j/plugins:/var/lib/neo4j/plugins
ports:
- 7474:7474
- 7687:7687
networks:
- CO_Network
CO_ES_01:
image: docker.elastic.co/elasticsearch/elasticsearch:7.10.1
container_name: CO_ES_01
environment:
- node.name=CO_ES_01
- cluster.name=es-docker-cluster
- discovery.seed_hosts=CO_ES_02
- cluster.initial_master_nodes=CO_ES_01,CO_ES_02
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- /opt/cropontology/es/data:/usr/share/elasticsearch/data
ports:
- 9200:9200
networks:
- CO_Network
CO_ES_02:
image: docker.elastic.co/elasticsearch/elasticsearch:7.10.1
container_name: CO_ES_02
environment:
- node.name=CO_ES_02
- cluster.name=es-docker-cluster
- discovery.seed_hosts=CO_ES_01
- cluster.initial_master_nodes=CO_ES_01,CO_ES_02
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- /opt/cropontology/es/data2:/usr/share/elasticsearch/data
networks:
- CO_Network
networks:
CO_Network:
driver: bridge
Everything works well under Linux but if I try to run the same file under Mac I get:
CO_ES_01 | "stacktrace": ["java.net.UnknownHostException: CO_ES_02",
Do I need specific configuration under Mac for it to work?
I tried pinging from spring-boot container to cassandra container,it's working fine.But while bringing up my apllication I am getting error like .
NoHostAvailableException: All host(s) tried for query failed (tried:
cassandra/172.21.0.3:9042
(com.datastax.driver.core.exceptions.TransportException:
[cassandra/172.21.0.3:9042] Cannot connect))
docker-compose.yml
version: "2"
services:
zookeeper:
image: confluentinc/cp-zookeeper:5.3.1
hostname: zookeeper
container_name: zookeeper
ports:
- "2181:2181"
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
volumes:
- ./create_topic.sh:/create_topics.sh
broker:
image: confluentinc/cp-enterprise-kafka:5.3.1
hostname: broker
container_name: broker
depends_on:
- zookeeper
ports:
- "29092:29092"
- "9092:9092"
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: "zookeeper:2181"
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://broker:29092,PLAINTEXT_HOST://localhost:9092
KAFKA_METRIC_REPORTERS: io.confluent.metrics.reporter.ConfluentMetricsReporter
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
CONFLUENT_METRICS_REPORTER_BOOTSTRAP_SERVERS: broker:29092
CONFLUENT_METRICS_REPORTER_ZOOKEEPER_CONNECT: zookeeper:2181
CONFLUENT_METRICS_REPORTER_TOPIC_REPLICAS: 1
CONFLUENT_METRICS_ENABLE: "true"
CONFLUENT_SUPPORT_CUSTOMER_ID: "anonymous"
control-center:
image: confluentinc/cp-enterprise-control-center:5.3.1
hostname: control-center
container_name: control-center
depends_on:
- zookeeper
- broker
ports:
- "9021:9021"
environment:
CONTROL_CENTER_BOOTSTRAP_SERVERS: "broker:29092"
CONTROL_CENTER_ZOOKEEPER_CONNECT: "zookeeper:2181"
CONTROL_CENTER_REPLICATION_FACTOR: 1
CONTROL_CENTER_INTERNAL_TOPICS_PARTITIONS: 1
CONTROL_CENTER_MONITORING_INTERCEPTOR_TOPIC_PARTITIONS: 1
CONFLUENT_METRICS_TOPIC_REPLICATION: 1
PORT: 9021
cassandra:
image: ************/cassandra_goldendata_baseimage:1.0.0
container_name: cassandra
ports:
- "9042:9042"
item-service:
image: item-service
depends_on:
- zookeeper
- broker
- cassandra
container_name: item-servicecontainer
ports:
- "4545:8080"
When I enter on the url http://0.0.0.0:9200/ is working.
I am getting the following error when I want to save or retrieve data:
ConnectionError(<urllib3.connection.HTTPConnection object at
0x7f234afdacc0>: Failed to establish a new connection: [Errno 111]
Connection refused) caused by:
NewConnectionError(<urllib3.connection.HTTPConnection object at
0x7f234afdacc0>: Failed to establish a new connection: [Errno 111]
Connection refused)
My docker-compose.yml:
version: "2"
services:
redis:
image: redis:latest
rabbit:
image: rabbitmq:latest
ports:
- "5672:5672"
- "15672:15672"
mysql:
image: mysql:5.7.22
environment:
MYSQL_DATABASE: db
MYSQL_ROOT_PASSWORD: 'db'
ports:
- 3306
phpmyadmin:
image: nazarpc/phpmyadmin
environment:
MYSQL_USERNAME: db
ports:
- "0.0.0.0:8081:80"
links:
- mysql:mysql
celery_worker:
build:
context: .
command: bash -c "sleep 3 && celery -A wk worker -l debug"
volumes:
- /log:/log
- /tmp:/tmp
- ./wk:/wk
env_file:
- ./envs/development.env
environment:
- C_FORCE_ROOT=true
- BROKER_URL=amqp://guest:guest#rabbit//
working_dir: /wk
links:
- mysql:mysql
- rabbit:rabbit
- redis:redis
celery_worker_refactor:
build:
context: .
command: bash -c "sleep 10 && celery -A wk worker -l error -Ofair -Q refactor"
volumes:
- /log:/log
- /tmp:/tmp
- ./wk:/wk
env_file:
- ./envs/development.env
environment:
- C_FORCE_ROOT=true
- BROKER_URL=amqp://guest:guest#rabbit//
working_dir: /wk
links:
- mysql:mysql
- rabbit:rabbit
- redis:redis
celery_beat:
build:
context: .
command: bash -c "rm -f /tmp/celerybeat.pid && sleep 3 && celery -A wk beat -l debug -s /log/celerybeat --pidfile=/tmp/celerybeat.pid"
volumes:
- /log:/log
- /tmp:/tmp
- ./wk:/wk
env_file:
- ./envs/development.env
environment:
- C_FORCE_ROOT=true
- BROKER_URL=amqp://guest:guest#rabbit//
working_dir: /wk
links:
- mysql:mysql
- rabbit:rabbit
- redis:redis
ssh_server:
build:
context: .
dockerfile: Dockerfile-ssh
command: /usr/sbin/sshd -D
environment:
DEBUG: 'True'
env_file:
- ./envs/development.env
environment:
- BROKER_URL=amqp://guest:guest#rabbit//
volumes:
- ./wk:/wk
ports:
- "2222:22"
links:
- mysql:mysql
- redis:redis
- rabbit:rabbit
elasticsearch:
image: elasticsearch
environment:
- cluster.name=docker-cluster
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- xpack.security.enabled=false
volumes:
- esdata:/usr/share/elasticsearch/data
ports:
- "9200:9200"
- "9300:9300"
kibana:
image: kibana
ports:
- 5601:5601
web:
build:
context: .
command: bash -c "sleep 3 && python manage.py runserver 0.0.0.0:8000"
privileged: true
env_file:
- ./envs/development.env
environment:
- BROKER_URL=amqp://guest:guest#rabbit//
volumes:
- /log:/log
- /tmp:/tmp
- ./wk:/wk
depends_on:
- elasticsearch
links:
- mysql:mysql
- redis:redis
- rabbit:rabbit
- elasticsearch:elasticsearch
ports:
- "0.0.0.0:8000:8000"
volumes:
esdata:
driver: local
I tried to create e network between web and elastic search, same result.
When I call http://0.0.0.0:9200/ I get a response from server with a JSON.
My Haystack config in settings.py
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE':'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
'URL': '0.0.0.0:9200/',
'INDEX_NAME': 'haystack'
}
}
HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor'
Some content so I can post this question, Is not only code.
You should use elasticsearch instead of 0.0.0.0:
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE':'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
>>> 'URL': 'elasticsearch:9200',
'INDEX_NAME': 'haystack'
}
}