From 623b991920ebb21e2bb9f2381fe551c7381dd273 Mon Sep 17 00:00:00 2001 From: Claude-51124 Date: Tue, 14 Oct 2025 01:07:36 +0900 Subject: [PATCH] =?UTF-8?q?docs:=20skill-rag-file=20SSHFS=20allow=5Fother?= =?UTF-8?q?=20=EA=B6=8C=ED=95=9C=20=EB=AC=B8=EC=A0=9C=20=ED=95=B4=EA=B2=B0?= =?UTF-8?q?=20=EB=B0=8F=20=EA=B4=80=EB=A0=A8=20=EB=AC=B8=EC=84=9C=20?= =?UTF-8?q?=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 신규: 251014_skill-rag-file_sshfs_allow_other_해결.md - /etc/fuse.conf user_allow_other 활성화 - SSHFS allow_other,default_permissions 옵션 추가 - docker-compose.yml 볼륨 마운트 추가 - 파일 영속성 검증 완료 - 수정: 250915_skill-rag-file_Docker_빌드_및_볼륨_마운트_문제.md - SSHFS 볼륨 충돌 임시/최종 해결 구분 - docker-compose.yml 볼륨 마운트 반영 - 수정: 250915_skill-rag-file_초기_구축.md - SSHFS 명령 allow_other 옵션 추가 - /etc/fuse.conf 설정 주의사항 추가 - 수정: 250731_claude_SSHFS권한문제해결.md - 2025-10-14 업데이트 섹션 추가 - Docker SSHFS 충돌 allow_other로 해결 가능 명시 - 수정: 251014_slack_lists_file_attachment.md - 우선순위 0: 파일 영속성 문제 해결 추가 - 교훈: FUSE 권한 모델 이해 부족 추가 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../250731_claude_SSHFS권한문제해결.md | 16 ++ ...cker_빌드_및_볼륨_마운트_문제.md | 8 +- .../250915_skill-rag-file_초기_구축.md | 4 +- ...skill-rag-file_sshfs_allow_other_해결.md | 175 ++++++++++++++++++ .../251014_slack_lists_file_attachment.md | 36 ++++ 5 files changed, 236 insertions(+), 3 deletions(-) create mode 100644 troubleshooting/251014_skill-rag-file_sshfs_allow_other_해결.md diff --git a/troubleshooting/250731_claude_SSHFS권한문제해결.md b/troubleshooting/250731_claude_SSHFS권한문제해결.md index ad58a57..0f46ec9 100644 --- a/troubleshooting/250731_claude_SSHFS권한문제해결.md +++ b/troubleshooting/250731_claude_SSHFS권한문제해결.md @@ -148,6 +148,22 @@ Docker가 볼륨 마운트 시 상위 디렉토리를 새로 만들려고 했지 --- +## 2025-10-14 업데이트: 해결 방법 발견 + +### 근본 원인 +- SSHFS가 user_id=1001로 마운트됨 +- 컨테이너 내부 사용자(root 또는 다른 UID)가 접근 불가 +- allow_other 옵션 없이는 마운트한 사용자만 접근 가능 + +### 해결 방법 +1. /etc/fuse.conf에 `user_allow_other` 활성화 +2. SSHFS 재마운트 시 `allow_other,default_permissions` 옵션 추가 +3. docker-compose.yml에 볼륨 마운트 추가 가능 + +**상세 내용**: 251014_skill-rag-file_sshfs_allow_other_해결.md 참고 + +--- + 작성일: 2025-07-31 23:49 - 23:58 작성자: Claude (51124 서버) 주제: SSHFS 마운트 권한 불일치로 인한 컨테이너 로그 쓰기 실패 해결 \ No newline at end of file diff --git a/troubleshooting/250915_skill-rag-file_Docker_빌드_및_볼륨_마운트_문제.md b/troubleshooting/250915_skill-rag-file_Docker_빌드_및_볼륨_마운트_문제.md index fb75bee..4f67288 100644 --- a/troubleshooting/250915_skill-rag-file_Docker_빌드_및_볼륨_마운트_문제.md +++ b/troubleshooting/250915_skill-rag-file_Docker_빌드_및_볼륨_마운트_문제.md @@ -18,10 +18,13 @@ RUN pip install --no-cache-dir uv && \ # 문제: Docker가 SSHFS 마운트 포인트에 mkdir 시도 Error: mkdir /mnt/51123data: file exists -# 해결: documents 볼륨 제거, network_mode: host로 직접 접근 +# 임시 해결: documents 볼륨 제거, network_mode: host로 직접 접근 volumes: - ./logs:/app/logs # documents 볼륨 제거 network_mode: host + +# 최종 해결 (2025-10-14): SSHFS allow_other 옵션 사용 +# 상세: 251014_skill-rag-file_sshfs_allow_other_해결.md 참고 ``` ### SQLAlchemy metadata 예약어 @@ -49,7 +52,7 @@ chromadb==1.0.21 # 버전 업그레이드 # readme = "README.md" 제거 ``` -### docker-compose.yml +### docker-compose.yml (2025-10-14 업데이트) ```yaml services: skill-rag-file: @@ -60,6 +63,7 @@ services: volumes: - ./logs:/app/logs - ./.env:/app/.env:ro + - /mnt/51123data:/mnt/51123data:rw # SSHFS allow_other 후 추가 network_mode: host ``` diff --git a/troubleshooting/250915_skill-rag-file_초기_구축.md b/troubleshooting/250915_skill-rag-file_초기_구축.md index 66be63d..83c06ce 100644 --- a/troubleshooting/250915_skill-rag-file_초기_구축.md +++ b/troubleshooting/250915_skill-rag-file_초기_구축.md @@ -18,8 +18,10 @@ ### 파일 저장 구조 설정 - **51123 디렉토리**: /mnt/hdd/data/documents/ - **51124 마운트**: /mnt/51123data/ (SSHFS) -- **SSHFS 명령**: `sshfs -o IdentityFile=/home/admin/.ssh/id_rsa_deploy,reconnect,uid=$(id -u),gid=$(id -g) admin@192.168.219.45:/mnt/hdd/data /mnt/51123data -p 51123` +- **SSHFS 명령 (초기)**: `sshfs -o IdentityFile=/home/admin/.ssh/id_rsa_deploy,reconnect,uid=$(id -u),gid=$(id -g) admin@192.168.219.45:/mnt/hdd/data /mnt/51123data -p 51123` +- **SSHFS 명령 (2025-10-14 수정)**: `sshfs -o allow_other,default_permissions,IdentityFile=/home/admin/.ssh/id_rsa_deploy,reconnect,uid=1001,gid=1000 admin@192.168.219.45:/mnt/hdd/data /mnt/51123data -p 51123` - **권한**: admin:xusers (읽기/쓰기 가능) +- **주의**: allow_other 사용 시 /etc/fuse.conf에 user_allow_other 필요 ### 서비스 구성 - **Gitea 레포**: https://git.ro-being.com/ivada_Ro-being/skill-rag-file diff --git a/troubleshooting/251014_skill-rag-file_sshfs_allow_other_해결.md b/troubleshooting/251014_skill-rag-file_sshfs_allow_other_해결.md new file mode 100644 index 0000000..06bd1b6 --- /dev/null +++ b/troubleshooting/251014_skill-rag-file_sshfs_allow_other_해결.md @@ -0,0 +1,175 @@ +# skill-rag-file SSHFS allow_other 권한 문제 해결 + +**날짜**: 2025-10-14 +**작성자**: Claude +**관련 파일**: `skill-rag-file/docker-compose.yml` + +--- + +## 문제 상황 + +### 증상 +- skill-rag-file 컨테이너가 `/mnt/51123data/documents/`에 파일 저장 +- 컨테이너 내부에서만 파일 보임 +- 호스트와 51123 서버 HDD에는 저장 안됨 +- 컨테이너 재시작 시 파일 손실 + +### 근본 원인 +1. **SSHFS 마운트**: `user_id=1001,group_id=1000` (admin:xusers) +2. **컨테이너 실행**: root (UID 0) +3. **권한 불일치**: FUSE는 기본적으로 마운트한 사용자만 접근 허용 +4. **allow_other 미사용**: 다른 UID 접근 차단 + +### 검증 +```bash +# 컨테이너 내부 +docker exec skill-rag-file ls /mnt/51123data/documents/79441171.../2025-10/ +# → 파일 보임 + +# 호스트 +ls /mnt/51123data/documents/79441171.../2025-10/ +# → No such file or directory +``` + +--- + +## 해결 과정 + +### 1단계: /etc/fuse.conf 수정 + +```bash +sudo sed -i 's/^#user_allow_other/user_allow_other/' /etc/fuse.conf +``` + +**결과**: +``` +user_allow_other +``` + +**의미**: 일반 사용자가 `allow_other` 옵션 사용 가능 + +### 2단계: SSHFS 재마운트 + +```bash +# 기존 마운트 해제 +sudo fusermount -u /mnt/51123data + +# allow_other 옵션 추가하여 재마운트 +sshfs -o allow_other,default_permissions,IdentityFile=/home/admin/.ssh/id_rsa_deploy,reconnect,uid=1001,gid=1000 admin@192.168.219.45:/mnt/hdd/data /mnt/51123data -p 51123 +``` + +**마운트 옵션 확인**: +```bash +mount | grep 51123data +# admin@192.168.219.45:/mnt/hdd/data on /mnt/51123data type fuse.sshfs (rw,nosuid,nodev,relatime,user_id=1001,group_id=1000,default_permissions,allow_other) +``` + +### 3단계: docker-compose.yml 볼륨 추가 + +**파일**: skill-rag-file/docker-compose.yml + +```yaml +volumes: + - ./chroma_db:/app/chroma_db + - ./logs:/app/logs + - ./.env:/app/.env:ro + - /mnt/51123data:/mnt/51123data:rw # 추가 +``` + +### 4단계: 컨테이너 재시작 + +```bash +cd /home/admin/ivada_project/skill-rag-file +docker compose down +docker compose up -d +``` + +**결과**: 컨테이너 정상 시작 (DOCS/250915 문서의 "mkdir /mnt/51123data: file exists" 에러 발생 안함) + +--- + +## 검증 결과 + +### 테스트 1: 파일 쓰기 +```bash +docker exec skill-rag-file touch /mnt/51123data/documents/test_write_from_container.txt +ls -la /mnt/51123data/documents/ | grep test_write +# -rw-r--r-- 1 admin xusers 0 10월 14 01:01 test_write_from_container.txt +``` + +**결과**: ✅ 컨테이너 → 호스트 즉시 동기화 + +### 테스트 2: 디렉토리 생성 +```bash +docker exec skill-rag-file mkdir -p /mnt/51123data/documents/test_team/2025-10 +docker exec skill-rag-file touch /mnt/51123data/documents/test_team/2025-10/test.pdf +ls -la /mnt/51123data/documents/test_team/2025-10/ +# total 8 +# drwxr-xr-x 1 admin xusers 4096 10월 14 01:01 . +# -rw-r--r-- 1 admin xusers 0 10월 14 01:01 test.pdf +``` + +**결과**: ✅ 디렉토리 생성 및 권한 매핑 정상 + +### 테스트 3: 영속성 +```bash +docker compose down && docker compose up -d +docker exec skill-rag-file ls /mnt/51123data/documents/ | grep test +# test.txt +# test_team +# test_write_from_container.txt +``` + +**결과**: ✅ 재시작 후에도 파일 유지 + +--- + +## 핵심 설정 요약 + +### /etc/fuse.conf +``` +user_allow_other +``` + +### SSHFS 마운트 명령 +```bash +sshfs -o allow_other,default_permissions,IdentityFile=/home/admin/.ssh/id_rsa_deploy,reconnect,uid=1001,gid=1000 admin@192.168.219.45:/mnt/hdd/data /mnt/51123data -p 51123 +``` + +### docker-compose.yml +```yaml +volumes: + - /mnt/51123data:/mnt/51123data:rw +``` + +--- + +## 교훈 + +### FUSE 기본 보안 정책 +- FUSE는 기본적으로 마운트한 사용자만 접근 허용 +- 컨테이너 내부 다른 UID 사용 시 접근 불가 +- `allow_other` 옵션으로 해결 가능 + +### allow_other 사용 조건 +- `/etc/fuse.conf`에 `user_allow_other` 필수 +- `default_permissions` 옵션 권장 (일반 파일시스템 권한 체크) +- 보안 위험: 모든 사용자가 접근 가능하므로 신중히 사용 + +### Docker 볼륨 마운트 +- SSHFS 마운트 포인트를 Docker 볼륨으로 사용 가능 +- `allow_other` 없으면 컨테이너 내부에만 파일 존재 (휘발성) +- 볼륨 마운트 시 `/mnt/51123data:/mnt/51123data:rw` 형태로 전체 마운트 포인트 바인드 + +### 과거 문서 오류 +- DOCS/250915: "볼륨 제거"가 해결책이 아님 → 임시 우회책 +- DOCS/250731: "Docker SSHFS 충돌"로 롤백 → allow_other로 해결 가능 +- 교훈: FUSE 권한 모델 이해 부족으로 잘못된 결론 도출 + +--- + +## 관련 문서 + +- 250915_skill-rag-file_Docker_빌드_및_볼륨_마운트_문제.md +- 250915_skill-rag-file_초기_구축.md +- 250731_claude_SSHFS권한문제해결.md diff --git a/troubleshooting/251014_slack_lists_file_attachment.md b/troubleshooting/251014_slack_lists_file_attachment.md index 887ad20..1c21595 100644 --- a/troubleshooting/251014_slack_lists_file_attachment.md +++ b/troubleshooting/251014_slack_lists_file_attachment.md @@ -13,6 +13,27 @@ --- +## 우선 해결: 파일 영속성 문제 (2025-10-14 해결) + +### 문제 +- skill-rag-file 컨테이너가 파일을 `/mnt/51123data/documents/`에 저장 +- SSHFS `user_id=1001`, 컨테이너 `root (UID 0)` 권한 불일치 +- 컨테이너 재시작 시 파일 손실 + +### 해결 +1. `/etc/fuse.conf`: `user_allow_other` 활성화 +2. SSHFS 재마운트: `allow_other,default_permissions` 옵션 추가 +3. `docker-compose.yml`: `/mnt/51123data:/mnt/51123data:rw` 볼륨 추가 + +### 결과 +- ✅ 컨테이너 → 호스트 파일 동기화 +- ✅ 51123 서버 HDD 영구 저장 +- ✅ 재시작 후에도 파일 유지 + +**상세**: 251014_skill-rag-file_sshfs_allow_other_해결.md + +--- + ## 현재 상태 ### skill-rag-file @@ -34,6 +55,11 @@ ## 해결 방안 +### 우선순위 0: skill-rag-file 파일 영속성 (✅ 완료) +- SSHFS allow_other 설정 +- docker-compose.yml 볼륨 마운트 추가 +- 상세: 251014_skill-rag-file_sshfs_allow_other_해결.md + ### 우선순위 1: skill-rag-file 다운로드 API **파일**: skill-rag-file/app/api/download.py (신규) @@ -73,6 +99,11 @@ ## 교훈 +### 파일 영속성 검증 누락 +- 컨테이너 내부에만 파일 존재, 호스트/51123 서버 저장 안됨 +- SSHFS allow_other 옵션 미사용으로 권한 불일치 +- 교훈: 파일 저장 시스템 구축 시 영속성 테스트 필수 + ### 테스트 파일 확인 누락 - test_slack_lists.py에 완전한 구현 예시 존재 - 문서만 보고 추측으로 작성 @@ -82,3 +113,8 @@ - attachment 필드 타입 확인 안 함 - document_id 문자열 전달 (오류) - 교훈: Slack API 필드 타입 사전 확인 필수 + +### FUSE 권한 모델 이해 부족 +- SSHFS 마운트는 기본적으로 마운트한 사용자만 접근 +- Docker 컨테이너는 다른 UID로 실행되어 접근 불가 +- 교훈: FUSE 기반 파일시스템 사용 시 allow_other 옵션 검토 필수