first commit
This commit is contained in:
43
logging/docker-compose.yml
Normal file
43
logging/docker-compose.yml
Normal file
@@ -0,0 +1,43 @@
|
||||
version: '3.7'
|
||||
services:
|
||||
|
||||
mongodb:
|
||||
restart: always
|
||||
build:
|
||||
context: ./mongodb/
|
||||
dockerfile: Dockerfile
|
||||
container_name: devmongo
|
||||
ports:
|
||||
- "27017:27017"
|
||||
volumes:
|
||||
- ./mongodb/data:/data/db
|
||||
- ./mongodb/init:/docker-entrypoint-initdb.d
|
||||
command: --bind_ip_all
|
||||
networks:
|
||||
- logging
|
||||
|
||||
fluentd:
|
||||
image: fluent/fluentd:edge-debian
|
||||
container_name: devfluentd
|
||||
restart: always
|
||||
user: root
|
||||
command: >
|
||||
/bin/sh -c "
|
||||
apt-get update &&
|
||||
apt-get install -y build-essential ruby-dev &&
|
||||
gem install fluent-plugin-mongo --no-document &&
|
||||
apt-get remove -y build-essential ruby-dev &&
|
||||
apt-get autoremove -y &&
|
||||
exec fluentd -c /fluentd/etc/fluent.conf"
|
||||
volumes:
|
||||
- ./fluentd/conf:/fluentd/etc
|
||||
- ../../bin/Debug/logs/archive/business:/fluentd/businesslogs
|
||||
depends_on:
|
||||
- mongodb
|
||||
networks:
|
||||
- logging
|
||||
|
||||
|
||||
networks:
|
||||
logging:
|
||||
driver: bridge
|
||||
23
logging/fluentd/conf/fluent.conf
Normal file
23
logging/fluentd/conf/fluent.conf
Normal file
@@ -0,0 +1,23 @@
|
||||
<match mongo.**>
|
||||
@type mongo
|
||||
host mongodb
|
||||
port 27017
|
||||
database LogDB
|
||||
collection Log
|
||||
<buffer>
|
||||
flush_interval 5s
|
||||
</buffer>
|
||||
</match>
|
||||
|
||||
|
||||
|
||||
<source>
|
||||
@type tail
|
||||
path /fluentd/businesslogs/*.json
|
||||
pos_file /var/log/td-agent/serverlog.pos
|
||||
<parse>
|
||||
@type json
|
||||
</parse>
|
||||
tag mongo.server.log
|
||||
</source>
|
||||
|
||||
10
logging/mongodb/Dockerfile
Normal file
10
logging/mongodb/Dockerfile
Normal file
@@ -0,0 +1,10 @@
|
||||
# Dockerfile
|
||||
|
||||
# 공식 MongoDB 이미지 사용
|
||||
FROM mongo:latest
|
||||
|
||||
# MongoDB 클라이언트 설치
|
||||
RUN apt-get install -y mongodb-org-shell && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# 컨테이너 시작시 MongoDB 클라이언트 도구를 사용하여 스크립트 실행
|
||||
CMD mongosh localhost:27017/LogDB /docker-entrypoint-initdb.d/init-mongo.js
|
||||
2
logging/mongodb/init/init-mongo.js
Normal file
2
logging/mongodb/init/init-mongo.js
Normal file
@@ -0,0 +1,2 @@
|
||||
db = db.getSiblingDB('LogDB');
|
||||
db.createCollection('Log');
|
||||
19
logging/실행전주의사항.txt
Normal file
19
logging/실행전주의사항.txt
Normal file
@@ -0,0 +1,19 @@
|
||||
해당 도커는 Local, Dev 환경에서 사용하기 위한 설정
|
||||
Local, Dev 환경에서 MongoDB, FluentD가 필요할경우 설치 진행
|
||||
|
||||
|
||||
|
||||
Fluentd 가 로그파일을 MongoDB로 전송하기 위해 docker-compose.yml 의 Fluentd Volume 정보를 해당 서버 경로 에 맞게 수정해줘야 한다.
|
||||
|
||||
docker-compose.yml 파일 실행 경로를 기준으로 로그파일 저장되어 있는 폴더를 상대 경로로 지정
|
||||
|
||||
예시 :
|
||||
|
||||
volumes:
|
||||
- ./fluentd/conf:/fluentd/etc
|
||||
- ../../bin/Debug/logs/archive/business:/fluentd/businesslogs
|
||||
|
||||
위 ./../bin/Debug/logs/archive/business: 라고 되어 있는 경로가 로그파일이 존재하는 경로
|
||||
|
||||
|
||||
다른내용은 바꾸지 않는다.
|
||||
Reference in New Issue
Block a user