二进制安装minio 并实现主从同步
一、安装部署minio
1.1、创建minio目录并下载minio
cd
mkdir -p /usr/local/minio
cd /usr/local/minio
wget https://dl.min.io/server/minio/release/linux-amd64/minio
1.2、授予执行权限
chmod +x minio
1.3、创建存储目录和日志目录
mkdir -p /usr/local/minio/data
mkdir -p /usr/local/minio/log
1.4、在目录下创建一个启动脚本
vi start.sh
#!/bin/bash
export MINIO_ROOT_USER=minio-username
export MINIO_ROOT_PASSWORD=minio-password
# nohup启动服务 指定文件存放路径 /root/data 还有设置日志文件路径 /root/minio/log
nohup /usr/local/minio/minio server --address :9002 --console-address :9001 /usr/local/minio/minio > /usr/local/minio/log/minio.log 2>&1 &
chmod +x start.sh
注:默认账号密码minioadmin/minioadmin
1.5、设置minio开机启动
设置rc.local 开机启动
chmod u+x /etc/rc.d/rc.local
chmod u+x /etc/rc.local
编辑rc.local
[root@localhost ~]# cat /etc/rc.local
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.
touch /var/lock/subsys/local
cd /usr/local/minio
./start.sh minio
重启服务器测试
二、minio主从配置
2.1、从服务器安装过程同《一》
2.2、从服务器下载mc
wget https://dl.min.io/client/mc/release/linux-amd64/mc -P /usr/local/bin/
chmod +x /usr/local/bin/mc
2.3、配置同步
mc config host add minio_master http://172.16.1.1:19000 minio-username minio-password
mc config host add minio_slave http://172.16.1.2:19000 minio-username minio-password
2.4、启动同步进程
将master的minio所有桶(bucker)数据同步至slave的minio中
mc mirror --remove --overwrite --watch minio_master minio_slave
可通过网页在master上上传文件,再到从服务器检查是否同步文件过去。
2.5、配置mc服务开机启动
[root@localhost ~]# vi /usr/lib/systemd/system/mc.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
2.6、开机启动
[root@localhost ~]# systemctl enable mc
[root@localhost ~]# systemctl start mc