mirror of
https://github.com/gluster/glusterd2.git
synced 2026-02-05 12:45:38 +01:00
Default configuration for glusterd2 when run using systemctl
systemctl enable glusterd2
systemctl start glusterd2
systemctl status glusterd2
Limited config file extension to `TOML` to avoid confusions with
multiple config extensions.
Signed-off-by: Aravinda VK <avishwan@redhat.com>
This commit is contained in:
@@ -51,15 +51,15 @@ $ mkdir -p /var/lib/gd2
|
||||
```
|
||||
|
||||
**Create a config file:** This is optional but if your VM/machine has multiple network interfaces, it is recommended to create a config file. The config file location can be passed to Glusterd2 using the `--config` option.
|
||||
Glusterd2 will also pick up conf files named `glusterd.{yaml|json|toml}` if available in `/etc/glusterd2/` or the current directory.
|
||||
Glusterd2 will also pick up conf file named `glusterd2.toml` if available in `/etc/glusterd2/` or the current directory.
|
||||
|
||||
```yaml
|
||||
$ cat conf.yaml
|
||||
workdir: "/var/lib/gd2"
|
||||
peeraddress: "192.168.56.101:24008"
|
||||
clientaddress: "192.168.56.101:24007"
|
||||
etcdcurls: "http://192.168.56.101:2379"
|
||||
etcdpurls: "http://192.168.56.101:2380"
|
||||
```toml
|
||||
$ cat conf.toml
|
||||
workdir = "/var/lib/gd2"
|
||||
peeraddress = "192.168.56.101:24008"
|
||||
clientaddress = "192.168.56.101:24007"
|
||||
etcdcurls = "http://192.168.56.101:2379"
|
||||
etcdpurls = "http://192.168.56.101:2380"
|
||||
```
|
||||
|
||||
Replace the IP address accordingly on each node.
|
||||
@@ -67,13 +67,13 @@ Replace the IP address accordingly on each node.
|
||||
**Start glusterd2 process:** Glusterd2 is not a daemon and currently can run only in the foreground.
|
||||
|
||||
```sh
|
||||
# ./glusterd2 --config conf.yaml
|
||||
# ./glusterd2 --config conf.toml
|
||||
```
|
||||
|
||||
You will see an output similar to the following:
|
||||
```log
|
||||
INFO[2017-08-28T16:03:58+05:30] Starting GlusterD pid=1650
|
||||
INFO[2017-08-28T16:03:58+05:30] loaded configuration from file file=conf.yaml
|
||||
INFO[2017-08-28T16:03:58+05:30] loaded configuration from file file=conf.toml
|
||||
INFO[2017-08-28T16:03:58+05:30] Generated new UUID uuid=19db62df-799b-47f1-80e4-0f5400896e05
|
||||
INFO[2017-08-28T16:03:58+05:30] started muxsrv listener
|
||||
INFO[2017-08-28T16:03:58+05:30] Started GlusterD ReST server ip:port=192.168.56.101:24007
|
||||
|
||||
6
e2e/config/1.toml
Normal file
6
e2e/config/1.toml
Normal file
@@ -0,0 +1,6 @@
|
||||
workdir = "/tmp/gd2_func_test/w1"
|
||||
logfile = "w1.log"
|
||||
peeraddress = "127.0.0.1:24008"
|
||||
clientaddress = "127.0.0.1:24007"
|
||||
etcdcurls = "http://127.0.0.1:2479"
|
||||
etcdpurls = "http://127.0.0.1:2480"
|
||||
@@ -1,6 +0,0 @@
|
||||
workdir: "/tmp/gd2_func_test/w1"
|
||||
logfile: "w1.log"
|
||||
peeraddress: "127.0.0.1:24008"
|
||||
clientaddress: "127.0.0.1:24007"
|
||||
etcdcurls: "http://127.0.0.1:2479"
|
||||
etcdpurls: "http://127.0.0.1:2480"
|
||||
6
e2e/config/2.toml
Normal file
6
e2e/config/2.toml
Normal file
@@ -0,0 +1,6 @@
|
||||
workdir = "/tmp/gd2_func_test/w2"
|
||||
logfile = "w2.log"
|
||||
peeraddress = "127.0.0.1:23008"
|
||||
clientaddress = "127.0.0.1:23007"
|
||||
etcdcurls = "http://127.0.0.1:2379"
|
||||
etcdpurls = "http://127.0.0.1:2380"
|
||||
@@ -1,6 +0,0 @@
|
||||
workdir: "/tmp/gd2_func_test/w2"
|
||||
logfile: "w2.log"
|
||||
peeraddress: "127.0.0.1:23008"
|
||||
clientaddress: "127.0.0.1:23007"
|
||||
etcdcurls: "http://127.0.0.1:2379"
|
||||
etcdpurls: "http://127.0.0.1:2380"
|
||||
6
e2e/config/3.toml
Normal file
6
e2e/config/3.toml
Normal file
@@ -0,0 +1,6 @@
|
||||
workdir = "/tmp/gd2_func_test/w3"
|
||||
logfile = "w3.log"
|
||||
peeraddress = "127.0.0.1:22008"
|
||||
clientaddress = "127.0.0.1:22007"
|
||||
etcdcurls = "http://127.0.0.1:2279"
|
||||
etcdpurls = "http://127.0.0.1:2280"
|
||||
@@ -1,6 +0,0 @@
|
||||
workdir: "/tmp/gd2_func_test/w3"
|
||||
logfile: "w3.log"
|
||||
peeraddress: "127.0.0.1:22008"
|
||||
clientaddress: "127.0.0.1:22007"
|
||||
etcdcurls: "http://127.0.0.1:2279"
|
||||
etcdpurls: "http://127.0.0.1:2280"
|
||||
7
e2e/config/4.toml
Normal file
7
e2e/config/4.toml
Normal file
@@ -0,0 +1,7 @@
|
||||
workdir = "/tmp/gd2_func_test/w4"
|
||||
logfile = "w4.log"
|
||||
peeraddress = "127.0.0.1:21008"
|
||||
clientaddress = "127.0.0.1:21007"
|
||||
etcdcurls = "http://127.0.0.1:2179"
|
||||
etcdpurls = "http://127.0.0.1:2180"
|
||||
restauth = true
|
||||
@@ -1,7 +0,0 @@
|
||||
workdir: "/tmp/gd2_func_test/w4"
|
||||
logfile: "w4.log"
|
||||
peeraddress: "127.0.0.1:21008"
|
||||
clientaddress: "127.0.0.1:21007"
|
||||
etcdcurls: "http://127.0.0.1:2179"
|
||||
etcdpurls: "http://127.0.0.1:2180"
|
||||
restauth: true
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
func TestGeorepCreateDelete(t *testing.T) {
|
||||
r := require.New(t)
|
||||
|
||||
gds, err := setupCluster("./config/1.yaml", "./config/2.yaml")
|
||||
gds, err := setupCluster("./config/1.toml", "./config/2.toml")
|
||||
r.Nil(err)
|
||||
defer teardownCluster(gds)
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ func TestGlusterShd(t *testing.T) {
|
||||
|
||||
r := require.New(t)
|
||||
|
||||
gds, err := setupCluster("./config/1.yaml", "./config/2.yaml")
|
||||
gds, err := setupCluster("./config/1.toml", "./config/2.toml")
|
||||
r.Nil(err)
|
||||
defer teardownCluster(gds)
|
||||
|
||||
|
||||
@@ -10,19 +10,19 @@ import (
|
||||
func TestAddRemovePeer(t *testing.T) {
|
||||
r := require.New(t)
|
||||
|
||||
g1, err := spawnGlusterd("./config/1.yaml", true)
|
||||
g1, err := spawnGlusterd("./config/1.toml", true)
|
||||
r.Nil(err)
|
||||
defer g1.Stop()
|
||||
defer g1.EraseWorkdir()
|
||||
r.True(g1.IsRunning())
|
||||
|
||||
g2, err := spawnGlusterd("./config/2.yaml", true)
|
||||
g2, err := spawnGlusterd("./config/2.toml", true)
|
||||
r.Nil(err)
|
||||
defer g2.Stop()
|
||||
defer g2.EraseWorkdir()
|
||||
r.True(g2.IsRunning())
|
||||
|
||||
g3, err := spawnGlusterd("./config/3.yaml", true)
|
||||
g3, err := spawnGlusterd("./config/3.toml", true)
|
||||
r.Nil(err)
|
||||
defer g3.Stop()
|
||||
defer g3.EraseWorkdir()
|
||||
|
||||
@@ -16,7 +16,7 @@ func testQuotaEnable(t *testing.T) {
|
||||
var err error
|
||||
r := require.New(t)
|
||||
|
||||
gds, err := setupCluster("./config/1.yaml", "./config/2.yaml")
|
||||
gds, err := setupCluster("./config/1.toml", "./config/2.toml")
|
||||
r.Nil(err)
|
||||
defer teardownCluster(gds)
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
func TestRESTAPIAuth(t *testing.T) {
|
||||
r := require.New(t)
|
||||
|
||||
g1, err := spawnGlusterd("./config/4.yaml", true)
|
||||
g1, err := spawnGlusterd("./config/4.toml", true)
|
||||
r.Nil(err)
|
||||
defer g1.Stop()
|
||||
defer g1.EraseWorkdir()
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
func TestRestart(t *testing.T) {
|
||||
r := require.New(t)
|
||||
|
||||
gd, err := spawnGlusterd("./config/1.yaml", true)
|
||||
gd, err := spawnGlusterd("./config/1.toml", true)
|
||||
r.Nil(err)
|
||||
r.True(gd.IsRunning())
|
||||
|
||||
@@ -42,7 +42,7 @@ func TestRestart(t *testing.T) {
|
||||
|
||||
r.Nil(gd.Stop())
|
||||
|
||||
gd, err = spawnGlusterd("./config/1.yaml", false)
|
||||
gd, err = spawnGlusterd("./config/1.toml", false)
|
||||
r.Nil(err)
|
||||
r.True(gd.IsRunning())
|
||||
|
||||
|
||||
@@ -15,14 +15,15 @@ import (
|
||||
|
||||
"github.com/gluster/glusterd2/pkg/api"
|
||||
"github.com/gluster/glusterd2/pkg/restclient"
|
||||
"gopkg.in/yaml.v2"
|
||||
|
||||
toml "github.com/pelletier/go-toml"
|
||||
)
|
||||
|
||||
type gdProcess struct {
|
||||
Cmd *exec.Cmd
|
||||
ClientAddress string `yaml:"clientaddress"`
|
||||
PeerAddress string `yaml:"peeraddress"`
|
||||
Workdir string `yaml:"workdir"`
|
||||
ClientAddress string `toml:"clientaddress"`
|
||||
PeerAddress string `toml:"peeraddress"`
|
||||
Workdir string `toml:"workdir"`
|
||||
uuid string
|
||||
}
|
||||
|
||||
@@ -98,7 +99,7 @@ func spawnGlusterd(configFilePath string, cleanStart bool) (*gdProcess, error) {
|
||||
}
|
||||
|
||||
g := gdProcess{}
|
||||
if err = yaml.Unmarshal(fContent, &g); err != nil {
|
||||
if err = toml.Unmarshal(fContent, &g); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ func TestVolume(t *testing.T) {
|
||||
|
||||
r := require.New(t)
|
||||
|
||||
gds, err = setupCluster("./config/1.yaml", "./config/2.yaml")
|
||||
gds, err = setupCluster("./config/1.toml", "./config/2.toml")
|
||||
r.Nil(err)
|
||||
defer teardownCluster(gds)
|
||||
|
||||
@@ -192,7 +192,7 @@ func TestVolumeOptions(t *testing.T) {
|
||||
|
||||
r := require.New(t)
|
||||
|
||||
gds, err := setupCluster("./config/1.yaml")
|
||||
gds, err := setupCluster("./config/1.toml")
|
||||
r.Nil(err)
|
||||
defer teardownCluster(gds)
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ Before=network-online.target
|
||||
Conflicts=glusterd.service
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/sbin/glusterd2
|
||||
ExecStart=/usr/sbin/glusterd2 --config=/etc/glusterd2/glusterd2.toml
|
||||
KillMode=process
|
||||
|
||||
[Install]
|
||||
|
||||
@@ -44,7 +44,7 @@ func parseFlags() {
|
||||
flag.String("workdir", "", "Working directory for GlusterD. (default: current directory)")
|
||||
flag.String("localstatedir", "", "Directory to store local state information. (default: workdir)")
|
||||
flag.String("rundir", "", "Directory to store runtime data. (default: workdir/run)")
|
||||
flag.String("config", "", "Configuration file for GlusterD. By default looks for glusterd2.(yaml|toml|json) in [/usr/local]/etc/glusterd2 and current working directory.")
|
||||
flag.String("config", "", "Configuration file for GlusterD. By default looks for glusterd2.toml in [/usr/local]/etc/glusterd2 and current working directory.")
|
||||
|
||||
flag.String(logging.DirFlag, "", logging.DirHelp+" (default: workdir/log)")
|
||||
flag.String(logging.FileFlag, "STDOUT", logging.FileHelp)
|
||||
@@ -135,6 +135,9 @@ func initConfig(confFile string) error {
|
||||
// If a config file was given, read in configration from that file.
|
||||
// If the file is not present panic.
|
||||
|
||||
// Limit config to toml only to avoid confusion with multiple config types
|
||||
config.SetConfigType("toml")
|
||||
|
||||
if confFile == "" {
|
||||
config.SetConfigName(defaultConfName)
|
||||
for _, p := range defaultConfPaths {
|
||||
@@ -148,7 +151,7 @@ func initConfig(confFile string) error {
|
||||
if confFile == "" {
|
||||
log.WithFields(log.Fields{
|
||||
"paths": defaultConfPaths,
|
||||
"config": defaultConfName + ".(toml|yaml|json)",
|
||||
"config": defaultConfName + ".toml",
|
||||
"error": err,
|
||||
}).Debug("failed to read any config files, continuing with defaults")
|
||||
} else {
|
||||
|
||||
@@ -4,10 +4,12 @@ PREFIX=${PREFIX:-/usr/local}
|
||||
DATADIR=${DATADIR:-$PREFIX/share}
|
||||
LOCALSTATEDIR=${LOCALSTATEDIR:-$PREFIX/var/lib}
|
||||
LOGDIR=${LOGDIR:-$PREFIX/var/log}
|
||||
RUNDIR=${RUNDIR:-$PREFIX/var/run}
|
||||
|
||||
GD2="glusterd2"
|
||||
GD2STATEDIR=${GD2STATEDIR:-$LOCALSTATEDIR/$GD2}
|
||||
GD2LOGDIR=${GD2LOGDIR:-$LOGDIR/$GD2}
|
||||
GD2RUNDIR=${GD2RUNDIR:-$RUNDIR/$GD2}
|
||||
|
||||
OUTDIR=${1:-build}
|
||||
mkdir -p $OUTDIR
|
||||
@@ -19,4 +21,5 @@ cat >$OUTPUT <<EOF
|
||||
localstatedir = "$GD2STATEDIR"
|
||||
logdir = "$GD2LOGDIR"
|
||||
logfile = "$GD2.log"
|
||||
rundir = "$GD2RUNDIR"
|
||||
EOF
|
||||
|
||||
Reference in New Issue
Block a user