ストレージシステム
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
標準のメールストレージフォーマット、メールごとに1つのファイル。
/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関連ドキュメント: