Setup Docker Swarm in Ubuntu

Ok let me drop down what i did here to setup this docker swarm without repeating since i have been very indecisive on whether to deploy multi-host docker swarm or just single location with fail over between multiple machines. In the end, i stick with single region and expand from here if needed.

Machines Setup

Installing Dockers

throw these in each machine

sudo apt-get install     apt-transport-https     ca-certificates     curl     software-properties-common -y
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository    "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt-get update
sudo apt-get install docker-ce -y

doing this gives us the latest docker setup

Installing Docker Swarm

Now i need to setup docker swarm, its pretty straight forward with the following command on the master machine

docker swarm init --advertise-addr 192.168.10.10

then on other worker machine do the following to add them into swarm,

docker swarm join --token secret-token 192.168.10.10:2377

replace your secret-token with the real deal. Now i'm gonna secret our network a bit with overlay with the name overnet

docker network create  --opt encrypted --driver overlay --attachable overnet

this doesn't make you feel any differences but it creates an overlay network between each node in the swarm.

Installing reverse proxy for docker swarm

now i need to create a reverse proxy for my docker swarm since i wants to do a lot with it.

docker service create \
--name traefik \
--constraint=node.role==manager \
--publish 80:80 \
--publish 8080:8080 \
--mount type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock \
--network overnet\
traefik:latest \
--docker \
--docker.swarmmode \
--docker.domain=traefik \
--docker.watch \
--web

for more information on this, you can visit traefik web page for more information on its configuration.

cPanel Webmail inbox disappear but are still visible in /cur

This is an interesting issue with cPanel recently faced by one of my clients. Searching on the internet brings me to an article in cPanel forum where someone else happens to also face such an issue. The solution is pretty straight forward firing the below command with the email affected.

 doveadm force-resync -u [email protected] INBOX

It seems like the inbox just needed a re-sync rather than the user third party email got deleted. This guy definitely save my ass!

Dell Powerconnect 6224 connect to serial port

Firstly you need a server/computer with a serial port. Next just fire the following command after you've connected your serial port into your machine.

screen /dev/ttyS0 19200

And it should show you your console. If it doesn't, restart your switch or just check your cable!

Find out more setting on its user guide.

cman gets stucked on unmounting configfs

well, once again i got stuck when my cluster suddenly doesn't work and i need to figure out why without restarting my server. restarting cman always throw me a stuck "Unmounting configfs..."

/etc/init.d/cman restart
Stopping cluster:
   Stopping dlm_controld... [  OK  ]
   Stopping fenced... [  OK  ]
   Stopping cman... [  OK  ]
   Unloading kernel modules... [  OK  ]
   Unmounting configfs...

running service cman status i get the following

service cman status
Found stale pid file

now i tried to stop all services that may caused this but apparently it was because the cluster is still running, hence, it wasn't able to unmount configfs

/etc/init.d/pve-cluster stop

once i've stopped my pve cluster. i tried restarting cman again

/etc/init.d/cman restart
Stopping cluster:
   Stopping dlm_controld... [  OK  ]
   Stopping fenced... [  OK  ]
   Stopping cman... [  OK  ]
   Unloading kernel modules... [  OK  ]
   Unmounting configfs... [  OK  ]
Starting cluster:
   Checking if cluster has been disabled at boot... [  OK  ]
   Checking Network Manager... [  OK  ]
   Global setup... [  OK  ]
   Loading kernel modules... [  OK  ]
   Mounting configfs... [  OK  ]
   Starting cman... [  OK  ]
   Waiting for quorum... [  OK  ]
   Starting fenced... [  OK  ]
   Starting dlm_controld... [  OK  ]
   Tuning DLM kernel config... [  OK  ]
   Unfencing self... [  OK  ]

now my cman starts running again i can start my cluster again

/etc/init.d/pve-cluster restart
Restarting pve cluster filesystem: pve-cluster.

just to make sure everything works, you can run the following

service cman status
cluster is running.

now i don't have to restart my server in order to get my cluster running again. Hope this helps!

SMTP Auth – SMTP Relay

If you are getting an error with the following error

SMTP error from remote mail server after RCPT TO:<admin @domain.com>: 550 smtp auth requried

from the script that is running on your server but the domain.com isn't locate on the same physical machine. You are most likely doing a SMTP Relay and your exim isn't really happy with not having authentication credential being provided.

In this case, you can just add the following to your exim.conf file, assuming 123.123.123.123 is your script server,

domainlist local_domains = dsearch;/etc/exim4/domains/
domainlist relay_to_domains = dsearch;/etc/exim4/domains/
hostlist relay_from_hosts = 127.0.0.1 : 123.123.123.123
hostlist whitelist = net-iplsearch;/etc/exim4/white-blocks.conf
hostlist spammers = net-iplsearch;/etc/exim4/spam-blocks.conf

you can also placed 123.123.123.123 into the file /etc/exim4/white-blocks.conf to whitelist the host on your server.

you might also need to add auth_advertise_hosts = * as show below,

host_lookup = *
auth_advertise_hosts = 123.123.123.123
rfc1413_hosts = *

which expand to all host other than localhost (of course, you might want to change it to ip instead of *)

this should allows your script to sent email using your smtp server as a relay without the need for authentication.