File Cluster
| Server IP | Host Role |
|---|---|
| 192.168.10.16 | File Node01 |
| 192.168.10.17 | File Node02 |
| 192.168.10.18 | File Node03 |
| 192.168.10.19 | File Node04 |
- Docker must be installed on all File nodes in advance.
Initialize Swarm Environment
-
Execute the swarm initialization command on File Node01
docker swarm init
# After executing the initialization command, a join command will be output, which needs to be run on the other three nodes.
# If the server has multiple IP addresses, you can use the --advertise-addr parameter to specify the IP and port for other nodes to connect to the current manager node.
# docker swarm init --advertise-addr 192.168.1.11 -
Run the join command on File Node02, 3, and 4 to join the swarm cluster
docker swarm join --token xxxxxxxx
# If you forget the token, you can check it on File Node01 with the following command:
# docker swarm join-token worker -
View and record the node IDs
docker node ls
Deploy File Storage
Steps 1 and 2 should be carried out on all four servers
-
Download the image
- Server supports internet access
- Server does not support internet access
docker pull registry.cn-hangzhou.aliyuncs.com/mdpublic/mingdaoyun-file:1.7.0# Download the offline image package file from the link, then upload it to the deployment server after download.
https://pdpublic.mingdao.com/private-deployment/offline/mingdaoyun-file-linux-amd64-1.7.0.tar.gz
# Load the offline image on the server using the docker load -i command
docker load -i mingdaoyun-file-linux-amd64-1.7.0.tar.gz -
Create data directory
mkdir -p /data/file/volume/{cache,data,fetchtmp,multitmp,tmp}
The following steps need to be performed only on File Node01
-
Create a directory for configuration files
mkdir -p /usr/local/MDPrivateDeployment/clusterMode -
Create the file.yaml file
cat > /usr/local/MDPrivateDeployment/clusterMode/file.yaml <<EOF
version: '3'
services:
file1:
hostname: file1
image: registry.cn-hangzhou.aliyuncs.com/mdpublic/mingdaoyun-file:1.7.0
volumes:
- /usr/share/zoneinfo/Etc/GMT-8:/etc/localtime
- /data/file/volume:/data/storage
ports:
- "9001:9000"
environment:
MINIO_ACCESS_KEY: storage
MINIO_SECRET_KEY: 123456
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"
command: "./main server http://file{1...4}/data/storage/data"
deploy:
placement:
constraints:
- node.id == xxxxxxxxxxxxxxxx # The node.id value of File Node01
file2:
hostname: file2
image: registry.cn-hangzhou.aliyuncs.com/mdpublic/mingdaoyun-file:1.7.0
volumes:
- /usr/share/zoneinfo/Etc/GMT-8:/etc/localtime
- /data/file/volume:/data/storage
ports:
- "9002:9000"
environment:
MINIO_ACCESS_KEY: storage
MINIO_SECRET_KEY: 123456
ENV_MINGDAO_PROTO: "http"
ENV_MINGDAO_HOST: "hap.domain.com"
ENV_MINGDAO_PORT: "80"
# 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: "file2"
command: "./main server http://file{1...4}/data/storage/data"
deploy:
placement:
constraints:
- node.id == xxxxxxxxxxxxxxxx # The node.id value of File Node02
file3:
hostname: file3
image: registry.cn-hangzhou.aliyuncs.com/mdpublic/mingdaoyun-file:1.7.0
volumes:
- /usr/share/zoneinfo/Etc/GMT-8:/etc/localtime
- /data/file/volume:/data/storage
ports:
- "9003:9000"
environment:
MINIO_ACCESS_KEY: storage
MINIO_SECRET_KEY: 123456
ENV_MINGDAO_PROTO: "http"
ENV_MINGDAO_HOST: "hap.domain.com"
ENV_MINGDAO_PORT: "80"
# 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: "file3"
command: "./main server http://file{1...4}/data/storage/data"
deploy:
placement:
constraints:
- node.id == xxxxxxxxxxxxxxxx # The node.id value of File Node03
file4:
hostname: file4
image: registry.cn-hangzhou.aliyuncs.com/mdpublic/mingdaoyun-file:1.7.0
volumes:
- /usr/share/zoneinfo/Etc/GMT-8:/etc/localtime
- /data/file/volume:/data/storage
ports:
- "9004:9000"
environment:
MINIO_ACCESS_KEY: storage
MINIO_SECRET_KEY: 123456
ENV_MINGDAO_PROTO: "http"
ENV_MINGDAO_HOST: "hap.domain.com"
ENV_MINGDAO_PORT: "80"
# 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: "file4"
command: "./main server http://file{1...4}/data/storage/data"
deploy:
placement:
constraints:
- node.id == xxxxxxxxxxxxxxxx # The node.id value of File Node04
EOF- Replace the specified access address in the variables with the actual main address of the system during deployment.
- Replace the Redis connection information with the actual password and IP in the actual deployment.
- Replace the node.id values for each node, which can be found using docker node ls.
-
Create the startup script
mkdir -p /usr/local/MDPrivateDeployment/clusterMode
cat > /usr/local/MDPrivateDeployment/start.sh <<EOF
docker stack deploy -c /usr/local/MDPrivateDeployment/clusterMode/file.yaml file
EOF
chmod +x /usr/local/MDPrivateDeployment/start.sh -
Start the service
bash /usr/local/MDPrivateDeployment/start.sh -
Add to startup on boot
echo "bash /usr/local/MDPrivateDeployment/start.sh" >> /etc/rc.local
chmod +x /etc/rc.local -
Confirm the service status is successfully running
$ docker stack ps file
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
XXXX1XXXX file_file4.1 registry.cn-hangzhou.aliyuncs.com/mdpublic/mingdaoyun-file:1.7.0 file1 Running Running 3 minutes ago
XXXX2XXXX file_file3.1 registry.cn-hangzhou.aliyuncs.com/mdpublic/mingdaoyun-file:1.7.0 file2 Running Running 3 minutes ago
XXXX3XXXX file_file2.1 registry.cn-hangzhou.aliyuncs.com/mdpublic/mingdaoyun-file:1.7.0 file3 Running Running 3 minutes ago
XXXX4XXXX file_file1.1 registry.cn-hangzhou.aliyuncs.com/mdpublic/mingdaoyun-file:1.7.0 file4 Running Running 3 minutes ago