Minio 集群部署

一、Minio 集群部署

1.1 相关包下载地址

go下载地址:https://golang.google.cn/dl/

minio下载地址:https://github.com/minio/minio/tags

  • 版本 RELEASE.2025-04-22 是最后一个保留完整 Web 控制台功能的社区版。

1.2 go编译环境安装

1
2
3
4
5
6
7
8
9
10
11
[czz@czz downloads]$ tar xf go1.25.5.linux-amd64.tar.gz
[czz@czz ~]$ mv -f downloads/go .
[czz@czz ~]$ vim .bashrc
export GOROOT=/home/czz/go
export GOPATH=/home/czz/go_path
export GOPROXY=https://goproxy.cn
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
[czz@czz ~]$ source .bashrc
[czz@czz ~]$ mkdir -p go_path/{src,bin,pkg}
[czz@czz ~]$ go version
go version go1.25.5 linux/amd64

1.3 编译minio二进制文件

1
2
3
[czz@czz downloads]$ tar xf go1.25.5.linux-amd64.tar.gz 
[czz@czz downloads]$ cd minio-RELEASE.2025-04-22T22-12-26Z
[czz@czz minio-RELEASE.2025-04-22T22-12-26Z]$ env GOOS=linux GOARCh=amd64 go build

只需要把名为minio的二进制文件复制到需要部署的linux服务器即可

1.4 部署minio集群

安装路径:/opt/aspire/product/eisp/minio
日志路径:/opt/aspire/product/eisp/minio
数据路径:/data/minio/data

复制minio的二进制文件到三台服务器目录下

1
2
3
4
5
[eisp@qgplus-gate-30d6 ~]$ cd minio/
[eisp@qgplus-gate-30d6 minio]$ ll
-rwxr-xr-x 1 eisp aspire 103751832 Jun 16 2025 minio
-rwxr-xr-x 1 eisp aspire 0 Jun 16 2025 minio.log
-rwxr-xr-x 1 eisp aspire 282 Jan 14 2024 start.sh

3台minio服务器启动脚本

1
2
3
4
5
[eisp@qgplus-gate-30d6 minio]$ cat start.sh
#!/bin/bash
export MINIO_ROOT_USER=minio
export MINIO_ROOT_PASSWORD='******'
/opt/aspire/product/eisp/minio/minio server http://10.183.33.153/data/minio/data http://10.183.33.199/data/minio/data http://10.183.33.181/data/minio/data --console-address ":9001" > minio.log &

启动3台主机上的minio服务

1
[eisp@qgplus-gate-30d6 minio]$ bash start.sh

web控制台

访问任意一台minio主机的–console-address地址

二、Minio集群数据迁移

2.1 使用 rclone 迁移minio数据

安装rclone

1
2
[root@5gxx-2-32 ~]# yum install unzip
[root@5gxx-2-32 ~]# curl https://rclone.org/install.sh | sudo bash

网络无法下载使用以下install.sh脚本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#!/usr/bin/env bash

# error codes
# 0 - exited without problems
# 1 - parameters not supported were used or some unexpected error occurred
# 2 - OS not supported by this script
# 3 - installed version of rclone is up to date
# 4 - supported unzip tools are not available

set -e

#when adding a tool to the list make sure to also add its corresponding command further in the script
unzip_tools_list=('unzip' '7z' 'busybox')

usage() { echo "Usage: sudo -v ; curl https://rclone.org/install.sh | sudo bash [-s beta]" 1>&2; exit 1; }

#check for beta flag
if [ -n "$1" ] && [ "$1" != "beta" ]; then
usage
fi

if [ -n "$1" ]; then
install_beta="beta "
fi


#create tmp directory and move to it with macOS compatibility fallback
tmp_dir=$(mktemp -d 2>/dev/null || mktemp -d -t 'rclone-install.XXXXXXXXXX')
cd "$tmp_dir"


#make sure unzip tool is available and choose one to work with
set +e
for tool in ${unzip_tools_list[*]}; do
trash=$(hash "$tool" 2>>errors)
if [ "$?" -eq 0 ]; then
unzip_tool="$tool"
break
fi
done
set -e

# exit if no unzip tools available
if [ -z "$unzip_tool" ]; then
printf "\nNone of the supported tools for extracting zip archives (${unzip_tools_list[*]}) were found. "
printf "Please install one of them and try again.\n\n"
exit 4
fi

# Make sure we don't create a root owned .config/rclone directory #2127
export XDG_CONFIG_HOME=config

#check installed version of rclone to determine if update is necessary
version=$(rclone --version 2>>errors | head -n 1)
if [ -z "$install_beta" ]; then
current_version=$(curl -fsS https://downloads.rclone.org/version.txt)
else
current_version=$(curl -fsS https://beta.rclone.org/version.txt)
fi

if [ "$version" = "$current_version" ]; then
printf "\nThe latest ${install_beta}version of rclone ${version} is already installed.\n\n"
exit 3
fi


#detect the platform
OS="$(uname)"
case $OS in
Linux)
OS='linux'
;;
FreeBSD)
OS='freebsd'
;;
NetBSD)
OS='netbsd'
;;
OpenBSD)
OS='openbsd'
;;
Darwin)
OS='osx'
binTgtDir=/usr/local/bin
man1TgtDir=/usr/local/share/man/man1
;;
SunOS)
OS='solaris'
echo 'OS not supported'
exit 2
;;
*)
echo 'OS not supported'
exit 2
;;
esac

OS_type="$(uname -m)"
case "$OS_type" in
x86_64|amd64)
OS_type='amd64'
;;
i?86|x86)
OS_type='386'
;;
aarch64|arm64)
OS_type='arm64'
;;
armv7*)
OS_type='arm-v7'
;;
armv6*)
OS_type='arm-v6'
;;
arm*)
OS_type='arm'
;;
*)
echo 'OS type not supported'
exit 2
;;
esac


#download and unzip
if [ -z "$install_beta" ]; then
download_link="https://downloads.rclone.org/rclone-current-${OS}-${OS_type}.zip"
rclone_zip="rclone-current-${OS}-${OS_type}.zip"
else
download_link="https://beta.rclone.org/rclone-beta-latest-${OS}-${OS_type}.zip"
rclone_zip="rclone-beta-latest-${OS}-${OS_type}.zip"
fi

curl -OfsS "$download_link"
unzip_dir="tmp_unzip_dir_for_rclone"
# there should be an entry in this switch for each element of unzip_tools_list
case "$unzip_tool" in
'unzip')
unzip -a "$rclone_zip" -d "$unzip_dir"
;;
'7z')
7z x "$rclone_zip" "-o$unzip_dir"
;;
'busybox')
mkdir -p "$unzip_dir"
busybox unzip "$rclone_zip" -d "$unzip_dir"
;;
esac

cd $unzip_dir/*

#mounting rclone to environment

case "$OS" in
'linux')
#binary
cp rclone /usr/bin/rclone.new
chmod 755 /usr/bin/rclone.new
chown root:root /usr/bin/rclone.new
mv /usr/bin/rclone.new /usr/bin/rclone
#manual
if ! [ -x "$(command -v mandb)" ]; then
echo 'mandb not found. The rclone man docs will not be installed.'
else
mkdir -p /usr/local/share/man/man1
cp rclone.1 /usr/local/share/man/man1/
mandb
fi
;;
'freebsd'|'openbsd'|'netbsd')
#binary
cp rclone /usr/bin/rclone.new
chown root:wheel /usr/bin/rclone.new
mv /usr/bin/rclone.new /usr/bin/rclone
#manual
mkdir -p /usr/local/man/man1
cp rclone.1 /usr/local/man/man1/
makewhatis
;;
'osx')
#binary
mkdir -m 0555 -p ${binTgtDir}
cp rclone ${binTgtDir}/rclone.new
mv ${binTgtDir}/rclone.new ${binTgtDir}/rclone
chmod a=x ${binTgtDir}/rclone
#manual
mkdir -m 0555 -p ${man1TgtDir}
cp rclone.1 ${man1TgtDir}
chmod a=r ${man1TgtDir}/rclone.1
;;
*)
echo 'OS not supported'
exit 2
esac


#update version variable post install
version=$(rclone --version 2>>errors | head -n 1)

printf "\n${version} has successfully installed."
printf '\nNow run "rclone config" for setup. Check https://rclone.org/docs/ for more details.\n\n'
exit 0

配置rclone

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[root@5gxx-2-32 ~]# vim /root/.config/rclone/rclone.conf
/root/.config/rclone/rclone.conf
[minio-old]
type = s3
provider = Minio
env_auth = false
access_key_id = minio
secret_access_key = ***
endpoint = http://192.168.64.32:9000
[minio-new]
type = s3
provider = Minio
env_auth = false
access_key_id = minio
secret_access_key = ***
endpoint = http://192.168.223.128:9000

使用rclone迁移数据到新的minio上

1
2
3
4
5
##迁移所有数据
[root@5gxx-2-32 ~]# rclone sync minio-old:/ minio-new:/

##如果想迁移单个Bucket,指定源和目标Bucket名称即可
[root@5gxx-2-32 ~]# rclone sync minio-old:/bj-manager-sjb minio-new:/bj-manager-sjb

也可以迁移到本地目录

1
2
3
4
5
##从minio迁移到本地目录
rclone copy minio-old:/ /tmp/rclone/

##从本地目录迁移到minio
rclone copy /tmp/rclone/ minio-new:/
-------------本文结束感谢您的阅读-------------