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"
2019-07-08 22:51:18 +02:00
"encoding/gob"
2019-11-14 02:38:05 +01:00
"errors"
2018-05-09 04:04:36 +02:00
"fmt"
2017-07-13 01:33:21 +02:00
"net/http"
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"
2017-07-13 01:33:21 +02:00
"syscall"
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"
2019-10-23 07:59:13 +02:00
"github.com/minio/minio/pkg/auth"
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"
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
)
2018-05-21 20:11:57 +02:00
func init ( ) {
2018-06-18 21:04:46 +02:00
logger . Init ( GOPATH , GOROOT )
2019-10-04 19:35:33 +02:00
logger . RegisterError ( config . FmtError )
2019-12-17 05:30:57 +01:00
// Initialize globalConsoleSys system
globalConsoleSys = NewConsoleLogger ( context . Background ( ) )
logger . AddTarget ( globalConsoleSys )
2020-01-15 03:45:17 +01:00
gob . Register ( StorageErr ( "" ) )
2018-05-21 20:11:57 +02: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" ,
2018-12-19 01:08:11 +01: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 } }
2018-02-03 03:18:52 +01:00
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
2019-12-17 05:30:57 +01:00
2. Start distributed minio server on an 32 node setup with 32 drives each , run following command on all the nodes
2019-05-15 10:32:44 +02:00
{ { . Prompt } } { { . EnvVarSetCommand } } MINIO_ACCESS_KEY { { . AssignmentOperator } } minio
{ { . Prompt } } { { . EnvVarSetCommand } } MINIO_SECRET_KEY { { . AssignmentOperator } } miniostorage
{ { . Prompt } } { { . HelpName } } http : //node{1...32}.example.com/mnt/export/{1...32}
2018-05-19 02:51:03 +02:00
2019-12-17 05:30:57 +01:00
3. Start distributed minio server in an expanded setup , run the following command on all the nodes
{ { . Prompt } } { { . EnvVarSetCommand } } MINIO_ACCESS_KEY { { . AssignmentOperator } } minio
{ { . Prompt } } { { . EnvVarSetCommand } } MINIO_SECRET_KEY { { . AssignmentOperator } } miniostorage
{ { . 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
` ,
}
2018-05-19 02:51:03 +02:00
// Checks if endpoints are either available through environment
// or command line, returns false if both fails.
func endpointsPresent ( ctx * cli . Context ) bool {
2019-10-31 07:39:09 +01:00
endpoints := env . Get ( config . EnvEndpoints , strings . Join ( ctx . Args ( ) , config . ValueSeparator ) )
return len ( endpoints ) != 0
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-04-12 00:44:27 +02:00
var setupType SetupType
2017-01-11 22:59:51 +01:00
var err error
2017-08-16 00:10:50 +02:00
2019-11-26 20:42:10 +01:00
globalMinioAddr = globalCLIContext . Addr
globalMinioHost , globalMinioPort = mustSplitHostPort ( globalMinioAddr )
2019-10-08 07:47:56 +02:00
endpoints := strings . Fields ( env . Get ( config . EnvEndpoints , "" ) )
2018-05-19 02:51:03 +02:00
if len ( endpoints ) > 0 {
2019-11-21 13:24:51 +01:00
globalEndpoints , globalXLSetDriveCount , setupType , err = createServerEndpoints ( globalCLIContext . Addr , endpoints ... )
2018-05-19 02:51:03 +02:00
} else {
2019-11-21 13:24:51 +01:00
globalEndpoints , globalXLSetDriveCount , setupType , err = createServerEndpoints ( globalCLIContext . Addr , ctx . Args ( ) ... )
2018-05-19 02:51:03 +02:00
}
2018-05-09 04:04:36 +02:00
logger . FatalIf ( err , "Invalid command line arguments" )
2018-02-16 02:45:57 +01:00
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
2017-04-12 00:44:27 +02:00
globalIsXL = ( setupType == XLSetupType )
globalIsDistXL = ( setupType == DistXLSetupType )
if globalIsDistXL {
2017-01-23 09:32:55 +01:00
globalIsXL = true
}
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
}
2019-11-09 18:27:23 +01:00
func newAllSubsystems ( ) {
// Create new notification system and initialize notification targets
globalNotificationSys = NewNotificationSys ( globalEndpoints )
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 ( )
}
2019-12-15 02:27:57 +01:00
func initSafeMode ( buckets [ ] BucketInfo ) ( err error ) {
2019-11-20 02:42:27 +01:00
newObject := newObjectLayerWithoutSafeModeFn ( )
// Construct path to config/transaction.lock for locking
transactionConfigPrefix := minioConfigPrefix + "/transaction.lock"
// 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.
objLock := newObject . NewNSLock ( context . Background ( ) , minioMetaBucket , transactionConfigPrefix )
if err = objLock . GetLock ( globalOperationTimeout ) ; err != nil {
return err
}
2019-11-20 11:09:30 +01:00
defer func ( objLock RWLocker ) {
2019-11-20 02:42:27 +01:00
objLock . Unlock ( )
2019-11-09 18:27:23 +01:00
if err != nil {
2019-11-14 02:38:05 +01:00
var cerr config . Err
if errors . As ( err , & cerr ) {
2019-11-11 21:01:21 +01:00
return
}
2019-12-05 00:32:37 +01:00
2019-11-09 18:27:23 +01:00
// Prints the formatted startup message in safe mode operation.
printStartupSafeModeMessage ( getAPIEndpoints ( ) , err )
// Initialization returned error reaching safe mode and
// not proceeding waiting for admin action.
handleSignals ( )
}
2019-11-20 11:09:30 +01:00
} ( objLock )
2019-11-09 18:27:23 +01:00
2019-12-15 02:27:57 +01:00
// Migrate all backend configs to encrypted backend configs, optionally
// handles rotating keys for encryption.
2019-11-09 18:27:23 +01:00
if err = handleEncryptedConfigBackend ( newObject , true ) ; err != nil {
2019-12-17 19:13:12 +01:00
return fmt . Errorf ( "Unable to handle encrypted backend for config, iam and policies: %w" , err )
2019-10-31 07:39:09 +01: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.
// Validate and initialize all subsystems.
if err = initAllSubsystems ( buckets , newObject ) ; err != nil {
return err
2019-10-31 07:39:09 +01:00
}
2019-11-09 18:27:23 +01:00
return nil
}
func initAllSubsystems ( buckets [ ] BucketInfo , newObject ObjectLayer ) ( err error ) {
// Initialize config system.
if err = globalConfigSys . Init ( newObject ) ; err != nil {
2019-11-11 21:01:21 +01:00
return fmt . Errorf ( "Unable to initialize config system: %w" , err )
2019-11-09 18:27:23 +01:00
}
2019-11-12 12:16:25 +01:00
if globalEtcdClient != nil {
// **** WARNING ****
// Migrating to encrypted backend on etcd should happen before initialization of
// IAM sub-systems, make sure that we do not move the above codeblock elsewhere.
if err = migrateIAMConfigsEtcdToEncrypted ( globalEtcdClient ) ; err != nil {
2019-12-02 18:28:01 +01:00
return fmt . Errorf ( "Unable to handle encrypted backend for iam and policies: %w" , err )
2019-11-12 12:16:25 +01:00
}
}
2019-11-09 18:27:23 +01:00
if err = globalIAMSys . Init ( newObject ) ; err != nil {
2019-11-11 21:01:21 +01:00
return fmt . Errorf ( "Unable to initialize IAM system: %w" , err )
2019-10-31 07:39:09 +01:00
}
// Initialize notification system.
if err = globalNotificationSys . Init ( buckets , newObject ) ; err != nil {
2019-11-11 21:01:21 +01:00
return fmt . Errorf ( "Unable to initialize notification system: %w" , err )
2019-10-31 07:39:09 +01:00
}
// Initialize policy system.
if err = globalPolicySys . Init ( buckets , newObject ) ; err != nil {
2019-11-11 21:01:21 +01:00
return fmt . Errorf ( "Unable to initialize policy system; %w" , err )
2019-10-31 07:39:09 +01:00
}
// Initialize lifecycle system.
if err = globalLifecycleSys . Init ( buckets , newObject ) ; err != nil {
2019-12-02 18:28:01 +01:00
return fmt . Errorf ( "Unable to initialize lifecycle system: %w" , err )
2019-10-31 07:39:09 +01: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 ) {
2018-05-19 02:51:03 +02:00
if ctx . Args ( ) . First ( ) == "help" || ! endpointsPresent ( ctx ) {
2017-03-30 20:21:19 +02:00
cli . ShowCommandHelpAndExit ( ctx , "server" , 1 )
}
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
globalConsoleSys = NewConsoleLogger ( context . Background ( ) )
2019-04-19 19:26:44 +02:00
signal . Notify ( globalOSSignalCh , os . Interrupt , syscall . SIGTERM )
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.
globalConsoleSys . SetNodeName ( globalEndpoints )
2019-12-05 00:32:37 +01:00
// Initialize all help
initHelp ( )
2018-10-28 02:51:00 +02:00
// Check and load TLS certificates.
2017-03-30 20:21:19 +02:00
var err error
2018-10-28 02:51:00 +02:00
globalPublicCerts , globalTLSCerts , globalIsSSL , err = getTLSConfig ( )
2018-05-09 04:04:36 +02:00
logger . FatalIf ( err , "Unable to load the TLS configuration" )
2017-03-30 20:21:19 +02:00
2018-10-28 02:51:00 +02:00
// Check and load Root CAs.
2019-10-08 07:47:56 +02:00
globalRootCAs , err = config . GetRootCAs ( globalCertsCADir . Get ( ) )
2018-10-28 02:51:00 +02:00
logger . FatalIf ( err , "Failed to read root CAs (%v)" , err )
2017-12-04 07:47:12 +01:00
// Is distributed setup, error out if no certificates are found for HTTPS endpoints.
2018-04-10 04:10:23 +02:00
if globalIsDistXL {
2019-11-20 02:42:27 +01:00
if globalEndpoints . HTTPS ( ) && ! globalIsSSL {
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
}
2019-11-20 02:42:27 +01:00
if ! globalEndpoints . HTTPS ( ) && globalIsSSL {
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
}
2018-12-19 01:08:11 +01:00
if ! globalCLIContext . Quiet {
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
}
2019-10-23 07:59:13 +02:00
if ! globalActiveCred . IsValid ( ) && globalIsDistXL {
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.
2019-12-05 00:32:37 +01:00
if err = setMaxResources ( ) ; err != nil {
logger . Info ( "Unable to set system resources to maximum %s" , err )
}
2017-03-30 20:21:19 +02:00
2019-06-09 07:14:07 +02:00
if globalIsXL {
// Init global heal state
globalAllHealState = initHealState ( )
2019-10-28 18:27:49 +01:00
globalBackgroundHealState = initHealState ( )
2019-06-09 07:14:07 +02:00
}
2018-01-22 23:54:55 +01:00
2017-03-30 20:21:19 +02:00
// Configure server.
2017-07-13 01:33:21 +02:00
var handler http . Handler
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
}
2019-12-03 00:54:26 +01:00
httpServer := xhttp . NewServer ( [ ] string { globalMinioAddr } , criticalErrorHandler { handler } , getCert )
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
2019-12-03 00:54:26 +01:00
globalObjLayerMutex . Lock ( )
globalHTTPServer = httpServer
globalObjLayerMutex . Unlock ( )
2019-11-22 21:45:13 +01:00
if globalIsDistXL && globalEndpoints . FirstLocal ( ) {
// Additionally in distributed setup validate
if err := verifyServerSystemConfig ( globalEndpoints ) ; err != nil {
logger . Fatal ( err , "Unable to initialize distributed setup" )
}
}
2017-04-12 00:44:27 +02:00
newObject , err := newObjectLayer ( globalEndpoints )
2019-07-01 21:22:01 +02:00
logger . SetDeploymentID ( globalDeploymentID )
2017-07-13 01:33:21 +02:00
if err != nil {
2018-05-31 21:30:15 +02:00
// Stop watching for any certificate changes.
globalTLSCerts . Stop ( )
2018-05-09 04:04:36 +02:00
globalHTTPServer . Shutdown ( )
2019-11-09 18:27:23 +01:00
logger . Fatal ( err , "Unable to initialize backend" )
2018-04-05 17:18:42 +02:00
}
2019-11-09 18:27:23 +01:00
// Once endpoints are finalized, initialize the new object api in safe mode.
globalObjLayerMutex . Lock ( )
globalSafeMode = true
globalObjectAPI = newObject
globalObjLayerMutex . Unlock ( )
2019-11-01 23:53:16 +01:00
2020-01-10 11:35:06 +01:00
// Calls New() and initializes all sub-systems.
newAllSubsystems ( )
// Enable healing to heal drives if possible
if globalIsXL {
initBackgroundHealing ( )
initLocalDisksAutoHeal ( )
initGlobalHeal ( )
}
2019-11-09 18:27:23 +01:00
buckets , err := newObject . ListBuckets ( context . Background ( ) )
if err != nil {
logger . Fatal ( err , "Unable to list buckets" )
}
2018-08-15 06:41:47 +02:00
2019-12-15 02:27:57 +01:00
logger . FatalIf ( initSafeMode ( buckets ) , "Unable to initialize server switching into safe-mode" )
2019-10-23 07:59:13 +02:00
2019-11-09 18:27:23 +01:00
if globalCacheConfig . Enabled {
2019-12-05 00:32:37 +01:00
// initialize the new disk cache objects.
var cacheAPI CacheObjectLayer
cacheAPI , err = newServerCacheObjects ( context . Background ( ) , globalCacheConfig )
logger . FatalIf ( err , "Unable to initialize disk caching" )
globalObjLayerMutex . Lock ( )
globalCacheObjectAPI = cacheAPI
globalObjLayerMutex . Unlock ( )
2019-10-23 07:59:13 +02:00
}
2019-12-17 22:50:07 +01:00
// Populate existing buckets to the etcd backend
if globalDNSConfig != nil {
initFederatorBackend ( buckets , newObject )
}
2019-12-12 15:02:37 +01:00
initDataUsageStats ( )
2019-08-09 19:02:41 +02:00
initDailyLifecycle ( )
2019-11-09 18:27:23 +01:00
// Disable safe mode operation, after all initialization is over.
globalObjLayerMutex . Lock ( )
globalSafeMode = false
globalObjLayerMutex . Unlock ( )
2018-08-23 08:11:17 +02:00
2016-10-05 21:48:07 +02:00
// Prints the formatted startup message once object layer is initialized.
2018-12-14 08:37:46 +01:00
printStartupMessage ( getAPIEndpoints ( ) )
2016-10-05 21:48:07 +02:00
2019-10-23 07:59:13 +02:00
if globalActiveCred . Equal ( auth . DefaultCredentials ) {
msg := fmt . Sprintf ( "Detected default credentials '%s', please change the credentials immediately using 'MINIO_ACCESS_KEY' and 'MINIO_SECRET_KEY'" , globalActiveCred )
2019-11-09 18:27:23 +01:00
logger . StartupMessage ( color . RedBold ( msg ) )
2019-10-23 07:59:13 +02:00
}
2017-02-10 08:26:44 +01:00
// Set uptime time after object layer has initialized.
2017-03-18 19:28:41 +01:00
globalBootTime = UTCNow ( )
2017-02-10 08:26:44 +01:00
2017-07-13 01:33:21 +02:00
handleSignals ( )
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.
2019-11-20 02:42:27 +01:00
func newObjectLayer ( endpointZones EndpointZones ) ( newObject ObjectLayer , err error ) {
2017-01-17 02:05:00 +01:00
// For FS only, directly use the disk.
2018-02-16 02:45:57 +01:00
2019-11-20 02:42:27 +01:00
if endpointZones . Nodes ( ) == 1 {
2017-01-17 02:05:00 +01:00
// Initialize new FS object layer.
2019-11-20 02:42:27 +01:00
return NewFSObjectLayer ( endpointZones [ 0 ] . Endpoints [ 0 ] . Path )
2017-01-17 02:05:00 +01:00
}
2019-11-21 13:24:51 +01:00
return newXLZones ( endpointZones )
2017-01-17 02:05:00 +01:00
}