西安女子 發表於 2022-2-25 14:08:00

超详细centos中部署minio

<h1 id="准备工作">准备工作</h1>
<h2 id="1寻找国外minio官网并安装minio">1.寻找国外minio官网,并安装minio</h2>
<h2 id="2格式化并挂载好硬盘">2.格式化并挂载好硬盘</h2>
<h2 id="3centos系统需要打开端口">3.centos系统需要打开端口</h2>
<h2 id="4下载配置mc和prometheus非必需">4.下载配置mc和Prometheus(非必需)</h2>
<hr>
<h2 id="安装">安装</h2>
<h3 id="安装前准备文件夹创建控制台登入root账户sudo-su并进入根目录cd-">安装前准备,文件夹创建,控制台登入root账户(<code>sudo su</code>)并进入根目录(<code>cd /</code>)</h3>
<h3 id="创建运行文件夹mkdir-optminio">创建<em>运行文件夹</em>(<code>mkdir /opt/minio</code>)</h3>
<h3 id="创建存储文件夹mkdir-mntminio进入后创建子文件夹data1">创建<em>存储文件夹</em>(<code>mkdir /mnt/minio</code>),进入后创建子文件夹data1</h3>
<hr>
<h3 id="下载并赋予权限进入运行文件夹">下载并赋予权限,进入<em>运行文件夹</em></h3>
<h3 id="wget-httpsdlminioserverminioreleaselinux-amd64minio"><code>wget https://dl.min.io/server/minio/release/linux-amd64/minio</code></h3>
<h3 id="chmod-x-minio"><code>chmod +x minio</code></h3>
<hr>
<h2 id="挂载硬盘">挂载硬盘</h2>
<h3 id="查看主机内存在的所有硬盘fdisk--l-">查看主机内存在的所有硬盘(<code>fdisk -l </code>)</h3>
<h3 id="新挂载的硬盘可以根据大小区分举例sdf这块盘当运行格式化命令后mkfs--t-ext4-devsdf运行blkid可以查看到uuid此时将硬盘挂载到储存文件夹下的子文件夹data1运行vim-etcfstab-按-i-末尾追加uuidd765d835-4989-4bff-8ae8-116c654d4bba---mntminiodata1--ext4----defaults----0---2---保存后重启reboot">新挂载的硬盘可以根据大小区分'举例sdf这块盘',当运行格式化命令后(<code>mkfs -t ext4 /dev/sdf</code>),运行(<code>blkid</code>)可以查看到UUID,此时将硬盘挂载到<em>储存文件夹</em>下的子文件夹data1。运行<code>vim /etc/fstab</code> 按 i 末尾追加<code>UUID=d765d835-4989-4bff-8ae8-116c654d4bba   /mnt/minio/data1ext4    defaults    0   2</code>.   保存后重启(<code>reboot</code>).</h3>
<hr>
<h2 id="测试运行minio">测试运行minio</h2>
<h3 id="单机单磁盘">单机单磁盘</h3>
<h4 id="运行netstat--anpt-查看9000-9001端口是否被使用docker容器容易占用当然了console和api使用的端口都是可以自由设置的我只是用常见的9000和9001举例">运行<code>netstat -anpt</code> 查看9000 9001端口是否被使用,docker容器容易占用。当然了,console和API使用的端口都是可以自由设置的,我只是用常见的9000和9001举例。</h4>
<h4 id="进入运行文件夹输入-minio-server---console-address-9001---address-9000-miniolog-mntminiodata1">进入<em>运行文件夹</em>,输入<code> ./minio server --console-address :9001 --address :9000 &gt;minio.log /mnt/minio/data1</code></h4>
<p><em>./minio代表刚才下载并附权的那个文件。 --console-address :9001 代表将console页面指定为9001端口访问。 -- address :9000 指定API访问端口。 &gt;minio.log 表示当前文件夹下创建了一个日志文件。 /mnt/minio/data1表示指明在<strong>储存文件夹</strong>里的位置</em></p>
<h4 id="此模式下不能自由的创建桶个人使用的话可以手动在储存文件夹下创建文件夹即创建了桶">此模式下,不能自由的创建桶,个人使用的话可以手动在<em>储存文件夹</em>下创建文件夹,即创建了桶。</h4>
<hr>
<h3 id="单机多磁盘与分布式">单机多磁盘与分布式</h3>
<h4 id="单机多磁盘4块或4的倍数块相同大小的磁盘并自动引入纠删码模式">单机多磁盘,4块或4的倍数块相同大小的磁盘。并自动引入纠删码模式。</h4>
<h5 id="minio-server---console-address-9001---address-9000-miniolog-mntminiodata1-mntminiodata2-mntminiodata3-mntminiodata4分布式部署至少四个节点运行相同minio配置也是自动引入纠删码模式"><code>./minio server --console-address :9001 --address :9000 &gt;minio.log /mnt/minio/data1 /mnt/minio/data2 /mnt/minio/data3 /mnt/minio/data4</code>分布式部署,至少四个节点,运行相同minio配置。也是自动引入纠删码模式。</h5>
<h4 id="多节点分布式节点为1010520010105203-文件夹都为data1data4四个节点依次运行相同命令节点中相近版本可以组成分布式没限制必须所有节点minio版本一致">多节点分布式(节点为10.10.5.200~10.10.5.203 文件夹都为data1~data4)四个节点依次运行相同命令。(<em>节点中相近版本可以组成分布式,没限制必须所有节点minio版本一致</em>)</h4>
<h5 id="minio-server---console-address-9001---address-9000-miniolog-http10105200203mntminiodata14"><code>./minio server --console-address :9001 --address :9000 &gt;minio.log http:10.10.5.{200...203}/mnt/minio/data{1...4}</code></h5>
<h5 id="分布式部署还可以使用第五个节点对上述四点进行负载均衡配置合并成一个连接访问">分布式部署还可以使用第五个节点对上述四点进行负载均衡配置,合并成一个连接访问。</h5>
<hr>
<h3 id="正式运行">正式运行</h3>
<h4 id="在运行文件夹下执行vim-startminiosh">在<em>运行文件夹</em>下执行<code>vim startminio.sh</code>,</h4>
<pre><code>#!/bin/bash
export MINIO_ROOT_USER=admin
export MINIO_ROOT_PASSWORD=12345678

/opt/minio/minio server --console-address :9001 --address :9000 /mnt/minio/data{1...4} &gt;minio.log
</code></pre>
<hr>
<h4 id="赋予权限">赋予权限</h4>
<h4 id="chmod-x-startminiosh"><code>chmod +x startminio.sh</code></h4>
<hr>
<h4 id="创建开机执行服务">创建开机执行服务</h4>
<h4 id="vim-usrlibsystemdsystemminioservice"><code>vim /usr/lib/systemd/system/minio.service</code></h4>
<pre><code>
Description=Minio server
After=network.target


Type=simple
User=root
Group=root

ExecStart=/opt/minio/startminio.sh

# Give a reasonable amount of time for the server to start up/shut down
TimeoutSec=300

# Place temp files in a secure directory, not /tmp
PrivateTmp=true


WantedBy=multi-user.target
</code></pre>
<hr>
<h4 id="赋予权限并开机启动">赋予权限并开机启动</h4>
<h4 id="chmod-644-usrlibsystemdsystemminioservice"><code>chmod 644 /usr/lib/systemd/system/minio.service</code></h4>
<h4 id="systemctl-daemon-reload"><code>systemctl daemon-reload</code></h4>
<h4 id="systemctl-start-minioservice"><code>systemctl start minio.service</code></h4>
<h4 id="systemctl-enable-minioservice"><code>systemctl enable minio.service</code></h4>
<hr>
<h2 id="打开防火墙中的9000与9001端口">打开防火墙中的9000与9001端口</h2>
<h4 id="查看状态">查看状态</h4>
<h4 id="systemctl-status-firewalld"><code>systemctl status firewalld</code></h4>
<h4 id="查看已开放端口">查看已开放端口</h4>
<h4 id="firewall-cmd---list-all"><code>firewall-cmd --list-all</code></h4>
<h4 id="开放9000端口">开放9000端口</h4>
<h4 id="firewall-cmd---zonepublic---add-port9000tcp---permanent"><code>firewall-cmd --zone=public --add-port=9000/tcp --permanent</code></h4>
<h4 id="防火墙重载">防火墙重载</h4>
<h4 id="firewall-cmd---reload"><code>firewall-cmd --reload</code></h4>
<hr>
<h2 id="此时访问http101052009001登录admin12345678可以使用">此时访问http://10.10.5.200:9001,登录admin,12345678,可以使用</h2>
<hr>
<h2 id="安装mc">安装mc</h2>
<h3 id="还是进入国外minio官网进入下载附权运行">还是进入国外minio官网,进入下载,附权,运行</h3>
<h4 id="wget-httpsdlminioclientmcreleaselinux-amd64mc"><code>wget https://dl.min.io/client/mc/release/linux-amd64/mc</code></h4>
<h4 id="chmod-x-mc"><code>chmod +x mc</code></h4>
<h4 id="mc-alias-set-myminio-http00009000-admin-12345678"><code>./mc alias set myminio/ http://0.0.0.0:9000 admin 12345678</code></h4>
<hr>
<h2 id="安装运行prometheus">安装运行Prometheus</h2>
<h3 id="下载解压调整配置运行">下载,解压,调整配置,运行</h3>
<h4 id="wget-httpsgithubcomprometheusprometheusreleasesdownloadv2334prometheus-2334linux-amd64targz"><code>wget https://github.com/prometheus/prometheus/releases/download/v2.33.4/prometheus-2.33.4.linux-amd64.tar.gz</code></h4>
<h4 id="tar-xvfz-prometheus-2334linux-amd64targztargz"><code>tar xvfz prometheus-2.33.4.linux-amd64.tar.gz.tar.gz</code></h4>
<h4 id="cd-prometheus-2334linux-amd64"><code>cd prometheus-2.33.4.linux-amd64</code></h4>
<h4 id="optminiomc-admin-prometheus-generate-myminio--这里的myminio是前文mc-alias-set-myminio中设置的"><code>/opt/minio/mc admin prometheus generate myminio</code>这里的myminio是前文(./mc alias set myminio)中设置的。</h4>
<h4 id="复制scrape_configs之后的内容追加到prometheusyml末尾注意格式缩进">复制scrape_configs之后的内容,追加到prometheus.yml末尾,注意格式缩进</h4>
<pre><code>scrape_configs:
- job_name: minio-job
bearer_token: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJleHAiOjQ3OTkzNTcwMDUsImlzcyI6InByb21ldGhldXMiLCJzdWIiOiJhZG1pbiJ9.7o0ewFRd7EbwWneh0Vg09R4UljwAL4B0zUKovBwWPlVfPkGxSe2l_DNnDPO-jwGBcn77LsxOaldRww7YAIlJjA
metrics_path: /minio/v2/metrics/cluster
scheme: http
static_configs:
- targets: ['0.0.0.0:9000']
</code></pre>
<h4 id="配置文件startminiosh中还要-追加">配置文件startminio.sh中还要 追加</h4>
<h4 id="export-minio_prometheus_auth_typepublic"><code>export MINIO_PROMETHEUS_AUTH_TYPE="public"</code></h4>
<h4 id="export-minio_prometheus_urlhttp101052009090"><code>export MINIO_PROMETHEUS_URL="http://10.10.5.200:9090"</code></h4>
<h4 id="在prometheus-2334linux-amd64文件夹中运行prometheus---configfileprometheusyml">在prometheus-2.33.4.linux-amd64文件夹中运行<code>./prometheus --config.file=prometheus.yml</code></h4>
<h5 id="ps-yaml跟yml本质是一个东西近些年常用后者"><em>ps: .yaml跟.yml本质是一个东西,近些年常用后者</em></h5>
<hr>
<h2 id="重启后三者一起运行顺序为minio--mc--prometheus">重启后三者一起运行,顺序为minio &gt; mc &gt; prometheus</h2>
<hr>
<h2 id="设置证书绑定外网ip等操作下次更新">设置证书绑定外网IP等操作,下次更新</h2><br><br>
来源:https://www.cnblogs.com/qiangqiangpeng/p/15935836.html
頁: [1]
查看完整版本: 超详细centos中部署minio