2024-03-18 02:42:40 -04:00
// Copyright (c) 2015-2024 MinIO, Inc.
2021-04-18 15:41:13 -04:00
//
// This file is part of MinIO Object Storage stack
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
config/main: Re-write config files - add to new config v3
- New config format.
```
{
"version": "3",
"address": ":9000",
"backend": {
"type": "fs",
"disk": "/path"
},
"credential": {
"accessKey": "WLGDGYAQYIGI833EV05A",
"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
},
"region": "us-east-1",
"logger": {
"file": {
"enable": false,
"fileName": "",
"level": "error"
},
"syslog": {
"enable": false,
"address": "",
"level": "debug"
},
"console": {
"enable": true,
"level": "fatal"
}
}
}
```
New command lines in lieu of supporting XL.
Minio initialize filesystem backend.
~~~
$ minio init fs <path>
~~~
Minio initialize XL backend.
~~~
$ minio init xl <url1>...<url16>
~~~
For 'fs' backend it starts the server.
~~~
$ minio server
~~~
For 'xl' backend it waits for servers to join.
~~~
$ minio server
... [PROGRESS BAR] of servers connecting
~~~
Now on other servers execute 'join' and they connect.
~~~
....
minio join <url1> -- from <url2> && minio server
minio join <url1> -- from <url3> && minio server
...
...
minio join <url1> -- from <url16> && minio server
~~~
2016-02-12 18:27:10 -05:00
2016-08-18 19:23:42 -04:00
package cmd
config/main: Re-write config files - add to new config v3
- New config format.
```
{
"version": "3",
"address": ":9000",
"backend": {
"type": "fs",
"disk": "/path"
},
"credential": {
"accessKey": "WLGDGYAQYIGI833EV05A",
"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
},
"region": "us-east-1",
"logger": {
"file": {
"enable": false,
"fileName": "",
"level": "error"
},
"syslog": {
"enable": false,
"address": "",
"level": "debug"
},
"console": {
"enable": true,
"level": "fatal"
}
}
}
```
New command lines in lieu of supporting XL.
Minio initialize filesystem backend.
~~~
$ minio init fs <path>
~~~
Minio initialize XL backend.
~~~
$ minio init xl <url1>...<url16>
~~~
For 'fs' backend it starts the server.
~~~
$ minio server
~~~
For 'xl' backend it waits for servers to join.
~~~
$ minio server
... [PROGRESS BAR] of servers connecting
~~~
Now on other servers execute 'join' and they connect.
~~~
....
minio join <url1> -- from <url2> && minio server
minio join <url1> -- from <url3> && minio server
...
...
minio join <url1> -- from <url16> && minio server
~~~
2016-02-12 18:27:10 -05:00
import (
2024-05-03 11:54:03 -04:00
"bytes"
2018-04-05 18:04:40 -04:00
"context"
2023-01-25 13:25:36 -05:00
"encoding/hex"
2019-11-13 20:38:05 -05:00
"errors"
2018-05-08 22:04:36 -04:00
"fmt"
2021-05-17 18:13:14 -04:00
"io"
2021-06-17 23:27:04 -04:00
"log"
2020-11-02 20:52:13 -05:00
"math/rand"
2022-10-21 17:42:28 -04:00
"net"
2017-03-06 22:35:26 -05:00
"os"
2017-07-12 19:33:21 -04:00
"os/signal"
2024-05-01 13:57:52 -04:00
"path/filepath"
2022-03-21 22:05:04 -04:00
"runtime"
2018-05-18 20:51:03 -04:00
"strings"
2017-07-12 19:33:21 -04:00
"syscall"
2020-03-22 15:16:36 -04:00
"time"
config/main: Re-write config files - add to new config v3
- New config format.
```
{
"version": "3",
"address": ":9000",
"backend": {
"type": "fs",
"disk": "/path"
},
"credential": {
"accessKey": "WLGDGYAQYIGI833EV05A",
"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
},
"region": "us-east-1",
"logger": {
"file": {
"enable": false,
"fileName": "",
"level": "error"
},
"syslog": {
"enable": false,
"address": "",
"level": "debug"
},
"console": {
"enable": true,
"level": "fatal"
}
}
}
```
New command lines in lieu of supporting XL.
Minio initialize filesystem backend.
~~~
$ minio init fs <path>
~~~
Minio initialize XL backend.
~~~
$ minio init xl <url1>...<url16>
~~~
For 'fs' backend it starts the server.
~~~
$ minio server
~~~
For 'xl' backend it waits for servers to join.
~~~
$ minio server
... [PROGRESS BAR] of servers connecting
~~~
Now on other servers execute 'join' and they connect.
~~~
....
minio join <url1> -- from <url2> && minio server
minio join <url1> -- from <url3> && minio server
...
...
minio join <url1> -- from <url16> && minio server
~~~
2016-02-12 18:27:10 -05:00
2023-05-02 02:15:08 -04:00
"github.com/coreos/go-systemd/v22/daemon"
2024-04-24 00:08:47 -04:00
"github.com/dustin/go-humanize"
config/main: Re-write config files - add to new config v3
- New config format.
```
{
"version": "3",
"address": ":9000",
"backend": {
"type": "fs",
"disk": "/path"
},
"credential": {
"accessKey": "WLGDGYAQYIGI833EV05A",
"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
},
"region": "us-east-1",
"logger": {
"file": {
"enable": false,
"fileName": "",
"level": "error"
},
"syslog": {
"enable": false,
"address": "",
"level": "debug"
},
"console": {
"enable": true,
"level": "fatal"
}
}
}
```
New command lines in lieu of supporting XL.
Minio initialize filesystem backend.
~~~
$ minio init fs <path>
~~~
Minio initialize XL backend.
~~~
$ minio init xl <url1>...<url16>
~~~
For 'fs' backend it starts the server.
~~~
$ minio server
~~~
For 'xl' backend it waits for servers to join.
~~~
$ minio server
... [PROGRESS BAR] of servers connecting
~~~
Now on other servers execute 'join' and they connect.
~~~
....
minio join <url1> -- from <url2> && minio server
minio join <url1> -- from <url3> && minio server
...
...
minio join <url1> -- from <url16> && minio server
~~~
2016-02-12 18:27:10 -05:00
"github.com/minio/cli"
2023-06-19 20:53:08 -04:00
"github.com/minio/madmin-go/v3"
2022-09-19 14:05:16 -04:00
"github.com/minio/minio-go/v7"
2022-07-12 13:12:47 -04:00
"github.com/minio/minio-go/v7/pkg/credentials"
2022-10-21 17:42:28 -04:00
"github.com/minio/minio-go/v7/pkg/set"
2021-06-01 17:59:40 -04:00
"github.com/minio/minio/internal/auth"
"github.com/minio/minio/internal/bucket/bandwidth"
"github.com/minio/minio/internal/color"
"github.com/minio/minio/internal/config"
2023-04-25 18:50:32 -04:00
"github.com/minio/minio/internal/handlers"
2023-01-25 13:25:36 -05:00
"github.com/minio/minio/internal/hash/sha256"
2021-06-01 17:59:40 -04:00
xhttp "github.com/minio/minio/internal/http"
2024-01-28 13:04:17 -05:00
xioutil "github.com/minio/minio/internal/ioutil"
2021-06-01 17:59:40 -04:00
"github.com/minio/minio/internal/logger"
2023-09-04 15:57:37 -04:00
"github.com/minio/pkg/v2/certs"
"github.com/minio/pkg/v2/env"
2023-06-06 13:12:52 -04:00
"golang.org/x/exp/slices"
2023-12-07 04:33:56 -05:00
"gopkg.in/yaml.v2"
config/main: Re-write config files - add to new config v3
- New config format.
```
{
"version": "3",
"address": ":9000",
"backend": {
"type": "fs",
"disk": "/path"
},
"credential": {
"accessKey": "WLGDGYAQYIGI833EV05A",
"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
},
"region": "us-east-1",
"logger": {
"file": {
"enable": false,
"fileName": "",
"level": "error"
},
"syslog": {
"enable": false,
"address": "",
"level": "debug"
},
"console": {
"enable": true,
"level": "fatal"
}
}
}
```
New command lines in lieu of supporting XL.
Minio initialize filesystem backend.
~~~
$ minio init fs <path>
~~~
Minio initialize XL backend.
~~~
$ minio init xl <url1>...<url16>
~~~
For 'fs' backend it starts the server.
~~~
$ minio server
~~~
For 'xl' backend it waits for servers to join.
~~~
$ minio server
... [PROGRESS BAR] of servers connecting
~~~
Now on other servers execute 'join' and they connect.
~~~
....
minio join <url1> -- from <url2> && minio server
minio join <url1> -- from <url3> && minio server
...
...
minio join <url1> -- from <url16> && minio server
~~~
2016-02-12 18:27:10 -05:00
)
2019-06-10 10:57:42 -04:00
// ServerFlags - server command specific flags
var ServerFlags = [ ] cli . Flag {
2023-12-07 04:33:56 -05:00
cli . StringFlag {
Name : "config" ,
Usage : "specify server configuration via YAML configuration" ,
EnvVar : "MINIO_CONFIG" ,
} ,
2016-09-01 18:12:49 -04:00
cli . StringFlag {
2022-01-15 19:20:02 -05:00
Name : "address" ,
Value : ":" + GlobalMinioDefaultPort ,
Usage : "bind to a specific ADDRESS:PORT, ADDRESS can be an IP or hostname" ,
EnvVar : "MINIO_ADDRESS" ,
2016-09-01 18:12:49 -04:00
} ,
2021-10-08 19:58:24 -04:00
cli . IntFlag {
2022-10-19 11:45:50 -04:00
Name : "listeners" , // Deprecated Oct 2022
2022-01-15 19:20:02 -05:00
Value : 1 ,
Usage : "bind N number of listeners per ADDRESS:PORT" ,
EnvVar : "MINIO_LISTENERS" ,
2022-10-19 11:45:50 -04:00
Hidden : true ,
2021-10-08 19:58:24 -04:00
} ,
2021-06-17 23:27:04 -04:00
cli . StringFlag {
2022-01-15 19:20:02 -05:00
Name : "console-address" ,
Usage : "bind to a specific ADDRESS:PORT for embedded Console UI, ADDRESS can be an IP or hostname" ,
EnvVar : "MINIO_CONSOLE_ADDRESS" ,
2021-06-17 23:27:04 -04:00
} ,
2021-11-29 12:06:56 -05:00
cli . DurationFlag {
Name : "shutdown-timeout" ,
Value : xhttp . DefaultShutdownTimeout ,
Usage : "shutdown timeout to gracefully shutdown server" ,
2022-01-15 19:20:02 -05:00
EnvVar : "MINIO_SHUTDOWN_TIMEOUT" ,
2021-11-29 12:06:56 -05:00
Hidden : true ,
} ,
2022-05-30 09:24:51 -04:00
cli . DurationFlag {
Name : "idle-timeout" ,
Value : xhttp . DefaultIdleTimeout ,
2024-01-18 02:03:17 -05:00
Usage : "idle timeout is the maximum amount of time to wait for the next request when keep-alive are enabled" ,
2022-05-30 09:24:51 -04:00
EnvVar : "MINIO_IDLE_TIMEOUT" ,
Hidden : true ,
} ,
cli . DurationFlag {
Name : "read-header-timeout" ,
Value : xhttp . DefaultReadHeaderTimeout ,
Usage : "read header timeout is the amount of time allowed to read request headers" ,
EnvVar : "MINIO_READ_HEADER_TIMEOUT" ,
Hidden : true ,
} ,
2024-02-09 16:25:16 -05:00
cli . DurationFlag {
Name : "conn-client-read-deadline" ,
Usage : "custom connection READ deadline for incoming requests" ,
Hidden : true ,
EnvVar : "MINIO_CONN_CLIENT_READ_DEADLINE" ,
} ,
2024-03-01 11:00:42 -05:00
cli . DurationFlag {
Name : "conn-client-write-deadline" ,
Usage : "custom connection WRITE deadline for outgoing requests" ,
Hidden : true ,
EnvVar : "MINIO_CONN_CLIENT_WRITE_DEADLINE" ,
} ,
2022-11-05 14:09:21 -04:00
cli . DurationFlag {
Name : "conn-read-deadline" ,
Usage : "custom connection READ deadline" ,
Hidden : true ,
Value : 10 * time . Minute ,
EnvVar : "MINIO_CONN_READ_DEADLINE" ,
} ,
cli . DurationFlag {
Name : "conn-write-deadline" ,
Usage : "custom connection WRITE deadline" ,
Hidden : true ,
Value : 10 * time . Minute ,
EnvVar : "MINIO_CONN_WRITE_DEADLINE" ,
} ,
2023-05-03 17:12:25 -04:00
cli . DurationFlag {
Name : "conn-user-timeout" ,
Usage : "custom TCP_USER_TIMEOUT for socket buffers" ,
Hidden : true ,
Value : 10 * time . Minute ,
EnvVar : "MINIO_CONN_USER_TIMEOUT" ,
} ,
cli . StringFlag {
Name : "interface" ,
Usage : "bind to right VRF device for MinIO services" ,
Hidden : true ,
EnvVar : "MINIO_INTERFACE" ,
} ,
2023-07-24 18:13:35 -04:00
cli . DurationFlag {
Name : "dns-cache-ttl" ,
2024-03-26 11:00:38 -04:00
Usage : "custom DNS cache TTL" ,
2023-07-24 18:13:35 -04:00
Hidden : true ,
2024-03-26 11:00:38 -04:00
Value : func ( ) time . Duration {
if orchestrated {
return 30 * time . Second
}
return 10 * time . Minute
} ( ) ,
2023-07-24 18:13:35 -04:00
EnvVar : "MINIO_DNS_CACHE_TTL" ,
} ,
2024-01-29 19:50:37 -05:00
cli . IntFlag {
Name : "max-idle-conns-per-host" ,
Usage : "set a custom max idle connections per host value" ,
Hidden : true ,
Value : 2048 ,
EnvVar : "MINIO_MAX_IDLE_CONNS_PER_HOST" ,
} ,
2023-04-15 10:34:02 -04:00
cli . StringSliceFlag {
Name : "ftp" ,
Usage : "enable and configure an FTP(Secure) server" ,
} ,
cli . StringSliceFlag {
Name : "sftp" ,
Usage : "enable and configure an SFTP server" ,
} ,
2024-03-18 02:42:40 -04:00
cli . StringFlag {
Name : "crossdomain-xml" ,
Usage : "provide a custom crossdomain-xml configuration to report at http://endpoint/crossdomain.xml" ,
Hidden : true ,
EnvVar : "MINIO_CROSSDOMAIN_XML" ,
} ,
2024-04-04 08:06:57 -04:00
cli . StringFlag {
Name : "memlimit" ,
Usage : "set global memory limit per server via GOMEMLIMIT" ,
Hidden : true ,
EnvVar : "MINIO_MEMLIMIT" ,
} ,
2024-04-24 00:08:47 -04:00
cli . IntFlag {
Name : "send-buf-size" ,
Value : 4 * humanize . MiByte ,
EnvVar : "MINIO_SEND_BUF_SIZE" ,
Hidden : true ,
} ,
cli . IntFlag {
Name : "recv-buf-size" ,
Value : 4 * humanize . MiByte ,
EnvVar : "MINIO_RECV_BUF_SIZE" ,
Hidden : true ,
} ,
2024-05-01 13:57:52 -04:00
cli . StringFlag {
Name : "log-dir" ,
Usage : "specify the directory to save the server log" ,
EnvVar : "MINIO_LOG_DIR" ,
Hidden : true ,
} ,
cli . IntFlag {
Name : "log-size" ,
Usage : "specify the maximum server log file size in bytes before its rotated" ,
Value : 10 * humanize . MiByte ,
EnvVar : "MINIO_LOG_SIZE" ,
Hidden : true ,
} ,
2024-05-01 18:38:07 -04:00
cli . BoolFlag {
Name : "log-compress" ,
Usage : "specify if we want the rotated logs to be gzip compressed or not" ,
EnvVar : "MINIO_LOG_COMPRESS" ,
Hidden : true ,
} ,
2024-05-09 17:29:37 -04:00
cli . StringFlag {
Name : "log-prefix" ,
Usage : "specify the log prefix name for the server log" ,
EnvVar : "MINIO_LOG_PREFIX" ,
Hidden : true ,
} ,
2022-10-28 17:11:20 -04:00
}
2016-09-01 18:12:49 -04:00
var serverCmd = cli . Command {
Name : "server" ,
2018-11-20 20:35:33 -05:00
Usage : "start object storage server" ,
2019-06-10 10:57:42 -04:00
Flags : append ( ServerFlags , GlobalFlags ... ) ,
config: Migrate to the new version. Remove backend details.
Migrate to new config format v4.
```
{
"version": "4",
"credential": {
"accessKey": "WLGDGYAQYIGI833EV05A",
"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
},
"region": "us-east-1",
"logger": {
"console": {
"enable": true,
"level": "fatal"
},
"file": {
"enable": false,
"fileName": "",
"level": "error"
},
"syslog": {
"enable": false,
"address": "",
"level": "debug"
}
}
}
```
This patch also updates [minio cli spec](./minio.md)
2016-04-01 22:19:44 -04:00
Action : serverMain ,
config/main: Re-write config files - add to new config v3
- New config format.
```
{
"version": "3",
"address": ":9000",
"backend": {
"type": "fs",
"disk": "/path"
},
"credential": {
"accessKey": "WLGDGYAQYIGI833EV05A",
"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
},
"region": "us-east-1",
"logger": {
"file": {
"enable": false,
"fileName": "",
"level": "error"
},
"syslog": {
"enable": false,
"address": "",
"level": "debug"
},
"console": {
"enable": true,
"level": "fatal"
}
}
}
```
New command lines in lieu of supporting XL.
Minio initialize filesystem backend.
~~~
$ minio init fs <path>
~~~
Minio initialize XL backend.
~~~
$ minio init xl <url1>...<url16>
~~~
For 'fs' backend it starts the server.
~~~
$ minio server
~~~
For 'xl' backend it waits for servers to join.
~~~
$ minio server
... [PROGRESS BAR] of servers connecting
~~~
Now on other servers execute 'join' and they connect.
~~~
....
minio join <url1> -- from <url2> && minio server
minio join <url1> -- from <url3> && minio server
...
...
minio join <url1> -- from <url16> && minio server
~~~
2016-02-12 18:27:10 -05:00
CustomHelpTemplate : ` NAME :
2017-03-16 15:21:58 -04:00
{ { . HelpName } } - { { . Usage } }
config/main: Re-write config files - add to new config v3
- New config format.
```
{
"version": "3",
"address": ":9000",
"backend": {
"type": "fs",
"disk": "/path"
},
"credential": {
"accessKey": "WLGDGYAQYIGI833EV05A",
"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
},
"region": "us-east-1",
"logger": {
"file": {
"enable": false,
"fileName": "",
"level": "error"
},
"syslog": {
"enable": false,
"address": "",
"level": "debug"
},
"console": {
"enable": true,
"level": "fatal"
}
}
}
```
New command lines in lieu of supporting XL.
Minio initialize filesystem backend.
~~~
$ minio init fs <path>
~~~
Minio initialize XL backend.
~~~
$ minio init xl <url1>...<url16>
~~~
For 'fs' backend it starts the server.
~~~
$ minio server
~~~
For 'xl' backend it waits for servers to join.
~~~
$ minio server
... [PROGRESS BAR] of servers connecting
~~~
Now on other servers execute 'join' and they connect.
~~~
....
minio join <url1> -- from <url2> && minio server
minio join <url1> -- from <url3> && minio server
...
...
minio join <url1> -- from <url16> && minio server
~~~
2016-02-12 18:27:10 -05:00
USAGE :
2018-02-15 20:45:57 -05:00
{ { . HelpName } } { { if . VisibleFlags } } [ FLAGS ] { { end } } DIR1 [ DIR2 . . ]
{ { . HelpName } } { { if . VisibleFlags } } [ FLAGS ] { { end } } DIR { 1. . .64 }
2019-12-16 23:30:57 -05:00
{ { . HelpName } } { { if . VisibleFlags } } [ FLAGS ] { { end } } DIR { 1. . .64 } DIR { 65. . .128 }
2018-02-15 20:45:57 -05:00
DIR :
DIR points to a directory on a filesystem . When you want to combine
multiple drives into a single large system , pass one directory per
filesystem separated by space . You may also use a ' ... ' convention
to abbreviate the directory arguments . Remote directories in a
distributed setup are encoded as HTTP ( s ) URIs .
2017-02-15 20:45:08 -05:00
{ { if . VisibleFlags } }
2016-08-28 23:04:47 -04:00
FLAGS :
2017-02-15 05:25:38 -05:00
{ { range . VisibleFlags } } { { . } }
2017-02-15 20:45:08 -05:00
{ { end } } { { end } }
config/main: Re-write config files - add to new config v3
- New config format.
```
{
"version": "3",
"address": ":9000",
"backend": {
"type": "fs",
"disk": "/path"
},
"credential": {
"accessKey": "WLGDGYAQYIGI833EV05A",
"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
},
"region": "us-east-1",
"logger": {
"file": {
"enable": false,
"fileName": "",
"level": "error"
},
"syslog": {
"enable": false,
"address": "",
"level": "debug"
},
"console": {
"enable": true,
"level": "fatal"
}
}
}
```
New command lines in lieu of supporting XL.
Minio initialize filesystem backend.
~~~
$ minio init fs <path>
~~~
Minio initialize XL backend.
~~~
$ minio init xl <url1>...<url16>
~~~
For 'fs' backend it starts the server.
~~~
$ minio server
~~~
For 'xl' backend it waits for servers to join.
~~~
$ minio server
... [PROGRESS BAR] of servers connecting
~~~
Now on other servers execute 'join' and they connect.
~~~
....
minio join <url1> -- from <url2> && minio server
minio join <url1> -- from <url3> && minio server
...
...
minio join <url1> -- from <url16> && minio server
~~~
2016-02-12 18:27:10 -05:00
EXAMPLES :
2023-04-15 10:34:02 -04:00
1. Start MinIO server on "/home/shared" directory .
2019-05-15 04:32:44 -04:00
{ { . Prompt } } { { . HelpName } } / home / shared
config: Migrate to the new version. Remove backend details.
Migrate to new config format v4.
```
{
"version": "4",
"credential": {
"accessKey": "WLGDGYAQYIGI833EV05A",
"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
},
"region": "us-east-1",
"logger": {
"console": {
"enable": true,
"level": "fatal"
},
"file": {
"enable": false,
"fileName": "",
"level": "error"
},
"syslog": {
"enable": false,
"address": "",
"level": "debug"
}
}
}
```
This patch also updates [minio cli spec](./minio.md)
2016-04-01 22:19:44 -04:00
2020-04-22 02:59:13 -04:00
2. Start single node server with 64 local drives "/mnt/data1" to "/mnt/data64" .
{ { . Prompt } } { { . HelpName } } / mnt / data { 1. . .64 }
2023-04-15 10:34:02 -04:00
3. Start distributed MinIO server on an 32 node setup with 32 drives each , run following command on all the nodes
2020-03-27 00:07:39 -04:00
{ { . Prompt } } { { . HelpName } } http : //node{1...32}.example.com/mnt/export{1...32}
2018-05-18 20:51:03 -04:00
2023-04-15 10:34:02 -04:00
4. Start distributed MinIO server in an expanded setup , run the following command on all the nodes
2020-03-27 00:07:39 -04:00
{ { . Prompt } } { { . HelpName } } http : //node{1...16}.example.com/mnt/export{1...32} \
http : //node{17...64}.example.com/mnt/export{1...64}
2023-04-15 10:34:02 -04:00
5. Start distributed MinIO server , with FTP and SFTP servers on all interfaces via port 8021 , 8022 respectively
{ { . Prompt } } { { . HelpName } } http : //node{1...4}.example.com/mnt/export{1...4} \
-- ftp = "address=:8021" -- ftp = "passive-port-range=30000-40000" \
-- sftp = "address=:8022" -- sftp = "ssh-private-key=${HOME}/.ssh/id_rsa"
config/main: Re-write config files - add to new config v3
- New config format.
```
{
"version": "3",
"address": ":9000",
"backend": {
"type": "fs",
"disk": "/path"
},
"credential": {
"accessKey": "WLGDGYAQYIGI833EV05A",
"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
},
"region": "us-east-1",
"logger": {
"file": {
"enable": false,
"fileName": "",
"level": "error"
},
"syslog": {
"enable": false,
"address": "",
"level": "debug"
},
"console": {
"enable": true,
"level": "fatal"
}
}
}
```
New command lines in lieu of supporting XL.
Minio initialize filesystem backend.
~~~
$ minio init fs <path>
~~~
Minio initialize XL backend.
~~~
$ minio init xl <url1>...<url16>
~~~
For 'fs' backend it starts the server.
~~~
$ minio server
~~~
For 'xl' backend it waits for servers to join.
~~~
$ minio server
... [PROGRESS BAR] of servers connecting
~~~
Now on other servers execute 'join' and they connect.
~~~
....
minio join <url1> -- from <url2> && minio server
minio join <url1> -- from <url3> && minio server
...
...
minio join <url1> -- from <url16> && minio server
~~~
2016-02-12 18:27:10 -05:00
` ,
}
2020-08-06 21:03:16 -04:00
func serverCmdArgs ( ctx * cli . Context ) [ ] string {
2021-09-01 14:34:07 -04:00
v , _ , _ , err := env . LookupEnv ( config . EnvArgs )
if err != nil {
logger . FatalIf ( err , "Unable to validate passed arguments in %s:%s" ,
config . EnvArgs , os . Getenv ( config . EnvArgs ) )
}
2022-06-10 12:59:15 -04:00
if v == "" {
v , _ , _ , err = env . LookupEnv ( config . EnvVolumes )
if err != nil {
logger . FatalIf ( err , "Unable to validate passed arguments in %s:%s" ,
config . EnvVolumes , os . Getenv ( config . EnvVolumes ) )
}
}
2020-08-06 21:03:16 -04:00
if v == "" {
2021-09-01 14:34:07 -04:00
// Fall back to older environment value MINIO_ENDPOINTS
v , _ , _ , err = env . LookupEnv ( config . EnvEndpoints )
if err != nil {
logger . FatalIf ( err , "Unable to validate passed arguments in %s:%s" ,
config . EnvEndpoints , os . Getenv ( config . EnvEndpoints ) )
}
2020-08-06 21:03:16 -04:00
}
if v == "" {
2020-10-14 16:51:51 -04:00
if ! ctx . Args ( ) . Present ( ) || ctx . Args ( ) . First ( ) == "help" {
cli . ShowCommandHelpAndExit ( ctx , ctx . Command . Name , 1 )
}
2020-08-06 21:03:16 -04:00
return ctx . Args ( )
}
return strings . Fields ( v )
2018-05-18 20:51:03 -04:00
}
2024-05-03 11:54:03 -04:00
func configCommonToSrvCtx ( cf config . ServerConfigCommon , ctxt * serverCtxt ) {
2023-12-08 15:04:54 -05:00
ctxt . RootUser = cf . RootUser
ctxt . RootPwd = cf . RootPwd
2023-12-07 04:33:56 -05:00
if cf . Addr != "" {
ctxt . Addr = cf . Addr
}
if cf . ConsoleAddr != "" {
ctxt . ConsoleAddr = cf . ConsoleAddr
}
if cf . CertsDir != "" {
ctxt . CertsDir = cf . CertsDir
ctxt . certsDirSet = true
}
if cf . Options . FTP . Address != "" {
ctxt . FTP = append ( ctxt . FTP , fmt . Sprintf ( "address=%s" , cf . Options . FTP . Address ) )
}
if cf . Options . FTP . PassivePortRange != "" {
ctxt . FTP = append ( ctxt . FTP , fmt . Sprintf ( "passive-port-range=%s" , cf . Options . FTP . PassivePortRange ) )
}
if cf . Options . SFTP . Address != "" {
ctxt . SFTP = append ( ctxt . SFTP , fmt . Sprintf ( "address=%s" , cf . Options . SFTP . Address ) )
}
if cf . Options . SFTP . SSHPrivateKey != "" {
ctxt . SFTP = append ( ctxt . SFTP , fmt . Sprintf ( "ssh-private-key=%s" , cf . Options . SFTP . SSHPrivateKey ) )
}
2024-05-03 11:54:03 -04:00
}
func mergeServerCtxtFromConfigFile ( configFile string , ctxt * serverCtxt ) error {
rd , err := xioutil . ReadFile ( configFile )
if err != nil {
return err
}
cfReader := bytes . NewReader ( rd )
cv := config . ServerConfigVersion { }
if err = yaml . Unmarshal ( rd , & cv ) ; err != nil {
return err
}
2023-12-07 04:33:56 -05:00
2024-05-03 11:54:03 -04:00
switch cv . Version {
case "v1" , "v2" :
default :
return fmt . Errorf ( "unexpected version: %s" , cv . Version )
}
cfCommon := config . ServerConfigCommon { }
if err = yaml . Unmarshal ( rd , & cfCommon ) ; err != nil {
return err
}
configCommonToSrvCtx ( cfCommon , ctxt )
v , err := env . GetInt ( EnvErasureSetDriveCount , 0 )
if err != nil {
return err
}
setDriveCount := uint64 ( v )
var pools [ ] poolArgs
switch cv . Version {
case "v1" :
cfV1 := config . ServerConfigV1 { }
if err = yaml . Unmarshal ( rd , & cfV1 ) ; err != nil {
return err
}
pools = make ( [ ] poolArgs , 0 , len ( cfV1 . Pools ) )
for _ , list := range cfV1 . Pools {
pools = append ( pools , poolArgs {
args : list ,
setDriveCount : setDriveCount ,
} )
}
case "v2" :
cf := config . ServerConfig { }
cfReader . Seek ( 0 , io . SeekStart )
if err = yaml . Unmarshal ( rd , & cf ) ; err != nil {
return err
}
pools = make ( [ ] poolArgs , 0 , len ( cf . Pools ) )
for _ , list := range cf . Pools {
driveCount := list . SetDriveCount
if setDriveCount > 0 {
driveCount = setDriveCount
}
pools = append ( pools , poolArgs {
args : list . Args ,
setDriveCount : driveCount ,
} )
}
}
ctxt . Layout , err = buildDisksLayoutFromConfFile ( pools )
2023-12-07 04:33:56 -05:00
return err
}
func serverHandleCmdArgs ( ctxt serverCtxt ) {
handleCommonArgs ( ctxt )
2017-03-29 11:55:33 -04:00
2021-06-21 02:04:47 -04:00
logger . FatalIf ( CheckLocalServerAddr ( globalMinioAddr ) , "Unable to validate passed arguments" )
config: Migrate to the new version. Remove backend details.
Migrate to new config format v4.
```
{
"version": "4",
"credential": {
"accessKey": "WLGDGYAQYIGI833EV05A",
"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
},
"region": "us-east-1",
"logger": {
"console": {
"enable": true,
"level": "fatal"
},
"file": {
"enable": false,
"fileName": "",
"level": "error"
},
"syslog": {
"enable": false,
"address": "",
"level": "debug"
}
}
}
```
This patch also updates [minio cli spec](./minio.md)
2016-04-01 22:19:44 -04:00
2017-01-11 16:59:51 -05:00
var err error
2020-08-06 21:03:16 -04:00
var setupType SetupType
// Check and load TLS certificates.
2020-12-22 00:42:38 -05:00
globalPublicCerts , globalTLSCerts , globalIsTLS , err = getTLSConfig ( )
2020-08-06 21:03:16 -04:00
logger . FatalIf ( err , "Unable to load the TLS configuration" )
// Check and load Root CAs.
2020-08-11 11:29:50 -04:00
globalRootCAs , err = certs . GetRootCAs ( globalCertsCADir . Get ( ) )
2020-08-06 21:03:16 -04:00
logger . FatalIf ( err , "Failed to read root CAs (%v)" , err )
2020-08-13 12:46:50 -04:00
// Add the global public crts as part of global root CAs
for _ , publicCrt := range globalPublicCerts {
globalRootCAs . AddCert ( publicCrt )
}
2020-08-06 21:03:16 -04:00
// Register root CAs for remote ENVs
env . RegisterGlobalCAs ( globalRootCAs )
2017-08-15 18:10:50 -04:00
2023-12-07 04:33:56 -05:00
globalEndpoints , setupType , err = createServerEndpoints ( globalMinioAddr , ctxt . Layout . pools , ctxt . Layout . legacy )
2021-03-26 14:37:58 -04:00
logger . FatalIf ( err , "Invalid command line arguments" )
2023-06-23 14:48:23 -04:00
globalNodes = globalEndpoints . GetNodes ( )
2021-03-26 14:37:58 -04:00
2023-09-12 22:10:49 -04:00
globalIsErasure = ( setupType == ErasureSetupType )
globalIsDistErasure = ( setupType == DistErasureSetupType )
if globalIsDistErasure {
globalIsErasure = true
}
globalIsErasureSD = ( setupType == ErasureSDSetupType )
if globalDynamicAPIPort && globalIsDistErasure {
2023-12-07 04:33:56 -05:00
logger . FatalIf ( errInvalidArgument , "Invalid --address=\"%s\", port '0' is not allowed in a distributed erasure coded setup" , ctxt . Addr )
2023-09-12 22:10:49 -04:00
}
2021-03-26 14:37:58 -04:00
globalLocalNodeName = GetLocalPeer ( globalEndpoints , globalMinioHost , globalMinioPort )
2023-05-06 16:35:43 -04:00
nodeNameSum := sha256 . Sum256 ( [ ] byte ( globalLocalNodeName ) )
2023-01-25 13:25:36 -05:00
globalLocalNodeNameHex = hex . EncodeToString ( nodeNameSum [ : ] )
2018-02-15 20:45:57 -05:00
2023-07-18 22:18:11 -04:00
// Initialize, see which NIC the service is running on, and save it as global value
2023-12-07 04:33:56 -05:00
setGlobalInternodeInterface ( ctxt . Interface )
2023-07-18 22:18:11 -04:00
2024-04-21 07:43:18 -04:00
globalTCPOptions = xhttp . TCPOptions {
UserTimeout : int ( ctxt . UserTimeout . Milliseconds ( ) ) ,
ClientReadTimeout : ctxt . ConnClientReadDeadline ,
ClientWriteTimeout : ctxt . ConnClientWriteDeadline ,
Interface : ctxt . Interface ,
2024-04-24 00:08:47 -04:00
SendBufSize : ctxt . SendBufSize ,
RecvBufSize : ctxt . RecvBufSize ,
2024-04-21 07:43:18 -04:00
}
2020-12-22 00:42:38 -05:00
// allow transport to be HTTP/1.1 for proxying.
2020-11-02 10:43:11 -05:00
globalProxyEndpoints = GetProxyEndpoints ( globalEndpoints )
2024-01-29 19:50:37 -05:00
globalInternodeTransport = NewInternodeHTTPTransport ( ctxt . MaxIdleConnsPerHost ) ( )
2023-06-30 11:04:13 -04:00
globalRemoteTargetTransport = NewRemoteTargetHTTPTransport ( false ) ( )
2023-04-25 18:50:32 -04:00
globalForwarder = handlers . NewForwarder ( & handlers . Forwarder {
PassHost : true ,
2024-04-21 07:43:18 -04:00
RoundTripper : globalRemoteTargetTransport ,
2023-04-25 18:50:32 -04:00
Logger : func ( err error ) {
if err != nil && ! errors . Is ( err , context . Canceled ) {
2024-04-04 08:04:40 -04:00
replLogIf ( GlobalContext , err )
2023-04-25 18:50:32 -04:00
}
} ,
} )
2018-05-08 22:04:36 -04:00
// On macOS, if a process already listens on LOCALIPADDR:PORT, net.Listen() falls back
// to IPv6 address ie minio will start listening on IPv6 address whereas another
// (non-)minio process is listening on IPv4 of given port.
2020-01-03 20:43:16 -05:00
// To avoid this error situation we check for port availability.
2023-05-03 17:12:25 -04:00
logger . FatalIf ( xhttp . CheckPortAvailability ( globalMinioHost , globalMinioPort , globalTCPOptions ) , "Unable to start the server" )
2017-03-30 14:21:19 -04:00
}
2022-10-14 06:08:40 -04:00
func initAllSubsystems ( ctx context . Context ) {
2022-08-24 09:42:36 -04:00
// Initialize notification peer targets
2019-11-09 12:27:23 -05:00
globalNotificationSys = NewNotificationSys ( globalEndpoints )
2022-08-24 09:42:36 -04:00
// Create new notification system
2023-12-05 05:16:33 -05:00
globalEventNotifier = NewEventNotifier ( GlobalContext )
2022-08-24 09:42:36 -04:00
2020-05-19 16:53:54 -04:00
// Create new bucket metadata system.
2021-01-05 13:45:26 -05:00
if globalBucketMetadataSys == nil {
globalBucketMetadataSys = NewBucketMetadataSys ( )
} else {
// Reinitialize safely when testing.
globalBucketMetadataSys . Reset ( )
}
2020-05-19 16:53:54 -04:00
2020-10-09 23:36:00 -04:00
// Create the bucket bandwidth monitor
2024-01-24 16:36:44 -05:00
globalBucketMonitor = bandwidth . NewMonitor ( ctx , uint64 ( totalNodeCount ( ) ) )
2020-10-09 23:36:00 -04:00
2019-10-31 02:39:09 -04:00
// Create a new config system.
globalConfigSys = NewConfigSys ( )
// Create new IAM system.
globalIAMSys = NewIAMSys ( )
2019-11-09 12:27:23 -05:00
// Create new policy system.
globalPolicySys = NewPolicySys ( )
// Create new lifecycle system.
globalLifecycleSys = NewLifecycleSys ( )
2020-02-05 04:42:34 -05:00
// Create new bucket encryption subsystem
globalBucketSSEConfigSys = NewBucketSSEConfigSys ( )
2020-05-04 12:42:58 -04:00
2020-05-08 16:44:44 -04:00
// Create new bucket object lock subsystem
globalBucketObjectLockSys = NewBucketObjectLockSys ( )
2020-05-04 12:42:58 -04:00
// Create new bucket quota subsystem
globalBucketQuotaSys = NewBucketQuotaSys ( )
2020-06-12 23:04:01 -04:00
// Create new bucket versioning subsystem
2021-01-05 13:45:26 -05:00
if globalBucketVersioningSys == nil {
globalBucketVersioningSys = NewBucketVersioningSys ( )
}
2020-07-21 20:49:56 -04:00
2024-01-18 02:03:17 -05:00
// Create new bucket replication subsystem
2022-08-16 20:46:22 -04:00
globalBucketTargetSys = NewBucketTargetSys ( GlobalContext )
2021-04-19 13:30:42 -04:00
// Create new ILM tier configuration subsystem
globalTierConfigMgr = NewTierConfigMgr ( )
2022-11-14 10:16:40 -05:00
2023-02-08 02:11:42 -05:00
globalTransitionState = newTransitionState ( GlobalContext )
2022-11-14 10:16:40 -05:00
globalSiteResyncMetrics = newSiteResyncMetrics ( GlobalContext )
2019-11-09 12:27:23 -05:00
}
2021-03-18 17:09:55 -04:00
func configRetriableErrors ( err error ) bool {
2023-10-23 15:30:20 -04:00
if err == nil {
return false
}
2023-10-24 16:22:44 -04:00
notInitialized := strings . Contains ( err . Error ( ) , "Server not initialized, please try again" ) ||
errors . Is ( err , errServerNotInitialized )
2023-10-23 15:30:20 -04:00
2021-03-18 17:09:55 -04:00
// Initializing sub-systems needs a retry mechanism for
// the following reasons:
// - Read quorum is lost just after the initialization
// of the object layer.
// - Write quorum not met when upgrading configuration
// version is needed, migration is needed etc.
rquorum := InsufficientReadQuorum { }
wquorum := InsufficientWriteQuorum { }
// One of these retriable errors shall be retried.
return errors . Is ( err , errDiskNotFound ) ||
errors . Is ( err , errConfigNotFound ) ||
errors . Is ( err , context . DeadlineExceeded ) ||
errors . Is ( err , errErasureWriteQuorum ) ||
errors . Is ( err , errErasureReadQuorum ) ||
2021-05-17 18:13:14 -04:00
errors . Is ( err , io . ErrUnexpectedEOF ) ||
2021-03-18 17:09:55 -04:00
errors . As ( err , & rquorum ) ||
errors . As ( err , & wquorum ) ||
2022-01-12 21:49:01 -05:00
isErrObjectNotFound ( err ) ||
2021-03-18 17:09:55 -04:00
isErrBucketNotFound ( err ) ||
2023-10-23 15:30:20 -04:00
errors . Is ( err , os . ErrDeadlineExceeded ) ||
notInitialized
2021-03-18 17:09:55 -04:00
}
2023-08-23 06:07:06 -04:00
func bootstrapTraceMsg ( msg string ) {
info := madmin . TraceInfo {
TraceType : madmin . TraceBootstrap ,
Time : UTCNow ( ) ,
NodeName : globalLocalNodeName ,
FuncName : "BOOTSTRAP" ,
Message : fmt . Sprintf ( "%s %s" , getSource ( 2 ) , msg ) ,
}
globalBootstrapTracer . Record ( info )
2023-06-08 11:39:47 -04:00
if serverDebugLog {
2024-02-15 18:13:30 -05:00
fmt . Println ( time . Now ( ) . Round ( time . Millisecond ) . Format ( time . RFC3339 ) , " bootstrap: " , msg )
2023-06-08 11:39:47 -04:00
}
2023-03-17 19:01:03 -04:00
2023-08-23 06:07:06 -04:00
noSubs := globalTrace . NumSubscribers ( madmin . TraceBootstrap ) == 0
if noSubs {
2022-12-21 18:52:29 -05:00
return
}
2023-08-23 06:07:06 -04:00
globalTrace . Publish ( info )
}
func bootstrapTrace ( msg string , worker func ( ) ) {
if serverDebugLog {
2024-02-15 18:13:30 -05:00
fmt . Println ( time . Now ( ) . Round ( time . Millisecond ) . Format ( time . RFC3339 ) , " bootstrap: " , msg )
2023-08-23 06:07:06 -04:00
}
now := time . Now ( )
worker ( )
dur := time . Since ( now )
info := madmin . TraceInfo {
2022-12-21 18:52:29 -05:00
TraceType : madmin . TraceBootstrap ,
2023-08-23 06:07:06 -04:00
Time : UTCNow ( ) ,
2022-12-21 18:52:29 -05:00
NodeName : globalLocalNodeName ,
FuncName : "BOOTSTRAP" ,
2023-08-23 06:07:06 -04:00
Message : fmt . Sprintf ( "%s %s (duration: %s)" , getSource ( 2 ) , msg , dur ) ,
}
globalBootstrapTracer . Record ( info )
if globalTrace . NumSubscribers ( madmin . TraceBootstrap ) == 0 {
return
}
globalTrace . Publish ( info )
2022-12-21 18:52:29 -05:00
}
2023-06-20 12:28:23 -04:00
func initServerConfig ( ctx context . Context , newObject ObjectLayer ) error {
2022-03-25 19:29:45 -04:00
t1 := time . Now ( )
2020-11-02 20:52:13 -05:00
r := rand . New ( rand . NewSource ( time . Now ( ) . UnixNano ( ) ) )
for {
select {
case <- ctx . Done ( ) :
// Retry was canceled successfully.
2022-02-07 13:39:57 -05:00
return fmt . Errorf ( "Initializing sub-systems stopped gracefully %w" , ctx . Err ( ) )
2020-11-02 20:52:13 -05:00
default :
}
2020-05-07 19:12:16 -04:00
// These messages only meant primarily for distributed setup, so only log during distributed setup.
2020-06-12 23:04:01 -04:00
if globalIsDistErasure {
2023-04-21 16:56:08 -04:00
logger . Info ( "Waiting for all MinIO sub-systems to be initialize..." )
2020-05-07 19:12:16 -04:00
}
2020-05-06 17:25:05 -04:00
2023-04-21 16:56:08 -04:00
// Upon success migrating the config, initialize all sub-systems
// if all sub-systems initialized successfully return right away
err := initConfigSubsystem ( ctx , newObject )
if err == nil {
// All successful return.
if globalIsDistErasure {
// These messages only meant primarily for distributed setup, so only log during distributed setup.
logger . Info ( "All MinIO sub-systems initialized successfully in %s" , time . Since ( t1 ) )
2020-02-01 20:07:43 -05:00
}
2023-04-21 16:56:08 -04:00
return nil
2020-05-04 23:04:06 -04:00
}
2021-03-18 17:09:55 -04:00
if configRetriableErrors ( err ) {
2020-05-06 17:25:05 -04:00
logger . Info ( "Waiting for all MinIO sub-systems to be initialized.. possible cause (%v)" , err )
2020-11-02 20:52:13 -05:00
time . Sleep ( time . Duration ( r . Float64 ( ) * float64 ( 5 * time . Second ) ) )
2020-05-04 23:04:06 -04:00
continue
2020-02-01 20:07:43 -05:00
}
2020-05-04 23:04:06 -04:00
// Any other unhandled return right here.
2022-02-07 13:39:57 -05:00
return fmt . Errorf ( "Unable to initialize sub-systems: %w" , err )
2020-05-04 23:04:06 -04:00
}
2019-11-09 12:27:23 -05:00
}
2022-02-07 13:39:57 -05:00
func initConfigSubsystem ( ctx context . Context , newObject ObjectLayer ) error {
2020-05-06 17:25:05 -04:00
// %w is used by all error returns here to make sure
// we wrap the underlying error, make sure when you
// are modifying this code that you do so, if and when
// you want to add extra context to your error. This
// ensures top level retry works accordingly.
2021-01-03 14:27:57 -05:00
2019-11-09 12:27:23 -05:00
// Initialize config system.
2022-02-07 13:39:57 -05:00
if err := globalConfigSys . Init ( newObject ) ; err != nil {
2021-03-18 17:09:55 -04:00
if configRetriableErrors ( err ) {
2022-02-07 13:39:57 -05:00
return fmt . Errorf ( "Unable to initialize config system: %w" , err )
2020-10-09 12:59:52 -04:00
}
2022-02-07 13:39:57 -05:00
2020-10-09 12:59:52 -04:00
// Any other config errors we simply print a message and proceed forward.
2024-04-04 08:04:40 -04:00
configLogIf ( ctx , fmt . Errorf ( "Unable to initialize config, some features may be missing: %w" , err ) )
2019-11-09 12:27:23 -05:00
}
2020-05-04 23:04:06 -04:00
2022-02-07 13:39:57 -05:00
return nil
2019-10-31 02:39:09 -04:00
}
2023-07-18 22:18:11 -04:00
func setGlobalInternodeInterface ( interfaceName string ) {
2023-07-13 14:41:19 -04:00
globalInternodeInterfaceOnce . Do ( func ( ) {
2023-07-18 22:18:11 -04:00
if interfaceName != "" {
globalInternodeInterface = interfaceName
2023-07-13 14:41:19 -04:00
return
}
ip := "127.0.0.1"
2023-07-18 22:18:11 -04:00
host , _ := mustSplitHostPort ( globalLocalNodeName )
2023-07-13 14:41:19 -04:00
if host != "" {
2023-07-18 22:18:11 -04:00
if net . ParseIP ( host ) != nil {
ip = host
} else {
ctx , cancel := context . WithTimeout ( context . Background ( ) , 2 * time . Second )
defer cancel ( )
2024-03-26 11:00:38 -04:00
haddrs , err := globalDNSCache . LookupHost ( ctx , host )
2023-07-18 22:18:11 -04:00
if err == nil {
ip = haddrs [ 0 ]
}
}
2023-07-13 14:41:19 -04:00
}
ifs , _ := net . Interfaces ( )
for _ , interf := range ifs {
addrs , err := interf . Addrs ( )
if err == nil {
for _ , addr := range addrs {
if strings . SplitN ( addr . String ( ) , "/" , 2 ) [ 0 ] == ip {
globalInternodeInterface = interf . Name
}
}
}
}
} )
}
2022-10-21 17:42:28 -04:00
// Return the list of address that MinIO server needs to listen on:
// - Returning 127.0.0.1 is necessary so Console will be able to send
// requests to the local S3 API.
// - The returned List needs to be deduplicated as well.
func getServerListenAddrs ( ) [ ] string {
// Use a string set to avoid duplication
addrs := set . NewStringSet ( )
// Listen on local interface to receive requests from Console
for _ , ip := range mustGetLocalIPs ( ) {
if ip != nil && ip . IsLoopback ( ) {
addrs . Add ( net . JoinHostPort ( ip . String ( ) , globalMinioPort ) )
}
}
2022-12-12 21:48:46 -05:00
host , _ := mustSplitHostPort ( globalMinioAddr )
if host != "" {
ctx , cancel := context . WithTimeout ( context . Background ( ) , 2 * time . Second )
defer cancel ( )
2024-03-26 11:00:38 -04:00
haddrs , err := globalDNSCache . LookupHost ( ctx , host )
2022-12-12 21:48:46 -05:00
if err == nil {
for _ , addr := range haddrs {
addrs . Add ( net . JoinHostPort ( addr , globalMinioPort ) )
}
} else {
// Unable to lookup host in 2-secs, let it fail later anyways.
addrs . Add ( globalMinioAddr )
}
} else {
addrs . Add ( globalMinioAddr )
}
2022-10-21 17:42:28 -04:00
return addrs . ToSlice ( )
}
2024-05-01 13:57:52 -04:00
var globalLoggerOutput io . WriteCloser
func initializeLogRotate ( ctx * cli . Context ) ( io . WriteCloser , error ) {
lgDir := ctx . String ( "log-dir" )
if lgDir == "" {
return os . Stderr , nil
}
lgDirAbs , err := filepath . Abs ( lgDir )
if err != nil {
return nil , err
}
lgSize := ctx . Int ( "log-size" )
2024-05-09 17:29:37 -04:00
var fileNameFunc func ( ) string
if ctx . IsSet ( "log-prefix" ) {
fileNameFunc = func ( ) string {
return fmt . Sprintf ( "%s-%s.log" , ctx . String ( "log-prefix" ) , fmt . Sprintf ( "%X" , time . Now ( ) . UTC ( ) . UnixNano ( ) ) )
}
}
2024-05-01 13:57:52 -04:00
output , err := logger . NewDir ( logger . Options {
Directory : lgDirAbs ,
MaximumFileSize : int64 ( lgSize ) ,
2024-05-01 18:38:07 -04:00
Compress : ctx . Bool ( "log-compress" ) ,
2024-05-09 17:29:37 -04:00
FileNameFunc : fileNameFunc ,
2024-05-01 13:57:52 -04:00
} )
if err != nil {
return nil , err
}
logger . EnableJSON ( )
return output , nil
}
2017-03-30 14:21:19 -04:00
// serverMain handler called for 'minio server' command.
func serverMain ( ctx * cli . Context ) {
2024-03-08 22:07:08 -05:00
var warnings [ ] string
2020-10-12 17:19:46 -04:00
signal . Notify ( globalOSSignalCh , os . Interrupt , syscall . SIGTERM , syscall . SIGQUIT )
2020-09-08 12:10:55 -04:00
go handleSignals ( )
2020-01-21 18:49:25 -05:00
setDefaultProfilerRates ( )
2017-03-30 14:21:19 -04:00
2024-02-26 04:33:48 -05:00
// Initialize globalConsoleSys system
bootstrapTrace ( "newConsoleLogger" , func ( ) {
2024-05-01 13:57:52 -04:00
output , err := initializeLogRotate ( ctx )
if err == nil {
logger . Output = output
globalConsoleSys = NewConsoleLogger ( GlobalContext , output )
globalLoggerOutput = output
} else {
logger . Output = os . Stderr
globalConsoleSys = NewConsoleLogger ( GlobalContext , os . Stderr )
}
2024-02-26 04:33:48 -05:00
logger . AddSystemTarget ( GlobalContext , globalConsoleSys )
// Set node name, only set for distributed setup.
globalConsoleSys . SetNodeName ( globalLocalNodeName )
2024-05-01 13:57:52 -04:00
if err != nil {
// We can only log here since we need globalConsoleSys initialized
logger . Fatal ( err , "invalid --logrorate-dir option" )
}
2024-02-26 04:33:48 -05:00
} )
2023-10-16 00:13:43 -04:00
// Always load ENV variables from files first.
loadEnvVarsFromFiles ( )
2023-12-07 04:33:56 -05:00
// Handle all server command args and build the disks layout
2023-08-23 06:07:06 -04:00
bootstrapTrace ( "serverHandleCmdArgs" , func ( ) {
2023-12-07 04:33:56 -05:00
err := buildServerCtxt ( ctx , & globalServerCtxt )
logger . FatalIf ( err , "Unable to prepare the list of endpoints" )
serverHandleCmdArgs ( globalServerCtxt )
2023-08-23 06:07:06 -04:00
} )
2022-06-10 12:59:15 -04:00
2023-12-07 04:33:56 -05:00
// DNS cache subsystem to reduce outgoing DNS requests
runDNSCache ( ctx )
2023-10-12 18:32:38 -04:00
// Handle all server environment vars.
serverHandleEnvVars ( )
2023-12-08 15:04:54 -05:00
// Load the root credentials from the shell environment or from
// the config file if not defined, set the default one.
loadRootCredentials ( )
2023-08-23 06:07:06 -04:00
// Perform any self-tests
bootstrapTrace ( "selftests" , func ( ) {
bitrotSelfTest ( )
erasureSelfTest ( )
compressSelfTest ( )
} )
2022-06-13 16:06:13 -04:00
2023-08-23 06:07:06 -04:00
// Initialize KMS configuration
bootstrapTrace ( "handleKMSConfig" , handleKMSConfig )
2019-12-16 23:30:57 -05:00
2019-12-04 18:32:37 -05:00
// Initialize all help
2023-08-23 06:07:06 -04:00
bootstrapTrace ( "initHelp" , initHelp )
2019-12-04 18:32:37 -05:00
2020-10-19 12:54:40 -04:00
// Initialize all sub-systems
2023-08-23 06:07:06 -04:00
bootstrapTrace ( "initAllSubsystems" , func ( ) {
initAllSubsystems ( GlobalContext )
} )
2020-10-19 12:54:40 -04:00
2017-12-04 01:47:12 -05:00
// Is distributed setup, error out if no certificates are found for HTTPS endpoints.
2020-06-12 23:04:01 -04:00
if globalIsDistErasure {
2020-12-22 00:42:38 -05:00
if globalEndpoints . HTTPS ( ) && ! globalIsTLS {
2019-10-04 13:35:33 -04:00
logger . Fatal ( config . ErrNoCertsAndHTTPSEndpoints ( nil ) , "Unable to start the server" )
2018-04-09 22:10:23 -04:00
}
2020-12-22 00:42:38 -05:00
if ! globalEndpoints . HTTPS ( ) && globalIsTLS {
2019-10-04 13:35:33 -04:00
logger . Fatal ( config . ErrCertsAndHTTPEndpoints ( nil ) , "Unable to start the server" )
2018-04-09 22:10:23 -04:00
}
2017-12-04 01:47:12 -05:00
}
2021-12-13 12:43:03 -05:00
// Check for updates in non-blocking manner.
go func ( ) {
2023-12-07 04:33:56 -05:00
if ! globalServerCtxt . Quiet && ! globalInplaceUpdateDisabled {
2021-12-13 12:43:03 -05:00
// Check for new updates from dl.min.io.
2023-08-23 06:07:06 -04:00
bootstrapTrace ( "checkUpdate" , func ( ) {
checkUpdate ( getMinioMode ( ) )
} )
2021-12-13 12:43:03 -05:00
}
} ( )
2017-03-16 15:21:58 -04:00
2017-03-30 14:21:19 -04:00
// Set system resources to maximum.
2023-08-23 06:07:06 -04:00
bootstrapTrace ( "setMaxResources" , func ( ) {
2024-04-04 08:06:57 -04:00
_ = setMaxResources ( ctx )
2023-08-23 06:07:06 -04:00
} )
2017-03-30 14:21:19 -04:00
2022-03-10 20:36:13 -05:00
// Verify kernel release and version.
if oldLinux ( ) {
2024-03-09 01:42:32 -05:00
warnings = append ( warnings , color . YellowBold ( "- Detected Linux kernel version older than 4.0.0 release, there are some known potential performance problems with this kernel version. MinIO recommends a minimum of 4.x.x linux kernel version for best performance" ) )
2022-03-10 20:36:13 -05:00
}
2022-03-21 22:05:04 -04:00
maxProcs := runtime . GOMAXPROCS ( 0 )
cpuProcs := runtime . NumCPU ( )
if maxProcs < cpuProcs {
2024-03-09 01:42:32 -05:00
warnings = append ( warnings , color . YellowBold ( "- Detected GOMAXPROCS(%d) < NumCPU(%d), please make sure to provide all PROCS to MinIO for optimal performance" , maxProcs , cpuProcs ) )
2022-03-21 22:05:04 -04:00
}
2018-05-31 15:30:15 -04:00
var getCert certs . GetCertificateFunc
if globalTLSCerts != nil {
getCert = globalTLSCerts . GetCertificate
}
2024-01-24 16:36:44 -05:00
// Initialize gridn
perf: websocket grid connectivity for all internode communication (#18461)
This PR adds a WebSocket grid feature that allows servers to communicate via
a single two-way connection.
There are two request types:
* Single requests, which are `[]byte => ([]byte, error)`. This is for efficient small
roundtrips with small payloads.
* Streaming requests which are `[]byte, chan []byte => chan []byte (and error)`,
which allows for different combinations of full two-way streams with an initial payload.
Only a single stream is created between two machines - and there is, as such, no
server/client relation since both sides can initiate and handle requests. Which server
initiates the request is decided deterministically on the server names.
Requests are made through a mux client and server, which handles message
passing, congestion, cancelation, timeouts, etc.
If a connection is lost, all requests are canceled, and the calling server will try
to reconnect. Registered handlers can operate directly on byte
slices or use a higher-level generics abstraction.
There is no versioning of handlers/clients, and incompatible changes should
be handled by adding new handlers.
The request path can be changed to a new one for any protocol changes.
First, all servers create a "Manager." The manager must know its address
as well as all remote addresses. This will manage all connections.
To get a connection to any remote, ask the manager to provide it given
the remote address using.
```
func (m *Manager) Connection(host string) *Connection
```
All serverside handlers must also be registered on the manager. This will
make sure that all incoming requests are served. The number of in-flight
requests and responses must also be given for streaming requests.
The "Connection" returned manages the mux-clients. Requests issued
to the connection will be sent to the remote.
* `func (c *Connection) Request(ctx context.Context, h HandlerID, req []byte) ([]byte, error)`
performs a single request and returns the result. Any deadline provided on the request is
forwarded to the server, and canceling the context will make the function return at once.
* `func (c *Connection) NewStream(ctx context.Context, h HandlerID, payload []byte) (st *Stream, err error)`
will initiate a remote call and send the initial payload.
```Go
// A Stream is a two-way stream.
// All responses *must* be read by the caller.
// If the call is canceled through the context,
//The appropriate error will be returned.
type Stream struct {
// Responses from the remote server.
// Channel will be closed after an error or when the remote closes.
// All responses *must* be read by the caller until either an error is returned or the channel is closed.
// Canceling the context will cause the context cancellation error to be returned.
Responses <-chan Response
// Requests sent to the server.
// If the handler is defined with 0 incoming capacity this will be nil.
// Channel *must* be closed to signal the end of the stream.
// If the request context is canceled, the stream will no longer process requests.
Requests chan<- []byte
}
type Response struct {
Msg []byte
Err error
}
```
There are generic versions of the server/client handlers that allow the use of type
safe implementations for data types that support msgpack marshal/unmarshal.
2023-11-20 20:09:35 -05:00
bootstrapTrace ( "initGrid" , func ( ) {
logger . FatalIf ( initGlobalGrid ( GlobalContext , globalEndpoints ) , "Unable to configure server grid RPC services" )
} )
2023-08-23 06:07:06 -04:00
// Configure server.
bootstrapTrace ( "configureServer" , func ( ) {
handler , err := configureServerHandler ( globalEndpoints )
2023-06-12 12:09:28 -04:00
if err != nil {
2023-08-23 06:07:06 -04:00
logger . Fatal ( config . ErrUnexpectedError ( err ) , "Unable to configure one of server's RPC services" )
2023-06-12 12:09:28 -04:00
}
perf: websocket grid connectivity for all internode communication (#18461)
This PR adds a WebSocket grid feature that allows servers to communicate via
a single two-way connection.
There are two request types:
* Single requests, which are `[]byte => ([]byte, error)`. This is for efficient small
roundtrips with small payloads.
* Streaming requests which are `[]byte, chan []byte => chan []byte (and error)`,
which allows for different combinations of full two-way streams with an initial payload.
Only a single stream is created between two machines - and there is, as such, no
server/client relation since both sides can initiate and handle requests. Which server
initiates the request is decided deterministically on the server names.
Requests are made through a mux client and server, which handles message
passing, congestion, cancelation, timeouts, etc.
If a connection is lost, all requests are canceled, and the calling server will try
to reconnect. Registered handlers can operate directly on byte
slices or use a higher-level generics abstraction.
There is no versioning of handlers/clients, and incompatible changes should
be handled by adding new handlers.
The request path can be changed to a new one for any protocol changes.
First, all servers create a "Manager." The manager must know its address
as well as all remote addresses. This will manage all connections.
To get a connection to any remote, ask the manager to provide it given
the remote address using.
```
func (m *Manager) Connection(host string) *Connection
```
All serverside handlers must also be registered on the manager. This will
make sure that all incoming requests are served. The number of in-flight
requests and responses must also be given for streaming requests.
The "Connection" returned manages the mux-clients. Requests issued
to the connection will be sent to the remote.
* `func (c *Connection) Request(ctx context.Context, h HandlerID, req []byte) ([]byte, error)`
performs a single request and returns the result. Any deadline provided on the request is
forwarded to the server, and canceling the context will make the function return at once.
* `func (c *Connection) NewStream(ctx context.Context, h HandlerID, payload []byte) (st *Stream, err error)`
will initiate a remote call and send the initial payload.
```Go
// A Stream is a two-way stream.
// All responses *must* be read by the caller.
// If the call is canceled through the context,
//The appropriate error will be returned.
type Stream struct {
// Responses from the remote server.
// Channel will be closed after an error or when the remote closes.
// All responses *must* be read by the caller until either an error is returned or the channel is closed.
// Canceling the context will cause the context cancellation error to be returned.
Responses <-chan Response
// Requests sent to the server.
// If the handler is defined with 0 incoming capacity this will be nil.
// Channel *must* be closed to signal the end of the stream.
// If the request context is canceled, the stream will no longer process requests.
Requests chan<- []byte
}
type Response struct {
Msg []byte
Err error
}
```
There are generic versions of the server/client handlers that allow the use of type
safe implementations for data types that support msgpack marshal/unmarshal.
2023-11-20 20:09:35 -05:00
// Allow grid to start after registering all services.
2024-01-28 13:04:17 -05:00
xioutil . SafeClose ( globalGridStart )
2016-09-14 04:11:03 -04:00
2023-08-23 06:07:06 -04:00
httpServer := xhttp . NewServer ( getServerListenAddrs ( ) ) .
UseHandler ( setCriticalErrorHandler ( corsHandler ( handler ) ) ) .
UseTLSConfig ( newTLSConfig ( getCert ) ) .
2023-12-07 04:33:56 -05:00
UseShutdownTimeout ( globalServerCtxt . ShutdownTimeout ) .
UseIdleTimeout ( globalServerCtxt . IdleTimeout ) .
UseReadHeaderTimeout ( globalServerCtxt . ReadHeaderTimeout ) .
2023-08-23 06:07:06 -04:00
UseBaseContext ( GlobalContext ) .
UseCustomLogger ( log . New ( io . Discard , "" , 0 ) ) . // Turn-off random logging by Go stdlib
UseTCPOptions ( globalTCPOptions )
httpServer . TCPOptions . Trace = bootstrapTraceMsg
go func ( ) {
serveFn , err := httpServer . Init ( GlobalContext , func ( listenAddr string , err error ) {
2024-04-04 08:04:40 -04:00
bootLogIf ( GlobalContext , fmt . Errorf ( "Unable to listen on `%s`: %v" , listenAddr , err ) )
2023-08-23 06:07:06 -04:00
} )
if err != nil {
globalHTTPServerErrorCh <- err
return
}
globalHTTPServerErrorCh <- serveFn ( )
} ( )
setHTTPServer ( httpServer )
} )
2019-12-02 18:54:26 -05:00
2022-11-16 10:59:10 -05:00
if globalIsDistErasure {
2023-08-23 06:07:06 -04:00
bootstrapTrace ( "verifying system configuration" , func ( ) {
// Additionally in distributed setup, validate the setup and configuration.
2024-01-24 16:36:44 -05:00
if err := verifyServerSystemConfig ( GlobalContext , globalEndpoints , globalGrid . Load ( ) ) ; err != nil {
2023-08-23 06:07:06 -04:00
logger . Fatal ( err , "Unable to start the server" )
}
} )
2019-11-22 15:45:13 -05:00
}
2023-06-20 12:28:23 -04:00
if ! globalDisableFreezeOnBoot {
// Freeze the services until the bucket notification subsystem gets initialized.
2023-08-23 06:07:06 -04:00
bootstrapTrace ( "freezeServices" , freezeServices )
2023-06-20 12:28:23 -04:00
}
2023-08-23 06:07:06 -04:00
var newObject ObjectLayer
bootstrapTrace ( "newObjectLayer" , func ( ) {
var err error
newObject , err = newObjectLayer ( GlobalContext , globalEndpoints )
if err != nil {
logFatalErrs ( err , Endpoint { } , true )
}
} )
2022-02-04 15:21:21 -05:00
2023-10-18 11:06:57 -04:00
xhttp . SetDeploymentID ( globalDeploymentID ( ) )
2022-02-23 16:36:01 -05:00
xhttp . SetMinIOVersion ( Version )
2020-09-28 22:39:32 -04:00
2023-06-27 12:23:50 -04:00
for _ , n := range globalNodes {
nodeName := n . Host
if n . IsLocal {
nodeName = globalLocalNodeName
}
2023-10-18 11:06:57 -04:00
nodeNameSum := sha256 . Sum256 ( [ ] byte ( nodeName + globalDeploymentID ( ) ) )
2023-06-27 12:23:50 -04:00
globalNodeNamesHex [ hex . EncodeToString ( nodeNameSum [ : ] ) ] = struct { } { }
}
2023-08-23 06:07:06 -04:00
var err error
bootstrapTrace ( "initServerConfig" , func ( ) {
if err = initServerConfig ( GlobalContext , newObject ) ; err != nil {
var cerr config . Err
// For any config error, we don't need to drop into safe-mode
// instead its a user error and should be fixed by user.
if errors . As ( err , & cerr ) {
logger . FatalIf ( err , "Unable to initialize the server" )
}
// If context was canceled
if errors . Is ( err , context . Canceled ) {
logger . FatalIf ( err , "Server startup canceled upon user request" )
}
2024-04-04 08:04:40 -04:00
bootLogIf ( GlobalContext , err )
2023-08-23 06:07:06 -04:00
}
2023-12-07 04:33:56 -05:00
if ! globalServerCtxt . StrictS3Compat {
2024-03-09 01:42:32 -05:00
warnings = append ( warnings , color . YellowBold ( "- Strict AWS S3 compatible incoming PUT, POST content payload validation is turned off, caution is advised do not use in production" ) )
2023-08-23 06:07:06 -04:00
}
} )
2023-06-20 12:28:23 -04:00
if globalActiveCred . Equal ( auth . DefaultCredentials ) {
2024-03-09 01:42:32 -05:00
msg := fmt . Sprintf ( "- Detected default credentials '%s', we recommend that you change these values with 'MINIO_ROOT_USER' and 'MINIO_ROOT_PASSWORD' environment variables" ,
2023-06-20 12:28:23 -04:00
globalActiveCred )
2024-03-09 01:42:32 -05:00
warnings = append ( warnings , color . YellowBold ( msg ) )
2023-06-20 12:28:23 -04:00
}
2022-08-13 15:54:41 -04:00
// Initialize users credentials and policies in background right after config has initialized.
go func ( ) {
2023-08-23 06:07:06 -04:00
bootstrapTrace ( "globalIAMSys.Init" , func ( ) {
globalIAMSys . Init ( GlobalContext , newObject , globalEtcdClient , globalRefreshIAMInterval )
} )
2022-02-07 03:17:26 -05:00
2023-06-20 12:28:23 -04:00
// Initialize Console UI
2022-08-13 15:54:41 -04:00
if globalBrowserEnabled {
2023-08-23 06:07:06 -04:00
bootstrapTrace ( "initConsoleServer" , func ( ) {
srv , err := initConsoleServer ( )
if err != nil {
logger . FatalIf ( err , "Unable to initialize console service" )
}
2022-02-07 03:17:26 -05:00
2023-08-23 06:07:06 -04:00
setConsoleSrv ( srv )
2022-02-07 03:17:26 -05:00
2023-08-23 06:07:06 -04:00
go func ( ) {
logger . FatalIf ( newConsoleServerFn ( ) . Serve ( ) , "Unable to initialize console server" )
} ( )
} )
2022-08-13 15:54:41 -04:00
}
2023-04-15 10:34:02 -04:00
// if we see FTP args, start FTP if possible
2023-12-07 04:33:56 -05:00
if len ( globalServerCtxt . FTP ) > 0 {
2023-08-23 06:07:06 -04:00
bootstrapTrace ( "go startFTPServer" , func ( ) {
2023-12-07 04:33:56 -05:00
go startFTPServer ( globalServerCtxt . FTP )
2023-08-23 06:07:06 -04:00
} )
2023-04-15 10:34:02 -04:00
}
// If we see SFTP args, start SFTP if possible
2023-12-07 04:33:56 -05:00
if len ( globalServerCtxt . SFTP ) > 0 {
bootstrapTrace ( "go startSFTPServer" , func ( ) {
go startSFTPServer ( globalServerCtxt . SFTP )
2023-08-23 06:07:06 -04:00
} )
2023-04-15 10:34:02 -04:00
}
2022-08-13 15:54:41 -04:00
} ( )
2021-11-17 16:42:08 -05:00
2022-02-07 13:39:57 -05:00
go func ( ) {
2023-10-23 15:30:20 -04:00
r := rand . New ( rand . NewSource ( time . Now ( ) . UnixNano ( ) ) )
2023-05-19 11:44:48 -04:00
if ! globalDisableFreezeOnBoot {
2023-08-23 06:07:06 -04:00
defer bootstrapTrace ( "unfreezeServices" , unfreezeServices )
2023-05-19 11:44:48 -04:00
t := time . AfterFunc ( 5 * time . Minute , func ( ) {
2024-03-09 01:42:32 -05:00
warnings = append ( warnings , color . YellowBold ( "- Initializing the config subsystem is taking longer than 5 minutes. Please set '_MINIO_DISABLE_API_FREEZE_ON_BOOT=true' to not freeze the APIs" ) )
2023-05-19 11:44:48 -04:00
} )
defer t . Stop ( )
}
2023-02-07 15:46:47 -05:00
// Initialize data scanner.
2023-08-23 06:07:06 -04:00
bootstrapTrace ( "initDataScanner" , func ( ) {
2023-11-22 16:46:17 -05:00
if v := env . Get ( "_MINIO_SCANNER" , config . EnableOn ) ; v == config . EnableOn {
initDataScanner ( GlobalContext , newObject )
}
2023-08-23 06:07:06 -04:00
} )
2023-02-07 15:46:47 -05:00
// Initialize background replication
2023-08-23 06:07:06 -04:00
bootstrapTrace ( "initBackgroundReplication" , func ( ) {
initBackgroundReplication ( GlobalContext , newObject )
} )
2023-02-07 15:46:47 -05:00
2024-03-02 00:11:03 -05:00
// Initialize background ILM worker poool
bootstrapTrace ( "initBackgroundExpiry" , func ( ) {
initBackgroundExpiry ( GlobalContext , newObject )
} )
2023-08-23 06:07:06 -04:00
bootstrapTrace ( "globalTransitionState.Init" , func ( ) {
globalTransitionState . Init ( newObject )
} )
2022-02-07 13:39:57 -05:00
2023-02-07 15:46:47 -05:00
// Initialize batch job pool.
2023-08-23 06:07:06 -04:00
bootstrapTrace ( "newBatchJobPool" , func ( ) {
globalBatchJobPool = newBatchJobPool ( GlobalContext , newObject , 100 )
} )
2022-10-03 05:10:15 -04:00
2023-02-07 15:46:47 -05:00
// Initialize the license update job
2023-08-23 06:07:06 -04:00
bootstrapTrace ( "initLicenseUpdateJob" , func ( ) {
initLicenseUpdateJob ( GlobalContext , newObject )
} )
2023-02-07 15:46:47 -05:00
2022-05-30 13:58:37 -04:00
go func ( ) {
2023-02-07 15:46:47 -05:00
// Initialize transition tier configuration manager
2023-08-23 06:07:06 -04:00
bootstrapTrace ( "globalTierConfigMgr.Init" , func ( ) {
if err := globalTierConfigMgr . Init ( GlobalContext , newObject ) ; err != nil {
2024-04-04 08:04:40 -04:00
bootLogIf ( GlobalContext , err )
2023-08-23 06:07:06 -04:00
}
} )
2022-05-30 13:58:37 -04:00
} ( )
2021-11-17 16:42:08 -05:00
2023-05-19 11:44:48 -04:00
// Initialize bucket notification system.
2023-08-23 06:07:06 -04:00
bootstrapTrace ( "initBucketTargets" , func ( ) {
2024-04-04 08:04:40 -04:00
bootLogIf ( GlobalContext , globalEventNotifier . InitBucketTargets ( GlobalContext , newObject ) )
2023-08-23 06:07:06 -04:00
} )
2023-05-19 11:44:48 -04:00
2023-08-23 06:07:06 -04:00
var buckets [ ] BucketInfo
2023-05-19 11:44:48 -04:00
// List buckets to initialize bucket metadata sub-sys.
2023-08-23 06:07:06 -04:00
bootstrapTrace ( "listBuckets" , func ( ) {
2023-10-23 15:30:20 -04:00
for {
buckets , err = newObject . ListBuckets ( GlobalContext , BucketOptions { } )
if err != nil {
if configRetriableErrors ( err ) {
logger . Info ( "Waiting for list buckets to succeed to initialize buckets.. possible cause (%v)" , err )
time . Sleep ( time . Duration ( r . Float64 ( ) * float64 ( time . Second ) ) )
continue
}
2024-04-04 08:04:40 -04:00
bootLogIf ( GlobalContext , fmt . Errorf ( "Unable to list buckets to initialize bucket metadata sub-system: %w" , err ) )
2023-10-23 15:30:20 -04:00
}
break
2023-08-23 06:07:06 -04:00
}
} )
2022-01-20 16:03:15 -05:00
2022-02-07 13:39:57 -05:00
// Initialize bucket metadata sub-system.
2023-08-23 06:07:06 -04:00
bootstrapTrace ( "globalBucketMetadataSys.Init" , func ( ) {
globalBucketMetadataSys . Init ( GlobalContext , buckets , newObject )
} )
2020-11-02 20:52:13 -05:00
2023-05-19 11:44:48 -04:00
// initialize replication resync state.
2023-08-23 06:07:06 -04:00
bootstrapTrace ( "initResync" , func ( ) {
globalReplicationPool . initResync ( GlobalContext , buckets , newObject )
} )
2023-05-19 11:44:48 -04:00
// Initialize site replication manager after bucket metadata
2023-08-23 06:07:06 -04:00
bootstrapTrace ( "globalSiteReplicationSys.Init" , func ( ) {
globalSiteReplicationSys . Init ( GlobalContext , newObject )
} )
2022-06-16 22:00:35 -04:00
2023-02-07 15:46:47 -05:00
// Initialize quota manager.
2023-08-23 06:07:06 -04:00
bootstrapTrace ( "globalBucketQuotaSys.Init" , func ( ) {
globalBucketQuotaSys . Init ( newObject )
} )
2020-10-12 17:19:46 -04:00
2023-02-07 15:46:47 -05:00
// Populate existing buckets to the etcd backend
if globalDNSConfig != nil {
// Background this operation.
2023-08-23 06:07:06 -04:00
bootstrapTrace ( "go initFederatorBackend" , func ( ) {
go initFederatorBackend ( buckets , newObject )
} )
2022-02-07 13:39:57 -05:00
}
2019-10-23 01:59:13 -04:00
2022-02-07 13:39:57 -05:00
// Prints the formatted startup message, if err is not nil then it prints additional information as well.
printStartupMessage ( getAPIEndpoints ( ) , err )
2023-01-10 02:07:45 -05:00
// Print a warning at the end of the startup banner so it is more noticeable
2023-05-04 17:44:30 -04:00
if newObject . BackendInfo ( ) . StandardSCParity == 0 {
2024-03-09 01:42:32 -05:00
warnings = append ( warnings , color . YellowBold ( "- The standard parity is set to 0. This can lead to data loss." ) )
2024-03-08 22:07:08 -05:00
}
objAPI := newObjectLayerFn ( )
if objAPI != nil {
printStorageInfo ( objAPI . StorageInfo ( GlobalContext , true ) )
}
if len ( warnings ) > 0 {
logger . Info ( color . Yellow ( "STARTUP WARNINGS:" ) )
for _ , warn := range warnings {
logger . Info ( warn )
}
2023-01-10 02:07:45 -05:00
}
2022-02-07 13:39:57 -05:00
} ( )
2021-10-08 15:40:34 -04:00
2022-07-12 13:12:47 -04:00
region := globalSite . Region
if region == "" {
region = "us-east-1"
}
2023-08-23 06:07:06 -04:00
bootstrapTrace ( "globalMinioClient" , func ( ) {
globalMinioClient , err = minio . New ( globalLocalNodeName , & minio . Options {
Creds : credentials . NewStaticV4 ( globalActiveCred . AccessKey , globalActiveCred . SecretKey , "" ) ,
Secure : globalIsTLS ,
2024-04-21 07:43:18 -04:00
Transport : globalRemoteTargetTransport ,
2023-08-23 06:07:06 -04:00
Region : region ,
} )
logger . FatalIf ( err , "Unable to initialize MinIO client" )
2022-07-12 13:12:47 -04:00
} )
2023-09-30 16:40:20 -04:00
go bootstrapTrace ( "startResourceMetricsCollection" , func ( ) {
startResourceMetricsCollection ( )
} )
2023-02-14 16:19:30 -05:00
// Add User-Agent to differentiate the requests.
globalMinioClient . SetAppInfo ( "minio-perf-test" , ReleaseTag )
2021-09-27 22:51:24 -04:00
if serverDebugLog {
2024-02-15 18:13:30 -05:00
fmt . Println ( "== DEBUG Mode enabled ==" )
fmt . Println ( "Currently set environment settings:" )
2022-01-20 16:03:15 -05:00
ks := [ ] string {
config . EnvAccessKey ,
config . EnvSecretKey ,
config . EnvRootUser ,
config . EnvRootPassword ,
}
2021-09-27 22:51:24 -04:00
for _ , v := range os . Environ ( ) {
2022-01-20 16:03:15 -05:00
// Do not print sensitive creds in debug.
2023-06-06 13:12:52 -04:00
if slices . Contains ( ks , strings . Split ( v , "=" ) [ 0 ] ) {
2022-01-20 16:03:15 -05:00
continue
}
2024-02-15 18:13:30 -05:00
fmt . Println ( v )
2021-09-27 22:51:24 -04:00
}
2024-02-15 18:13:30 -05:00
fmt . Println ( "======" )
2021-09-27 22:51:24 -04:00
}
2022-02-07 13:39:57 -05:00
2023-05-12 19:42:17 -04:00
daemon . SdNotify ( false , daemon . SdNotifyReady )
2021-08-31 21:52:48 -04:00
<- globalOSSignalCh
config/main: Re-write config files - add to new config v3
- New config format.
```
{
"version": "3",
"address": ":9000",
"backend": {
"type": "fs",
"disk": "/path"
},
"credential": {
"accessKey": "WLGDGYAQYIGI833EV05A",
"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
},
"region": "us-east-1",
"logger": {
"file": {
"enable": false,
"fileName": "",
"level": "error"
},
"syslog": {
"enable": false,
"address": "",
"level": "debug"
},
"console": {
"enable": true,
"level": "fatal"
}
}
}
```
New command lines in lieu of supporting XL.
Minio initialize filesystem backend.
~~~
$ minio init fs <path>
~~~
Minio initialize XL backend.
~~~
$ minio init xl <url1>...<url16>
~~~
For 'fs' backend it starts the server.
~~~
$ minio server
~~~
For 'xl' backend it waits for servers to join.
~~~
$ minio server
... [PROGRESS BAR] of servers connecting
~~~
Now on other servers execute 'join' and they connect.
~~~
....
minio join <url1> -- from <url2> && minio server
minio join <url1> -- from <url3> && minio server
...
...
minio join <url1> -- from <url16> && minio server
~~~
2016-02-12 18:27:10 -05:00
}
2017-01-16 20:05:00 -05:00
// Initialize object layer with the supplied disks, objectLayer is nil upon any error.
2020-12-01 16:50:33 -05:00
func newObjectLayer ( ctx context . Context , endpointServerPools EndpointServerPools ) ( newObject ObjectLayer , err error ) {
return newErasureServerPools ( ctx , endpointServerPools )
2017-01-16 20:05:00 -05:00
}