This system is a Synology RAID system (specifically RS3614xs), with 12 4-TB disks. 9 of these disks provide RAID5 (total ~29 TB of space) with 3 disks acting as hot spares. The system runs a linux distribution (DSM) and is generally administrated either from the command line (e.g. ssh) or via a web interface.
The primary purpose of this machine is to synchronize with the Internal DB/Raid system.
See here.
Replication of the local DB occurs via a tunnel through the optimal system. If a new system needs to be setup to replicate all dbs from the internal DB server, then one can use the following script:
""" | |
Setup replication for a CouchDB server | |
""" | |
import cloudant | |
import json | |
_replicate_source_server = { | |
"protocol" : "http", | |
"address" : "optimal.universe-cluster.de", | |
"port" : "15984", | |
"credentials" : ("nedm_user", "pw"), | |
} | |
_replicate_target_server = { | |
"protocol" : "http", | |
"address" : "cluster-server-default", | |
"port" : "5984", | |
"credentials" : ("admin", """admin_pw"""), | |
} | |
pull_from = True | |
bidirectional = False | |
base_doc = { | |
"user_ctx" : { | |
"name" : "admin", | |
"roles" : ["_admin"] | |
}, | |
"continuous" : True, | |
"create_target" : True, | |
} | |
def get_acct(serv): | |
acct = cloudant.Account(uri="{protocol}://{address}:{port}".format(**serv)) | |
res = acct.login(*serv["credentials"]) | |
assert res.status_code == 200 | |
return acct | |
def get_all_dbs(serv): | |
acct = get_acct(serv) | |
res = acct.all_dbs().json() | |
_nedm_pre = "nedm/" | |
return [k[len(_nedm_pre):] for k in res if k[:len(_nedm_pre)] == _nedm_pre] | |
def setup_replicate(dbs, from_serv, to_serv, pull): | |
temp_doc = base_doc.copy() | |
save_on_serv = from_serv | |
other_serv = to_serv | |
temp_doc["source"] = "nedm/{db_name}" | |
temp_doc["target"] = "{protocol}://{un}:{pw}@{address}:{port}/nedm%2F{db_name}" | |
if pull: | |
save_on_serv = to_serv | |
other_serv = from_serv | |
src = temp_doc["source"] | |
temp_doc["source"] = temp_doc["target"] | |
temp_doc["target"] = src | |
print dbs | |
acct = get_acct(save_on_serv) | |
print acct | |
repl = acct["_replicator"] | |
all_docs = repl.all_docs().get().json() | |
_des_prepend = "_design/" | |
print all_docs | |
all_docs = [k["id"] for k in all_docs["rows"] if k["id"][:len(_des_prepend)] != _des_prepend ] | |
use_other_serv = other_serv.copy() | |
use_other_serv["un"] = use_other_serv["credentials"][0] | |
use_other_serv["pw"] = use_other_serv["credentials"][1] | |
for db in dbs: | |
# Make new replication document | |
if db in all_docs: | |
print("{} is already being replicated, skipping".format(db)) | |
continue | |
adoc = temp_doc.copy() | |
adoc["_id"] = db | |
for k in adoc: | |
try: | |
adoc[k] = adoc[k].format(db_name=db, **use_other_serv) | |
except: pass | |
print repl.post(data=json.dumps(adoc)).json() | |
if __name__ == '__main__': | |
dbs_to_replicate = get_all_dbs(_replicate_source_server) | |
setup_replicate(dbs_to_replicate, _replicate_source_server, _replicate_target_server, True) | |