Sunday, September 01, 2013

Installing Docker.io version 0.6.1 on Centos / Fedora

Docker.io has released 0.6.1 version with the following changelog

If you have already installed docker.io on your centos/rhel system. Just do the upgrade with the following steps

Upgrading from 0.5.3 to 0.6.1

1. Make sure you have enabled hop5.in repository as mentioned in previous post

2. Do a yum upgrade

yum update docker-io

Wednesday, August 21, 2013

Installing docker.io on centos 6.4 (64-bit)

NOTES: epel has another package called docker (which is a KDE docking application and is not related to this). So, you will get an error performing these steps, if you have that package already installed.

UPDATE-1: Docker version-0.6.1 is released. Upgrade instructions are available here

UPDATE-2: Docker version-0.6.2 is released. 

Docker.io is the lightweight "container engine + image repository" built on top of LXC (linux lightweight containers) to ship any application.

At the core of docker.io there are
  1.  an application "/usr/bin/docker" 
  2.  set of pre-created operating-system/application images hosted with "docker.io"
  3.  AUFS (Another Union filesystem) to take care of snapshots, diffs, ro/rw requirements
  4. LXC (Linux lightweight containers)
  5. cgroups (for resource management and namespacing)
As of writing this blog, the latest version is 0.5.3 . The project is actively being developed and things can change in near future.

Follow these instructions to get docker.io installed on your system.

0. Install centos 6.x

1. Disable selinux as it interferes with functionality of LXC

[root@localhost ~]# cat /etc/selinux/config 
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#       enforcing - SELinux security policy is enforced.
#       permissive - SELinux prints warnings instead of enforcing.
#       disabled - SELinux is fully disabled.
SELINUX=disabled
# SELINUXTYPE= type of policy in use. Possible values are:
#       targeted - Only targeted network daemons are protected.
#       strict - Full SELinux protection.
SELINUXTYPE=targeted
2. Download and setup Fedora EPEL Repository

sudo yum install http://ftp.riken.jp/Linux/fedora/epel/6/i386/epel-release-6-8.noarch.rpm

3. Setup hop5.in repository

cd /etc/yum.repos.d
sudo wget http://www.hop5.in/yum/el6/hop5.repo

4. Install docker-io package

[root@localhost ~]# yum install docker-io
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
 * base: centos.excellmedia.net
 * epel: kartolo.sby.datautama.net.id
 * extras: centos.excellmedia.net
 * updates: centos.excellmedia.net
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package docker-io.x86_64 0:0.5.3-4.el6 will be installed
--> Processing Dependency: lxc >= 0.8.0 for package: docker-io-0.5.3-4.el6.x86_64
--> Processing Dependency: kernel-ml-aufs >= 3.10.5 for package: docker-io-0.5.3-4.el6.x86_64
--> Running transaction check
---> Package kernel-ml-aufs.x86_64 0:3.10.5-3.el6 will be installed
---> Package lxc.x86_64 0:0.8.0-3.el6 will be installed
--> Processing Dependency: liblxc.so.0()(64bit) for package: lxc-0.8.0-3.el6.x86_64
--> Running transaction check
---> Package lxc-libs.x86_64 0:0.8.0-3.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

============================================================================================
 Package                   Arch              Version                  Repository       Size
============================================================================================
Installing:
 docker-io                 x86_64            0.5.3-4.el6              hop5            1.2 M
Installing for dependencies:
 kernel-ml-aufs            x86_64            3.10.5-3.el6             hop5             33 M
 lxc                       x86_64            0.8.0-3.el6              hop5             81 k
 lxc-libs                  x86_64            0.8.0-3.el6              hop5             75 k

Transaction Summary
============================================================================================
Install       4 Package(s)

Total download size: 34 M
Installed size: 159 M
Is this ok [y/N]: y
Downloading Packages:
(1/4): docker-io-0.5.3-4.el6.x86_64.rpm                              | 1.2 MB     00:03     
(2/4): kernel-ml-aufs-3.10.5-3.el6.x86_64.rpm                        |  33 MB     00:33     
(3/4): lxc-0.8.0-3.el6.x86_64.rpm                                    |  81 kB     00:00     
(4/4): lxc-libs-0.8.0-3.el6.x86_64.rpm                               |  75 kB     00:00     
--------------------------------------------------------------------------------------------
Total                                                       896 kB/s |  34 MB     00:39     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : lxc-libs-0.8.0-3.el6.x86_64                                              1/4 
  Installing : lxc-0.8.0-3.el6.x86_64                                                   2/4 
  Installing : kernel-ml-aufs-3.10.5-3.el6.x86_64                                       3/4 
  Installing : docker-io-0.5.3-4.el6.x86_64                                             4/4 
  Verifying  : kernel-ml-aufs-3.10.5-3.el6.x86_64                                       1/4 
  Verifying  : lxc-0.8.0-3.el6.x86_64                                                   2/4 
  Verifying  : lxc-libs-0.8.0-3.el6.x86_64                                              3/4 
  Verifying  : docker-io-0.5.3-4.el6.x86_64                                             4/4 

Installed:
  docker-io.x86_64 0:0.5.3-4.el6                                                            

Dependency Installed:
  kernel-ml-aufs.x86_64 0:3.10.5-3.el6               lxc.x86_64 0:0.8.0-3.el6              
  lxc-libs.x86_64 0:0.8.0-3.el6                     

Complete!
[root@localhost ~]#

5. See the package is installed correctly

[root@localhost ~]# docker -h
Usage of docker:
  -D=false: Debug mode
  -H=[unix:///var/run/docker.sock]: tcp://host:port to bind/connect to or unix://path/to/socket to use
  -api-enable-cors=false: Enable CORS requests in the remote api.
  -b="": Attach containers to a pre-existing network bridge. Use 'none' to disable container networking
  -d=false: Daemon mode
  -dns="": Set custom dns servers
  -g="/var/lib/docker": Path to graph storage base dir.
  -p="/var/run/docker.pid": File containing process PID
  -r=false: Restart previously running containers

6. Add cgroup filesystem to /etc/fstab , so that docker will work correctly

[root@localhost ~]# echo "none                    /sys/fs/cgroup          cgroup  defaults        0 0" >> /etc/fstab 
[root@localhost ~]# mount /sys/fs/cgroup

Per "Peter Zimmerman" a reboot is needed to actually mount /sys/fs/cgroup (due to the kernel doesn't have cgroup support). So, the above mount step is not really needed. As its used only upon reboot.

7. Reboot the system ; make sure to select "3.10.5-3.el6.x86_64" kernel version while booting.

8. Once system is up and running, make sure you are on right kernel

[root@localhost ~]# uname -r
3.10.5-3.el6.x86_64

[root@localhost ~]# grep aufs /proc/filesystems 
nodev   aufs
 
9. Start the docker.io in daemon mode (in a different terminal)

[root@localhost ~]# docker -d 
2013/08/21 07:47:07 WARNING: Your kernel does not support cgroup swap limit.
2013/08/21 07:47:07 Listening for HTTP on /var/run/docker.sock (unix)

10. Print hello world from a centos 6.4 container.

[root@localhost ~]# docker run centos:6.4 echo "hello world"
2013/08/21 07:48:41 POST /v1.4/containers/create
2013/08/21 07:48:41 POST /v1.4/containers/c6bc9e80097e/start
2013/08/21 07:48:41 POST /v1.4/containers/c6bc9e80097e/attach?logs=1&stderr=1&stdout=1&stream=1
hello world

11. Ping from inside the container
[root@localhost ~]# docker -dns '8.8.8.8' run centos:6.4 ping -c 3 yahoo.com
2013/08/21 08:02:15 POST /v1.4/containers/create
2013/08/21 08:02:15 POST /v1.4/containers/c40a1244f9bc/start
2013/08/21 08:02:15 POST /v1.4/containers/c40a1244f9bc/attach?logs=1&stderr=1&stdout=1&stream=1
PING yahoo.com (98.138.253.109) 56(84) bytes of data.
64 bytes from ir1.fp.vip.ne1.yahoo.com (98.138.253.109): icmp_seq=1 ttl=48 time=323 ms
64 bytes from ir1.fp.vip.ne1.yahoo.com (98.138.253.109): icmp_seq=2 ttl=48 time=329 ms
64 bytes from ir1.fp.vip.ne1.yahoo.com (98.138.253.109): icmp_seq=3 ttl=49 time=302 ms

--- yahoo.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2304ms
rtt min/avg/max/mdev = 302.032/318.318/329.656/11.807 ms

TROUBLESHOOTING

"DNS/Networking Errors inside the docker"

[root@localhost ~]# docker -dns="8.8.8.8" run centos:6.4 yum install hiphop-php
2013/08/21 07:53:05 POST /v1.4/containers/create
2013/08/21 07:53:05 POST /v1.4/containers/6d9fef14bd1a/start
2013/08/21 07:53:05 POST /v1.4/containers/6d9fef14bd1a/attach?logs=1&stderr=1&stdout=1&stream=1
Loaded plugins: fastestmirror
Error: Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=os error was
14: PYCURL ERROR 6 - "Couldn't resolve host 'mirrorlist.centos.org'"


Please issue the following commands, so that docker and its environment will be reset and above issue will be taken care of.

pkill docker
iptables -t nat -F
ifconfig docker0 down
brctl delbr docker0
docker -d

CREDITS: Thanks to sciurus for doing the hardwork in creating the spec file for kernel-ml-aufs.

Monday, August 19, 2013

Installing Go Lang 1.1 on centos 6.4 *64-bit

UPDATE: 28/Apr/2014 - Golang package is now available on Fedora EPEL Repository. You can just configure EPEL repo and do a "yum install golang".

I have added go-lang package to the current repository. So you can try installing it using the following steps.

1. Install centos 6.x

2. Download and setup Fedora EPEL Repository

sudo yum install http://ftp.riken.jp/Linux/fedora/epel/6/i386/epel-release-6-8.noarch.rpm

(Step-3 not needed, if you are seeing this on Apr/2014)

3. Setup hop5.in repository


cd /etc/yum.repos.d
sudo wget http://www.hop5.in/yum/el6/hop5.repo

4. Install go package

sudo yum install golang

5. Write a simple "hello world" program to get started with go

[nareshv@fallenangel tmp]$ cat hello.go
package main

import "fmt"

func main() {
    fmt.Println("Hello, World.")
}
[nareshv@fallenangel tmp]$ go run hello.go
Hello, World. 

6. Continue exploring go-lang, from here

(Note is not applicable if you are using golang from EPEL Repository)

Note: Please note that, go-lang is compiled without emacs support (to avoid pulling tons of packages) and with gcc-4.6.3.

Monday, July 15, 2013

Installing HHVM (Hiphop PHP) 2.1.0 On Centos 6.x

HHVM 2.1.0 was released a day ago (as of writing this blog).  In order to install this stable version on your server / development environment. Follow these steps

1. Configure the Repository as mentioned in my previous post

2. Upgrade to the latest version

sudo yum update hiphop-php

3. Confirm that the package is installed correctly

/usr/bin/hhvm --help

NOTE: You need to re-build your we-application (if you are using repo-authoritative mode) with the current version and then only upgrade your production server, or else you might not have this application working correctly.

Have fun with this stable version.

Saturday, July 13, 2013

Wednesday, July 10, 2013

Install TokuDB Mysql Server along with Existing mysql-server on Centos/Ubuntu Server

Tokudb has fractal tree engine which is mentioned to perform bettern than innodb in certain instances. In some scenarios you might want to run mysql-server which is patched with tokudb engine along with your current mysql server (for performance testing, evaluation etc).

A straightforward installation will mess up /var/lib/mysql, so follow these instructions to make sure that the server installation doesn't mess up existing installation.

1. Download and unzip the tokudb to /usr/local/

nareshv@fallenangel:~/Downloads$ sudo mv mysql-5.5.30-tokudb-7.0.1-linux-x86_64 /usr/local/
nareshv@fallenangel:/usr/local$ sudo ln -s mysql-5.5.30-tokudb-7.0.1-linux-x86_64 mysql
nareshv@fallenangel:/usr/local$ cd mysql
nareshv@fallenangel:/usr/local/mysql$ ls -l
total 80
drwxrwxr-x  2 nareshv nareshv  4096 Apr 19 04:57 bin
-rw-r--r--  1 nareshv nareshv 17987 Apr 19 03:11 COPYING
drwxrwxr-x  4 nareshv nareshv  4096 Apr 19 04:57 data
drwxrwxr-x  2 nareshv nareshv  4096 Apr 19 04:57 docs
drwxrwxr-x  3 nareshv nareshv  4096 Apr 19 04:57 include
-rw-r--r--  1 nareshv nareshv  7469 Apr 19 03:11 INSTALL-BINARY
drwxrwxr-x  3 nareshv nareshv  4096 Apr 19 04:57 lib
drwxrwxr-x  4 nareshv nareshv  4096 Apr 19 04:57 man
drwxrwxr-x 10 nareshv nareshv  4096 Apr 19 04:57 mysql-test
-rw-r--r--  1 nareshv nareshv  2552 Apr 19 03:11 README
-rw-r--r--  1 nareshv nareshv  3659 Apr 19 04:52 README-TOKUDB
drwxrwxr-x  2 nareshv nareshv  4096 Apr 19 04:57 scripts
drwxrwxr-x 27 nareshv nareshv  4096 Apr 19 04:57 share
drwxrwxr-x  4 nareshv nareshv  4096 Apr 19 04:57 sql-bench
drwxrwxr-x  2 nareshv nareshv  4096 Apr 19 04:57 support-files

2. Install the mysqlserver to /usr/local/mysql (not /var/lib/mysql)

nareshv@fallenangel:/usr/local/mysql$ sudo -u mysql ./scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql
Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/local/mysql/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql/bin/mysqladmin -u root -h fallenangel password 'new-password'

Alternatively you can run:
/usr/local/mysql/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr/local/mysql ; /usr/local/mysql/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/local/mysql/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/local/mysql/scripts/mysqlbug script!

3. Create a new startup script to launch mysqld on port 3307

nareshv@fallenangel:/usr/local/mysql-5.5.30-tokudb-7.0.1-linux-x86_64$ sudo vi run.sh
#!/bin/bash

/usr/bin/env MYSQL_HOME=/usr/local/mysql ./bin/mysqld --user=mysql \
    --pid-file=/usr/local/mysql/mysqld.pid \
    --socket=/usr/local/mysql/mysqld.sock \
    --port=3307 \
    --basedir=/usr/local/mysql \
    --datadir=/usr/local/mysql/data \
    --lc-messages-dir=/usr/local/mysql/share \
    --tmpdir=/tmp \
    --skip-external-locking \
    --bind-address=127.0.0.1 \

nareshv@fallenangel:/usr/local/mysql-5.5.30-tokudb-7.0.1-linux-x86_64$

4. Run the mysql server in another terminal as root user

nareshv@fallenangel:/usr/local/mysql-5.5.30-tokudb-7.0.1-linux-x86_64$ sudo ./run.sh

5. Connect and check if mysql is available on 3307 / 127.0.0.1

nareshv@fallenangel:/usr/local/mysql-5.5.30-tokudb-7.0.1-linux-x86_64$ mysql -u root -h 127.0.0.1 -P 3307
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.30-tokudb-7.0.1 MySQL Community Server (GPL)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)

mysql> quit
Bye

Confirm that variables point to /usr/share/mysql only
mysql> show variables like '%dir%';
+-----------------------------------------+-------------------------------------------------------------------+
| Variable_name                           | Value                                                             |
+-----------------------------------------+-------------------------------------------------------------------+
| basedir                                 | /usr/local/mysql                                                  |
| binlog_direct_non_transactional_updates | OFF                                                               |
| character_sets_dir                      | /usr/local/mysql-5.5.30-tokudb-7.0.1-linux-x86_64/share/charsets/ |
| datadir                                 | /usr/local/mysql/data/                                            |
| innodb_data_home_dir                    | /usr/local/mysql/data                                             |
| innodb_log_group_home_dir               | /usr/local/mysql/data                                             |
| innodb_max_dirty_pages_pct              | 75                                                                |
| lc_messages_dir                         | /usr/local/mysql/share/                                           |
| plugin_dir                              | /usr/local/mysql-5.5.30-tokudb-7.0.1-linux-x86_64/lib/plugin/     |
| slave_load_tmpdir                       | /tmp                                                              |
| tmpdir                                  | /tmp                                                              |
| tokudb_data_dir                         |                                                                   |
| tokudb_directio                         | OFF                                                               |
| tokudb_log_dir                          |                                                                   |
| tokudb_tmp_dir                          |                                                                   |
+-----------------------------------------+-------------------------------------------------------------------+
15 rows in set (0.00 sec)

Friday, May 17, 2013

Install HHVM (Hiphop PHP) on Centos 6.4 (64-bit)

UPDATED: 10/July/2013 - Fixed the errors which are causing repo not available. Sorry for the trouble.

UPDATEd: 19/Oct/2013 - HHVM 2.2.0 Release is available now

UPDATED: 18/Dec/2013 - HHVM 2.3.0 Release is available now  

UPDATED: 14/Apr/2014 - HHVM 3.0.1 Release is available now

I have created a repository and compiled HHVM (v2 of HPHP) rpm packages. Follow these steps to get started.

1. Install Centos 6.x (minimal is preferred)

2. Install epel repository

sudo yum install http://ftp.riken.jp/Linux/fedora/epel/6/i386/epel-release-6-8.noarch.rpm

(or get the latest version from http://ftp.riken.jp/Linux/fedora/epel/6/i386/repoview/epel-release.html)

3. download the hop5 repository configuration file

cd /etc/yum.repos.d

sudo wget http://www.hop5.in/yum/el6/hop5.repo
 
If you are here after Mar-2014, use hhvm as package name instead of hiphop-php

4. Install hiphop-php
sudo yum install hiphop-php

5. Follow the instructions at https://github.com/facebook/hiphop-php to get started


Please note that, i have compiled the required rpms from fedora distribution. DO NOT FILE ANY BUGS WITH CENTOS/FEDORA regarding the rpms that you are about to install from this repoisitory.