centos7 搭建minio 一、下載安裝文件 二、創建數據文件夾 三、啓動 四、設置永久訪問鏈接 五、修改用戶名密碼: 六、集羣部署

一、下載安裝文件

wget http://dl.minio.org.cn/server/minio/release/linux-amd64/minio

二、創建數據文件夾

mkdir /opt/minio/data

三、啓動

# 賦予權限
chmod 777 minio
# 啓動命令
./minio server /opt/minio/data
# 後臺啓動
nohup ./minio server /opt/minio/data >/dev/null &

如發下以下問題是發生端口占用:

請更換端口或殺死佔用端口的進程。

啓動成功如下所示:

訪問console直接ip:9000就可以了,會直接跳轉到控制檯。

四、設置永久訪問鏈接

很多情況下,我們的圖片是需要瀏覽器直接訪問的,這裏通過minio的客戶端進行設置。

下載客戶端:

wget https://dl.minio.io/client/mc/release/linux-amd64/mc

賦予權限

chmod 777 mc

添加server

./mc config host add minio http://172.16.3.28:9000/ minioadmin minioadmin

設置需要開放下載的bucket, 注意需要帶minio

./mc  policy  set  download  minio/graph-editor

訪問圖片:

http://172.16.3.28:9000/graph-editor/img/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20210820174907.jpg

五、修改用戶名密碼:

export MINIO_ROOT_USER=admin
export MINIO_ROOT_PASSWORD=12345678

注意,minio的密碼要求達到8個字符,否則會啓動失敗,如下所示:

[root@public-server9 minio]# ./minio server /opt/minio/data1
ERROR Unable to validate credentials inherited from the shell environment: Invalid credentials
      > Please provide correct credentials
      HINT:
        Access key length should be at least 3, and secret key length at least 8 characters

六、集羣部署

需要在每臺節點執行以下的命令,如下所示,共三個節點,每個節點三個目錄

nohup ./minio server --console-address ":10001"  http://172.16.3.28/opt/minio/data1 http://172.16.3.28/opt/minio/data2 http://172.16.3.28/opt/minio/data3 \
http://172.16.3.29/opt/minio/data1 http://172.16.3.29/opt/minio/data2 http://172.16.3.29/opt/minio/data3 \
http://172.16.3.30/opt/minio/data1 http://172.16.3.30/opt/minio/data2 http://172.16.3.30/opt/minio/data3 \
>/dev/null &

設置永久訪問權限和前面一樣,不同是在一臺節點設置,訪問其他節點,會自動跳到被設置的訪問節點。

添加nginx負載:

# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 4096;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

   upstream minio {
        server 172.16.3.28:9000 fail_timeout=10s max_fails=2 weight=1;
        server 172.16.3.29:9000 fail_timeout=10s max_fails=2 weight=1;
        server 172.16.3.30:9000 fail_timeout=10s max_fails=2 weight=1;
    }

   upstream minio-console {
        server 172.16.3.28:10001 fail_timeout=10s max_fails=2 weight=1;
        server 172.16.3.29:10001 fail_timeout=10s max_fails=2 weight=1;
        server 172.16.3.30:10001 fail_timeout=10s max_fails=2 weight=1;
    }

    server {
        listen       10000;
        server_name  _;
        root         /usr/share/nginx/html;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
        proxy_pass http://minio;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-for $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $remote_addr;
    }

        error_page 404 /404.html;
        location = /404.html {
        }

        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
        }
    }
    
    server {
        listen       11000;
        server_name  _;
        root         /usr/share/nginx/html;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
                proxy_pass http://minio-console;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-for $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto $remote_addr;
        }
                
        error_page 404 /404.html;
        location = /404.html {
        }

        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
        }
    }
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章