文档地址:https://docs.min.io/
基本上MinIO
服务器和客户端支持在很多系统上安装,比如Windows
、macOS
等,这里主要说Linux
系统。
wget https://dl.minio.io/server/minio/release/linux-amd64/minio
chmod +x minio
chmod +x /opt/minio/run.sh
systemctl start minio
systemctl enable minio
systemctl stop minio
vi /opt/minio/run.sh
run.sh文件
#多节点配置
export MINIO_ACCESS_KEY=自定义的账户
export MINIO_SECRET_KEY=自定义的密码
/opt/minio/minio server --address 0.0.0.0:9999 --config-dir /etc/minio \
http://192.168.1.1/home/data http:/192.168.1.2/home/data \
http://192.168.1.3/home/data http://192.168.1.4/home/data \
#单节点配置
export MINIO_ACCESS_KEY=自定义的账户
export MINIO_SECRET_KEY=自定义的密码
/opt/minio/minio server --address 0.0.0.0:9999 --config-dir /etc/minio /home/data
1、安装MinIO Client
wget https://dl.min.io/client/mc/release/linux-amd64/mc -P /usr/local/bin/
chmod +x /usr/local/bin/mc
2、添加云存储
如需添加 MinIO云存储,则需要在另一台服务器安装MinIO服务,教程查看 ->传送门
#MinIO云存储
mc config host add minio S3v4
#Amazon S3云存储
mc config host add s3 https://s3.amazonaws.com S3v4
#Google云存储
mc config host add gcs https://storage.googleapis.com S3v2
例如:
mc config host add minio(自定义名字) ip:端口号 aicadmin admin9695 S3v4
这里只说MinIO
云存储,Amazon S3
云存储参数获取查看→传送门,Google云存储参数获取查看→传送门。
基本上这里配置好了后,我们可以使用很多命令远程操作云存储上的文件了。
3、开始同步
先创建一个桶,名称为moewah
,可自行修改,使用命令:
在远程创建桶
mc mb minio/moewah
接下来开始同步:
当本地目录上传文件自动同步到远程
mc mirror(配置时候自定义的别名) -w 本地目录 对象名/桶名
mc mirror -w /www/wwwroot/www.moewah.com minio/moewah
然后你会发现远程MinIO
云存储里的MOEWAH
就会出现你网站根目录所有文件了,以后根目录新增文件都会实时同步进去。
当然这里我们也可以同时实时备份多个文件夹到多个存储桶,自行修改名称就行了。
4、开机自启
新建systemd
配置文件,适用CentOS 7
、Debian 8+
、Ubuntu 16+
。
#修改成你需要实时同步备份的文件夹
backup="/www/wwwroot/www.moewah.com"
#修改成你要备份到的存储桶
bucket="moewah"
#将以下代码一起复制到SSH运行
cat > /etc/systemd/system/minioc.service <
启动并设置开机自启:
systemctl start minioc
systemctl enable minioc
mc ls minio(之前添加的名字)
mc cp 本地文件目录 mimio/桶名/
例如 mc cp ./test1 mimio/public/
mc cp mimio/public/文件名 ./
加-r可以下载目录下所有文件
例如 /mc cp -r minio/ /home/data/
[root@mysql minio]# ./mc -help
NAME:
mc - MinIO Client for cloud storage and filesystems.
USAGE:
mc [FLAGS] COMMAND [COMMAND FLAGS | -h] [ARGUMENTS...]
COMMANDS:
alias set, remove and list aliases in configuration file
ls list buckets and objects
mb make a bucket
rb remove a bucket
cp copy objects
mirror synchronize object(s) to a remote site
cat display object contents
head display first 'n' lines of an object
pipe stream STDIN to an object
share generate URL for temporary access to an object
find search for objects
sql run sql queries on objects
stat show object metadata
mv move objects
tree list buckets and objects in a tree format
du summarize disk usage recursively
retention set retention for object(s)
legalhold manage legal hold for object(s)
diff list differences in object name, size, and date between two buckets
rm remove objects
version manage bucket versioning
ilm manage bucket lifecycle
encrypt manage bucket encryption config
event manage object notifications
watch listen for object notification events
undo undo PUT/DELETE operations
policy manage anonymous access to buckets and objects
tag manage tags for bucket and object(s)
replicate configure server side bucket replication
admin manage MinIO servers
update update mc to latest release
GLOBAL FLAGS:
--autocompletion install auto-completion for your shell
--config-dir value, -C value path to configuration folder (default: "/root/.mc")
--quiet, -q disable progress bar display
--no-color disable color theme
--json enable JSON lines formatted output
--debug enable debug output
--insecure disable SSL certificate verification
--help, -h show help
--version, -v print the version
TIP:
Use 'mc --autocompletion' to enable shell autocompletion
VERSION:
RELEASE.2021-03-23T05-46-11Z