Skip to content

스토리지 시스템

SirrMesh는 로컬 파일시스템부터 클라우드 오브젝트 스토리지까지 다양한 스토리지 백엔드를 지원하는 유연한 스토리지 옵션을 제공합니다.

스토리지 유형

로컬 스토리지

가장 간단한 스토리지 방식으로 단일 서버 배포에 적합합니다.

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/sirrmeshd/sirrchat.db"

이메일 스토리지 형식

Maildir

표준 이메일 스토리지 형식으로 이메일당 하나의 파일을 사용합니다.

/var/mail/user@example.com/
  ├── 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
sirrmeshd quota set --user user@example.com --quota 5GB

할당량 사용량 조회

bash
sirrmeshd quota get --user user@example.com

백업 및 복구

자동 백업

toml
[storage.backup]
enabled = true
schedule = "0 2 * * *"  # 매일 오전 2시
retention_days = 30

[storage.backup.destination]
type = "s3"
bucket = "sirrchat-backups"

수동 백업

bash
# 모든 데이터 백업
sirrmeshd backup create --output /backups/sirrchat-$(date +%Y%m%d).tar.gz

# 특정 사용자 백업
sirrmeshd backup create --user user@example.com

데이터 복원

bash
# 모든 데이터 복원
sirrmeshd backup restore --input /backups/sirrchat-20250115.tar.gz

# 특정 사용자 복원
sirrmeshd backup restore --user user@example.com --input backup.tar.gz

데이터 마이그레이션

다른 메일 서버에서 마이그레이션

Postfix/Dovecot에서

bash
sirrmeshd migrate --from maildir --source /var/mail/vhosts

Exchange에서

bash
sirrmeshd migrate --from pst --source /exports/*.pst

스토리지 백엔드 마이그레이션

로컬에서 S3로 마이그레이션:

bash
sirrmeshd storage migrate --from local --to s3

모니터링 및 유지 관리

스토리지 사용 통계

bash
sirrmeshd storage stats

출력:

총 용량: 125.5 GB
사용자: 1,234
사용자당 평균: 104.2 MB
최대 사용자: user@example.com (5.2 GB)

정리 작업

만료된 이메일 삭제

bash
sirrmeshd cleanup --older-than 2y

휴지통 비우기

bash
sirrmeshd cleanup --trash --older-than 30d

임시 파일 정리

bash
sirrmeshd 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/sirrmeshd/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
# 스토리지 연결 확인
sirrmeshd storage test

# 데이터 무결성 검증
sirrmeshd storage verify

# 손상된 메일함 복구
sirrmeshd storage repair --user user@example.com

자주 발생하는 문제

디스크 공간 부족

bash
# 오래된 이메일 정리
sirrmeshd cleanup --older-than 1y

# 이메일 압축
sirrmeshd storage compress

S3 연결 실패

bash
# S3 연결 테스트
sirrmeshd storage test --type s3

# 상세 오류 보기
sirrmeshd storage test --debug

관련 문서:

Released under the GPL 3.0 License.