[O’Reilly Media / Infinite Skills] Introduction to CoreOS Training Video [2015, ENG] : Deploying A DatabaseBacked Web Application : Deploying RethinkDB Database

DataBase Layer (RethinkDB) 8080 port - database admin dashboard

$ cd ~/coreos-vagrant


$ vi config.rb

Прописываем:

$forwarded_ports = {80 => 8000, 3000 => 3000, 8080 => 8080 }


$ vagrant reload


$ vagrant ssh core-01 -- -A


core-01



[Unit]
Description=Announce RethinkDB %i service

[Service]
EnvironmentFile=/etc/environment
ExecStart=/bin/sh -c "while true; do etcdctl set /services/rethinkdb/rethinkdb-%i \${COREOS_PUBLIC_IPV4} --ttl 60; sleep 45; done"
ExecStop=/usr/bin/etcdctl rm /services/rethinkdb/rethinkdb-%i

[X-Fleet]
X-Conflicts=rethinkdb-announce@\*.service



[Unit]
Description=RethinkDB %i service
After=docker.service
BindsTo=rethinkdb-announce@%i.service

[Service]
EnvironmentFile=/etc/environment
TimeoutStartSec=0
ExecStartPre=-/usr/bin/docker kill rethinkdb-%i
ExecStartPre=-/usr/bin/docker rm rethinkdb-%i
ExecStartPre=-/usr/bin/mkdir -p /home/core/docker-volumes/rethinkdb
ExecStartPre=/usr/bin/docker pull marley/coreos-rethinkdb:latest
ExecStart=/bin/sh -c '/usr/bin/docker run --name rethinkdb-%i \
 -p ${COREOS_PUBLIC_IPV4}:8080:8080                        \
 -p ${COREOS_PUBLIC_IPV4}:28015:28015 \
 -p ${COREOS_PUBLIC_IPV4}:29015:29015                      \
 marley/coreos-rethinkdb:latest rethinkdb --bind all \
 --canonical-address ${COREOS_PUBLIC_IPV4} \
 $(/usr/bin/etcdctl ls /services/rethinkdb |               \
     xargs -I {} /usr/bin/etcdctl get {} |                 \
     sed s/^/"--join "/ | sed s/$/":29015"/ | \
 tr "\n" " ")'

ExecStop=/usr/bin/docker stop rethinkdb-%i

[X-Fleet]
X-ConditionMachineOf=rethinkdb-announce@%i.service


$ fleetctl submit *


$ fleetctl list-unit-files
UNIT				HASH	DSTATE		STATE		TARGET
[email protected]	3f7611a	inactive	inactive	-
[email protected]		5698af1	inactive	inactive	-


$ fleetctl start rethinkdb@1 rethinkdb-announce@1
$ fleetctl start rethinkdb@2 rethinkdb-announce@2


Несколько минут ждал, чтобы статус стал active running у всех сервисов

$ fleetctl list-units
UNIT				MACHINE				ACTIVE	SUB
[email protected]	3408f7ab.../172.17.8.103	active	running
[email protected]	b2ca4512.../172.17.8.101	active	running
[email protected]		3408f7ab.../172.17.8.103	active	running
[email protected]		b2ca4512.../172.17.8.101	active	running


$ curl 172.17.8.101:8080


// лог
$ fleetctl journal -f --lines=50 rethinkdb@1
$ fleetctl journal -f --lines=50 rethinkdb@2

$ fleetctl journal -f --lines=50 ethinkdb-announce@1
$ fleetctl journal -f --lines=50 ethinkdb-announce@2


http://172.17.8.101:8080/#servers
http://172.17.8.103:8080/#servers


coreos cluster