Friday, September 06, 2013

Installing Facebook's Hiphop "Kimchi" Release on Centos 6.x , RHEL 6.x

Facebook's hiphop changelog is updated for "Kimchi" release in github with the following list.

"Kimchi" 2-Sep-2013
  - Fix order of custom attributes and visibility in ctor arg promotion
  - Implement CachingIterator
  - Implement RecursiveCachingIterator
  - Generalized heuristic for choosing when to inline in the jit
  - Imported calendar extension
  - Use gcc-4.8.1 by default
  - Improve hhvm commandline parsing logic
  - Fix register_shutdown in session_set_save_handler to match PHP 5.4
  - Add "native" functions for use in Systemlib
  - PHP extension source-compatitblility layer
  - Fix ArrayIterator constructor PHP compatibility
  - Enable building against libmemcached 1.0.8
  - Debugger: $_ not cleared but still printed after exception
  - Fix clone of SplPriorityQueue
  - Debugger: Fix bugs when multiple threads hit the same breakpoint
  - Fix several namespace bugs
  - Several PHP compatibility fixes for ArrayObject and ArrayIterator
  - Fix list assignment with collection literals
  - support "tuple(...)" in initializer expressions
  - HHVM should compile with libmemcached 1.0.9+
  - Support "(new Vector {..})->method()" style syntax
  - use trigger_error in PHP for Redis user errors
  - multiple simplexml fixes
  - fixed serialize/unserialize for SplObjectStorage
  - Implement ReflectionParameter::IsCallable()

I have pushed a new package to the hop5.in repository, Grab the package and test it out.

Major change from packaging point of view is the libmemcached version, which is upgraded to 1.0.16

Follow these steps to upgrade

1. Enable hop5.in repository as mentioned before

2. Do a yum upgrade (or yum install)

yum install hiphop-php-2.1.210.2-1.el6 -y
Resolving Dependencies
--> Running transaction check
---> Package hiphop-php.x86_64 0:2.1.210-4.el6 will be updated
---> Package hiphop-php.x86_64 0:2.1.210.2-1.el6 will be an update
--> Processing Dependency: libmemcached >= 1.0.9 for package: hiphop-php-2.1.210.2-1.el6.x86_64
--> Processing Dependency: libmemcached.so.11()(64bit) for package: hiphop-php-2.1.210.2-1.el6.x86_64
--> Running transaction check
---> Package libmemcached.x86_64 0:0.49-1.el6 will be updated
---> Package libmemcached.x86_64 0:1.0.16-1.el6 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package              Arch           Version                 Repository    Size
================================================================================
Updating:
 hiphop-php           x86_64         2.1.210.2-1.el6         hop5          19 M
Updating for dependencies:
 libmemcached         x86_64         1.0.16-1.el6            hop5         208 k

Transaction Summary
================================================================================
Upgrade       2 Package(s)

Total download size: 19 M
Downloading Packages:
--------------------------------------------------------------------------------
Total                                           777 kB/s |  19 MB     00:24     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating   : libmemcached-1.0.16-1.el6.x86_64                             1/4 
  Updating   : hiphop-php-2.1.210.2-1.el6.x86_64                            2/4 
  Cleanup    : hiphop-php-2.1.210-4.el6.x86_64                              3/4 
  Cleanup    : libmemcached-0.49-1.el6.x86_64                               4/4 
  Verifying  : hiphop-php-2.1.210.2-1.el6.x86_64                            1/4 
  Verifying  : libmemcached-1.0.16-1.el6.x86_64                             2/4 
  Verifying  : hiphop-php-2.1.210-4.el6.x86_64                              3/4 
  Verifying  : libmemcached-0.49-1.el6.x86_64                               4/4 

Updated:
  hiphop-php.x86_64 0:2.1.210.2-1.el6                                           

Dependency Updated:
  libmemcached.x86_64 0:1.0.16-1.el6                                            

Complete!
 
3. See that new package is installed

bash-4.1# rpm -qa | grep hiphop-php
hiphop-php-2.1.210.2-1.el6.x86_64
4. Check the hhvm version details

bash-4.1# /usr/bin/hhvm --version
HipHop VM v2.1.0-dev (rel)
Compiler: heads/master-0-g13ddbb4ec17cffeeaaa83940016e6811cd71b387
Repo schema: a40e2fdb7f3c4700ef306f956630f09cd1ba53e0
bash-4.1# cd /var/www && /usr/bin/hhvm index.php 
Hello world.
5. Have fun!

NOTE: Please be aware that, from facebook's point of view this is just a internal release in the 2.1.0-dev series.

Monday, September 02, 2013

Getting ready for the faster HHVM (hiphop php) version

UPDATE: Now you can install "Kimchi" release as of 6-Sep-2013 

HHVM (hiphop php) is getting ready for a faster version with the following changes

I have built a preview version as of Sep-1-2013, which can be easily installed on your system.

Steps to Upgrade from 2.1.0 on CentOS-6.x / RHEL-6.x


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

2. Update hiphop-php

[nareshv@fallenangel ~]$ sudo yum install hiphop-php-2.1.210.1-1.el6
Total download size: 19 M
Is this ok [y/N]: y
Downloading Packages:
hiphop-php-2.1.210.1-1.el6.x86_64.rpm                                                                                                                                          |  19 MB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating   : hiphop-php-2.1.210.1-1.el6.x86_64   1/2 
  Cleanup    : hiphop-php-2.1.210-4.el6.x86_64     2/2 
  Verifying  : hiphop-php-2.1.210.1-1.el6.x86_64   1/2 
  Verifying  : hiphop-php-2.1.210-4.el6.x86_64     2/2 

Updated:
  hiphop-php.x86_64 0:2.1.210.1-1.el6                                                                                                                                                                 

Complete!


3. Check the version of new Hiphop

[nareshv@fallenangel ~]$ /usr/bin/hhvm --version
HipHop VM v2.1.0-dev (rel)
Compiler: heads/master-0-ged8774975e0c017b8baf09d1547d769b26c5f278
Repo schema: d74c9a7e6b05d0018945a73ae5567bafa294f29d

NOTES:Be sure to test this preview release on your testing environment before using it on production.

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