Skip to content

Commit

Permalink
Multiple cluster config with include directory in default conf file
Browse files Browse the repository at this point in the history
  • Loading branch information
svaroqui committed Dec 20, 2017
1 parent 43db233 commit 549187b
Show file tree
Hide file tree
Showing 4 changed files with 246 additions and 0 deletions.
1 change: 1 addition & 0 deletions etc/cluster.d/cluster01.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[Cluster01]
title = "Cluster01"
db-servers-hosts = "127.0.0.1:3333,127.0.0.1:3334"
db-servers-prefered-master = "127.0.0.1:3333"
Expand Down
1 change: 1 addition & 0 deletions etc/cluster.d/cluster02.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[Cluster01]
title = "Cluster02"
db-servers-hosts = "127.0.0.1:3333,127.0.0.1:3334"
db-servers-prefered-master = "127.0.0.1:3333"
Expand Down
223 changes: 223 additions & 0 deletions etc/config.toml.sample.tst.include
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
## config.toml
## Example replication-manager configuration file

## change the service file in /etc/systemd/system/replication-manager.service to looks like :
## replication-manager-osc --config=./etc/config.toml.sample --cluster=Cluster01,Cluster_Test_2_Nodes monitor


[Default]

include = "./etc/cluster.d"

# monitoring-datadir = "/var/lib/replication-manager"
# monitoring-sharedir = "/usr/share/replication-manager"

## Timeout in seconds between consecutive monitoring

# monitoring-ticker = 2

#########
## LOG ##
#########

# log-file = "/var/log/replication-manager.log"
verbose = true

##############
## TOPOLOGY ##
##############

# replication-multi-master = false
# replication-multi-tier-slave = false

##############
## FAILOVER ##
##############

# failover-mode = "manual"
# failover-pre-script = ""
# failover-post-script = ""

## Slaves will re enter with read-only

# failover-readonly-state = true
# failover-event-scheduler = false
# failover-event-status = false

## Failover after N failures detection

# failover-falsepositive-ping-counter = 5

## Cancel failover if already N failover
## Cancel failover if last failover was N seconds before
## Cancel failover in semi-sync when one slave is not in sync
## Cancel failover if one slave receive master heartbeat
## Cancel failover when replication delay is more than N seconds

# failover-limit = 0
# failover-time-limit = 0
# failover-at-sync = false
# failover-max-slave-delay = 30
# failover-restart-unsafe = false

# failover-falsepositive-heartbeat = true
# failover-falsepositive-heartbeat-timeout = 3
# failover-falsepositive-maxscale = false
# failover-falsepositive-maxscale-timeout = 14
# failover-falsepositive-external = false
# failover-falsepositive-external-port = 80

################
## SWITCHOVER ##
################

## In switchover Wait N milliseconds before killing long running transactions
## Cancel switchover if transaction running more than N seconds
## Cancel switchover if write query running more than N seconds
## Cancel switchover if one of the slaves is not synced based on GTID equality

# switchover-wait-kill = 5000
# switchover-wait-trx = 10
# switchover-wait-write-query = 10
# switchover-at-equal-gtid = false
# switchover-at-sync = false
# switchover-max-slave-delay = 30

############
## REJOIN ##
############

# autorejoin = true
# autorejoin-script = ""
# autorejoin-semisync = true
# autorejoin-backup-binlog = true
# autorejoin-flashback = false
# autorejoin-mysqldump = false

####################
## CHECKS & FORCE ##
####################

# check-replication-filters = true
# check-binlog-filters = true
# check-replication-state = true

# force-slave-heartbeat= false
# force-slave-heartbeat-retry = 5
# force-slave-heartbeat-time = 3
# force-slave-gtid-mode = false
# force-slave-semisync = false
# force-slave-failover-readonly-state = false
# force-binlog-row = false
# force-binlog-annotate = false
# force-binlog-slowqueries = false
# force-binlog-compress = false
# force-binlog-checksum = false
# force-inmemory-binlog-cache-size = false
# force-disk-relaylog-size-limit = false
# force-disk-relaylog-size-limit-size = 1000000000
# force-sync-binlog = false
# force-sync-innodb = false

##############
## MAXSCALE ##
##############

## for 2 nodes cluster maxscale can be driven by replication manager

# maxscale = false
# maxscale-binlog = false
# maxscale-servers = "192.168.0.201"
# maxscale-port = 4003
# maxscale-user = "admin"
# maxscale-pass = "mariadb"

## When true replication manager drive maxscale server state
## Not required unless multiple maxscale or release does not support detect_stale_slave

# maxscale-disable-monitor = false

## maxinfo|maxadmin

# maxscale-get-info-method = "maxadmin"
# maxscale-maxinfo-port = 4002

# maxscale-write-port = 4007
# maxscale-read-port = 4008
# maxscale-read-write-port = 4006
# maxscale-binlog-port = 4000

#############
## HAPROXY ##
#############

## Wrapper mode unless maxscale or proxysql required to be located with replication-manager

# haproxy = false
# haproxy-binary-path = "/usr/sbin/haproxy"

## Read write traffic
## Read only load balance least connection traffic
# haproxy-write-port = 3306
# haproxy-read-port = 3307

####################
## SHARDING PROXY ##
####################

# mdbshardproxy = false
# mdbshardproxy-hosts = "127.0.0.1:3306"
# mdbshardproxy-user = "root:mariadb"

#################
## ARBITRATION ##
#################

# arbitration-external = false
# arbitration-external-secret = "13787932529099014144"
# arbitration-external-hosts = "88.191.151.84:80"
# arbitration-peer-hosts ="127.0.0.1:10002"

## Unique value on each replication-manager

# arbitration-external-unique-id = 0

##########
## HTTP ##
##########

http-server = true
http-bind-address = "0.0.0.0"
# http-port = "10001"
# http-auth = false
# http-session-lifetime = 3600
# http-bootstrap-button = false

#########
## API ##
#########

# api-credential = "admin:repman"
# api-port = "3000"

############
## ALERTS ##
############

# mail-from = "replication-manager@localhost"
# mail-smtp-addr = "localhost:25"
# mail-to = "replication-manager@signal18.io"

##########
# STATS ##
##########

# graphite-metrics = false
# graphite-carbon-host = "127.0.0.1"
# graphite-carbon-port = 2003
# graphite-embedded = false
# graphite-carbon-api-port = 10002
# graphite-carbon-server-port = 10003
# graphite-carbon-link-port = 7002
# graphite-carbon-pickle-port = 2004
# graphite-carbon-pprof-port = 7007
21 changes: 21 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ package main

import (
"fmt"
"io/ioutil"
"os"
"strings"

Expand Down Expand Up @@ -161,6 +162,26 @@ func initConfig() {
if _, ok := err.(viper.ConfigParseError); ok {
log.WithError(err).Fatal("Could not parse config file")
}
// Procedd include files
if viper.GetString("default.include") != "" {
if _, err := os.Stat(viper.GetString("default.include")); os.IsNotExist(err) {
log.Fatal("No include config directory " + conf.Include)
}
files, err := ioutil.ReadDir(viper.GetString("default.include"))
if err != nil {
log.Fatal(err)
}
for _, f := range files {
if !f.IsDir() {
viper.SetConfigName(f.Name())
viper.SetConfigFile(viper.GetString("default.include") + "/" + f.Name())
viper.MergeInConfig()
//fmt.Println(f.Name())
}
}
}
// Procedd include files

m := viper.AllKeys()
currentClusterName = cfgGroup
if currentClusterName == "" {
Expand Down

0 comments on commit 549187b

Please sign in to comment.