环境说明
1. 安装
-
下载地址:
http://dl.minio.org.cn/client/mc/release/linux-amd64/mc -
安装
- 只有一个二进制文件,放到目标服务器的
/usr/local/bin/
下即可 - 我是放在minio-backup上
- 只有一个二进制文件,放到目标服务器的
-
主节点配置
[root@liubei minio]# mc config host add minio_master http://10.10.xxx.251:9000 minio liubei@161
mc: Configuration written to `/root/.mc/config.json`. Please update your access credentials.
mc: Successfully created `/root/.mc/share`.
mc: Initialized share uploads `/root/.mc/share/uploads.json` file.
mc: Initialized share downloads `/root/.mc/share/downloads.json` file.
Added `minio_master` successfully.
- 从节点配置
[root@luibei minio]# mc config host add minio_slave http://10.10.xxx.204:9000 minio liubei@161
Added `minio_slave` successfully.
- 创建启动文件
/usr/lib/systemd/system/minioc.service
,内容如下:
[Unit]
Description=startup minioc mirror master to slave
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/mc mirror --remove --overwrite --watch minio_master minio_slave
Restart=on-failure
[Install]
WantedBy=multi-user.target
- 启动服务
systemctl start minioc.service
- 设置开机自启
systemctl enable minioc.service
- 查看服务状态
● minioc.service - startup minioc mirror master to slave
Loaded: loaded (/usr/lib/systemd/system/minioc.service; enabled; vendor preset: disabled)
Active: active (running) since 日 2024-04-28 09:39:00 CST; 1h 2min ago
Main PID: 222131 (mc)
CGroup: /system.slice/minioc.service
└─222131 /usr/local/bin/mc mirror --remove --overwrite --watch minio_master minio_slave
4月 28 09:39:00 esl_w-sit-202441117-3 systemd[1]: Started startup minioc mirror master to slave.
4月 28 09:39:00 esl_w-sit-202441117-3 mc[222131]: `minio_master/liubei` -> `minio_slave/liubei`
4月 28 09:39:00 esl_w-sit-202441117-3 mc[222131]: `minio_master/liubei/nginx.jpg` -> `minio_slave/liubei/nginx.jpg`
4月 28 09:40:08 esl_w-sit-202441117-3 mc[222131]: `minio_master/liubei/u=2859650906,3717257575&fm=253&fmt=auto&app=138&f=JPEG.webp` -> `minio_slave/liubei/u=2859650906...JPEG.webp`
Hint: Some lines were ellipsized, use -l to show in full.
2. 测试
- 登录salver,可以看到master上的文件已经同步进来了。
- 登录master,创建bucket或上传图片,可以看到,slave都能同步
3. 双机热备
- 用同样方法,在master上也安装一个mc,配置方法也相同。