Download CentOS 7

[1]
This is the configuration Examples for CentOS 7.x that is compatible with Red Hat Enterprise Linux 7.x. CentOS 7 was released on 7 July 2014 and will be supported untill the end of June, 2024.
Download the CentOS 7.3 ISO file for installation from the following site.
Create an Installation disk for CentOS 7
 
After downloading ISO of CentOS 7.x, Burn it to a DVD with an burning application to create an installation disk. If you create it with the function of Windows 7/8/10, refer to follows.
[2]Insert an empty DVD first. Next, click right button of the mouse and select "Burn disk image".
[3]Click "Burn" button and start burning.
[4]After finishing burning, eject the disk and proceed to the installation.

Install CentOS 7

[1]Insert CentOS install disk and start the Computer. Then, Following screen is displayed, Push Enter key to proceed.
[2]Select the language you'd like to use during the installation.
 
[3]This is the default screen for some basic configuration. First, set timezone, click the "DATE&TIME" icon.
 
[4]Click a point on the map you'd like to set your timezone and push "Done" button which is on the upper left.
 
[5]Back to the default screen. Next, click the "KEYBOARD" icon.
 
[6]click "+" button on under-left to add another keyboard type for your language.
 
[7]Select your keyboard type and click "Add" button.
 
[8]After adding keyboard layout, send up your keyboard on the top for 1st priority like follows and click "Done" button which is upper left to finish.
  
[9]Back to the default screen. For "SOFTWARE SELECTION", it's OK to keep default because it had better to install with "Minimal Install" for initial installation. Next, click the "INSTALLATION DESTINATION" icon.
 
[10]Select installation disk. Click the disk icon you'd like to install and next, click "Done" button on upper left to proceed. If you'd like to customize partition layouts, check a box "I will configure partitioning" and proceed.
 
[11]Back to the default screen. click the "NETWORK & HOSTNAME" icon.
 
[12]Input any hostname you like in "Hostname" field and click "ON" button on upper-right to enable networking.
  
[13]Click "Done" button which is upper left to finish.
 
[14]If it's OK all, click "Begin Installation" and proceed to next.
 
[15]Installation starts and required to set root password and to create a common user. Click the each icon and move to configuration.
[16]On the root password settings, input any password you like and click "Done" button to finish as follows.
 
[17]On the common user settings, input any user name and password you like and click "Done" button to finish as follows.
 
[18]After finishing installation, click "Reboot" button.
 
[19]After rebooting, login prompt is shown like follows. login with root user and password you set during installation. Installing CentOS completes if you can login normally.

Docker : Use Docker Swarm


Configure Docker Swarm to create Docker Cluster with multiple Docker nodes.
On this example, Configure Swarm Cluster with 3 Docker nodes like follows.
There are 2 roles on Swarm Cluster, those are [Manager nodes] and [Worker nodes].
This example shows to set those roles like follows.
 -----------+---------------------------+--------------------------+------------
            |                           |                          |
        eth0|10.0.0.51              eth0|10.0.0.52             eth0|10.0.0.53
 +----------+-----------+   +-----------+----------+   +-----------+----------+
 | [ node01.srv.world ] |   | [ node02.srv.world ] |   | [ node03.srv.world ] |
 |       Manager        |   |        Worker        |   |        Worker        |
 +----------------------+   +----------------------+   +----------------------+

[1]Install and run Docker service on all nodes, refer to here.
The Docker version must be up to v1.12. If your Docker is not the version, update Docker with [yum update docker], it's possible to update it from CentOS Extras repository.
[root@node01 ~]# 
docker -v 

Docker version 1.12.6, build 96d83a5/1.12.6
[2]Turn to disable "live-restore" option on all Nodes. (because it can not run with Swarm mode)
[root@node01 ~]# 
vi /etc/docker/daemon.json
{
    "live-restore": false
}

[root@node01 ~]# 
systemctl restart docker 
[3]Configure Swarm Cluster on Manager Node.
[root@node01 ~]# 
docker swarm init 

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

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

    docker swarm join \
    --token SWMTKN-1-1l6o776w0ktvg6vw4cony5et76gkrjzw4xke0cmas3ftl6ghnm-8ppur7wbl9bej6fjcrdtaufsg \
    10.0.0.51:2377

To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
[4]Join in Swarm Cluster on all Worker Nodes.
It's OK to run the command which was shown when running swarm init on Manager Node.
[root@node02 ~]# 
docker swarm join \
--token SWMTKN-1-1l6o776w0ktvg6vw4cony5et76gkrjzw4xke0cmas3ftl6ghnm-8ppur7wbl9bej6fjcrdtaufsg \
10.0.0.51:2377 

This node joined a swarm as a worker.
[5]Verify with a command [node ls] that worker nodes could join in Cluster normally.
[root@node01 ~]# 
docker node ls 

ID                           HOSTNAME          STATUS  AVAILABILITY  MANAGER STATUS
2f7pmmoilf753g7wfctcik7yh *  node01.srv.world  Ready   Active        Leader
6ok99v3dkt9mg4jvzg7qi4zqb    node02.srv.world  Ready   Active
a3dtuaqibnrym3u3wg32cuq7p    node03.srv.world  Ready   Active
[6]
After creating Swarm Cluster, next, configure services that the Swarm Cluster provides.
Create the same container image on all Nodes for the service first.
On this exmaple, use a Container image which provides http service like an example of the link.
[7]Configure service on Manager Node.
After successing to configure service, access to the Manager node's Hostname or IP address to verify it works normally. By the way, requests to worker nodes are load-balanced with round-robin like follows.
[root@node01 ~]# 
docker images 

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
web_server          latest              b7cf7440922c        4 minutes ago       306.4 MB
docker.io/centos    latest              98d35105a391        3 weeks ago         192.5 MB

# create a service with 2 repricas

[root@node01 ~]# 
docker service create --name swarm_cluster --replicas=2 -p 80:80 web_server:latest 

7xg4yssy516xwgkjx2vxbw05d
# show service list

[root@node01 ~]# 
docker service ls 

ID            NAME           REPLICAS  IMAGE              COMMAND
7xg4yssy516x  swarm_cluster  2/2       web_server:latest

# inspect the service

[root@node01 ~]# 
docker service inspect swarm_cluster --pretty 

ID:             7xg4yssy516xwgkjx2vxbw05d
Name:           swarm_cluster
Mode:           Replicated
 Replicas:      2
Placement:
UpdateConfig:
 Parallelism:   1
 On failure:    pause
ContainerSpec:
 Image:         web_server:latest
Resources:
Ports:
 Protocol = tcp
 TargetPort = 80
 PublishedPort = 80

# show service status

[root@node01 ~]# 
docker service ps swarm_cluster 

ID              NAME             IMAGE              NODE              DESIRED STATE  CURRENT STATE               ERROR
78lh8sn1myw...  swarm_cluster.1  web_server:latest  node01.srv.world  Running        Running about a minute ago
4ag74wr59rb...  swarm_cluster.2  web_server:latest  node03.srv.world  Running        Running about a minute ago

# verify it works normally

[root@node01 ~]# 
curl http://node01.srv.world/ 

Docker Node : node03.srv.world
[root@node01 ~]# 
curl http://node01.srv.world/ 

Docker Node : node01.srv.world
[root@node01 ~]# 
curl http://node01.srv.world/ 

Docker Node : node03.srv.world
[root@node01 ~]# 
curl http://node01.srv.world/ 

Docker Node : node01.srv.world
[8]If you'd like to change the number of repricas, configure like follows.
# change repricas to 3

[root@node01 ~]# 
docker service scale swarm_cluster=3 

swarm_cluster scaled to 3
[root@node01 ~]# 
docker service ps swarm_cluster 

ID              NAME             IMAGE              NODE              DESIRED STATE  CURRENT STATE           ERROR
78lh8sn1myw...  swarm_cluster.1  web_server:latest  node01.srv.world  Running        Running 34 minutes ago
4ag74wr59rb...  swarm_cluster.2  web_server:latest  node03.srv.world  Running        Running 34 minutes ago
46ecs1c0tjv...  swarm_cluster.3  web_server:latest  node02.srv.world  Running        Running 13 seconds ago

# verify working

[root@node01 ~]# 
curl http://node01.srv.world/ 

Docker Node : node01.srv.world
[root@node01 ~]# 
curl http://node01.srv.world/ 

Docker Node : node02.srv.world
[root@node01 ~]# 
curl http://node01.srv.world/ 

Docker Node : node03.srv.world

Docker : Use Persistent Storage


When Container is removed, data in it are also lost, so it's necessary to use external filesystem in Container as persistent storage if you need.
[1]For exmaple, create a Container only for using to save data as a storage server with an image busybox.
[root@dlp ~]# 
vi Dockerfile
# create new

FROM busybox
MAINTAINER ServerWorld <admin@srv.world>

VOLUME /storage
CMD /bin/sh

# build image

[root@dlp ~]# 
docker build -t storage .
[root@dlp ~]# 
docker images 

REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
storage             latest              65c5cce81114        20 seconds ago      1.113 MB
docker.io/centos    latest              14dab3d40372        6 days ago          194.7 MB
docker.io/busybox   latest              fc0db02f3072        13 days ago         1.113 MB

# generate a Container with any name you like

[root@dlp ~]# 
docker run -i -t --name storage_server storage 

/ # 
exit
[2]To use the Container above as a Storage Server from other Containers, add an option "--volumes-from".
[root@dlp ~]# 
docker run -i -t --name centos_server --volumes-from storage_server centos /bin/bash
[root@b9b7a2d35b51 /]# 
df -hT 

Filesystem                              Type   Size  Used Avail Use% Mounted on
/dev/mapper/docker-253:0-67164897-..... ext4    99G  266M   94G   1% /
tmpfs                                   tmpfs  2.0G     0  2.0G   0% /dev
shm                                     tmpfs   64M     0   64M   0% /dev/shm
tmpfs                                   tmpfs  2.0G     0  2.0G   0% /sys/fs/cgroup
/dev/mapper/centos-root                 xfs     27G  3.2G   24G  13% /storage
tmpfs                                   tmpfs  2.0G     0  2.0G   0% /run/secrets

[root@b9b7a2d35b51 /]# 
echo "persistent storage" >> /storage/testfile.txt 

[root@b9b7a2d35b51 /]# 
ll /storage 

total 4
-rw-r--r-- 1 root root 19 Dec 22 02:15 testfile.txt
[3]Make sure data are saved to run a Container of Storage Server like follows.
[root@dlp ~]# 
docker start storage_server 

[root@dlp ~]# 
docker attach storage_server 

/ # 
cat /storage/testfile.txt 

persistent storage
[4]For other way to save data in external filesystem, it's possible to mount a directory on Docker Host into Containers.
# create a directory

[root@www ~]# 
mkdir -p /var/docker/disk01 

[root@www ~]# 
echo "persistent storage" >> /var/docker/disk01/testfile.txt
# run a Container with mounting the directory above on /mnt

[root@www ~]# 
docker run -i -t -v /var/docker/disk01:/mnt centos /bin/bash
[root@bc9a4d5578a6 /]# 
df -hT 

Filesystem                              Type   Size  Used Avail Use% Mounted on
/dev/mapper/docker-253:0-67164897-..... ext4    99G  266M   94G   1% /
tmpfs                                   tmpfs  2.0G     0  2.0G   0% /dev
shm                                     tmpfs   64M     0   64M   0% /dev/shm
tmpfs                                   tmpfs  2.0G     0  2.0G   0% /sys/fs/cgroup
/dev/mapper/centos-root                 xfs     27G  3.2G   24G  13% /mnt
tmpfs                                   tmpfs  2.0G     0  2.0G   0% /run/secrets

[root@bc9a4d5578a6 /]# 
cat /mnt/testfile.txt 

persistent storage

Configure SSL


Configure SSL to use secure encrypt connection.
[1]
Create certificates first. See here.
[2]Configure SSL.
[root@www ~]# 
yum -y install mod_ssl
[root@www ~]# 
vi /etc/httpd/conf.d/ssl.conf
# line 59: uncomment

DocumentRoot "/var/www/html"
# line 60: uncomment and specify the server name

ServerName 
www.srv.world:443
# line 75: change

SSLProtocol 
-All +TLSv1 +TLSv1.1 +TLSv1.2
# line 100: change to the one created in [1]

SSLCertificateFile 
/etc/pki/tls/certs/server.crt
# line 107: change to the one created in [1]

SSLCertificateKeyFile 
/etc/pki/tls/certs/server.key
[root@www ~]# 
systemctl restart httpd 
[3]If Firewalld is running, allow HTTPS service. HTTPS uses 443/TCP.
[root@www ~]# 
firewall-cmd --add-service=https --permanent 

success
[root@www ~]# 
firewall-cmd --reload 

success
[4]Access to the test page from a client computer with a Web browser via HTTPS. The example below is the Fiorefix. Following screen is shown because Certificates is own created one, but it's no ploblem, Proceed to next.
[5]Just accessed.

Install Apache httpd

 
Install httpd to configure Web Server. HTTP uses 80/TCP.
[1]Install httpd.
[root@www ~]# 
yum -y install httpd
# remove welcome page

[root@www ~]# 
rm -f /etc/httpd/conf.d/welcome.conf
[2]Configure httpd. Replace server name to your own environment.
[root@www ~]# 
vi /etc/httpd/conf/httpd.conf
# line 86: change to admin's email address

ServerAdmin 
root@srv.world
# line 95: change to your server's name

ServerName 
www.srv.world:80
# line 151: change

AllowOverride 
All
# line 164: add file name that it can access only with directory's name

DirectoryIndex index.html 
index.cgi index.php
# add follows to the end

# server's response header

ServerTokens Prod
# keepalive is ON

KeepAlive On
[root@www ~]# 
systemctl start httpd 

[root@www ~]# 
systemctl enable httpd 
[3]If Firewalld is running, allow HTTP service. HTTP uses 80/TCP.
[root@www ~]# 
firewall-cmd --add-service=http --permanent 

success
[root@www ~]# 
firewall-cmd --reload 

success
[4]Create a HTML test page and access to it from client PC with web browser. It's OK if following page is shown.
[root@www ~]# 
vi /var/www/html/index.html
<html>
<body>
<div style="width: 100%; font-size: 40px; font-weight: bold; text-align: center;">
Test Page
</div>
</body>
</html>