elasticsearch-无法将spring引导应用程序连接到logstash-它始终引发未知主机异常
发布时间:2022-08-19 07:46:18 336
相关标签: # less# java# sql# postgresql# git
当我尝试运行 docker 容器中的所有内容时,我在将我的 spring boot 应用程序与 logstash 连接时遇到问题。分享一下我做了什么:
这是我的 docker-compose.yaml
version: '3.8'
services:
learndockerpostgres:
container_name: learndockerpostgres
build: .
ports:
- 8080:8080
depends_on:
- postgres_db
- logstash
networks:
- learn-application
postgres_db:
image: postgres:latest
container_name: postgres_db
restart: always
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: root
POSTGRES_DB: client
ports:
- 5432:5432
networks:
- learn-application
postgres_admin:
image: dpage/pgadmin4
container_name: pgadmin
restart: always
environment:
PGADMIN_DEFAULT_EMAIL: admin@admin.com
PGADMIN_DEFAULT_PASSWORD: root
ports:
- 5050:80
depends_on:
- postgres_db
rabbitmq:
image: rabbitmq:3.8-management-alpine
container_name: rabbitmq
environment:
RABBITMQ_DEFAULT_USER: myuser
RABBITMQ_DEFAULT_PASS: mypassword
ports:
- 5672:5672
- 15672:15672
networks:
- learn-application
elasticsearch:
container_name: elasticsearch
image: elasticsearch:7.14.1
volumes:
- elasticsearch:/usr/share/elasticsearch/data
restart: unless-stopped
environment:
discovery.type: single-node
ES_JAVA_OPTS: "-Xmx256m -Xms256m"
ELASTIC_PASSWORD: changeme
xpack.security.enabled: true
ports:
- 9200:9200
- 9300:9300
networks:
- elastic
logstash:
container_name: logstash
image: logstash:7.14.1
volumes:
- ./env/logstash/pipeline:/usr/share/logstash/pipeline:ro
restart: unless-stopped
environment:
LS_JAVA_OPTS: "-Xmx256m -Xms256m"
ELASTIC_USER: elastic
ELASTIC_PASSWORD: changeme
XPACK_MONITORING_ELASTICSEARCH_USERNAME: elastic
XPACK_MONITORING_ELASTICSEARCH_PASSWORD: changeme
XPACK_MONITORING_ELASTICSEARCH_HOSTS: "elasticsearch:9200"
XPACK_MONITORING_ENABLED: "true"
ports:
- 5000:5000
- 9600:9600
networks:
- elastic
- learn-application
depends_on:
- elasticsearch
kibana:
container_name: kibana
image: kibana:7.14.1
restart: unless-stopped
environment:
ELASTICSEARCH_USERNAME: elastic
ELASTICSEARCH_PASSWORD: changeme
XPACK_MONITORING_UI_CONTAINER_ELASTICSEARCH_ENABLED: "true"
ports:
- 5601:5601
depends_on:
- elasticsearch
- logstash
networks:
- elastic
volumes:
elasticsearch:
networks:
elastic:
learn-application:
这是我的Dockerfile:
FROM openjdk:11
VOLUME /learndockerpostgres
EXPOSE 8080
ARG JAR_FILE=target/learn-docker-postgres-0.0.1-SNAPSHOT.jar
ADD ${JAR_FILE} learn-docker-postgres.jar
ENTRYPOINT ["java", "-jar", "learn-docker-postgres.jar"]
这是我的 application.yaml 文件:
server:
port: 8080
application:
name: learn-docker-postgres
logstash:
host: logstash
port: 5000
spring:
jpa:
show-sql: true
generate-ddl: true
properties:
hibernate:
dialect: org.hibernate.dialect.PostgreSQLDialect
hibernate:
ddl-auto: update
datasource:
driver-class-name: org.postgresql.Driver
url: jdbc:postgresql://postgres_db:5432/client
username: postgres
password: root
项目:https://gitlab.com/markozivkovic95/learn-docker-postgres/-/tree/main/我看不出任何问题,但例外情况是:
00:17:54,988 |-WARN in net.logstash.logback.appender.LogstashTcpSocketAppender[logstash] - Log destination logstash:5000: connection failed. java.net.ConnectException: Connection refused (Connection refused)
at java.net.ConnectException: Connection refused (Connection refused)
at at java.base/java.net.PlainSocketImpl.socketConnect(Native Method)
at at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:412)
at at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:255)
at at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:237)
at at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at at java.base/java.net.Socket.connect(Socket.java:609)
at at net.logstash.logback.appender.AbstractLogstashTcpSocketAppender$TcpSendingEventHandler.openSocket(AbstractLogstashTcpSocketAppender.java:717)
at at net.logstash.logback.appender.AbstractLogstashTcpSocketAppender$TcpSendingEventHandler.onStart(AbstractLogstashTcpSocketAppender.java:637)
at at net.logstash.logback.appender.AsyncDisruptorAppender$EventClearingEventHandler.onStart(AsyncDisruptorAppender.java:351)
at at net.logstash.logback.encoder.com.lmax.disruptor.BatchEventProcessor.notifyStart(BatchEventProcessor.java:224)
at at net.logstash.logback.encoder.com.lmax.disruptor.BatchEventProcessor.run(BatchEventProcessor.java:120)
at at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
at at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at at java.base/java.lang.Thread.run(Thread.java:829)
特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报