Skip to content
Snippets Groups Projects
Commit fd345f23 authored by Sergey Yakubov's avatar Sergey Yakubov
Browse files

revert to single mongo instance

parent ea660b5b
No related branches found
No related tags found
No related merge requests found
...@@ -72,51 +72,5 @@ job "asapo-brokers" { ...@@ -72,51 +72,5 @@ job "asapo-brokers" {
change_mode = "restart" change_mode = "restart"
} }
} #task brokers } #task brokers
task "mongos-broker" {
driver = "docker"
config {
network_mode = "host"
image = "mongo:4.0.0"
dns_servers = ["127.0.0.1"]
command = "mongos"
args = ["--config","local/mongo-mongos.yaml"]
}
resources {
network {
port "mongos" {
static = 27016
}
}
}
service {
name = "mongos-broker"
check {
type = "script"
name = "mongos-broker-alive"
command = "mongo"
args = ["--host","${attr.unique.network.ip-address}","--port","27016","--eval","db.version()"]
interval = "10s"
timeout = "5s"
}
check_restart {
limit = 2
grace = "90s"
ignore_warnings = false
}
}
template {
source = "@NOMAD_INSTALL@/mongo-mongos.yaml.tpl"
destination = "local/mongo-mongos.yaml"
change_mode = "restart"
}
} # task mongos
} }
} }
job "asapo-mongo-sharded" {
datacenters = ["dc1"]
update {
max_parallel = 1
min_healthy_time = "10s"
healthy_deadline = "3m"
auto_revert = false
}
group "mongo-config-srv" {
count = 1
restart {
attempts = 2
interval = "3m"
delay = "15s"
mode = "fail"
}
task "mongo-config-srv" {
driver = "docker"
config {
network_mode = "host"
image = "mongo:4.0.0"
dns_servers = ["127.0.0.1"]
volumes = ["/${meta.shared_storage}/mongodb_config:/data/configdb"]
command = "mongod"
args = ["--config","local/mongo-configsrv.yaml"]
}
resources {
network {
port "config" {
static = 27010
}
}
}
service {
port = "config"
name = "mongo-config-srv"
check {
type = "script"
name = "alive"
command = "mongo"
args = ["--host","${attr.unique.network.ip-address}","--port","27010","--eval","db.version()"]
interval = "10s"
timeout = "5s"
}
check_restart {
limit = 2
grace = "90s"
ignore_warnings = false
}
}
template {
source = "@NOMAD_INSTALL@/mongo-configsrv.yaml.tpl"
destination = "local/mongo-configsrv.yaml"
change_mode = "restart"
}
}
} # config server group
group "mongo-shard1" {
count = 1
restart {
attempts = 2
interval = "3m"
delay = "15s"
mode = "fail"
}
task "mongo-shard1" {
driver = "docker"
config {
network_mode = "host"
image = "mongo:4.0.0"
dns_servers = ["127.0.0.1"]
volumes = ["/${meta.shared_storage}/mongodb_shard1:/data/db"]
command = "mongod"
args = ["--config","local/mongo-shardsrv.yaml"]
}
resources {
network {
port "shard" {
static = 27011
}
}
}
service {
port = "shard"
name = "mongo-shard1"
check {
type = "script"
name = "alive"
command = "mongo"
args = ["--host","${attr.unique.network.ip-address}","--port","27011","--eval","db.version()"]
interval = "10s"
timeout = "5s"
}
check_restart {
limit = 2
grace = "90s"
ignore_warnings = false
}
}
template {
source = "@NOMAD_INSTALL@/mongo-shardsrv.yaml.tpl"
destination = "local/mongo-shardsrv.yaml"
change_mode = "restart"
}
}
} # shard1 group
group "mongo-shard2" {
count = 1
restart {
attempts = 2
interval = "3m"
delay = "15s"
mode = "fail"
}
task "mongo-shard2" {
driver = "docker"
config {
network_mode = "host"
image = "mongo:4.0.0"
dns_servers = ["127.0.0.1"]
volumes = ["/${meta.shared_storage}/mongodb_shard2:/data/db"]
command = "mongod"
args = ["--config","local/mongo-shardsrv.yaml"]
}
resources {
network {
port "shard" {
static = 27012
}
}
}
service {
port = "shard"
name = "mongo-shard2"
check {
type = "script"
name = "alive"
command = "mongo"
args = ["--host","${attr.unique.network.ip-address}","--port","27012","--eval","db.version()"]
interval = "10s"
timeout = "5s"
}
check_restart {
limit = 2
grace = "90s"
ignore_warnings = false
}
}
template {
source = "@NOMAD_INSTALL@/mongo-shardsrv.yaml.tpl"
destination = "local/mongo-shardsrv.yaml"
change_mode = "restart"
}
}
} # shard2 group
group "mongo-shard3" {
count = 1
restart {
attempts = 2
interval = "3m"
delay = "15s"
mode = "fail"
}
task "mongo-shard3" {
driver = "docker"
config {
network_mode = "host"
image = "mongo:4.0.0"
dns_servers = ["127.0.0.1"]
volumes = ["/${meta.shared_storage}/mongodb_shard3:/data/db"]
command = "mongod"
args = ["--config","local/mongo-shardsrv.yaml"]
}
resources {
network {
port "shard" {
static = 27013
}
}
}
service {
port = "shard"
name = "mongo-shard3"
check {
type = "script"
name = "alive"
command = "mongo"
args = ["--host","${attr.unique.network.ip-address}","--port","27013","--eval","db.version()"]
interval = "10s"
timeout = "5s"
}
check_restart {
limit = 2
grace = "90s"
ignore_warnings = false
}
}
template {
source = "@NOMAD_INSTALL@/mongo-shardsrv.yaml.tpl"
destination = "local/mongo-shardsrv.yaml"
change_mode = "restart"
}
}
} # shard3 group
}
...@@ -65,52 +65,6 @@ job "asapo-receivers" { ...@@ -65,52 +65,6 @@ job "asapo-receivers" {
change_mode = "restart" change_mode = "restart"
} }
} #task receivers } #task receivers
task "mongos-receiver" {
driver = "docker"
config {
network_mode = "host"
image = "mongo:4.0.0"
dns_servers = ["127.0.0.1"]
command = "mongos"
args = ["--config","local/mongo-mongos.yaml"]
}
resources {
network {
port "mongos" {
static = 27015
}
}
}
service {
name = "mongos-receiver"
check {
type = "script"
name = "mongos-receiver-alive"
command = "mongo"
args = ["--host","${attr.unique.network.ip-address}","--port","27015","--eval","db.version()"]
interval = "10s"
timeout = "5s"
}
check_restart {
limit = 2
grace = "90s"
ignore_warnings = false
}
}
template {
source = "@NOMAD_INSTALL@/mongo-mongos.yaml.tpl"
destination = "local/mongo-mongos.yaml"
change_mode = "restart"
}
} # task mongos
} }
} }
job "asapo-test" {
datacenters = ["dc1"]
type = "batch"
group "windows-test" {
constraint {
attribute = "${attr.kernel.name}"
value = "windows"
}
count = 1
task "producer" {
driver = "raw_exec"
config {
command = "local/dummy-data-producer.exe"
args = [
"psana002:8400",
"asapo_test1",
"5000",
"10000",
"8",
"0",
"100"]
}
artifact {
source = "https://stash.desy.de/rest/git-lfs/storage/ASAPO/asapo-bin/d42330e599f0197e8acc17fedb10c8ae897b57def38b207f1a58f14c8a524100?response-content-disposition=attachment%253B%2520filename%253D%2522dummy-data-producer.exe%2522%253B%2520filename*%253Dutf-8%27%27dummy-data-producer.exe"
mode = "file"
destination = "local/dummy-data-producer.exe"
}
# resources {
# cpu = 5000
# memory = 128
# network {
# mbits = 10000
# }
}
} #windows
group "linux-test" {
constraint {
attribute = "${attr.kernel.name}"
value = "linux"
}
constraint {
attribute = "${meta.location}"
value = "petra3"
}
count = 1
task "producer" {
driver = "raw_exec"
config {
command = "local/dummy-data-producer"
args = [
"psana002:8400",
"asapo_test2",
"5000",
"10000",
"8",
"0",
"100"]
}
artifact {
source = "https://stash.desy.de/projects/ASAPO/repos/asapo-bin/raw/dummy-data-producer?at=refs%2Fheads%2Ffeature_ha"
}
# resources {
# cpu = 5000
# memory = 128
# network {
# mbits = 10000
# }
# }
}
} #linux
}
\ No newline at end of file
{ {
"BrokerDbAddress":"{{ env "attr.unique.network.ip-address" }}:27016", "BrokerDbAddress":"mongo.service.asapo:27017",
"MonitorDbAddress":"influxdb.service.asapo:8086", "MonitorDbAddress":"influxdb.service.asapo:8086",
"MonitorDbName": "asapo_brokers", "MonitorDbName": "asapo_brokers",
"port":{{ env "NOMAD_PORT_broker" }}, "port":{{ env "NOMAD_PORT_broker" }},
......
#!/usr/bin/env bash
mongoaddr=`dig +short @127.0.0.1 mongo-config-srv.service.asapo | head -1`
cont=$(ssh $mongoaddr bash -c "'docker ps | grep mongo-config-srv'")
image=`echo "${cont##* }"`
ssh $mongoaddr docker exec $image bash -c "'echo \"rs.initiate()\" | mongo --host $mongoaddr --port 27010'"
mongoaddr=`dig +short @127.0.0.1 mongos-broker.service.asapo | head -1`
cont=$(ssh $mongoaddr bash -c "'docker ps | grep mongos'")
image=`echo "${cont##* }"`
shardaddr1=`dig +short @127.0.0.1 mongo-shard1.service.asapo | head -1`
shardaddr2=`dig +short @127.0.0.1 mongo-shard2.service.asapo | head -1`
shardaddr3=`dig +short @127.0.0.1 mongo-shard3.service.asapo | head -1`
ssh $mongoaddr docker exec $image bash -c "'echo \"sh.addShard('\"'$shardaddr1:27011'\"')\" | mongo --host $mongoaddr --port 27016'"
ssh $mongoaddr docker exec $image bash -c "'echo \"sh.addShard('\"'$shardaddr2:27012'\"')\" | mongo --host $mongoaddr --port 27016 '"
ssh $mongoaddr docker exec $image bash -c "'echo \"sh.addShard('\"'$shardaddr3:27013'\"')\" | mongo --host $mongoaddr --port 27016 '"
sharding:
clusterRole: configsvr
replication:
replSetName: config
net:
bindIp: {{ env "attr.unique.network.ip-address" }}
port: {{ env "NOMAD_PORT_config" }}
sharding:
configDB: "config/mongo-config-srv.service.asapo:27010"
net:
bindIp: {{ env "attr.unique.network.ip-address" }}
port: {{ env "NOMAD_PORT_mongos" }}
sharding:
clusterRole: shardsvr
net:
bindIp: {{ env "attr.unique.network.ip-address" }}
port: {{ env "NOMAD_PORT_shard" }}
{ {
"MonitorDbAddress":"influxdb.service.asapo:8086", "MonitorDbAddress":"influxdb.service.asapo:8086",
"MonitorDbName": "asapo_receivers", "MonitorDbName": "asapo_receivers",
"BrokerDbAddress":"{{ env "attr.unique.network.ip-address" }}:27015", "BrokerDbAddress":"mongo.service.asapo:27017",
"AuthorizationServer": "asapo-authorizer.service.asapo:5007", "AuthorizationServer": "asapo-authorizer.service.asapo:5007",
"AuthorizationInterval": 10000, "AuthorizationInterval": 10000,
"ListenPort": {{ env "NOMAD_PORT_recv" }}, "ListenPort": {{ env "NOMAD_PORT_recv" }},
......
...@@ -2,12 +2,7 @@ ...@@ -2,12 +2,7 @@
nomad run asapo-nginx.nmd nomad run asapo-nginx.nmd
nomad run asapo-logging.nmd nomad run asapo-logging.nmd
nomad run asapo-mongo-sharded.nmd nomad run asapo-mongo.nmd
#if mongo replica sets and shards not created yet might be necessary to wait here, than start mongos (run init_mongo.sh first time to create replicas,
#then start mongos (e.g. in asapo-brokers job), then run init_mongo.sh once more
nomad run asapo-brokers.nmd nomad run asapo-brokers.nmd
nomad run asapo-services.nmd nomad run asapo-services.nmd
nomad run asapo-perfmetrics.nmd nomad run asapo-perfmetrics.nmd
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
nomad stop asapo-nginx nomad stop asapo-nginx
nomad stop asapo-logging nomad stop asapo-logging
nomad stop asapo-mongo-sharded nomad stop asapo-mongo
nomad stop asapo-services nomad stop asapo-services
nomad stop asapo-perfmetrics nomad stop asapo-perfmetrics
nomad stop asapo-receivers nomad stop asapo-receivers
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment