Docker basic foundation

Base on CentOS 7, Docker 1.12.6 Install Docker Some pre-requirment to install Docker to a Linux OS. Docker only can be installed on a 64 bit OS. Kernel version over 3.10 is recommended. recommend Need to enable cgroup and namespace. Now it is easier to install Docker in CentOS or Fedora, it can be searched by yum command like below: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 # yum search docker | grep ^docker docker-client.

How to disable IPv6 inside a container/pod in OpenShift

Although the container/pod in OpenShift transfer data by IPv4 protocol, and you do not need to worry about the setting of IPv6. But in some case people want to disable IPv6 inside the container without effecting other container/pods or host OS. Here is an example of the IPv6 info outputed from a container. 1 2 3 4 5 6 7 8 9 10 11 12 13 [[email protected] ~]# oc exec django-ex-4-6gmsj -- ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.

Gluster filename and GFID interconversion

create test file Mount gluster volume and create a file 1 2 3 4 [[email protected] ~]# mount -t glusterfs gluster-node-1:/vol /mnt [[email protected] ~]# mkdir -p /mnt/hoge/hello-gluster/ [[email protected] ~]# touch /mnt/hoge/hello-gluster/file [[email protected] ~]# umount /mnt/ Get GFID of a file in Gluster volume From brick directory Login to gluster node and locate file in brick directory. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 [[email protected] ~]# gluster volume info vol Volume Name: vol Type: Replicate Volume ID: 4ac36bcc-7127-48c4-ac21-421850d8bc47 Status: Started Snapshot Count: 0 Number of Bricks: 1 x 3 = 3 Transport-type: tcp,rdma Bricks: Brick1: gluster-node-1:/gluster/brick-vol <-- confirm the brick path Brick2: gluster-node-2:/gluster/brick-vol Brick3: gluster-node-3:/gluster/brick-vol Options Reconfigured: performance.

AWK - time functions

Apart of date, awk also has below built-in time functions which will help you to resolve time convert problem systime() This will return the current time as the number of seconds since the Epoch (1970-01-01 00:00:00). 1 2 3 4 $ awk 'BEGIN { > print "Number of seconds since the Epoch = " systime() > }' Number of seconds since the Epoch = 1511480989 mktime(YYYY MM DD HH MM SS) This will convert date string “YYYY MM DD HH MM SS” to the number of seconds since the Epoch.

How to check if a disk is SSD or HDD

Linux will detects SSD automatically. Since kernel version 2.6.29, you can check /dev/sda with following command 1 # cat /sys/block/sda/queue/rotational The return number 0 shows you /dev/sda is a SSD, and 1 shows it is a HDD. Note that this command may not work when your disk is created by hardware RAID. Another way is to use lsblk command, a part of the util-linux package. 1 2 3 4 # lsblk -d -o name,rota NAME ROTA sda 0 sdb 1 ROTA means rotational device, 1 for true, 0 for false.

How to sort ps command output

ps command has a --sort option which can help you to sort processes. 1 2 3 4 5 6 7 --sort spec Specify sorting order. Sorting syntax is [+|-]key[,[+|-]key[,...]]. Choose a multi-letter key from the STANDARD FORMAT SPECIFIERS section. The "+" is optional since default direction is increasing numerical or lexicographic order. Identical to k. For example: ps jax --sort=uid,-ppid, +pid Sort ps output by memory From high to low The highest is at the top of the command

Beginner guide of systemd on CentOS7/RHEL7

Introduction of systemd Before CentOS 7 and RHEL 7, System V was used to be the system controller. The system controller can manage all processes, services, and start task. System V has a performance problem as it is using script to manage the tasks. So it can only start the task serially, which will slow down the startup of the system. From CentOS 7, the systemd become the new system

systemctl command return 'Failed to connect to bus: No such file or directory' in a docker container

To enable and start a cron job and a httpd server in a docker container, I tried systemctl command but get an error output like this 1 2 3 4 [[email protected] app]# systemctl status crond Failed to connect to bus: No such file or directory [[email protected] app]# systemctl status httpd Failed to connect to bus: No such file or directory Fix this issue by add --privileged parameter to docker run command

How to change timezone in CentOS 7 or RHEL 7

check the current timezone status 1 2 3 4 5 6 7 8 9 10 [[email protected] ~]# timedatectl Local time: Thu 2017-08-10 05:19:53 UTC Universal time: Thu 2017-08-10 05:19:53 UTC RTC time: Thu 2017-08-10 05:19:52 Time zone: UTC (UTC, +0000) NTP enabled: yes NTP synchronized: yes RTC in local TZ: no DST active: n/a list the avaliable timezones 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 [[email protected] ~]# timedatectl list-timezones Asia/Aden Asia/Almaty Asia/Amman Asia/Anadyr Asia/Aqtau Asia/Aqtobe Asia/Ashgabat .

Desktop Notifier by Python

This article show how to send desktop notice using Python Install requirments we need to install notify2 by pip 1 2 3 4 5 # pip install notify2 Collecting notify2 Downloading notify2-0.3.1-py2.py3-none-any.whl Installing collected packages: notify2 Successfully installed notify2-0.3.1 Coding First we need to import notify2 1 import notify2 Then need to initialise the d-bus connection. D-Bus is a message bus system, a simple way for applications to talk to one another.