docker pull mongo:4.2
docker pull elasitcsearch:7.8.0
docker pull graylog/graylog:4.2
2,启动容器version: '3'
services:
mongo:
image: mongo:4.2
volumes:
- /usr/local/mapping/mongo/data:/data/db
- /usr/local/mapping/mongo/conf:/data/configdb
networks:
- graylog
elasticsearch:
image: elasticsearch:7.8.0
volumes:
- /usr/local/mapping/elasticsearch/data:/usr/share/elasticsearch/data
- /usr/local/mapping/elasticsearch/plugins:/usr/share/elasticsearch/plugins
environment:
- http.host=0.0.0.0
- transport.host=localhost
- network.host=0.0.0.0
- ES_JAVA_OPTS=-Dlog4j2.formatMsgNoLookups=true -Xms512m -Xmx512m
ulimits:
memlock:
soft: -1
hard: -1
deploy:
resources:
limits:
memory: 1g
networks:
- graylog
graylog:
image: graylog/graylog:4.2
environment:
- GRAYLOG_PASSWORD_SECRET=somepasswordpepper
# Password: 9Ji315Rx4yUvro8H
- GRAYLOG_ROOT_PASSWORD_SHA2=cc090167df736bc65c0bd69551f405aa52fbb5ae9c791c3a9e42742af6074d66 #默认密码:9Ji315Rx4yUvro8H
- GRAYLOG_HTTP_EXTERNAL_URI=http://127.0.0.1:9000/
- GRAYLOG_ROOT_TIMEZONE=Asia/Shanghai #设置时区
- GRAYLOG_ALLOW_HIGHLIGHTING=true #搜索高亮
entrypoint: /usr/bin/tini -- wait-for-it elasticsearch:9200 -- /docker-entrypoint.sh
networks:
- graylog
restart: always
depends_on:
- mongo
- elasticsearch
ports:
- 9000:9000
- 1514:1514
- 1514:1514/udp
- 12201:12201
- 12201:12201/udp
networks:
graylog:
driver: bridge
docker-compose up -d 启动
配置建议:
1,密码建议修改
2,mongo和elasticsearch 建议都挂接本地磁盘,否则down之后 数据内容全部丢失了
3,设置Graylog登录graylog, http://公网IP:9000
帐号admin 密码9Ji315Rx4yUvro8H
4,Springboot集成Graylog
pom.xml增加
de.siegmar
logback-gelf
3.0.0
logback.xml中增加
服务器公网IP
12201
508
true
false
true
true
false
false
true
%m%nopex
%d - [%thread] %-5level %logger{35} - %msg%n
app_name:ops
这里如果用的云服务器,开端口的时候,切记开放UDP端口,
一般默认开放TCP端口,死活收不到消息,在这里坑了我整整1天。
5,结果springboot 控制台展示
graylog 展示
这里是最基础的搭建配置,
而在实际微服务或者分布式应用中,配置比这个复杂的多,需要的得做更深度研究
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)