Skip to main content

Single Node

Deploy File Service

  1. Download the Image

    docker pull registry.cn-hangzhou.aliyuncs.com/mdpublic/mingdaoyun-file:2.1.0
  2. Create Data Directories

    mkdir -p /data/file/volume/{cache,data,fetchtmp,multitmp,tmp}
  3. Create Configuration File Directory

    mkdir -p /usr/local/MDPrivateDeployment/clusterMode/config
  4. Create s3-config.json File for Storage Integration, Template Below

    cat > /usr/local/MDPrivateDeployment/clusterMode/config/s3-config.json << EOF
    {
    "mode": 1,
    "accessKeyID": "your_accessKey",
    "secretAccessKey": "your_secretKey",
    "bucketEndPoint": "http://192.168.0.11:9011",
    "bucketName": {
    "mdmedia": "mdmedia",
    "mdpic": "mdpic",
    "mdpub": "mdpub",
    "mdoc": "mdoc"
    },
    "region": "1",
    "addressingModel": 1
    }
    EOF
    • For self-hosted MinIO object storage, replace accessKeyID and secretAccessKey with MinIO service MINIO_ROOT_USER and MINIO_ROOT_PASSWORD variable values
    • Self-hosted MinIO object storage typically does not define region, so a random value of 1 can be filled
    • Self-hosted MinIO object storage is usually accessed via IP. The "addressingModel": 1 parameter should be included to prevent the bucket from being automatically prefixed to the IP and forming an incorrect endpoint address
  5. Create file.yaml File

    cat > /usr/local/MDPrivateDeployment/clusterMode/file.yaml <<EOF
    version: '3'
    services:
    file:
    image: registry.cn-hangzhou.aliyuncs.com/mdpublic/mingdaoyun-file:2.1.0
    volumes:
    - /usr/share/zoneinfo/Etc/GMT-8:/etc/localtime
    - /data/file/volume:/data/storage
    - /usr/local/MDPrivateDeployment/clusterMode/config/s3-config.json:/usr/local/file/s3-config.json
    ports:
    - "9000:9000"
    environment:
    ENV_ACCESS_KEY_FILE: storage
    ENV_SECRET_KEY_FILE: 12345678910
    ENV_MINGDAO_PROTO: "http"
    ENV_MINGDAO_HOST: "hap.domain.com"
    ENV_MINGDAO_PORT: "80"
    # Redis master-slave mode
    ENV_FILE_CACHE: "redis://:123456@192.168.10.13:6379"
    # Redis sentinel mode
    #ENV_REDIS_SENTINEL_ENDPOINTS: "192.168.10.13:26379,192.168.10.14:26379,192.168.10.15:26379"
    #ENV_REDIS_SENTINEL_MASTER: "mymaster"
    #ENV_REDIS_SENTINEL_PASSWORD: "password"
    ENV_FILECACHE_EXPIRE: "false"
    ENV_FILE_ID: "file1"
    ENV_FILE_DOMAIN: "http://file:9000"
    command: ["./main", "server", "/data/storage/data"]
    EOF
    • Make sure to replace the variable-specified access addresses with the actual main system address during deployment
    • Replace Redis connection information with the actual password and IP during actual deployment
    • In multi-node deployments, ENV_FILE_ID should have unique values for each instance, such as file1, file2, file3, etc.
    • Note that in file v2 version, MINIO_ACCESS_KEY and MINIO_SECRET_KEY variables are deprecated. Use ENV_ACCESS_KEY_FILE and ENV_SECRET_KEY_FILE instead to validate microservice to file service authentication
    • The ENV_FILE_DOMAIN variable value must be consistent with ENV_FILE_ENDPOINTS in the microservice configuration file, but with an added http://
  6. Create Start and Stop Scripts

    cat > /usr/local/MDPrivateDeployment/clusterMode/start.sh <<EOF
    docker stack deploy -c /usr/local/MDPrivateDeployment/clusterMode/file.yaml file
    EOF

    cat > /usr/local/MDPrivateDeployment/clusterMode/stop.sh <<EOF
    docker stack rm file
    EOF

    chmod +x /usr/local/MDPrivateDeployment/clusterMode/start.sh
    chmod +x /usr/local/MDPrivateDeployment/clusterMode/stop.sh
  7. Initialize swarm (can be ignored if this node is already initialized)

    docker swarm init
  8. Start Service

    bash /usr/local/MDPrivateDeployment/clusterMode/start.sh
  9. Add to Startup

    echo "bash /usr/local/MDPrivateDeployment/clusterMode/start.sh" >> /etc/rc.local
    chmod +x /etc/rc.local
  10. After Deployment, Upload Prefabricated Files to MinIO Object Storage