스토리지 시스템
SirrChat은 로컬 파일시스템부터 클라우드 오브젝트 스토리지까지 다양한 스토리지 백엔드를 지원하는 유연한 스토리지 옵션을 제공합니다.
스토리지 유형
로컬 스토리지
가장 간단한 스토리지 방법으로 단일 서버 배포에 적합합니다.
toml
[storage]
type = "local"
local_path = "/var/mail"S3 호환 스토리지
AWS S3 및 모든 S3 호환 오브젝트 스토리지를 지원합니다.
toml
[storage]
type = "s3"
[storage.s3]
endpoint = "s3.amazonaws.com"
region = "us-east-1"
bucket = "sirrchat-storage"
access_key = "YOUR_ACCESS_KEY"
secret_key = "YOUR_SECRET_KEY"MinIO
오픈 소스 S3 호환 스토리지.
toml
[storage.s3]
endpoint = "minio.example.com:9000"
bucket = "sirrchat"
access_key = "minioadmin"
secret_key = "minioadmin"
use_ssl = false데이터베이스 스토리지
PostgreSQL
프로덕션 환경에 권장됩니다.
toml
[database]
type = "postgres"
dsn = "postgresql://user:password@localhost:5432/sirrchat?sslmode=require"
# 연결 풀 구성
max_open_conns = 25
max_idle_conns = 5
conn_max_lifetime = "5m"MySQL/MariaDB
널리 사용되는 관계형 데이터베이스.
toml
[database]
type = "mysql"
dsn = "user:password@tcp(localhost:3306)/sirrchat?parseTime=true&charset=utf8mb4"SQLite
개발 및 소규모 배포에 적합합니다.
toml
[database]
type = "sqlite"
dsn = "/var/lib/sirrchatd/sirrchat.db"이메일 스토리지 형식
Maildir
표준 이메일 스토리지 형식으로 이메일당 하나의 파일입니다.
/var/mail/[email protected]/
├── cur/ # 읽은 이메일
├── new/ # 새 이메일
└── tmp/ # 임시 파일파일 명명
1642123456.M123456P12345.hostname,S=1234:2,S- 타임스탬프
- 고유 ID
- 크기
- 플래그 (읽음, 답장 등)
스토리지 최적화
압축
오래된 이메일을 자동으로 압축하여 공간을 절약합니다.
toml
[storage.compression]
enabled = true
algorithm = "gzip" # gzip, bzip2, zstd
min_age_days = 30 # 30일 후 압축중복 제거
중복 이메일을 자동으로 감지하고 제거합니다.
toml
[storage.deduplication]
enabled = true
hash_algorithm = "sha256"계층화된 스토리지
액세스 빈도에 따라 데이터를 자동으로 마이그레이션합니다.
toml
[storage.tiering]
enabled = true
# 핫 스토리지: 자주 액세스
[storage.tiering.hot]
type = "local"
path = "/fast/ssd/mail"
max_age_days = 30
# 콜드 스토리지: 아카이브
[storage.tiering.cold]
type = "s3"
bucket = "sirrchat-archive"할당량 관리
사용자 할당량
toml
[storage.quota]
default_quota = "1GB"
max_quota = "10GB"
warning_threshold = 90 # 90%에서 경고사용자 할당량 설정
bash
sirrchatd quota set --user [email protected] --quota 5GB할당량 사용량 보기
bash
sirrchatd quota get --user [email protected]백업 및 복구
자동 백업
toml
[storage.backup]
enabled = true
schedule = "0 2 * * *" # 매일 오전 2시
retention_days = 30
[storage.backup.destination]
type = "s3"
bucket = "sirrchat-backups"수동 백업
bash
# 모든 데이터 백업
sirrchatd backup create --output /backups/sirrchat-$(date +%Y%m%d).tar.gz
# 특정 사용자 백업
sirrchatd backup create --user [email protected]데이터 복원
bash
# 모든 데이터 복원
sirrchatd backup restore --input /backups/sirrchat-20250115.tar.gz
# 특정 사용자 복원
sirrchatd backup restore --user [email protected] --input backup.tar.gz데이터 마이그레이션
다른 메일 서버에서 마이그레이션
Postfix/Dovecot에서
bash
sirrchatd migrate --from maildir --source /var/mail/vhostsExchange에서
bash
sirrchatd migrate --from pst --source /exports/*.pst스토리지 백엔드 마이그레이션
로컬에서 S3로 마이그레이션:
bash
sirrchatd storage migrate --from local --to s3모니터링 및 유지 관리
스토리지 사용 통계
bash
sirrchatd storage stats출력:
총 크기: 125.5 GB
사용자: 1,234
사용자당 평균: 104.2 MB
가장 큰 사용자: [email protected] (5.2 GB)정리 작업
만료된 이메일 삭제
bash
sirrchatd cleanup --older-than 2y휴지통 비우기
bash
sirrchatd cleanup --trash --older-than 30d임시 파일 정리
bash
sirrchatd cleanup --temp성능 최적화
캐시 구성
toml
[storage.cache]
enabled = true
size_mb = 512
ttl = "1h"인덱스 최적화
toml
[storage.indexing]
enabled = true
full_text_search = true동시성 제어
toml
[storage.concurrency]
max_workers = 10
queue_size = 1000데이터 보안
암호화
전송 암호화
toml
[storage.encryption]
# S3 전송 암호화
s3_use_tls = true저장 시 암호화
toml
[storage.encryption]
enabled = true
algorithm = "AES-256-GCM"
key_file = "/etc/sirrchatd/encryption.key"액세스 제어
toml
[storage.access]
# 액세스 경로 제한
allow_paths = ["/var/mail"]
deny_paths = ["/etc", "/root"]고가용성
복제
마스터-슬레이브 복제
toml
[storage.replication]
mode = "master"
slaves = ["slave1.example.com", "slave2.example.com"]멀티 마스터 복제
toml
[storage.replication]
mode = "multi-master"
peers = ["peer1.example.com", "peer2.example.com"]페일오버
toml
[storage.failover]
enabled = true
health_check_interval = "30s"
auto_failover = true문제 해결
진단 도구
bash
# 스토리지 연결 확인
sirrchatd storage test
# 데이터 무결성 확인
sirrchatd storage verify
# 손상된 메일함 복구
sirrchatd storage repair --user [email protected]일반적인 문제
디스크 공간 부족
bash
# 오래된 이메일 정리
sirrchatd cleanup --older-than 1y
# 이메일 압축
sirrchatd storage compressS3 연결 실패
bash
# S3 연결 테스트
sirrchatd storage test --type s3
# 세부 오류 보기
sirrchatd storage test --debug관련 문서: