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-08-13 00:25:34 -04: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-12 18:27:10 -05: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-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"
2019-07-08 16:51:18 -04:00
"encoding/gob"
2018-05-08 22:04:36 -04:00
"fmt"
2017-07-12 19:33:21 -04:00
"net/http"
2017-03-06 22:35:26 -05:00
"os"
2017-07-12 19:33:21 -04:00
"os/signal"
2018-05-18 20:51:03 -04:00
"strings"
2017-07-12 19:33:21 -04: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-12 18:27:10 -05:00
"github.com/minio/cli"
2019-06-29 01:09:17 -04:00
"github.com/minio/dsync/v2"
2019-10-04 13:35:33 -04:00
"github.com/minio/minio/cmd/config"
2018-04-21 22:23:54 -04:00
xhttp "github.com/minio/minio/cmd/http"
2018-04-05 18:04:40 -04:00
"github.com/minio/minio/cmd/logger"
2019-10-23 01:59:13 -04:00
"github.com/minio/minio/pkg/auth"
2018-05-31 15:30:15 -04:00
"github.com/minio/minio/pkg/certs"
2019-10-04 13:35:33 -04: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-12 18:27:10 -05:00
)
2018-05-21 14:11:57 -04:00
func init ( ) {
2018-06-18 15:04:46 -04:00
logger . Init ( GOPATH , GOROOT )
2019-10-04 13:35:33 -04:00
logger . RegisterError ( config . FmtError )
2019-10-01 16:12:15 -04:00
gob . Register ( VerifyFileError ( "" ) )
2019-09-30 22:01:28 -04:00
gob . Register ( DeleteFileError ( "" ) )
2018-05-21 14:11:57 -04: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 {
Name : "address" ,
2018-12-18 19:08:11 -05:00
Value : ":" + globalMinioDefaultPort ,
2018-11-20 20:35:33 -05:00
Usage : "bind to a specific ADDRESS:PORT, ADDRESS can be an IP or hostname" ,
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 }
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
ENVIRONMENT VARIABLES :
2016-07-10 17:38:15 -04:00
ACCESS :
2018-02-01 22:43:30 -05:00
MINIO_ACCESS_KEY : Custom username or access key of minimum 3 characters in length .
2017-08-03 23:03:37 -04:00
MINIO_SECRET_KEY : Custom password or secret key of minimum 8 characters in length .
2016-12-10 03:42:22 -05:00
BROWSER :
MINIO_BROWSER : To disable web browser access , set this value to "off" .
2016-07-10 17:38:15 -04:00
2018-03-26 12:11:39 -04:00
DOMAIN :
2019-04-09 14:39:42 -04:00
MINIO_DOMAIN : To enable virtual - host - style requests , set this value to MinIO host domain name .
2018-03-26 12:11:39 -04:00
2018-03-27 19:44:45 -04:00
WORM :
MINIO_WORM : To turn on Write - Once - Read - Many in server , set this value to "on" .
2018-02-02 21:18:52 -05:00
BUCKET - DNS :
2019-04-09 14:39:42 -04:00
MINIO_DOMAIN : To enable bucket DNS requests , set this value to MinIO host domain name .
MINIO_PUBLIC_IPS : To enable bucket DNS requests , set this value to list of MinIO host public IP ( s ) delimited by "," .
2018-04-05 11:18:42 -04:00
MINIO_ETCD_ENDPOINTS : To enable bucket DNS requests , set this value to list of etcd endpoints delimited by "," .
2018-08-19 16:57:18 -04:00
2018-08-17 15:52:14 -04:00
KMS :
2019-10-23 01:59:13 -04:00
MINIO_KMS_VAULT_ENDPOINT : To enable Vault as KMS , set this value to Vault endpoint .
MINIO_KMS_VAULT_APPROLE_ID : To enable Vault as KMS , set this value to Vault AppRole ID .
MINIO_KMS_VAULT_APPROLE_SECRET : To enable Vault as KMS , set this value to Vault AppRole Secret ID .
MINIO_KMS_VAULT_KEY_NAME : To enable Vault as KMS , set this value to Vault encryption key - ring name .
2018-02-02 21:18:52 -05: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-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
2017-02-24 17:19:20 -05:00
2. Start minio server bound to a specific ADDRESS : PORT .
2019-05-15 04:32:44 -04:00
{ { . Prompt } } { { . HelpName } } -- address 192.168 .1 .101 : 9000 / home / shared
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
2018-03-26 12:11:39 -04:00
3. Start minio server and enable virtual - host - style requests .
2019-05-15 04:32:44 -04:00
{ { . Prompt } } { { . EnvVarSetCommand } } MINIO_DOMAIN { { . AssignmentOperator } } mydomain . com
{ { . Prompt } } { { . HelpName } } -- address mydomain . com : 9000 / mnt / export
2018-03-26 12:11:39 -04:00
2018-07-24 20:17:25 -04:00
4. Start erasure coded minio server on a node with 64 drives .
2019-05-15 04:32:44 -04:00
{ { . Prompt } } { { . HelpName } } / mnt / export { 1. . .64 }
2018-02-15 20:45:57 -05:00
2018-11-20 20:35:33 -05:00
5. Start distributed minio server on an 32 node setup with 32 drives each . Run following command on all the 32 nodes .
2019-05-15 04:32:44 -04: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-18 20:51:03 -04:00
2019-09-16 17:24:04 -04:00
6. Start minio server with KMS enabled .
2019-10-23 01:59:13 -04:00
{ { . Prompt } } { { . EnvVarSetCommand } } MINIO_KMS_VAULT_APPROLE_ID { { . AssignmentOperator } } 9 b56cc08 - 8258 - 45 d5 - 24 a3 - 679876769126
{ { . Prompt } } { { . EnvVarSetCommand } } MINIO_KMS_VAULT_APPROLE_SECRET { { . AssignmentOperator } } 4e30 c52f - 13e4 - a6f5 - 0763 - d50e8cb4321f
{ { . Prompt } } { { . EnvVarSetCommand } } MINIO_KMS_VAULT_ENDPOINT { { . AssignmentOperator } } https : //vault-endpoint-ip:8200
{ { . Prompt } } { { . EnvVarSetCommand } } MINIO_KMS_VAULT_KEY_NAME { { . AssignmentOperator } } my - minio - key
2019-05-15 04:32:44 -04:00
{ { . Prompt } } { { . HelpName } } / home / shared
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
` ,
}
2018-05-18 20:51:03 -04: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 02:39:09 -04:00
endpoints := env . Get ( config . EnvEndpoints , strings . Join ( ctx . Args ( ) , config . ValueSeparator ) )
return len ( endpoints ) != 0
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
2018-12-18 19:08:11 -05: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-01 22:19:44 -04:00
2017-04-11 18:44:27 -04:00
var setupType SetupType
2017-01-11 16:59:51 -05:00
var err error
2017-08-15 18:10:50 -04:00
2018-02-15 20:45:57 -05:00
if len ( ctx . Args ( ) ) > serverCommandLineArgsMax {
2019-10-04 13:35:33 -04:00
uErr := config . ErrInvalidErasureEndpoints ( nil ) . Msg ( fmt . Sprintf ( "Invalid total number of endpoints (%d) passed, supported upto 32 unique arguments" ,
2018-05-18 20:51:03 -04:00
len ( ctx . Args ( ) ) ) )
2018-05-08 22:04:36 -04:00
logger . FatalIf ( uErr , "Unable to validate passed endpoints" )
2018-02-15 20:45:57 -05:00
}
2019-10-08 01:47:56 -04:00
endpoints := strings . Fields ( env . Get ( config . EnvEndpoints , "" ) )
2018-05-18 20:51:03 -04:00
if len ( endpoints ) > 0 {
2018-12-18 19:08:11 -05:00
globalMinioAddr , globalEndpoints , setupType , globalXLSetCount , globalXLSetDriveCount , err = createServerEndpoints ( globalCLIContext . Addr , endpoints ... )
2018-05-18 20:51:03 -04:00
} else {
2018-12-18 19:08:11 -05:00
globalMinioAddr , globalEndpoints , setupType , globalXLSetCount , globalXLSetDriveCount , err = createServerEndpoints ( globalCLIContext . Addr , ctx . Args ( ) ... )
2018-05-18 20:51:03 -04:00
}
2018-05-08 22:04:36 -04:00
logger . FatalIf ( err , "Invalid command line arguments" )
2018-02-15 20:45:57 -05:00
2019-04-29 00:40:50 -04:00
logger . LogIf ( context . Background ( ) , checkEndpointsSubOptimal ( ctx , setupType , globalEndpoints ) )
2017-04-11 18:44:27 -04:00
globalMinioHost , globalMinioPort = mustSplitHostPort ( globalMinioAddr )
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.
// To avoid this error sutiation 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
2017-04-11 18:44:27 -04:00
globalIsXL = ( setupType == XLSetupType )
globalIsDistXL = ( setupType == DistXLSetupType )
if globalIsDistXL {
2017-01-23 03:32:55 -05:00
globalIsXL = true
}
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
}
2019-11-09 12:27:23 -05:00
func newAllSubsystems ( ) {
// Create new notification system and initialize notification targets
globalNotificationSys = NewNotificationSys ( globalEndpoints )
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 ( )
}
func initSafeModeInit ( buckets [ ] BucketInfo ) ( err error ) {
defer func ( ) {
if err != nil {
2019-11-11 15:01:21 -05:00
switch err . ( type ) {
case config . Err :
return
}
2019-11-09 12:27:23 -05:00
// Enable logger
logger . Disable = false
// 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 ( )
}
} ( )
newObject := newObjectLayerWithoutSafeModeFn ( )
// Calls New() for all sub-systems.
newAllSubsystems ( )
// Migrate all backend configs to encrypted backend, also handles rotation as well.
if err = handleEncryptedConfigBackend ( newObject , true ) ; err != nil {
return fmt . Errorf ( "Unable to handle encrypted backend for config, iam and policies: %v" , err )
2019-10-31 02:39:09 -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.
// Validate and initialize all subsystems.
if err = initAllSubsystems ( buckets , newObject ) ; err != nil {
return err
2019-10-31 02:39:09 -04:00
}
2019-11-09 12:27:23 -05:00
return nil
}
func initAllSubsystems ( buckets [ ] BucketInfo , newObject ObjectLayer ) ( err error ) {
// Initialize config system.
if err = globalConfigSys . Init ( newObject ) ; err != nil {
2019-11-11 15:01:21 -05:00
return fmt . Errorf ( "Unable to initialize config system: %w" , err )
2019-11-09 12:27:23 -05:00
}
if err = globalNotificationSys . AddNotificationTargetsFromConfig ( globalServerConfig ) ; err != nil {
2019-11-11 15:01:21 -05:00
return fmt . Errorf ( "Unable to initialize notification target(s) from config: %w" , err )
2019-11-09 12:27:23 -05:00
}
2019-11-12 06:16:25 -05: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 {
return fmt . Errorf ( "Unable to handle encrypted backend for iam and policies: %v" , err )
}
}
2019-11-09 12:27:23 -05:00
if err = globalIAMSys . Init ( newObject ) ; err != nil {
2019-11-11 15:01:21 -05:00
return fmt . Errorf ( "Unable to initialize IAM system: %w" , err )
2019-10-31 02:39:09 -04:00
}
// Initialize notification system.
if err = globalNotificationSys . Init ( buckets , newObject ) ; err != nil {
2019-11-11 15:01:21 -05:00
return fmt . Errorf ( "Unable to initialize notification system: %w" , err )
2019-10-31 02:39:09 -04:00
}
// Initialize policy system.
if err = globalPolicySys . Init ( buckets , newObject ) ; err != nil {
2019-11-11 15:01:21 -05:00
return fmt . Errorf ( "Unable to initialize policy system; %w" , err )
2019-10-31 02:39:09 -04:00
}
// Initialize lifecycle system.
if err = globalLifecycleSys . Init ( buckets , newObject ) ; err != nil {
2019-11-09 12:27:23 -05:00
return fmt . Errorf ( "Unable to initialize lifecycle system: %v" , err )
2019-10-31 02:39:09 -04:00
}
2019-11-09 12:27:23 -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 ) {
2018-05-18 20:51:03 -04:00
if ctx . Args ( ) . First ( ) == "help" || ! endpointsPresent ( ctx ) {
2017-03-30 14:21:19 -04:00
cli . ShowCommandHelpAndExit ( ctx , "server" , 1 )
}
2019-04-19 13:26:44 -04:00
signal . Notify ( globalOSSignalCh , os . Interrupt , syscall . SIGTERM )
2018-05-08 22:04:36 -04:00
// Disable logging until server initialization is complete, any
// error during initialization will be shown as a fatal message
logger . Disable = true
2018-11-02 14:53:45 -04:00
// Handle all server command args.
serverHandleCmdArgs ( ctx )
2019-11-04 12:30:59 -05:00
// Handle all server environment vars.
serverHandleEnvVars ( )
2018-10-27 20:51:00 -04:00
// Check and load TLS certificates.
2017-03-30 14:21:19 -04:00
var err error
2018-10-27 20:51:00 -04:00
globalPublicCerts , globalTLSCerts , globalIsSSL , err = getTLSConfig ( )
2018-05-08 22:04:36 -04:00
logger . FatalIf ( err , "Unable to load the TLS configuration" )
2017-03-30 14:21:19 -04:00
2018-10-27 20:51:00 -04:00
// Check and load Root CAs.
2019-10-08 01:47:56 -04:00
globalRootCAs , err = config . GetRootCAs ( globalCertsCADir . Get ( ) )
2018-10-27 20:51:00 -04:00
logger . FatalIf ( err , "Failed to read root CAs (%v)" , err )
2017-12-04 01:47:12 -05:00
// Is distributed setup, error out if no certificates are found for HTTPS endpoints.
2018-04-09 22:10:23 -04:00
if globalIsDistXL {
if globalEndpoints . IsHTTPS ( ) && ! globalIsSSL {
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
}
if ! globalEndpoints . IsHTTPS ( ) && globalIsSSL {
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
}
2018-12-18 19:08:11 -05:00
if ! globalCLIContext . Quiet {
2019-04-09 14:39:42 -04:00
// Check for new updates from dl.min.io.
2019-08-14 14:43:43 -04:00
checkUpdate ( getMinioMode ( ) )
2017-03-16 15:21:58 -04:00
}
2019-10-23 01:59:13 -04:00
if ! globalActiveCred . IsValid ( ) && globalIsDistXL {
logger . Fatal ( config . ErrEnvCredentialsMissingDistributed ( nil ) ,
"Unable to initialize the server in distributed mode" )
2018-08-15 00:41:47 -04:00
}
2017-03-30 14:21:19 -04:00
// Set system resources to maximum.
2018-04-05 18:04:40 -04:00
logger . LogIf ( context . Background ( ) , setMaxResources ( ) )
2017-03-30 14:21:19 -04:00
// Set nodes for dsync for distributed setup.
if globalIsDistXL {
2019-10-10 00:44:17 -04:00
clnts , myNode , err := newDsyncNodes ( globalEndpoints )
if err != nil {
logger . Fatal ( err , "Unable to initialize distributed locking on %s" , globalEndpoints )
}
globalDsync , err = dsync . New ( clnts , myNode )
2018-05-08 22:04:36 -04:00
if err != nil {
logger . Fatal ( err , "Unable to initialize distributed locking on %s" , globalEndpoints )
}
2017-03-30 14:21:19 -04:00
}
2016-10-05 15:48:07 -04:00
// Initialize name space lock.
2016-11-07 15:09:24 -05:00
initNSLock ( globalIsDistXL )
2016-10-05 15:48:07 -04:00
2019-06-09 01:14:07 -04:00
if globalIsXL {
// Init global heal state
globalAllHealState = initHealState ( )
2019-10-28 13:27:49 -04:00
globalBackgroundHealState = initHealState ( )
2019-06-09 01:14:07 -04:00
}
2018-01-22 17:54:55 -05:00
2019-10-08 01:47:56 -04:00
// Initialize globalConsoleSys system
2019-09-03 14:10:48 -04:00
globalConsoleSys = NewConsoleLogger ( context . Background ( ) , globalEndpoints )
2019-10-08 01:47:56 -04:00
2017-03-30 14:21:19 -04:00
// Configure server.
2017-07-12 19:33:21 -04:00
var handler http . Handler
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
}
2018-06-25 16:51:49 -04:00
globalHTTPServer = xhttp . NewServer ( [ ] string { globalMinioAddr } , criticalErrorHandler { handler } , getCert )
2017-01-11 16:59:51 -05:00
go func ( ) {
2017-07-12 19:33:21 -04:00
globalHTTPServerErrorCh <- globalHTTPServer . Start ( )
2017-01-11 16:59:51 -05:00
} ( )
2016-09-14 04:11:03 -04:00
2017-04-11 18:44:27 -04:00
newObject , err := newObjectLayer ( globalEndpoints )
2019-07-01 15:22:01 -04:00
logger . SetDeploymentID ( globalDeploymentID )
2017-07-12 19:33:21 -04:00
if err != nil {
2018-05-31 15:30:15 -04:00
// Stop watching for any certificate changes.
globalTLSCerts . Stop ( )
2018-05-08 22:04:36 -04:00
globalHTTPServer . Shutdown ( )
2019-11-09 12:27:23 -05:00
logger . Fatal ( err , "Unable to initialize backend" )
2018-04-05 11:18:42 -04:00
}
2018-09-05 11:25:55 -04:00
// Re-enable logging
logger . Disable = false
2019-11-09 12:27:23 -05:00
// Once endpoints are finalized, initialize the new object api in safe mode.
globalObjLayerMutex . Lock ( )
globalSafeMode = true
globalObjectAPI = newObject
globalObjLayerMutex . Unlock ( )
2019-11-01 18:53:16 -04:00
2019-11-09 12:27:23 -05:00
buckets , err := newObject . ListBuckets ( context . Background ( ) )
if err != nil {
logger . Fatal ( err , "Unable to list buckets" )
}
2018-08-15 00:41:47 -04:00
2019-11-09 12:27:23 -05:00
// Populate existing buckets to the etcd backend
if globalDNSConfig != nil {
initFederatorBackend ( buckets , newObject )
2019-11-01 18:53:16 -04:00
}
2019-11-09 12:27:23 -05:00
initSafeModeInit ( buckets )
2019-10-23 01:59:13 -04:00
2019-11-09 12:27:23 -05:00
if globalCacheConfig . Enabled {
msg := color . RedBold ( "Disk caching is disabled in 'server' mode, 'caching' is only supported in gateway deployments" )
logger . StartupMessage ( msg )
2019-10-23 01:59:13 -04:00
}
2019-08-09 13:02:41 -04:00
initDailyLifecycle ( )
2019-06-09 01:14:07 -04:00
if globalIsXL {
initBackgroundHealing ( )
2019-10-28 13:27:49 -04:00
initLocalDisksAutoHeal ( )
initGlobalHeal ( )
2019-06-09 01:14:07 -04:00
}
2019-11-09 12:27:23 -05:00
// Disable safe mode operation, after all initialization is over.
globalObjLayerMutex . Lock ( )
globalSafeMode = false
globalObjLayerMutex . Unlock ( )
2018-08-23 02:11:17 -04:00
2016-10-05 15:48:07 -04:00
// Prints the formatted startup message once object layer is initialized.
2018-12-14 02:37:46 -05:00
printStartupMessage ( getAPIEndpoints ( ) )
2016-10-05 15:48:07 -04:00
2019-10-23 01:59:13 -04: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 12:27:23 -05:00
logger . StartupMessage ( color . RedBold ( msg ) )
2019-10-23 01:59:13 -04:00
}
2017-02-10 02:26:44 -05:00
// Set uptime time after object layer has initialized.
2017-03-18 14:28:41 -04:00
globalBootTime = UTCNow ( )
2017-02-10 02:26:44 -05:00
2017-07-12 19:33:21 -04: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-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.
2017-04-11 18:44:27 -04:00
func newObjectLayer ( endpoints EndpointList ) ( newObject ObjectLayer , err error ) {
2017-01-16 20:05:00 -05:00
// For FS only, directly use the disk.
2018-02-15 20:45:57 -05:00
2017-04-11 18:44:27 -04:00
isFS := len ( endpoints ) == 1
2017-01-16 20:05:00 -05:00
if isFS {
// Initialize new FS object layer.
2018-02-20 15:21:12 -05:00
return NewFSObjectLayer ( endpoints [ 0 ] . Path )
2017-01-16 20:05:00 -05:00
}
2019-10-15 21:35:41 -04:00
format , err := waitForFormatXL ( endpoints [ 0 ] . IsLocal , endpoints , globalXLSetCount , globalXLSetDriveCount )
2017-01-16 20:05:00 -05:00
if err != nil {
return nil , err
}
2018-02-15 20:45:57 -05:00
return newXLSets ( endpoints , format , len ( format . XL . Sets ) , len ( format . XL . Sets [ 0 ] ) )
2017-01-16 20:05:00 -05:00
}