Monday, March 30, 2015

Linux : Install docker-io

Red Hat 6.6

Download the following rpm from http://dl.fedoraproject.org/pub/epel/6/x86_64/repoview/

docker-io-1.4.1-3.el6.x86_64.rpm
lua-lxc-1.0.7-1.el6.x86_64.rpm
lua-alt-getopt-0.7.0-1.el6.noarch.rpm
lxc-1.0.7-1.el6.x86_64.rpm
lua-filesystem-1.4.2-1.el6.x86_64.rpm
lxc-libs-1.0.7-1.el6.x86_64.rpm


# rpm -Uvh *.rpm
warning: docker-io-1.4.1-3.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Preparing...                ########################################### [100%]
   1:lxc-libs               ########################################### [ 17%]
   2:lua-filesystem         ########################################### [ 33%]
   3:lua-lxc                ########################################### [ 50%]
   4:lua-alt-getopt         ########################################### [ 67%]
   5:lxc                    ########################################### [ 83%]
   6:docker-io              ########################################### [100%]

# chkconfig --list docker
docker          0:off   1:off   2:on    3:on    4:on    5:on    6:off

# service docker start
Starting cgconfig service:                                 [  OK  ]
Starting docker:                                           [  OK  ]

https://access.redhat.com/articles/881893
http://developerblog.redhat.com/2014/05/15/practical-introduction-to-docker-containers/

Docker has an official CentOS 6 repository which they support:

Download the docker image zip file manually

# cat centos-7-20150304_1234-docker.tar.xz | docker import - centos7:base
f4f6169a4b1175b2ed2f9c9f95369f8eec04b28c41b946280f45205e58bc7c05
# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
centos7             base                f4f6169a4b11        14 seconds ago      210 MB


Create docker image from my own system 
  1. Create the tar files for your file system, simply could be
    tar --numeric-owner --exclude=/proc --exclude=/sys -cvf centos6-base.tar /
    
  2. Transfer the tar file to other docker system if not installed locally and import it
    cat centos6-base.tar | docker import - centos6-base
    
  3. Now you can verify by running it.
    docker run -i -t centos6-base cat /etc/redhat-release 
     
     
    
    
    tar --numeric-owner --exclude=/proc --exclude=/sys --exclude=/root \
    --exclude=/var --exclude=/home --exclude=/docker --exclude=/tmp \
    -cvf centos6-base.tar /
    
    
    cat centos6-base.tar | docker import - centos6-base
    500e53a55f35cb64724a544b6b94d2db9629f9910564a3611ab106b78b7fd62f
     
    docker images
    REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
    centos6-base        latest              500e53a55f35        53 seconds ago      2.621 GB
     

Friday, March 6, 2015

Python script for multipath configuration creation

import os
A = []
B = []
C = 0
LUNPATH = set()
M_LUNPATH = set()
HOST_DEVICE = set()
HOST_DEVICE_LIST = []
HOST_STRING = "Host Device:"
HOST_LUN = {}
p = os.popen('sanlun lun show all', "r")
while 1:
        line = p.readline()
        if not line: break
        #print line
        A = line.split()
        #print len(A)
        if len(A) > 2 :
                controller = A[0]
                lunpathname = A[1]
                print lunpathname, controller
                if lunpathname == "device": continue
                if lunpathname == "lun-pathname": continue
                LUNPATH.add(lunpathname)

                p2 = os.popen('sanlun lun show -p '+controller+":"+lunpathname, "r")
                while 1:
                        line2 = p2.readline()
                        if not line2: break
                        if line2.find(HOST_STRING) != -1 :
                                print line2
                                B = line2.split()
                                print len(B)
                                C = len(B)-1
                                print B[C]
                                HOST_DEVICE.add(B[C])
                                #HOST_DEVICE_LIST.append(B[C])
                                HOST_LUN.update( {B[C]:lunpathname} )



print LUNPATH
for i in LUNPATH:
        # print i
        i = i.replace("/vol/","") # get rid of /vol/
        i = i.replace("/","_") # replace / with _
        M_LUNPATH.add(i)

for i in M_LUNPATH:
        print i

#HOST_DEVICE_LIST.sort()

#for i in HOST_DEVICE_LIST:
#       print i
#       HOST_DEVICE.add(i)

for i in HOST_DEVICE:
        print i

print HOST_LUN

print "mpathconf --enable --with_multipathd y"
print "multipaths {"
for i in HOST_DEVICE:
        #print i
        #print HOST_LUN.get(i)
        j = HOST_LUN.get(i)
        j = j.replace("/vol/","") # get rid of /vol/
        j = j.replace("/","_") # replace / with _
        print "         multipath {"
        print "                 wwid    " + i
        print "                 alias   " + j
        print "         }"

print "}"

print "service multipathd reload"

Tuesday, March 3, 2015

Linux : dmidecoe command

In a physical server :
# dmidecode -s system-manufacturer
Hewlett-Packard

In a VM :
# dmidecode -s system-manufacturer
VMware, Inc.

When calling HP support, to provide serial number :
dmidecode -s chassis-serial-number