Configuring nodes to work inside cluster

sudo docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                                         NAMES
ee1b24634918        couchdb20           "/couchdb/bin/couchdb"   15 minutes ago      Up 15 minutes       4369/tcp, 5984/tcp, 5986/tcp, 9100-9200/tcp   couchdb_node3
898ac8ef3ecb        couchdb20           "/couchdb/bin/couchdb"   15 minutes ago      Up 15 minutes       4369/tcp, 5984/tcp, 5986/tcp, 9100-9200/tcp   couchdb_node2
bf3e284c72cc        couchdb20           "/couchdb/bin/couchdb"   15 minutes ago      Up 15 minutes       4369/tcp, 5984/tcp, 5986/tcp, 9100-9200/tcp   couchdb_node1

[sergey@fcbs8200 ~]$  < /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-2048} |  sha256sum
3a8c47a23dee62ba68e696aea39e6c8e46e0b274b05beac542a6015f93e508ad  -

[sergey@fcbs8200 ~]$ sudo docker exec -i -t couchdb_node1 /bin/bash

root@bf3e284c72cc:/couchdb# apt-get install nano

root@bf3e284c72cc:/couchdb# nano /couchdb/etc/vm.args

# Each node in the system must have a unique name.  A name can be short
# (specified using -sname) or it can by fully qualified (-name).  There can be
# no communication between nodes running with the -sname flag and those running
# with the -name flag.
-name node_1@172.17.0.2

# All nodes must share the same magic cookie for distributed Erlang to work.
# Comment out this line if you synchronized the cookies by other means (using
# the ~/.erlang.cookie file, for example).
-setcookie 3a8c47a23dee62ba68e696aea39e6c8e46e0b274b05beac542a6015f93e508ad

root@bf3e284c72cc:/couchdb# exit

[sergey@fcbs8200 ~]$ sudo docker exec -i -t couchdb_node2 /bin/bash

root@898ac8ef3ecb:/couchdb# apt-get install nano

root@898ac8ef3ecb:/couchdb# nano /couchdb/etc/vm.args

# Each node in the system must have a unique name.  A name can be short
# (specified using -sname) or it can by fully qualified (-name).  There can be
# no communication between nodes running with the -sname flag and those running
# with the -name flag.
-name node_2@172.17.0.3

# All nodes must share the same magic cookie for distributed Erlang to work.
# Comment out this line if you synchronized the cookies by other means (using
# the ~/.erlang.cookie file, for example).
-setcookie 3a8c47a23dee62ba68e696aea39e6c8e46e0b274b05beac542a6015f93e508ad

root@898ac8ef3ecb:/couchdb# exit

[sergey@fcbs8200 ~]$ sudo docker exec -i -t couchdb_node3 /bin/bash

root@ee1b24634918:/couchdb# apt-get install nano

root@ee1b24634918:/couchdb# nano /couchdb/etc/vm.args

# Each node in the system must have a unique name.  A name can be short
# (specified using -sname) or it can by fully qualified (-name).  There can be
# no communication between nodes running with the -sname flag and those running
# with the -name flag.
-name node_3@172.17.0.4

# All nodes must share the same magic cookie for distributed Erlang to work.
# Comment out this line if you synchronized the cookies by other means (using
# the ~/.erlang.cookie file, for example).
-setcookie 3a8c47a23dee62ba68e696aea39e6c8e46e0b274b05beac542a6015f93e508ad

root@ee1b24634918:/couchdb# exit

[sergey@fcbs8200 ~]$ docker restart couchdb_node1 && docker restart couchdb_node2 && docker restart couchdb_node3
couchdb_node1
couchdb_node2
couchdb_node3

Go to
http://172.17.0.2:5986/_utils/#/database/_nodes/_all_docs
http://172.17.0.3:5986/_utils/#/database/_nodes/_all_docs
http://172.17.0.4:5986/_utils/#/database/_nodes/_all_docs

If you will shutdown containers, then you can to start again by command:

docker start couchdb_node1 couchdb_node2 couchdb_node3

By each address select and delete records with id couchdb@localhost

I recommend to backup created containers, by making snapshots.

[sergey@fcbs8200 ~]$ docker commit -p couchdb_node1 couchdb20:node1_start
sha256:8f3e5bdbb9d99f17f106371692e14925b58853f6b32facf28fa7765b38ee764d

[sergey@fcbs8200 ~]$ docker commit -p couchdb_node2 couchdb20:node2_start
sha256:6f6e02fe8d4700c2f0d23465ad1bfa62d8874e5dc6f6faa646467b17fbba0163

[sergey@fcbs8200 ~]$ docker commit -p couchdb_node3 couchdb20:node3_start
sha256:b123ebee0e5b8479355d17e4a25a82ba4d0cdcc771cdf20b69da789415634809

[sergey@fcbs8200 ~]$ docker images
REPOSITORY                             TAG                 IMAGE ID            CREATED              SIZE
couchdb20                              node3_start         b123ebee0e5b        37 seconds ago         626.7 MB
couchdb20                              node2_start         6f6e02fe8d47        About a minute ago   626.7 MB
couchdb20                              node1_start         8f3e5bdbb9d9       About a minute ago   626.7 MB
couchdb20                              latest                   25a0a1522fcf        3 days ago                  624.5 MB


Comments

Popular Posts