diff --git a/Environment-Variables.md b/Environment-Variables.md index 49e4672..d976fbf 100644 --- a/Environment-Variables.md +++ b/Environment-Variables.md @@ -13,6 +13,26 @@ weed master # Weed prefix For `v`, `logtostderr`, `stderrthreshold`, `vmoudle`, `options`, `logdir`, `alsologtostderr`, `log_backtrace_at` , and `config_dir` you have to use `WEED_` as prefix for environment variable like this `WEED_CONFIG_DIR=/tmp` +## Configuration File Settings +For configuration file settings (like filer stores, replication settings, etc.), you must use the `WEED_` prefix with dots (`.`) replaced by underscores (`_`). + +For example, the `filer.toml` configuration: +```toml +[redis2] +enabled = true +address = "localhost:6379" +password = "secret" +database = 0 +``` + +Becomes these environment variables: +```shell +WEED_REDIS2_ENABLED=true +WEED_REDIS2_ADDRESS=localhost:6379 +WEED_REDIS2_PASSWORD=secret +WEED_REDIS2_DATABASE=0 +``` + # S3 Admin Credentials For S3 API server authentication, see the dedicated **[S3 Credentials](S3-Credentials)** page which covers: - Configuration file setup (highest priority) @@ -69,3 +89,181 @@ services: depends_on: - filer ``` + +# Filer Metadata Store Configuration + +The filer supports multiple metadata storage backends. You can configure them using environment variables instead of a `filer.toml` file. + +## Redis Configuration + +### Basic Redis (`redis2`) +```yaml +version: '3.9' +services: + redis: + image: redis:7-alpine + ports: + - 6379:6379 + command: redis-server --requirepass your_password + + master: + image: chrislusf/seaweedfs:latest + ports: + - 9333:9333 + command: master + + volume: + image: chrislusf/seaweedfs:latest + ports: + - 8080:8080 + command: volume -mserver=master:9333 + depends_on: + - master + + filer: + image: chrislusf/seaweedfs:latest + ports: + - 8888:8888 + environment: + # Enable Redis as metadata store + - WEED_REDIS2_ENABLED=true + - WEED_REDIS2_ADDRESS=redis:6379 + - WEED_REDIS2_PASSWORD=your_password + - WEED_REDIS2_DATABASE=0 + # Optional: TLS configuration + - WEED_REDIS2_ENABLE_TLS=false + # Disable default leveldb2 + - WEED_LEVELDB2_ENABLED=false + command: filer -master=master:9333 + depends_on: + - master + - volume + - redis +``` + +### Redis Sentinel +```shell +WEED_REDIS2_SENTINEL_ENABLED=true +WEED_REDIS2_SENTINEL_ADDRESSES=sentinel1:26379,sentinel2:26379,sentinel3:26379 +WEED_REDIS2_SENTINEL_MASTERNAME=mymaster +WEED_REDIS2_SENTINEL_USERNAME= +WEED_REDIS2_SENTINEL_PASSWORD=secret +WEED_REDIS2_SENTINEL_DATABASE=0 +WEED_LEVELDB2_ENABLED=false +``` + +### Redis Cluster +```shell +WEED_REDIS_CLUSTER2_ENABLED=true +WEED_REDIS_CLUSTER2_ADDRESSES=redis1:6379,redis2:6379,redis3:6379 +WEED_REDIS_CLUSTER2_PASSWORD=secret +WEED_REDIS_CLUSTER2_READONLY=false +WEED_REDIS_CLUSTER2_ROUTEBYLATENCY=false +WEED_LEVELDB2_ENABLED=false +``` + +## MySQL/MariaDB Configuration +```yaml +version: '3.9' +services: + mysql: + image: mysql:8 + ports: + - 3306:3306 + environment: + - MYSQL_ROOT_PASSWORD=secret + - MYSQL_DATABASE=seaweedfs + - MYSQL_USER=seaweedfs + - MYSQL_PASSWORD=secret + + master: + image: chrislusf/seaweedfs:latest + ports: + - 9333:9333 + command: master + + volume: + image: chrislusf/seaweedfs:latest + ports: + - 8080:8080 + command: volume -mserver=master:9333 + depends_on: + - master + + filer: + image: chrislusf/seaweedfs:latest + ports: + - 8888:8888 + environment: + # MySQL configuration + - WEED_MYSQL_ENABLED=true + - WEED_MYSQL_HOSTNAME=mysql + - WEED_MYSQL_PORT=3306 + - WEED_MYSQL_DATABASE=seaweedfs + - WEED_MYSQL_USERNAME=seaweedfs + - WEED_MYSQL_PASSWORD=secret + - WEED_MYSQL_CONNECTION_MAX_IDLE=5 + - WEED_MYSQL_CONNECTION_MAX_OPEN=75 + - WEED_MYSQL_CONNECTION_MAX_LIFETIME_SECONDS=600 + - WEED_MYSQL_INTERPOLATEPARAMS=true + # Disable default leveldb2 + - WEED_LEVELDB2_ENABLED=false + command: filer -master=master:9333 + depends_on: + - master + - volume + - mysql +``` + +## PostgreSQL Configuration +```shell +WEED_POSTGRES_ENABLED=true +WEED_POSTGRES_HOSTNAME=postgres +WEED_POSTGRES_PORT=5432 +WEED_POSTGRES_DATABASE=seaweedfs +WEED_POSTGRES_USERNAME=seaweedfs +WEED_POSTGRES_PASSWORD=secret +WEED_POSTGRES_SSLMODE=disable +WEED_POSTGRES_CONNECTION_MAX_IDLE=5 +WEED_POSTGRES_CONNECTION_MAX_OPEN=75 +WEED_POSTGRES_CONNECTION_MAX_LIFETIME_SECONDS=600 +WEED_LEVELDB2_ENABLED=false +``` + +## MongoDB Configuration +```shell +WEED_MONGODB_ENABLED=true +WEED_MONGODB_URI=mongodb://mongodb:27017 +WEED_MONGODB_DATABASE=seaweedfs +WEED_MONGODB_USERNAME=seaweedfs +WEED_MONGODB_PASSWORD=secret +WEED_LEVELDB2_ENABLED=false +``` + +## Etcd Configuration +```shell +WEED_ETCD_ENABLED=true +WEED_ETCD_SERVERS=etcd1:2379,etcd2:2379,etcd3:2379 +WEED_ETCD_KEY_PREFIX=seaweedfs. +WEED_ETCD_TIMEOUT=3s +WEED_LEVELDB2_ENABLED=false +``` + +## Important Notes + +1. **Only one store can be enabled**: Make sure to disable the default `leveldb2` store when using an external metadata store: + ```shell + WEED_LEVELDB2_ENABLED=false + ``` + +2. **Available stores**: To see all available filer stores and their configuration options, run: + ```shell + weed scaffold -config=filer + ``` + +3. **Data migration**: Changing stores doesn't automatically migrate existing data. Apply these configurations to new installations or migrate data manually. + +4. **Array values**: For configuration options that accept arrays (like Redis cluster addresses), use comma-separated values: + ```shell + WEED_REDIS_CLUSTER2_ADDRESSES=host1:6379,host2:6379,host3:6379 + ```