2021-04-18 15:41:13 -04:00
// Copyright (c) 2015-2021 MinIO, Inc.
//
// 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 (
2018-04-05 18:04:40 -04:00
"context"
2020-11-02 10:43:11 -05:00
"crypto/tls"
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"
2017-03-06 22:35:26 -05:00
"os"
2017-07-12 19:33:21 -04:00
"os/signal"
2022-03-21 22:05:04 -04:00
"runtime"
2018-05-18 20:51:03 -04:00
"strings"
2020-12-13 14:57:08 -05:00
"sync"
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
"github.com/minio/cli"
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"
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"
"github.com/minio/minio/internal/fips"
xhttp "github.com/minio/minio/internal/http"
"github.com/minio/minio/internal/logger"
"github.com/minio/minio/internal/rest"
2021-05-28 18:17:01 -04:00
"github.com/minio/pkg/certs"
"github.com/minio/pkg/env"
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 {
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 ,
Usage : "idle timeout is the maximum amount of time to wait for the next request when keep-alives are enabled" ,
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 ,
} ,
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 :
2016-11-10 02:37:12 -05: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 }
3. Start distributed minio server on an 32 node setup with 32 drives each , run following command on all the nodes
2021-01-05 13:22:57 -05:00
{ { . Prompt } } { { . EnvVarSetCommand } } MINIO_ROOT_USER { { . AssignmentOperator } } minio
{ { . Prompt } } { { . EnvVarSetCommand } } MINIO_ROOT_PASSWORD { { . AssignmentOperator } } miniostorage
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
2020-04-22 02:59:13 -04:00
4. Start distributed minio server in an expanded setup , run the following command on all the nodes
2021-01-05 13:22:57 -05:00
{ { . Prompt } } { { . EnvVarSetCommand } } MINIO_ROOT_USER { { . AssignmentOperator } } minio
{ { . Prompt } } { { . EnvVarSetCommand } } MINIO_ROOT_PASSWORD { { . AssignmentOperator } } miniostorage
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}
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
}
2017-03-30 14:21:19 -04:00
func serverHandleCmdArgs ( ctx * cli . Context ) {
2017-06-09 22:50:51 -04:00
// Handle common command args.
handleCommonCmdArgs ( ctx )
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
2021-06-21 02:04:47 -04:00
globalEndpoints , setupType , err = createServerEndpoints ( globalMinioAddr , serverCmdArgs ( ctx ) ... )
2021-03-26 14:37:58 -04:00
logger . FatalIf ( err , "Invalid command line arguments" )
globalLocalNodeName = GetLocalPeer ( globalEndpoints , globalMinioHost , globalMinioPort )
2021-01-07 22:16:18 -05:00
globalRemoteEndpoints = make ( map [ string ] Endpoint )
for _ , z := range globalEndpoints {
for _ , ep := range z . Endpoints {
if ep . IsLocal {
2021-03-26 14:37:58 -04:00
globalRemoteEndpoints [ globalLocalNodeName ] = ep
2021-01-25 13:01:27 -05:00
} else {
globalRemoteEndpoints [ ep . Host ] = ep
2021-01-07 22:16:18 -05:00
}
}
}
2018-02-15 20:45:57 -05:00
2020-12-22 00:42:38 -05:00
// allow transport to be HTTP/1.1 for proxying.
globalProxyTransport = newCustomHTTPProxyTransport ( & tls . Config {
2022-01-06 14:34:02 -05:00
RootCAs : globalRootCAs ,
2022-06-21 10:54:48 -04:00
CipherSuites : fips . TLSCiphers ( ) ,
CurvePreferences : fips . TLSCurveIDs ( ) ,
2022-01-06 14:34:02 -05:00
ClientSessionCache : tls . NewLRUClientSessionCache ( tlsClientSessionCacheSize ) ,
2020-12-22 00:42:38 -05:00
} , rest . DefaultTimeout ) ( )
2020-11-02 10:43:11 -05:00
globalProxyEndpoints = GetProxyEndpoints ( globalEndpoints )
globalInternodeTransport = newInternodeHTTPTransport ( & tls . Config {
2022-01-06 14:34:02 -05:00
RootCAs : globalRootCAs ,
2022-06-21 10:54:48 -04:00
CipherSuites : fips . TLSCiphers ( ) ,
CurvePreferences : fips . TLSCurveIDs ( ) ,
2022-01-06 14:34:02 -05:00
ClientSessionCache : tls . NewLRUClientSessionCache ( tlsClientSessionCacheSize ) ,
2020-11-02 10:43:11 -05:00
} , rest . DefaultTimeout ) ( )
2022-06-22 19:28:25 -04:00
globalRemoteTargetTransport = NewRemoteTargetHTTPTransport ( ) ( )
2020-11-02 10:43:11 -05: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.
2019-06-24 18:02:40 -04:00
logger . FatalIf ( checkPortAvailability ( globalMinioHost , globalMinioPort ) , "Unable to start the server" )
2016-08-30 22:22:27 -04:00
2020-06-12 23:04:01 -04:00
globalIsErasure = ( setupType == ErasureSetupType )
globalIsDistErasure = ( setupType == DistErasureSetupType )
if globalIsDistErasure {
globalIsErasure = true
2017-01-23 03:32:55 -05:00
}
2022-05-30 13:58:37 -04:00
globalIsErasureSD = ( setupType == ErasureSDSetupType )
2017-03-30 14:21:19 -04:00
}
func serverHandleEnvVars ( ) {
2017-06-09 22:50:51 -04:00
// Handle common environment variables.
handleCommonEnvVars ( )
2017-03-30 14:21:19 -04:00
}
2020-12-13 14:57:08 -05:00
var globalHealStateLK sync . RWMutex
2022-10-14 06:08:40 -04:00
func initAllSubsystems ( ctx context . Context ) {
2022-05-30 13:58:37 -04:00
globalHealStateLK . Lock ( )
// New global heal state
2022-10-14 06:08:40 -04:00
globalAllHealState = newHealState ( ctx , true )
globalBackgroundHealState = newHealState ( ctx , false )
2022-05-30 13:58:37 -04:00
globalHealStateLK . Unlock ( )
2020-12-13 14:57:08 -05:00
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
globalEventNotifier = NewEventNotifier ( )
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
2022-10-14 06:08:40 -04:00
globalBucketMonitor = bandwidth . NewMonitor ( ctx , 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
// Create new bucket replication subsytem
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 ( )
2019-11-09 12:27:23 -05:00
}
2021-03-18 17:09:55 -04:00
func configRetriableErrors ( err error ) bool {
// 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 ) ||
errors . Is ( err , os . ErrDeadlineExceeded )
}
2022-02-07 13:39:57 -05:00
func initServer ( ctx context . Context , newObject ObjectLayer ) error {
2022-03-25 19:29:45 -04:00
t1 := time . Now ( )
2020-10-28 03:09:15 -04:00
// Once the config is fully loaded, initialize the new object layer.
2021-01-03 14:27:57 -05:00
setObjectLayer ( newObject )
2020-10-28 03:09:15 -04:00
2019-11-09 12:27:23 -05:00
// **** WARNING ****
// Migrating to encrypted backend should happen before initialization of any
// sub-systems, make sure that we do not move the above codeblock elsewhere.
2020-02-01 20:07:43 -05:00
2020-11-02 20:52:13 -05:00
r := rand . New ( rand . NewSource ( time . Now ( ) . UnixNano ( ) ) )
lockTimeout := newDynamicTimeout ( 5 * time . Second , 3 * time . Second )
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 :
}
2022-01-02 12:15:34 -05:00
// Make sure to hold lock for entire migration to avoid
// such that only one server should migrate the entire config
// at a given time, this big transaction lock ensures this
// appropriately. This is also true for rotation of encrypted
// content.
txnLk := newObject . NewNSLock ( minioMetaBucket , minioConfigPrefix + "/transaction.lock" )
2020-05-04 23:04:06 -04:00
// let one of the server acquire the lock, if not let them timeout.
// which shall be retried again by this loop.
2021-04-29 23:55:21 -04:00
lkctx , err := txnLk . GetLock ( ctx , lockTimeout )
2021-04-27 19:12:50 -04:00
if err != nil {
2020-05-06 17:25:05 -04:00
logger . Info ( "Waiting for all MinIO sub-systems to be initialized.. trying to acquire lock" )
2020-11-02 20:52:13 -05:00
time . Sleep ( time . Duration ( r . Float64 ( ) * float64 ( 5 * time . Second ) ) )
2020-05-06 17:25:05 -04:00
continue
}
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 {
2020-05-07 19:12:16 -04:00
logger . Info ( "Waiting for all MinIO sub-systems to be initialized.. lock acquired" )
}
2020-05-06 17:25:05 -04:00
// Migrate all backend configs to encrypted backend configs, optionally
// handles rotating keys for encryption, if there is any retriable failure
// that shall be retried if there is an error.
2020-06-25 06:29:28 -04:00
if err = handleEncryptedConfigBackend ( newObject ) ; err == nil {
2020-05-06 17:25:05 -04:00
// Upon success migrating the config, initialize all sub-systems
// if all sub-systems initialized successfully return right away
2022-02-07 13:39:57 -05:00
if err = initConfigSubsystem ( lkctx . Context ( ) , newObject ) ; err == nil {
2021-04-29 23:55:21 -04:00
txnLk . Unlock ( lkctx . Cancel )
2020-05-06 17:25:05 -04:00
// All successful return.
2020-06-12 23:04:01 -04:00
if globalIsDistErasure {
2020-05-07 19:12:16 -04:00
// These messages only meant primarily for distributed setup, so only log during distributed setup.
2022-03-25 19:29:45 -04:00
logger . Info ( "All MinIO sub-systems initialized successfully in %s" , time . Since ( t1 ) )
2020-05-07 19:12:16 -04:00
}
2022-02-07 13:39:57 -05:00
return nil
2020-02-01 20:07:43 -05:00
}
2020-05-04 23:04:06 -04:00
}
2021-04-29 23:55:21 -04:00
// Unlock the transaction lock and allow other nodes to acquire the lock if possible.
txnLk . Unlock ( lkctx . Cancel )
2020-10-09 12:59:52 -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.
2020-10-19 12:54:40 -04:00
logger . LogIf ( 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
}
2017-03-30 14:21:19 -04:00
// serverMain handler called for 'minio server' command.
func serverMain ( ctx * cli . Context ) {
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
2019-12-16 23:30:57 -05:00
// Initialize globalConsoleSys system
2020-04-09 12:30:02 -04:00
globalConsoleSys = NewConsoleLogger ( GlobalContext )
2022-02-24 12:05:33 -05:00
logger . AddSystemTarget ( globalConsoleSys )
2019-12-16 23:30:57 -05:00
2021-03-31 12:11:37 -04:00
// Perform any self-tests
2021-04-06 11:38:22 -04:00
bitrotSelfTest ( )
2021-03-31 12:11:37 -04:00
erasureSelfTest ( )
compressSelfTest ( )
2019-11-04 12:30:59 -05:00
// Handle all server environment vars.
serverHandleEnvVars ( )
2022-06-10 12:59:15 -04:00
// Handle all server command args.
serverHandleCmdArgs ( ctx )
2022-06-13 16:06:13 -04:00
// Initialize KMS configuration
handleKMSConfig ( )
2019-12-16 23:30:57 -05:00
// Set node name, only set for distributed setup.
2021-03-26 14:37:58 -04:00
globalConsoleSys . SetNodeName ( globalLocalNodeName )
2019-12-16 23:30:57 -05:00
2019-12-04 18:32:37 -05:00
// Initialize all help
initHelp ( )
2020-10-19 12:54:40 -04:00
// Initialize all sub-systems
2022-10-14 06:08:40 -04:00
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 ( ) {
if ! globalCLIContext . Quiet && ! globalInplaceUpdateDisabled {
// Check for new updates from dl.min.io.
checkUpdate ( getMinioMode ( ) )
}
} ( )
2017-03-16 15:21:58 -04:00
2020-06-12 23:04:01 -04:00
if ! globalActiveCred . IsValid ( ) && globalIsDistErasure {
2021-05-17 11:45:22 -04:00
globalActiveCred = auth . DefaultCredentials
2018-08-15 00:41:47 -04:00
}
2017-03-30 14:21:19 -04:00
// Set system resources to maximum.
2020-06-03 16:18:54 -04:00
setMaxResources ( )
2017-03-30 14:21:19 -04:00
2022-03-10 20:36:13 -05:00
// Verify kernel release and version.
if oldLinux ( ) {
logger . Info ( color . RedBold ( "WARNING: 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-21 22:05:04 -04:00
maxProcs := runtime . GOMAXPROCS ( 0 )
cpuProcs := runtime . NumCPU ( )
if maxProcs < cpuProcs {
logger . Info ( color . RedBold ( "WARNING: Detected GOMAXPROCS(%d) < NumCPU(%d), please make sure to provide all PROCS to MinIO for optimal performance" , maxProcs , cpuProcs ) )
}
2017-03-30 14:21:19 -04:00
// Configure server.
2020-05-25 03:17:52 -04:00
handler , err := configureServerHandler ( globalEndpoints )
2018-05-08 22:04:36 -04:00
if err != nil {
2019-10-04 13:35:33 -04:00
logger . Fatal ( config . ErrUnexpectedError ( err ) , "Unable to configure one of server's RPC services" )
2018-05-08 22:04:36 -04:00
}
2017-01-16 20:05:00 -05:00
2018-05-31 15:30:15 -04:00
var getCert certs . GetCertificateFunc
if globalTLSCerts != nil {
getCert = globalTLSCerts . GetCertificate
}
2022-10-19 11:45:50 -04:00
httpServer := xhttp . NewServer ( [ ] string { globalMinioAddr } ) .
2021-11-29 12:06:56 -05:00
UseHandler ( setCriticalErrorHandler ( corsHandler ( handler ) ) ) .
UseTLSConfig ( newTLSConfig ( getCert ) ) .
UseShutdownTimeout ( ctx . Duration ( "shutdown-timeout" ) ) .
2022-05-30 09:24:51 -04:00
UseIdleTimeout ( ctx . Duration ( "idle-timeout" ) ) .
UseReadHeaderTimeout ( ctx . Duration ( "read-header-timeout" ) ) .
2021-11-29 12:06:56 -05:00
UseBaseContext ( GlobalContext ) .
2022-09-19 14:05:16 -04:00
UseCustomLogger ( log . New ( io . Discard , "" , 0 ) ) // Turn-off random logging by Go stdlib
2021-11-29 12:06:56 -05:00
2017-01-11 16:59:51 -05:00
go func ( ) {
2021-10-05 13:13:04 -04:00
globalHTTPServerErrorCh <- httpServer . Start ( GlobalContext )
2017-01-11 16:59:51 -05:00
} ( )
2016-09-14 04:11:03 -04:00
2021-01-03 14:27:57 -05:00
setHTTPServer ( httpServer )
2019-12-02 18:54:26 -05:00
2020-06-12 23:04:01 -04:00
if globalIsDistErasure && globalEndpoints . FirstLocal ( ) {
2022-02-07 13:39:57 -05:00
// Additionally in distributed setup, validate the setup and configuration.
if err := verifyServerSystemConfig ( GlobalContext , globalEndpoints ) ; err != nil {
logger . Fatal ( err , "Unable to start the server" )
2019-11-22 15:45:13 -05:00
}
}
2020-04-14 20:52:38 -04:00
newObject , err := newObjectLayer ( GlobalContext , globalEndpoints )
2017-07-12 19:33:21 -04:00
if err != nil {
2020-09-28 22:39:32 -04:00
logFatalErrs ( err , Endpoint { } , true )
2018-04-05 11:18:42 -04:00
}
2022-02-04 15:21:21 -05:00
2022-02-23 16:36:01 -05:00
xhttp . SetDeploymentID ( globalDeploymentID )
xhttp . SetMinIOVersion ( Version )
2020-09-28 22:39:32 -04:00
2020-10-12 17:19:46 -04:00
// Enable background operations for erasure coding
2022-05-30 13:58:37 -04:00
initAutoHeal ( GlobalContext , newObject )
initHealMRF ( GlobalContext , newObject )
2021-04-16 17:09:25 -04:00
initBackgroundExpiry ( GlobalContext , newObject )
2020-12-13 14:57:08 -05:00
2022-02-07 13:39:57 -05:00
if ! globalCLIContext . StrictS3Compat {
2022-03-03 16:21:16 -05:00
logger . Info ( color . RedBold ( "WARNING: Strict AWS S3 compatible incoming PUT, POST content payload validation is turned off, caution is advised do not use in production" ) )
2022-02-07 13:39:57 -05:00
}
if err = initServer ( GlobalContext , newObject ) ; err != nil {
2020-10-12 17:19:46 -04:00
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" )
}
2021-05-18 18:19:20 -04:00
logger . LogIf ( GlobalContext , err )
2020-10-12 17:19:46 -04:00
}
2022-09-21 19:14:47 -04:00
if globalActiveCred . Equal ( auth . DefaultCredentials ) {
msg := fmt . Sprintf ( "WARNING: Detected default credentials '%s', we recommend that you change these values with 'MINIO_ROOT_USER' and 'MINIO_ROOT_PASSWORD' environment variables" ,
globalActiveCred )
logger . Info ( color . RedBold ( msg ) )
}
savedCreds , _ := config . LookupCreds ( globalServerConfig [ config . CredentialsSubSys ] [ config . Default ] )
if globalActiveCred . Equal ( auth . DefaultCredentials ) && ! globalActiveCred . Equal ( savedCreds ) {
msg := fmt . Sprintf ( "WARNING: Detected credentials changed to '%s', please set them back to previously set values" ,
globalActiveCred )
logger . Info ( color . RedBold ( msg ) )
}
2020-10-12 17:19:46 -04:00
2022-08-13 15:54:41 -04:00
// Initialize users credentials and policies in background right after config has initialized.
go func ( ) {
globalIAMSys . Init ( GlobalContext , newObject , globalEtcdClient , globalRefreshIAMInterval )
2022-02-07 03:17:26 -05:00
2022-08-13 15:54:41 -04:00
// Initialize
if globalBrowserEnabled {
srv , err := initConsoleServer ( )
if err != nil {
logger . FatalIf ( err , "Unable to initialize console service" )
}
2022-02-07 03:17:26 -05:00
2022-08-13 15:54:41 -04:00
setConsoleSrv ( srv )
2022-02-07 03:17:26 -05:00
2022-08-13 15:54:41 -04:00
go func ( ) {
logger . FatalIf ( newConsoleServerFn ( ) . Serve ( ) , "Unable to initialize console server" )
} ( )
}
} ( )
2021-11-17 16:42:08 -05:00
2022-02-07 13:39:57 -05:00
// Background all other operations such as initializing bucket metadata etc.
go func ( ) {
// Initialize transition tier configuration manager
2022-05-30 13:58:37 -04:00
initBackgroundReplication ( GlobalContext , newObject )
initBackgroundTransition ( GlobalContext , newObject )
2022-02-07 13:39:57 -05:00
2022-10-03 05:10:15 -04:00
globalBatchJobPool = newBatchJobPool ( GlobalContext , newObject , 100 )
2022-05-30 13:58:37 -04:00
go func ( ) {
2022-07-16 10:57:55 -04:00
err := globalTierConfigMgr . Init ( GlobalContext , newObject )
if err != nil {
2022-05-30 13:58:37 -04:00
logger . LogIf ( GlobalContext , err )
}
2021-11-17 16:42:08 -05:00
2022-05-30 13:58:37 -04:00
globalTierJournal , err = initTierDeletionJournal ( GlobalContext )
if err != nil {
logger . FatalIf ( err , "Unable to initialize remote tier pending deletes journal" )
}
} ( )
2021-11-17 16:42:08 -05:00
2022-02-07 13:39:57 -05:00
// Initialize quota manager.
globalBucketQuotaSys . Init ( newObject )
2021-06-04 14:15:13 -04:00
2022-02-07 13:39:57 -05:00
initDataScanner ( GlobalContext , newObject )
2021-06-03 22:18:59 -04:00
2022-02-07 13:39:57 -05:00
// List buckets to heal, and be re-used for loading configs.
2022-07-25 20:51:32 -04:00
buckets , err := newObject . ListBuckets ( GlobalContext , BucketOptions { } )
2022-02-07 13:39:57 -05:00
if err != nil {
logger . LogIf ( GlobalContext , fmt . Errorf ( "Unable to list buckets to heal: %w" , err ) )
}
2022-02-10 13:16:52 -05:00
// initialize replication resync state.
go globalReplicationPool . initResync ( GlobalContext , buckets , newObject )
2022-01-20 16:03:15 -05:00
2022-02-07 13:39:57 -05:00
// Populate existing buckets to the etcd backend
if globalDNSConfig != nil {
// Background this operation.
go initFederatorBackend ( buckets , newObject )
}
2021-04-19 13:30:42 -04:00
2022-02-07 13:39:57 -05:00
// Initialize bucket metadata sub-system.
globalBucketMetadataSys . Init ( GlobalContext , buckets , newObject )
2020-11-02 20:52:13 -05:00
2022-06-16 22:00:35 -04:00
// Initialize site replication manager.
globalSiteReplicationSys . Init ( GlobalContext , newObject )
2022-09-27 20:23:28 -04:00
// Initialize bucket notification system
logger . LogIf ( GlobalContext , globalEventNotifier . InitBucketTargets ( GlobalContext , newObject ) )
2020-11-02 20:52:13 -05:00
2022-02-07 13:39:57 -05:00
// initialize the new disk cache objects.
if globalCacheConfig . Enabled {
2022-08-04 19:10:08 -04:00
logger . Info ( color . Yellow ( "WARNING: Drive caching is deprecated for single/multi drive MinIO setups. Please migrate to using MinIO S3 gateway instead of drive caching" ) )
2022-02-07 13:39:57 -05:00
var cacheAPI CacheObjectLayer
cacheAPI , err = newServerCacheObjects ( GlobalContext , globalCacheConfig )
2022-08-04 19:10:08 -04:00
logger . FatalIf ( err , "Unable to initialize drive caching" )
2020-10-12 17:19:46 -04:00
2022-02-07 13:39:57 -05:00
setCacheObjectLayer ( cacheAPI )
}
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 )
} ( )
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"
}
globalMinioClient , err = minio . New ( globalLocalNodeName , & minio . Options {
Creds : credentials . NewStaticV4 ( globalActiveCred . AccessKey , globalActiveCred . SecretKey , "" ) ,
Secure : globalIsTLS ,
Transport : globalProxyTransport ,
Region : region ,
} )
logger . FatalIf ( err , "Unable to initialize MinIO client" )
2021-09-27 22:51:24 -04:00
if serverDebugLog {
logger . Info ( "== DEBUG Mode enabled ==" )
logger . Info ( "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.
if contains ( ks , strings . Split ( v , "=" ) [ 0 ] ) {
continue
}
2021-09-27 22:51:24 -04:00
logger . Info ( v )
}
logger . Info ( "======" )
}
2022-02-07 13:39:57 -05:00
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 ) {
2017-01-16 20:05:00 -05:00
// For FS only, directly use the disk.
2020-12-01 16:50:33 -05:00
if endpointServerPools . NEndpoints ( ) == 1 {
2017-01-16 20:05:00 -05:00
// Initialize new FS object layer.
2022-10-14 06:08:40 -04:00
newObject , err = NewFSObjectLayer ( ctx , endpointServerPools [ 0 ] . Endpoints [ 0 ] . Path )
2022-05-30 13:58:37 -04:00
if err == nil {
return newObject , nil
}
if err != nil && err != errFreshDisk {
return newObject , err
}
2017-01-16 20:05:00 -05:00
}
2020-12-01 16:50:33 -05:00
return newErasureServerPools ( ctx , endpointServerPools )
2017-01-16 20:05:00 -05:00
}