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-13 00:27:10 +01:00
/ *
2019-08-13 06:25:34 +02:00
* MinIO Cloud Storage , ( C ) 2015 - 2019 MinIO , Inc .
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-13 00:27:10 +01:00
*
* Licensed under the Apache License , Version 2.0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
* You may obtain a copy of the License at
*
* http : //www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing , software
* distributed under the License is distributed on an "AS IS" BASIS ,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied .
* See the License for the specific language governing permissions and
* limitations under the License .
* /
2016-08-19 01:23:42 +02: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-13 00:27:10 +01:00
import (
2018-04-06 00:04:40 +02:00
"context"
2020-11-02 16:43:11 +01:00
"crypto/tls"
2019-11-14 02:38:05 +01:00
"errors"
2018-05-09 04:04:36 +02:00
"fmt"
2020-11-03 02:52:13 +01:00
"math/rand"
2020-03-19 00:19:29 +01:00
"net"
2017-03-07 04:35:26 +01:00
"os"
2017-07-13 01:33:21 +02:00
"os/signal"
2018-05-19 02:51:03 +02:00
"strings"
2020-12-13 20:57:08 +01:00
"sync"
2017-07-13 01:33:21 +02:00
"syscall"
2020-03-22 20:16:36 +01: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-13 00:27:10 +01:00
"github.com/minio/cli"
2019-10-04 19:35:33 +02:00
"github.com/minio/minio/cmd/config"
2018-04-22 04:23:54 +02:00
xhttp "github.com/minio/minio/cmd/http"
2018-04-06 00:04:40 +02:00
"github.com/minio/minio/cmd/logger"
2020-11-02 16:43:11 +01:00
"github.com/minio/minio/cmd/rest"
2019-10-23 07:59:13 +02:00
"github.com/minio/minio/pkg/auth"
2020-10-10 05:36:00 +02:00
"github.com/minio/minio/pkg/bucket/bandwidth"
2018-05-31 21:30:15 +02:00
"github.com/minio/minio/pkg/certs"
2019-10-04 19:35:33 +02:00
"github.com/minio/minio/pkg/color"
"github.com/minio/minio/pkg/env"
2021-01-03 20:27:57 +01:00
"github.com/minio/minio/pkg/madmin"
2021-02-05 22:04:26 +01:00
"github.com/minio/minio/pkg/sync/errgroup"
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-13 00:27:10 +01:00
)
2019-06-10 16:57:42 +02:00
// ServerFlags - server command specific flags
var ServerFlags = [ ] cli . Flag {
2016-09-02 00:12:49 +02:00
cli . StringFlag {
Name : "address" ,
2020-05-17 17:46:23 +02:00
Value : ":" + GlobalMinioDefaultPort ,
2018-11-21 02:35:33 +01:00
Usage : "bind to a specific ADDRESS:PORT, ADDRESS can be an IP or hostname" ,
2016-09-02 00:12:49 +02:00
} ,
}
var serverCmd = cli . Command {
Name : "server" ,
2018-11-21 02:35:33 +01:00
Usage : "start object storage server" ,
2019-06-10 16:57:42 +02: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-02 04:19:44 +02: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-13 00:27:10 +01:00
CustomHelpTemplate : ` NAME :
2017-03-16 20:21:58 +01: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-13 00:27:10 +01:00
USAGE :
2018-02-16 02:45:57 +01:00
{ { . HelpName } } { { if . VisibleFlags } } [ FLAGS ] { { end } } DIR1 [ DIR2 . . ]
{ { . HelpName } } { { if . VisibleFlags } } [ FLAGS ] { { end } } DIR { 1. . .64 }
2019-12-17 05:30:57 +01:00
{ { . HelpName } } { { if . VisibleFlags } } [ FLAGS ] { { end } } DIR { 1. . .64 } DIR { 65. . .128 }
2018-02-16 02:45:57 +01: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-16 02:45:08 +01:00
{ { if . VisibleFlags } }
2016-08-29 05:04:47 +02:00
FLAGS :
2017-02-15 11:25:38 +01:00
{ { range . VisibleFlags } } { { . } }
2017-02-16 02:45:08 +01: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-13 00:27:10 +01:00
EXAMPLES :
2016-11-10 08:37:12 +01:00
1. Start minio server on "/home/shared" directory .
2019-05-15 10:32:44 +02: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-02 04:19:44 +02:00
2020-04-22 08:59:13 +02: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 19:22:57 +01:00
{ { . Prompt } } { { . EnvVarSetCommand } } MINIO_ROOT_USER { { . AssignmentOperator } } minio
{ { . Prompt } } { { . EnvVarSetCommand } } MINIO_ROOT_PASSWORD { { . AssignmentOperator } } miniostorage
2020-03-27 05:07:39 +01:00
{ { . Prompt } } { { . HelpName } } http : //node{1...32}.example.com/mnt/export{1...32}
2018-05-19 02:51:03 +02:00
2020-04-22 08:59:13 +02:00
4. Start distributed minio server in an expanded setup , run the following command on all the nodes
2021-01-05 19:22:57 +01:00
{ { . Prompt } } { { . EnvVarSetCommand } } MINIO_ROOT_USER { { . AssignmentOperator } } minio
{ { . Prompt } } { { . EnvVarSetCommand } } MINIO_ROOT_PASSWORD { { . AssignmentOperator } } miniostorage
2020-03-27 05:07:39 +01: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-13 00:27:10 +01:00
` ,
}
2020-08-07 03:03:16 +02:00
func serverCmdArgs ( ctx * cli . Context ) [ ] string {
v := env . Get ( config . EnvArgs , "" )
if v == "" {
// Fall back to older ENV MINIO_ENDPOINTS
v = env . Get ( config . EnvEndpoints , "" )
}
if v == "" {
2020-10-14 22:51:51 +02:00
if ! ctx . Args ( ) . Present ( ) || ctx . Args ( ) . First ( ) == "help" {
cli . ShowCommandHelpAndExit ( ctx , ctx . Command . Name , 1 )
}
2020-08-07 03:03:16 +02:00
return ctx . Args ( )
}
return strings . Fields ( v )
2018-05-19 02:51:03 +02:00
}
2017-03-30 20:21:19 +02:00
func serverHandleCmdArgs ( ctx * cli . Context ) {
2017-06-10 04:50:51 +02:00
// Handle common command args.
handleCommonCmdArgs ( ctx )
2017-03-29 17:55:33 +02:00
2018-12-19 01:08:11 +01:00
logger . FatalIf ( CheckLocalServerAddr ( globalCLIContext . Addr ) , "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-02 04:19:44 +02:00
2017-01-11 22:59:51 +01:00
var err error
2020-08-07 03:03:16 +02:00
var setupType SetupType
// Check and load TLS certificates.
2020-12-22 06:42:38 +01:00
globalPublicCerts , globalTLSCerts , globalIsTLS , err = getTLSConfig ( )
2020-08-07 03:03:16 +02:00
logger . FatalIf ( err , "Unable to load the TLS configuration" )
// Check and load Root CAs.
2020-08-11 17:29:50 +02:00
globalRootCAs , err = certs . GetRootCAs ( globalCertsCADir . Get ( ) )
2020-08-07 03:03:16 +02:00
logger . FatalIf ( err , "Failed to read root CAs (%v)" , err )
2020-08-13 18:46:50 +02:00
// Add the global public crts as part of global root CAs
for _ , publicCrt := range globalPublicCerts {
globalRootCAs . AddCert ( publicCrt )
}
2020-08-07 03:03:16 +02:00
// Register root CAs for remote ENVs
env . RegisterGlobalCAs ( globalRootCAs )
2017-08-16 00:10:50 +02:00
2019-11-26 20:42:10 +01:00
globalMinioAddr = globalCLIContext . Addr
globalMinioHost , globalMinioPort = mustSplitHostPort ( globalMinioAddr )
2020-08-07 03:03:16 +02:00
globalEndpoints , setupType , err = createServerEndpoints ( globalCLIContext . Addr , serverCmdArgs ( ctx ) ... )
2021-03-26 19:37:58 +01:00
logger . FatalIf ( err , "Invalid command line arguments" )
globalLocalNodeName = GetLocalPeer ( globalEndpoints , globalMinioHost , globalMinioPort )
2021-01-08 04:16:18 +01:00
globalRemoteEndpoints = make ( map [ string ] Endpoint )
for _ , z := range globalEndpoints {
for _ , ep := range z . Endpoints {
if ep . IsLocal {
2021-03-26 19:37:58 +01:00
globalRemoteEndpoints [ globalLocalNodeName ] = ep
2021-01-25 19:01:27 +01:00
} else {
globalRemoteEndpoints [ ep . Host ] = ep
2021-01-08 04:16:18 +01:00
}
}
}
2018-02-16 02:45:57 +01:00
2020-12-22 06:42:38 +01:00
// allow transport to be HTTP/1.1 for proxying.
globalProxyTransport = newCustomHTTPProxyTransport ( & tls . Config {
RootCAs : globalRootCAs ,
} , rest . DefaultTimeout ) ( )
2020-11-02 16:43:11 +01:00
globalProxyEndpoints = GetProxyEndpoints ( globalEndpoints )
globalInternodeTransport = newInternodeHTTPTransport ( & tls . Config {
RootCAs : globalRootCAs ,
} , rest . DefaultTimeout ) ( )
2018-05-09 04:04:36 +02: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-04 02:43:16 +01:00
// To avoid this error situation we check for port availability.
2019-06-25 00:02:40 +02:00
logger . FatalIf ( checkPortAvailability ( globalMinioHost , globalMinioPort ) , "Unable to start the server" )
2016-08-31 04:22:27 +02:00
2020-06-13 05:04:01 +02:00
globalIsErasure = ( setupType == ErasureSetupType )
globalIsDistErasure = ( setupType == DistErasureSetupType )
if globalIsDistErasure {
globalIsErasure = true
2017-01-23 09:32:55 +01:00
}
2017-03-30 20:21:19 +02:00
}
func serverHandleEnvVars ( ) {
2017-06-10 04:50:51 +02:00
// Handle common environment variables.
handleCommonEnvVars ( )
2017-03-30 20:21:19 +02:00
}
2020-12-13 20:57:08 +01:00
var globalHealStateLK sync . RWMutex
2019-11-09 18:27:23 +01:00
func newAllSubsystems ( ) {
2020-12-13 20:57:08 +01:00
if globalIsErasure {
globalHealStateLK . Lock ( )
// New global heal state
globalAllHealState = newHealState ( true )
globalBackgroundHealState = newHealState ( false )
globalHealStateLK . Unlock ( )
}
2019-11-09 18:27:23 +01:00
// Create new notification system and initialize notification targets
globalNotificationSys = NewNotificationSys ( globalEndpoints )
2020-05-19 22:53:54 +02:00
// Create new bucket metadata system.
2021-01-05 19:45:26 +01:00
if globalBucketMetadataSys == nil {
globalBucketMetadataSys = NewBucketMetadataSys ( )
} else {
// Reinitialize safely when testing.
globalBucketMetadataSys . Reset ( )
}
2020-05-19 22:53:54 +02:00
2020-10-10 05:36:00 +02:00
// Create the bucket bandwidth monitor
globalBucketMonitor = bandwidth . NewMonitor ( GlobalServiceDoneCh )
2019-10-31 07:39:09 +01:00
// Create a new config system.
globalConfigSys = NewConfigSys ( )
// Create new IAM system.
globalIAMSys = NewIAMSys ( )
2019-11-09 18:27:23 +01:00
// Create new policy system.
globalPolicySys = NewPolicySys ( )
// Create new lifecycle system.
globalLifecycleSys = NewLifecycleSys ( )
2020-02-05 10:42:34 +01:00
// Create new bucket encryption subsystem
globalBucketSSEConfigSys = NewBucketSSEConfigSys ( )
2020-05-04 18:42:58 +02:00
2020-05-08 22:44:44 +02:00
// Create new bucket object lock subsystem
globalBucketObjectLockSys = NewBucketObjectLockSys ( )
2020-05-04 18:42:58 +02:00
// Create new bucket quota subsystem
globalBucketQuotaSys = NewBucketQuotaSys ( )
2020-06-13 05:04:01 +02:00
// Create new bucket versioning subsystem
2021-01-05 19:45:26 +01:00
if globalBucketVersioningSys == nil {
globalBucketVersioningSys = NewBucketVersioningSys ( )
} else {
globalBucketVersioningSys . Reset ( )
}
2020-07-22 02:49:56 +02:00
// Create new bucket replication subsytem
2020-07-31 04:55:22 +02:00
globalBucketTargetSys = NewBucketTargetSys ( )
2019-11-09 18:27:23 +01:00
}
2021-03-18 22:09:55 +01: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 ) ||
errors . As ( err , & rquorum ) ||
errors . As ( err , & wquorum ) ||
isErrBucketNotFound ( err ) ||
errors . Is ( err , os . ErrDeadlineExceeded )
}
2020-10-12 23:19:46 +02:00
func initServer ( ctx context . Context , newObject ObjectLayer ) error {
2020-10-28 08:09:15 +01:00
// Once the config is fully loaded, initialize the new object layer.
2021-01-03 20:27:57 +01:00
setObjectLayer ( newObject )
2020-10-28 08:09:15 +01:00
2019-11-20 02:42:27 +01: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.
2020-11-04 17:25:42 +01:00
txnLk := newObject . NewNSLock ( minioMetaBucket , minioConfigPrefix + "/transaction.lock" )
2020-08-15 03:17:14 +02:00
2019-11-09 18:27:23 +01: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-02 02:07:43 +01:00
2020-11-03 02:52:13 +01:00
r := rand . New ( rand . NewSource ( time . Now ( ) . UnixNano ( ) ) )
lockTimeout := newDynamicTimeout ( 5 * time . Second , 3 * time . Second )
2020-10-12 23:19:46 +02:00
var err error
2020-11-03 02:52:13 +01:00
for {
select {
case <- ctx . Done ( ) :
// Retry was canceled successfully.
return fmt . Errorf ( "Initializing sub-systems stopped gracefully %w" , ctx . Err ( ) )
default :
}
2020-05-05 05:04:06 +02:00
// let one of the server acquire the lock, if not let them timeout.
// which shall be retried again by this loop.
2021-03-04 03:36:43 +01:00
if _ , err = txnLk . GetLock ( ctx , lockTimeout ) ; err != nil {
2020-05-06 23:25:05 +02:00
logger . Info ( "Waiting for all MinIO sub-systems to be initialized.. trying to acquire lock" )
2020-11-03 02:52:13 +01:00
time . Sleep ( time . Duration ( r . Float64 ( ) * float64 ( 5 * time . Second ) ) )
2020-05-06 23:25:05 +02:00
continue
}
2020-05-08 01:12:16 +02:00
// These messages only meant primarily for distributed setup, so only log during distributed setup.
2020-06-13 05:04:01 +02:00
if globalIsDistErasure {
2020-05-08 01:12:16 +02:00
logger . Info ( "Waiting for all MinIO sub-systems to be initialized.. lock acquired" )
}
2020-05-06 23:25:05 +02: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 12:29:28 +02:00
if err = handleEncryptedConfigBackend ( newObject ) ; err == nil {
2020-05-06 23:25:05 +02:00
// Upon success migrating the config, initialize all sub-systems
// if all sub-systems initialized successfully return right away
2020-10-09 18:59:52 +02:00
if err = initAllSubsystems ( ctx , newObject ) ; err == nil {
txnLk . Unlock ( )
2020-05-06 23:25:05 +02:00
// All successful return.
2020-06-13 05:04:01 +02:00
if globalIsDistErasure {
2020-05-08 01:12:16 +02:00
// These messages only meant primarily for distributed setup, so only log during distributed setup.
logger . Info ( "All MinIO sub-systems initialized successfully" )
}
2020-05-06 23:25:05 +02:00
return nil
2020-02-02 02:07:43 +01:00
}
2020-05-05 05:04:06 +02:00
}
2020-10-09 18:59:52 +02:00
txnLk . Unlock ( ) // Unlock the transaction lock and allow other nodes to acquire the lock if possible.
2021-03-18 22:09:55 +01:00
if configRetriableErrors ( err ) {
2020-05-06 23:25:05 +02:00
logger . Info ( "Waiting for all MinIO sub-systems to be initialized.. possible cause (%v)" , err )
2020-11-03 02:52:13 +01:00
time . Sleep ( time . Duration ( r . Float64 ( ) * float64 ( 5 * time . Second ) ) )
2020-05-05 05:04:06 +02:00
continue
2020-02-02 02:07:43 +01:00
}
2020-05-05 05:04:06 +02:00
// Any other unhandled return right here.
return fmt . Errorf ( "Unable to initialize sub-systems: %w" , err )
}
2019-11-09 18:27:23 +01:00
}
2020-06-10 04:19:03 +02:00
func initAllSubsystems ( ctx context . Context , newObject ObjectLayer ) ( err error ) {
2020-05-06 23:25:05 +02: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.
2020-09-24 18:53:38 +02:00
// List buckets to heal, and be re-used for loading configs.
2020-12-13 20:57:08 +01:00
2020-12-14 21:07:07 +01:00
buckets , err := newObject . ListBuckets ( ctx )
2020-12-13 20:57:08 +01:00
if err != nil {
return fmt . Errorf ( "Unable to list buckets to heal: %w" , err )
2020-05-05 05:04:06 +02:00
}
2021-01-03 20:27:57 +01:00
if globalIsErasure {
2021-01-04 01:27:34 +01:00
if len ( buckets ) > 0 {
if len ( buckets ) == 1 {
logger . Info ( fmt . Sprintf ( "Verifying if %d bucket is consistent across drives..." , len ( buckets ) ) )
} else {
logger . Info ( fmt . Sprintf ( "Verifying if %d buckets are consistent across drives..." , len ( buckets ) ) )
}
}
2021-02-05 22:04:26 +01:00
// Limit to no more than 50 concurrent buckets.
g := errgroup . WithNErrs ( len ( buckets ) ) . WithConcurrency ( 50 )
ctx , cancel := g . WithCancelOnError ( ctx )
defer cancel ( )
for index := range buckets {
index := index
g . Go ( func ( ) error {
2021-02-23 18:23:11 +01:00
_ , berr := newObject . HealBucket ( ctx , buckets [ index ] . Name , madmin . HealOpts { Recreate : true } )
return berr
2021-02-05 22:04:26 +01:00
} , index )
}
if err := g . WaitErr ( ) ; err != nil {
2021-02-23 18:23:11 +01:00
return fmt . Errorf ( "Unable to list buckets to heal: %w" , err )
2021-01-03 20:27:57 +01:00
}
}
2019-11-09 18:27:23 +01:00
// Initialize config system.
if err = globalConfigSys . Init ( newObject ) ; err != nil {
2021-03-18 22:09:55 +01:00
if configRetriableErrors ( err ) {
2020-10-09 18:59:52 +02:00
return fmt . Errorf ( "Unable to initialize config system: %w" , err )
}
// Any other config errors we simply print a message and proceed forward.
2020-10-19 18:54:40 +02:00
logger . LogIf ( ctx , fmt . Errorf ( "Unable to initialize config, some features may be missing %w" , err ) )
2019-11-09 18:27:23 +01:00
}
2020-05-05 05:04:06 +02:00
2020-06-10 04:19:03 +02:00
// Populate existing buckets to the etcd backend
if globalDNSConfig != nil {
// Background this operation.
go initFederatorBackend ( buckets , newObject )
2019-10-31 07:39:09 +01:00
}
2020-10-09 18:59:52 +02:00
// Initialize bucket metadata sub-system.
globalBucketMetadataSys . Init ( ctx , buckets , newObject )
2019-10-31 07:39:09 +01:00
// Initialize notification system.
2020-10-09 18:59:52 +02:00
globalNotificationSys . Init ( ctx , buckets , newObject )
2020-05-04 18:42:58 +02:00
2020-07-31 04:55:22 +02:00
// Initialize bucket targets sub-system.
2020-10-09 18:59:52 +02:00
globalBucketTargetSys . Init ( ctx , buckets , newObject )
2020-07-31 04:55:22 +02:00
2019-11-09 18:27:23 +01:00
return nil
2019-10-31 07:39:09 +01:00
}
2017-03-30 20:21:19 +02:00
// serverMain handler called for 'minio server' command.
func serverMain ( ctx * cli . Context ) {
2020-10-16 23:49:05 +02:00
defer globalDNSCache . Stop ( )
2020-10-12 23:19:46 +02:00
signal . Notify ( globalOSSignalCh , os . Interrupt , syscall . SIGTERM , syscall . SIGQUIT )
2020-09-08 18:10:55 +02:00
go handleSignals ( )
2020-01-22 00:49:25 +01:00
setDefaultProfilerRates ( )
2017-03-30 20:21:19 +02:00
2019-12-17 05:30:57 +01:00
// Initialize globalConsoleSys system
2020-04-09 18:30:02 +02:00
globalConsoleSys = NewConsoleLogger ( GlobalContext )
2020-09-16 03:02:54 +02:00
logger . AddTarget ( globalConsoleSys )
2019-12-17 05:30:57 +01:00
2021-03-31 18:11:37 +02:00
// Perform any self-tests
erasureSelfTest ( )
compressSelfTest ( )
2018-11-02 19:53:45 +01:00
// Handle all server command args.
serverHandleCmdArgs ( ctx )
2019-11-04 18:30:59 +01:00
// Handle all server environment vars.
serverHandleEnvVars ( )
2019-12-17 05:30:57 +01:00
// Set node name, only set for distributed setup.
2021-03-26 19:37:58 +01:00
globalConsoleSys . SetNodeName ( globalLocalNodeName )
2019-12-17 05:30:57 +01:00
2019-12-05 00:32:37 +01:00
// Initialize all help
initHelp ( )
2020-10-19 18:54:40 +02:00
// Initialize all sub-systems
newAllSubsystems ( )
2020-04-27 15:25:05 +02:00
globalMinioEndpoint = func ( ) string {
host := globalMinioHost
if host == "" {
host = sortIPs ( localIP4 . ToSlice ( ) ) [ 0 ]
}
2020-12-22 06:42:38 +01:00
return fmt . Sprintf ( "%s://%s" , getURLScheme ( globalIsTLS ) , net . JoinHostPort ( host , globalMinioPort ) )
2020-04-27 15:25:05 +02:00
} ( )
2017-12-04 07:47:12 +01:00
// Is distributed setup, error out if no certificates are found for HTTPS endpoints.
2020-06-13 05:04:01 +02:00
if globalIsDistErasure {
2020-12-22 06:42:38 +01:00
if globalEndpoints . HTTPS ( ) && ! globalIsTLS {
2019-10-04 19:35:33 +02:00
logger . Fatal ( config . ErrNoCertsAndHTTPSEndpoints ( nil ) , "Unable to start the server" )
2018-04-10 04:10:23 +02:00
}
2020-12-22 06:42:38 +01:00
if ! globalEndpoints . HTTPS ( ) && globalIsTLS {
2019-10-04 19:35:33 +02:00
logger . Fatal ( config . ErrCertsAndHTTPEndpoints ( nil ) , "Unable to start the server" )
2018-04-10 04:10:23 +02:00
}
2017-12-04 07:47:12 +01:00
}
2020-11-15 22:34:12 +01:00
if ! globalCLIContext . Quiet && ! globalInplaceUpdateDisabled {
2019-04-09 20:39:42 +02:00
// Check for new updates from dl.min.io.
2019-08-14 20:43:43 +02:00
checkUpdate ( getMinioMode ( ) )
2017-03-16 20:21:58 +01:00
}
2020-06-13 05:04:01 +02:00
if ! globalActiveCred . IsValid ( ) && globalIsDistErasure {
2019-10-23 07:59:13 +02:00
logger . Fatal ( config . ErrEnvCredentialsMissingDistributed ( nil ) ,
"Unable to initialize the server in distributed mode" )
2018-08-15 06:41:47 +02:00
}
2017-03-30 20:21:19 +02:00
// Set system resources to maximum.
2020-06-03 22:18:54 +02:00
setMaxResources ( )
2017-03-30 20:21:19 +02:00
// Configure server.
2020-05-25 09:17:52 +02:00
handler , err := configureServerHandler ( globalEndpoints )
2018-05-09 04:04:36 +02:00
if err != nil {
2019-10-04 19:35:33 +02:00
logger . Fatal ( config . ErrUnexpectedError ( err ) , "Unable to configure one of server's RPC services" )
2018-05-09 04:04:36 +02:00
}
2017-01-17 02:05:00 +01:00
2018-05-31 21:30:15 +02:00
var getCert certs . GetCertificateFunc
if globalTLSCerts != nil {
getCert = globalTLSCerts . GetCertificate
}
2020-07-12 19:56:57 +02:00
httpServer := xhttp . NewServer ( [ ] string { globalMinioAddr } , criticalErrorHandler { corsHandler ( handler ) } , getCert )
2020-03-19 00:19:29 +01:00
httpServer . BaseContext = func ( listener net . Listener ) context . Context {
return GlobalContext
}
2017-01-11 22:59:51 +01:00
go func ( ) {
2019-12-03 00:54:26 +01:00
globalHTTPServerErrorCh <- httpServer . Start ( )
2017-01-11 22:59:51 +01:00
} ( )
2016-09-14 10:11:03 +02:00
2021-01-03 20:27:57 +01:00
setHTTPServer ( httpServer )
2019-12-03 00:54:26 +01:00
2020-06-13 05:04:01 +02:00
if globalIsDistErasure && globalEndpoints . FirstLocal ( ) {
2020-04-02 06:40:03 +02:00
for {
// Additionally in distributed setup, validate the setup and configuration.
2020-07-10 18:26:21 +02:00
err := verifyServerSystemConfig ( GlobalContext , globalEndpoints )
2020-09-08 18:10:55 +02:00
if err == nil || errors . Is ( err , context . Canceled ) {
2020-04-02 06:40:03 +02:00
break
}
2020-07-10 18:26:21 +02:00
logger . LogIf ( GlobalContext , err , "Unable to initialize distributed setup, retrying.. after 5 seconds" )
2020-04-02 06:40:03 +02:00
select {
case <- GlobalContext . Done ( ) :
return
2020-09-08 18:10:55 +02:00
case <- time . After ( 500 * time . Millisecond ) :
2020-04-02 06:40:03 +02:00
}
2019-11-22 21:45:13 +01:00
}
}
2020-04-15 02:52:38 +02:00
newObject , err := newObjectLayer ( GlobalContext , globalEndpoints )
2017-07-13 01:33:21 +02:00
if err != nil {
2020-09-29 04:39:32 +02:00
logFatalErrs ( err , Endpoint { } , true )
2018-04-05 17:18:42 +02:00
}
2020-09-29 04:39:32 +02:00
logger . SetDeploymentID ( globalDeploymentID )
2020-10-12 23:19:46 +02:00
// Enable background operations for erasure coding
if globalIsErasure {
initAutoHeal ( GlobalContext , newObject )
2020-11-12 21:12:09 +01:00
initBackgroundTransition ( GlobalContext , newObject )
2021-02-01 18:52:11 +01:00
initBackgroundExpiry ( GlobalContext , newObject )
2020-10-12 23:19:46 +02:00
}
2021-02-17 21:04:11 +01:00
initDataScanner ( GlobalContext , newObject )
2020-12-13 20:57:08 +01:00
2020-10-12 23:19:46 +02:00
if err = initServer ( 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" )
}
}
2021-02-02 12:15:06 +01:00
if globalIsErasure { // to be done after config init
initBackgroundReplication ( GlobalContext , newObject )
}
2020-11-03 02:52:13 +01:00
if globalCacheConfig . Enabled {
// initialize the new disk cache objects.
var cacheAPI CacheObjectLayer
cacheAPI , err = newServerCacheObjects ( GlobalContext , globalCacheConfig )
logger . FatalIf ( err , "Unable to initialize disk caching" )
2021-01-03 20:27:57 +01:00
setCacheObjectLayer ( cacheAPI )
2020-11-03 02:52:13 +01:00
}
2020-10-12 23:19:46 +02:00
// Initialize users credentials and policies in background right after config has initialized.
go globalIAMSys . Init ( GlobalContext , newObject )
// Prints the formatted startup message, if err is not nil then it prints additional information as well.
printStartupMessage ( getAPIEndpoints ( ) , err )
if globalActiveCred . Equal ( auth . DefaultCredentials ) {
2021-01-05 19:22:57 +01:00
msg := fmt . Sprintf ( "Detected default credentials '%s', please change the credentials immediately using 'MINIO_ROOT_USER' and 'MINIO_ROOT_PASSWORD'" , globalActiveCred )
2020-10-12 23:19:46 +02:00
logger . StartupMessage ( color . RedBold ( msg ) )
}
2019-10-23 07:59:13 +02:00
2020-10-12 23:19:46 +02: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-13 00:27:10 +01:00
}
2017-01-17 02:05:00 +01:00
// Initialize object layer with the supplied disks, objectLayer is nil upon any error.
2020-12-01 22:50:33 +01:00
func newObjectLayer ( ctx context . Context , endpointServerPools EndpointServerPools ) ( newObject ObjectLayer , err error ) {
2017-01-17 02:05:00 +01:00
// For FS only, directly use the disk.
2020-12-01 22:50:33 +01:00
if endpointServerPools . NEndpoints ( ) == 1 {
2017-01-17 02:05:00 +01:00
// Initialize new FS object layer.
2020-12-01 22:50:33 +01:00
return NewFSObjectLayer ( endpointServerPools [ 0 ] . Endpoints [ 0 ] . Path )
2017-01-17 02:05:00 +01:00
}
2020-12-01 22:50:33 +01:00
return newErasureServerPools ( ctx , endpointServerPools )
2017-01-17 02:05:00 +01:00
}