Wednesday, October 26, 2016

Docker Swarm in CentOS 7, learn by example

Installation

1. Download CentOS 7 Minimal install ISO Image and install it on 5 machines (Could be VMs as well)
2. Set static IP address on all nodes

$cat /etc/sysconfig/network-scripts/ifcfg-ens160
 TYPE=Ethernet
BOOTPROTO=static
IPADDR=192.168.107.140
NETMASK=255.255.250.0
GATEWAY=192.168.104.1
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=ens160
UUID=012345678-2163-4bf8-850d-123456781234
DEVICE=ens160
ONBOOT=yes
3. $ service network restart 
4. $ sysctl -w net.ipv4.ip_forward=1

Install Docker Service on all machines

5. $ curl -sSL https://get.docker.com/ | sh
6. sudo systemctl stop docker

Configure instance

7. Create the directories and configuration files as


$ mkdir -p /etc/systemd/system/docker.service.d/
$ vi /etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=http://myProxy.com:80"
$ sudo systemctl daemon-reload
$ sudo systemctl show --property Environment docker 
 Environment="HTTP_PROXY=http://myProxy.com:80"

vi /etc/systemd/system/docker.service.d/docker.conf
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock
8. Check and validate instance configurations
$ sudo systemctl restart docker
$ sudo docker login
$ sudo docker run hello-world

Machine Configurations and roles


IP Fucntion Description
192.168.107.140Node 01Running containers and storing images
192.168.107.141Node 02Running containers and storing images
192.168.104.236Node 03Running containers and storing images
192.168.107.142Consul 01 & Management 01Consul: Discovery Background, Management: manage and access the Docker Swarm
192.168.104.235Node 04 & Management 02Running containers and storing images, Management: manage and access the Docker Swarm



Consul Instance Configuration

To keep things simple, we run a single consul daemon on the same host as one of the Swarm managers.

Use SSH to connect to the consul0 instance.
 $ ifconfig
From the output, copy the eth0 IP address from inet addr.
Paste the launch command into the command line:
 sysctl -w net.ipv4.ip_forward=1
 $ sudo docker run -d -p 8500:8500 --name=consul progrium/consul -server -bootstrap
Enter docker ps.
From the output, verify that a consul container is running. 

Management Instances Configuration

ssh to manager 01
$ sysctl -w net.ipv4.ip_forward=1
docker run -d -p 4000:4000 swarm manage -H :4000 --replication --advertise 192.168.107.142:4000 consul://192.168.107.142:8500
ssh to manager 02
 $ ifconfig
Start the secondary Swarm manager using following command.
 sysctl -w net.ipv4.ip_forward=1
 $ sudo docker run -d -p 4000:4000 swarm manage -H :4000 --replication --advertise 10.160.104.235:4000 consul://192.168.107.142:8500

Nodes Instances Configuration

Connect to node 1, node 2 and node 3 in turn and join them to the cluster.
 Start a Swarm container each using the following syntax:
 sysctl -w net.ipv4.ip_forward=1
 sudo docker run -d swarm join --advertise=192.168.107.140:2375 consul://192.168.107.142:8500
 sysctl -w net.ipv4.ip_forward=1
 sudo docker run -d swarm join --advertise=192.168.107.141:2375 consul://192.168.107.142:8500

 sysctl -w net.ipv4.ip_forward=1
 sudo docker run -d swarm join --advertise=192.168.104.236:2375 consul://192.168.107.142:8500
 

Test Configuration

Connect to Management 1Check Swarm information using following syntax:$ sudo docker -H :4000 info
Containers: 22
 Running: 6
 Paused: 0
 Stopped: 16
Images: 15
Server Version: swarm/1.2.5
Role: primary
Strategy: spread
Filters: health, port, containerslots, dependency, affinity, constraint
Nodes: 4
 dockerHost: 192.168.107.140:2375
  └ ID: RF2E:R27P:XFWC:2B36:DOYJ:RHRU:EIEF:NCLN:3YBY:HZ7A:RYKW:KMAT
  └ Status: Healthy
  └ Containers: 8 (1 Running, 0 Paused, 7 Stopped)
  └ Reserved CPUs: 0 / 8
  └ Reserved Memory: 0 B / 516.5 GiB
  └ Labels: kernelversion=3.10.0-327.el7.x86_64, operatingsystem=CentOS Linux 7 (Core), storagedriver=devicemapper
  └ UpdatedAt: 2016-10-27T05:07:28Z
  └ ServerVersion: 1.12.2
 localhost.localdomain: 192.168.104.236:2375
  └ ID: SP4D:OVOH:K5SF:BWNL:MRGD:EDZU:HJD6:Y5UX:DUR6:N7YD:LW5R:MTVN
  └ Status: Healthy
  └ Containers: 2 (1 Running, 0 Paused, 1 Stopped)
  └ Reserved CPUs: 0 / 1
  └ Reserved Memory: 0 B / 1.887 GiB
  └ Labels: kernelversion=3.10.0-327.el7.x86_64, operatingsystem=CentOS Linux 7 (Core), storagedriver=devicemapper
  └ UpdatedAt: 2016-10-27T05:07:16Z
  └ ServerVersion: 1.12.2
 localhost.localdomain: 192.168.107.141:2375
  └ ID: FGHH:CCLK:BTJD:PA27:6NMX:K6RQ:3ZPC:SVV4:HWML:HJYQ:MKJY:DHF4
  └ Status: Healthy
  └ Containers: 8 (2 Running, 0 Paused, 6 Stopped)
  └ Reserved CPUs: 0 / 8
  └ Reserved Memory: 0 B / 31.83 GiB
  └ Labels: kernelversion=3.10.0-327.el7.x86_64, operatingsystem=CentOS Linux 7 (Core), storagedriver=devicemapper
  └ UpdatedAt: 2016-10-27T05:07:44Z
  └ ServerVersion: 1.12.2
 localhost.localdomain: 192.168.107.142:2375
  └ ID: BM4X:XGZR:6YA5:WPVA:OKOB:ON76:3KSL:GMGI:ROPV:D2TB:VWCC:BJKB
  └ Status: Healthy
  └ Containers: 4 (2 Running, 0 Paused, 2 Stopped)
  └ Reserved CPUs: 0 / 2
  └ Reserved Memory: 0 B / 1.887 GiB
  └ Labels: kernelversion=3.10.0-327.el7.x86_64, operatingsystem=CentOS Linux 7 (Core), storagedriver=devicemapper
  └ UpdatedAt: 2016-10-27T05:07:30Z
  └ ServerVersion: 1.12.2
Plugins:
 Volume:
 Network:
Swarm:
 NodeID:
 Is Manager: false
 Node Address:
Security Options:
Kernel Version: 3.10.0-327.el7.x86_64
Operating System: linux
Architecture: amd64
CPUs: 19
Total Memory: 552.1 GiB
Name: 95d3e2eac529
Docker Root Dir:
Debug Mode (client): false
Debug Mode (server): false
WARNING: No kernel memory limit support 






Saturday, May 21, 2016

Docker Containers in Windows Server 2016 Pre Release

SQL server Express Example:

Installation:

  1. Download Windows server 2016 ISO image and install inside Virtual Box

2. Install-PackageProvider ContainerImage -Force
Once installed, a list of Base OS images can be returned using Find-ContainerImage.
Find-ContainerImage

Name                           Version          Source           Summary
----                           -------          ------           -------
NanoServer                     10.0.14300.1010  ContainerImag... Container OS Image of Windows Server 2016 Technical...
WindowsServerCore              10.0.14300.1000  ContainerImag... Container OS Image of Windows Server 2016 Technical...
3. Download WindowsServerCore and NanoServer Docker Images
Install-ContainerImage -Name NanoServer
Install-ContainerImage -Name WindowsServerCore
4. Download DockerFile for MS SQL Server Express

wget https://github.com/brogersyh/Dockerfiles-for-windows/archive/master.zip -outfile master.zip

5. Unzip Docker file and build docker image from docker file, this operation would take up to 1 hour.

expand-archive master.zip
cd master\dockerfiles-for-windows-master\sqlexpress

docker build -t sqlexpress .
docker images


6. This example demonstrate running 2 SQL Server Express instances together ruing on ports 1433 and 1434, following command with create firewall exception rules
if (!(Get-NetFirewallRule | where {$_.Name -eq "SQLServer 1433"})) { New-NetFirewallRule -Name "SQL Server 1433" -DisplayName "SQL Server 1433" -Protocol tcp -LocalPort 1433 -Action Allow -Enabled True}

if (!(Get-NetFirewallRule | where {$_.Name -eq "SQLServer 1434"})) { New-NetFirewallRule -Name "SQL Server 1434" -DisplayName "SQL Server 1434" -Protocol tcp -LocalPort 1434 -Action Allow -Enabled True} 

7. Run sqlexpress image on host post 1434 named as sql2
mkdir c:\sql
mkdir c:\sql2 



8. Connect SQL server express from network, this example using SQL Work Bench on a MAC






Tuesday, January 20, 2015

ESX/ESXi Copy Paste not working, ESXi Isolation issue


I several posts and guides I found that there is an issue that seems to be correct configuration of vmx file do not enable copy paste functionality, I finally figured out the issue.

Requirement


Enable Copy ans Paste between Virtual Machine and remote User Machine, given that VM is hosted on VMware ESX/ESXi server.

Even setting following properties in .vmx file it wont enable copy and paste

isolation.tools.copy.disable = "FALSE"
isolation.tools.paste.disable = "FALSE"


Solution

In most of the websites they do not mentioned case sensitivity requirement, for example ESXi 5.5 must required false in lower case, therefore correct property should be

isolation.tools.copy.disable = "false"
isolation.tools.paste.disable = "false"



Monday, January 19, 2015

Access Vmware ESXi guest console without runing vSphere client

There are several reasons to access remote console/desktop ESXi guest virtual machines without running vSphere client software

  1. You do not want keep your ESXi connected to vSphere while accessing a console one, because of security reasons.
  2. vSphere do not allow to get full screen console on secondary monitor.
  3. Access guest console from vSphere client is not a single step operation, and opens multiple application windows 

Depending on your installation of vSphere client your path may deffer, you can create a shortcut of Guest Console by using following command.


Command

C:\Program Files (x86)\Common Files\VMware\VMware VMRC Plug-in\Internet Explorer>vmware-vmrc -X -u root -p rootPassword -h 10.10.10.22:443 -d "[datastore1] Ubuntu 64-bit/ Ubuntu 64-bit.vmx"

Note:
Replace rootPassword with your Esxi root password, if you do not use -u and -p switch, vmware-vmrc pop up a dialog to input credentials.

Replace 10.10.10.22 with your ESXi server IP address 







Wednesday, February 6, 2013

MYSQL Enable Users or Root Remote Access Suse Linux 11.3



All you need to do is update the user table host field with % for which ever user you need to grant remote access permission.

Remember that when you remotely try to connect, if there is no connection, means Firewall or network issue, if there is an access dined error mean you need to follow the below demonstration:


TestManager:~ # mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.1.46-log SUSE MySQL RPM

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use mysql;Database changed
mysql> select host,user from user;
+------------+-----------------+
| host       | user                |
+------------+-----------------+
| %          | root                  |
| %          | super_user     |
| 127.0.0.1  | root             |
| linux-npc5 |                     |
| linux-npc5 | root             |
| localhost  |                      |
| localhost  | asad            |
| localhost  | my_new_username |
| localhost  | root              |
+------------+-----------------+
9 rows in set (0.00 sec)

mysql> update user set host='%' where user='root' and host='linux-npc5';
ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY'
(This error came because I have two records for user root, one is correct one is bad, let delte the bad one)
mysql> delete  from user where user='root' and host='linux-npc5';
Query OK, 1 row affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql>
========================================================================

Testing from Workbench:




Followers

Search This Blog