DOCKER CONCEPT FOR DBA– PART 5 Installation of Docker Swarm

What is a docker swarm?

A swarm consists of multiple Docker hosts which run in swarm mode and act as managers (to manage membership and delegation) and workers (which run swarm services). A given Docker host can be a manager, a worker, or perform both roles. When you create a service, you define its optimal state (number of replicas, network and storage resources available to it, ports the service exposes to the outside world, and more). Docker works to maintain that desired state. For instance, if a worker node becomes unavailable, Docker schedules that node’s tasks on other nodes. A task is a running container which is part of a swarm service and managed by a swarm manager, as opposed to a standalone container.

Installation of Docker Swarm

1.First identify IP of the host using below command

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 9001
inet 172.31.96.15 netmask 255.255.240.0 broadcast 172.31.111.255
inet6 fe80::102a:51ff:fee8:7188 prefixlen 64 scopeid 0x20<link>
ether 12:2a:51:e8:71:88 txqueuelen 1000 (Ethernet)
RX packets 52409 bytes 57532946 (54.8 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 15908 bytes 2546908 (2.4 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1 (Local Loopback)
RX packets 3378 bytes 1144813 (1.0 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3378 bytes 1144813 (1.0 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

2.Please bind the Docker swarm with the IP

[root@debasiseric1 ~]# docker swarm init --advertise-addr 172.31.96.15

Swarm initialized: current node (qs8cyp1whprtfqikran65p1pj) is now a manager.

3.To add a worker to this swarm, run the following command:

[root@debasiseric1 ~]#docker swarm join-token worker

docker swarm join –token SWMTKN-1-69aokcgwacepwojdrepq25twysj3bptuea3lc2yn6ghfy5f478-bdjnimy0962cmth54vzcb0lu4 172.31.96.15:2377

4.To add a manager to this swarm, run ‘docker swarm join-token manager’ and follow the instructions.

[root@debasiseric1 ~]#docker swarm join-token manager

docker swarm join –token SWMTKN-1-69aokcgwacepwojdrepq25twysj3bptuea3lc2yn6ghfy5f478-bdjnimy0962cmth54vzcb0lu4 172.31.96.15:2377

5.Please check currently running docker engine

[root@debasiseric1 ~]# docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
qs8cyp1whprtfqikran65p1pj * debasiseric1.mylabserver.com Ready Active Leader 18.03.0-ce

6.Please check the managers and nodes running now

[root@debasiseric1 ~]#docker system info|more

Containers: 1
Running: 0
Paused: 0
Stopped: 1
Images: 2
Server Version: 18.03.0-ce
Storage Driver: devicemapper
Pool Name: docker-202:1-50602726-pool
Pool Blocksize: 65.54kB
Base Device Size: 10.74GB
Backing Filesystem: xfs
Udev Sync Supported: true
Data file: /dev/loop0
Metadata file: /dev/loop1
Data loop file: /var/lib/docker/devicemapper/devicemapper/data
Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata
Data Space Used: 481.8MB
Data Space Total: 107.4GB
Data Space Available: 14.76GB
Metadata Space Used: 1.139MB
Metadata Space Total: 2.147GB
Metadata Space Available: 2.146GB
Thin Pool Minimum Free Space: 10.74GB
Deferred Removal Enabled: true
Deferred Deletion Enabled: true
Deferred Deleted Device Count: 0
Library Version: 1.02.140-RHEL7 (2017-05-03)
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: active
NodeID: qs8cyp1whprtfqikran65p1pj
Is Manager: true
ClusterID: ykxn4szm49ny348z3z8ws4xpp
Managers: 1
Nodes: 1
Orchestration:

7.Now I will make 2nd node to join as worker

7.1 Install docker in 2nd node.Please follow below note:-

//clouddba.co/docker-concept-part-1-concept-and-installation-of-docker-in-centos/

5.2 Configure docker in 2nd node

[root@debasiseric2 ~]# docker swarm join --token SWMTKN-1-69aokcgwacepwojdrepq25twysj3bptuea3lc2yn6ghfy5f478-bdjnimy0962cmth54vzcb0lu4 172.31.96.15:2377
This node joined a swarm as a worker.
[root@debasiseric2 ~]# docker node ls
Error response from daemon: This node is not a swarm manager. Worker nodes can't be used to view or modify cluster state. Please run this command on a manager node or promote the current node to a manager.
[root@debasiseric1 ~]# docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
qs8cyp1whprtfqikran65p1pj * debasiseric1.mylabserver.com Ready Active Leader 18.03.0-ce
rsux1r0yrm5uageho5wycrilk debasiseric2.mylabserver.com Ready Active 18.03.0-ce

8.Testing how Swarm works

8.1 Please create replica of 2 HTTPD instances to be running from different nodes of Docker

[root@debasiseric1 ~]# docker service create --name bkupweb --publish 80:80 --replicas 2 httpd

overall progress: 2 out of 2 tasks
1/2: running [==================================================>]
2/2: running [==================================================>]
verify: Service converged

8.2 Please check processes running for Docker

[root@debasiseric1 ~]# docker service ps bkupweb
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
2b6jegjjtpx9 bkupweb.1 httpd:latest debasiseric2.mylabserver.com Running Running 35 seconds ago
o4raa6qyt2ll bkupweb.2 httpd:latest debasiseric1.mylabserver.com Running Running 44 seconds ago

0 comments on “DOCKER CONCEPT FOR DBA– PART 5 Installation of Docker Swarm

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>