Monday, April 14, 2014

Installing HHVM 3.0.1 on Centos 6.5 (64-bit)

3.0.0 is the latest series in the HHVM world. In order to upgrade/install the 3.0.1 package. Follow these instructions

Compared to 2.4 HHVM release, the following packages were upgraded from the stock centos repository. Please be aware of these.

  1. ocaml (from 3.11 to 3.12)
  2. ImageMagick (from 6.5 to 6.8)

If you are here for the first time, configure hop5.in repo like this

 
cd /etc/yum.repos.d
sudo wget http://www.hop5.in/yum/el6/hop5.repo 
After that do a simple

[root@node1 ~]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: base elrepo epel extras hop5 mod-pagespeed nginx nikoforge pgdg92 rpmforge rpmforge-extras
              : rpmfusion-free-updates rpmfusion-nonfree-updates updates
Cleaning up Everything
Cleaning up list of fastest mirrors
 
[root@node1 ~]# yum install hhvm
Loaded plugins: fastestmirror
Determining fastest mirrors
epel/metalink                                                                                           |  14 kB     00:00
 * base: mirrors.advancedhosters.com
 * elrepo: ftp.nluug.nl
 * epel: epel.mirror.constant.com
 * extras: mirrors.lga7.us.voxel.net
 * rpmforge: mirror.nl.leaseweb.net
 * rpmforge-extras: mirror.nl.leaseweb.net
 * rpmfusion-free-updates: mirror.us.leaseweb.net
 * rpmfusion-nonfree-updates: mirror.us.leaseweb.net
 * updates: mirror.lug.udel.edu
base                                                                           | 3.7 kB     00:00
base/primary_db                                                                | 4.4 MB     00:01
elrepo                                                                         | 2.9 kB     00:00
elrepo/primary_db                                                              | 625 kB     00:00
epel                                                                           | 4.4 kB     00:00
epel/primary_db                                                                | 6.0 MB     00:01
extras                                                                         | 3.4 kB     00:00
extras/primary_db                                                              |  19 kB     00:00
hop5                                                                           | 2.9 kB     00:00
hop5/primary_db                                                                | 153 kB     00:00
mod-pagespeed                                                                  |  951 B     00:00
mod-pagespeed/primary                                                          | 5.1 kB     00:00
mod-pagespeed                                                                  32/32
nginx                                                                          | 2.9 kB     00:00
nginx/primary_db                                                               |  28 kB     00:00
nikoforge                                                                      | 1.3 kB     00:00
nikoforge/primary                                                              | 3.8 kB     00:00
nikoforge                                                                      8/8
pgdg92                                                                         | 3.7 kB     00:00
pgdg92/primary_db                                                              | 102 kB     00:00
rpmforge                                                                       | 1.9 kB     00:00
rpmforge/primary_db                                                            | 2.7 MB     00:00
rpmforge-extras                                                                | 1.9 kB     00:00
rpmforge-extras/primary_db                                                     | 471 kB     00:00
rpmfusion-free-updates                                                         | 2.7 kB     00:00
rpmfusion-free-updates/primary_db                                              | 267 kB     00:00
rpmfusion-nonfree-updates                                                      | 2.2 kB     00:00
rpmfusion-nonfree-updates/primary_db                                           |  65 kB     00:00
updates                                                                        | 3.4 kB     00:00
updates/primary_db                                                             | 2.6 MB     00:01
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package hhvm.x86_64 0:2.4.0-1.el6 will be updated
---> Package hhvm.x86_64 0:3.0.1-1.el6 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================
 Package                    Arch                         Version                              Repository                  Size
===============================================================================================================================
Updating:
 hhvm                       x86_64                       3.0.1-1.el6                          hop5                       9.4 M

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

Total download size: 9.4 M
Is this ok [y/N]: y
Downloading Packages:
hhvm-3.0.1-1.el6.x86_64.rpm                                                                             | 9.4 MB     00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating   : hhvm-3.0.1-1.el6.x86_64                                                                                     1/2
  Cleanup    : hhvm-2.4.0-1.el6.x86_64                                                                                     2/2
  Verifying  : hhvm-3.0.1-1.el6.x86_64                                                                                     1/2
  Verifying  : hhvm-2.4.0-1.el6.x86_64                                                                                     2/2

Updated:
  hhvm.x86_64 0:3.0.1-1.el6

Complete!
[root@node1 ~]#  
If you are upgrading from previous hiphop-php Package, Just do a
[root@node1 ~]# yum update hiphop-php

After this, check that hhvm is installed correctly

[root@node1 ~]# hhvm --version
HipHop VM 3.0.1 (rel)
Compiler: 
Repo schema: e69de29bb2d1d6434b8b29ae775ad8c2e48c5391

Have fun with this new and improved release.


Tuesday, March 18, 2014

AtomSQL - Simple Database Query Language for RDBMS & NoSQL Systems

AtomSQL came from the frustration of working too much with RDBMS systems and typing too much to get the necessary data from the Databases.

This post is an introduction to AtomSQL

Lets go through the following examples to see how we use SQL queries normally and in AtomSQL Format.

1. Create a new table

BEFORE:
CREATE TABLE myTable (id INTEGER PRIMARYKEY, name VARCHAR(255) ENGINE=INNODB


AFTER:

myTable { id INTEGER PRIMARY KEY, name VARCHAR(255) } ENGINE=INNODB


So, what has changed ???

We just got rid of the keywords and are letting the {} do the necessary JOB.

TIP: Remember C/C++ Structures ?

2. Inserting new records to the table

Before:

INSERT INTO myTable VALUES (1, 'Tom'), (2, 'Jerry')


After:

myTable = [ (1, 'Tom'), (2, 'Jerry') ]


Again, We use () for Tuples and [] for Array representation to get the job done. Keywords have gone away !
TIP: Remember JSON, Perl Arrays ?

3. Updating records

Before

UPDATE myTable SET name = 'Jerry Mouse' Where name = 'Jerry'


After

myTable /name = 'Jerry Mouse'/ (name = 'Jerry')


Again, we are using // for replacing data and () are used for condition to be used in WHERE Clause
TIP: Remember perl, sed, vim for data replacement ?

4. Deleting records

Before

DELETE FROM myTable Where name = 'Jerry'


After

! myTable (name = 'Jerry')


! Bang is the operator for destroying stuff. () is used for WHERE Clause

5. Seleting Records

Before

SELECT * from myTable where name != 'Jerry'


After

myTable <*> (name != 'Jerry')


<> is used for Column selection and () is used for WHERE clause

More Features/Limitations/Installation can be read from http://nareshv.github.io/atomsql/

Tuesday, February 11, 2014

Configure HHVM with Apache + FastCGI on Centos 6.5

On centos you can run regular fastcgi processes with mod_fcgid package. In order to communicate with HHVM over TCP/IP you need to install mod_fastcgi which is available elsewhere on the internet.

 Follow these instructions to use apache + fastcgi with hhvm.

0. Pre-requisites

Make sure you add the following to /etc/hosts on your server where you are going to use curl/browser

127.0.0.1 test.example.com

1. Install httpd-devel packages

[root@localhost yum.repos.d]# yum install httpd-devel -y

2. Download mod_fastcgi

 [root@localhost ~]# wget http://www.fastcgi.com/dist/mod_fastcgi-SNAP-0910052141.tar.gz

3. Compile and install mod_fastcgi

Make sure to change the top_dir variable in the Makefile to centos specific like below or else package wont compile

top_dir      = /usr/lib64/httpd

[root@localhost ~]# tar zxf mod_fastcgi-SNAP-0910052141.tar.gz 
[root@localhost ~]# cd mod_fastcgi-SNAP-0910052141
[root@localhost mod_fastcgi-SNAP-0910052141]# cp Makefile.AP2 Makefile
[root@localhost mod_fastcgi-SNAP-0910052141]# make
[root@localhost mod_fastcgi-SNAP-0910052141]# make install

4. Start the hhvm server in fastcgi mode

[root@localhost ~]# /usr/bin/hhvm --mode server -vServer.Port=9000 -vServer.Type=fastcgi 
mapping self...
mapping self took 0'00" (34658 us) wall time
loading static content...
loading static content took 0'00" (3 us) wall time
page server started
all servers started

5. Create a dummy apache configuration file

[root@localhost ~]# cat /etc/httpd/conf.d/1.conf 

    ServerName test.example.com
    DocumentRoot /var/www/localhost
    LoadModule fastcgi_module modules/mod_fastcgi.so
    FastCgiExternalServer /var/www/localhost -host 127.0.0.1:9000

[root@localhost ~]# 

6. Create document root and simple php file

mkdir -p /var/www/localhost && echo '<?php echo "hello world"; ?>' > /var/www/localhost/index.php

7. Start httpd from another terminal

[root@localhost ~]# service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName
                                                           [  OK  ]
8. Fire a request and see that you get response from HHVM
 nareshv @ localhost $ curl http://test.example.com/index.php ; echo
hello world!
 nareshv @ localhost $
 nareshv @ localhost $ curl http://test.example.com/404.php ; echo
Not Found
 nareshv @ localhost $

9. Final configurations

Once you have proper working setup like above, create a configuration file for hhvm and run it in daemon mode.

Have Fun!

Monday, February 10, 2014

Installing docker 0.8 version on Centos 6.5

1. Configure EPEL Repository
[root@localhost ~]# sudo yum install http://ftp.riken.jp/Linux/fedora/epel/6/i386/epel-release-6-8.noarch.rpm
Loaded plugins: fastestmirror
Determining fastest mirrors
 * base: centos.aol.in
 * extras: centos.aol.in
 * updates: centos.aol.in
Setting up Install Process
epel-release-6-8.noarch.rpm                                                                    |  14 kB     00:00     
Examining /var/tmp/yum-root-7UK58w/epel-release-6-8.noarch.rpm: epel-release-6-8.noarch
Marking /var/tmp/yum-root-7UK58w/epel-release-6-8.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:6-8 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================
 Package                     Arch                  Version              Repository                               Size
======================================================================================================================
Installing:
 epel-release                noarch                6-8                  /epel-release-6-8.noarch                 22 k

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

Total size: 22 k
Installed size: 22 k
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : epel-release-6-8.noarch                                                                            1/1 
  Verifying  : epel-release-6-8.noarch                                                                            1/1 

Installed:
  epel-release.noarch 0:6-8                                                                                           

Complete!

2. Install the docker-io package from EPEL Repository
[root@localhost ~]# yum install docker-io
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
epel/metalink                                                                                  | 4.6 kB     00:00     
 * base: centos.aol.in
 * epel: epel.mirror.net.in
 * extras: centos.aol.in
 * updates: centos.aol.in
epel                                                                                           | 4.2 kB     00:00     
epel/primary_db                                                                                | 5.9 MB     00:06     
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package docker-io.x86_64 0:0.7.6-2.el6 will be installed
--> Processing Dependency: xz for package: docker-io-0.7.6-2.el6.x86_64
--> Processing Dependency: lxc for package: docker-io-0.7.6-2.el6.x86_64
--> Processing Dependency: libcgroup for package: docker-io-0.7.6-2.el6.x86_64
--> Running transaction check
---> Package libcgroup.x86_64 0:0.40.rc1-5.el6_5.1 will be installed
---> Package lxc.x86_64 0:0.9.0-2.el6 will be installed
--> Processing Dependency: liblxc.so.0()(64bit) for package: lxc-0.9.0-2.el6.x86_64
---> Package xz.x86_64 0:4.999.9-0.3.beta.20091007git.el6 will be installed
--> Running transaction check
---> Package lxc-libs.x86_64 0:0.9.0-2.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================
 Package                Arch                Version                                        Repository            Size
======================================================================================================================
Installing:
 docker-io              x86_64              0.7.6-2.el6                                    epel                 3.4 M
Installing for dependencies:
 libcgroup              x86_64              0.40.rc1-5.el6_5.1                             updates              125 k
 lxc                    x86_64              0.9.0-2.el6                                    epel                  78 k
 lxc-libs               x86_64              0.9.0-2.el6                                    epel                 116 k
 xz                     x86_64              4.999.9-0.3.beta.20091007git.el6               base                 137 k

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

Total download size: 3.9 M
Installed size: 19 M
Is this ok [y/N]: y
Downloading Packages:
(1/5): docker-io-0.7.6-2.el6.x86_64.rpm                                                        | 3.4 MB     00:03     
(2/5): libcgroup-0.40.rc1-5.el6_5.1.x86_64.rpm                                                 | 125 kB     00:00     
(3/5): lxc-0.9.0-2.el6.x86_64.rpm                                                              |  78 kB     00:00     
(4/5): lxc-libs-0.9.0-2.el6.x86_64.rpm                                                         | 116 kB     00:00     
(5/5): xz-4.999.9-0.3.beta.20091007git.el6.x86_64.rpm                                          | 137 kB     00:00     
----------------------------------------------------------------------------------------------------------------------
Total                                                                                 858 kB/s | 3.9 MB     00:04     
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
Importing GPG key 0x0608B895:
 Userid : EPEL (6) 
 Package: epel-release-6-8.noarch (@/epel-release-6-8.noarch)
 From   : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
Is this ok [y/N]: y
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Importing GPG key 0xC105B9DE:
 Userid : CentOS-6 Key (CentOS 6 Official Signing Key) 
 Package: centos-release-6-5.el6.centos.11.1.x86_64 (@anaconda-CentOS-201311272149.x86_64/6.5)
 From   : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : libcgroup-0.40.rc1-5.el6_5.1.x86_64                                                                1/5 
  Installing : xz-4.999.9-0.3.beta.20091007git.el6.x86_64                                                         2/5 
  Installing : lxc-libs-0.9.0-2.el6.x86_64                                                                        3/5 
  Installing : lxc-0.9.0-2.el6.x86_64                                                                             4/5 
  Installing : docker-io-0.7.6-2.el6.x86_64                                                                       5/5 
  Verifying  : lxc-libs-0.9.0-2.el6.x86_64                                                                        1/5 
  Verifying  : xz-4.999.9-0.3.beta.20091007git.el6.x86_64                                                         2/5 
  Verifying  : docker-io-0.7.6-2.el6.x86_64                                                                       3/5 
  Verifying  : libcgroup-0.40.rc1-5.el6_5.1.x86_64                                                                4/5 
  Verifying  : lxc-0.9.0-2.el6.x86_64                                                                             5/5 

Installed:
  docker-io.x86_64 0:0.7.6-2.el6                                                                                      

Dependency Installed:
  libcgroup.x86_64 0:0.40.rc1-5.el6_5.1             lxc.x86_64 0:0.9.0-2.el6      lxc-libs.x86_64 0:0.9.0-2.el6     
  xz.x86_64 0:4.999.9-0.3.beta.20091007git.el6     

Complete!
[root@localhost ~]# 

3. For the brave, start the docker and see these warnings
[root@localhost ~]# docker -d &
[1] 1145
[root@localhost ~]# 2014/02/10 03:23:29 WARNING: You are running linux kernel version 2.6.32-431.el6.x86_64, which might be unstable running docker. Please upgrade your kernel to 3.8.0.
[/var/lib/docker|c3648251] +job initapi()
[/var/lib/docker|c3648251.initapi()] Creating server

Docker will continue to run. But, better upgrade to kernel 3.8 or higher. 4. Configure the elrepo repository so that we can upgrade kernel to 3.8 or higher
[root@localhost ~]# yum install http://www.elrepo.org/elrepo-release-6-5.el6.elrepo.noarch.rpm
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.aol.in
 * epel: epel.mirror.net.in
 * extras: centos.aol.in
 * updates: centos.aol.in
Setting up Install Process
elrepo-release-6-5.el6.elrepo.noarch.rpm                                                       | 7.2 kB     00:00     
Examining /var/tmp/yum-root-7UK58w/elrepo-release-6-5.el6.elrepo.noarch.rpm: elrepo-release-6-5.el6.elrepo.noarch
Marking /var/tmp/yum-root-7UK58w/elrepo-release-6-5.el6.elrepo.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package elrepo-release.noarch 0:6-5.el6.elrepo will be installed
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================
 Package                 Arch            Version                 Repository                                      Size
======================================================================================================================
Installing:
 elrepo-release          noarch          6-5.el6.elrepo          /elrepo-release-6-5.el6.elrepo.noarch          2.8 k

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

Total size: 2.8 k
Installed size: 2.8 k
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : elrepo-release-6-5.el6.elrepo.noarch                                                               1/1 
  Verifying  : elrepo-release-6-5.el6.elrepo.noarch                                                               1/1 

Installed:
  elrepo-release.noarch 0:6-5.el6.elrepo                                                                              

Complete!
5. Install the kernel-ml from elrepo
[root@localhost ~]# yum --enablerepo=elrepo-kernel install kernel-ml
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.aol.in
 * elrepo: mirror.smartmedia.net.id
 * elrepo-kernel: mirror.smartmedia.net.id
 * epel: epel.mirror.net.in
 * extras: centos.aol.in
 * updates: centos.aol.in
elrepo                                                                                         | 2.9 kB     00:00     
elrepo/primary_db                                                                              | 593 kB     00:02     
elrepo-kernel                                                                                  | 2.9 kB     00:00     
elrepo-kernel/primary_db                                                                       |  19 kB     00:00     
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package kernel-ml.x86_64 0:3.13.2-1.el6.elrepo will be installed
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================
 Package                  Arch                  Version                            Repository                    Size
======================================================================================================================
Installing:
 kernel-ml                x86_64                3.13.2-1.el6.elrepo                elrepo-kernel                 35 M

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

Total download size: 35 M
Installed size: 159 M
Is this ok [y/N]: y
Downloading Packages:
kernel-ml-3.13.2-1.el6.elrepo.x86_64.rpm                                                       |  35 MB     02:21     
warning: rpmts_HdrFromFdno: Header V4 DSA/SHA1 Signature, key ID baadae52: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
Importing GPG key 0xBAADAE52:
 Userid : elrepo.org (RPM Signing Key for elrepo.org) 
 Package: elrepo-release-6-5.el6.elrepo.noarch (@/elrepo-release-6-5.el6.elrepo.noarch)
 From   : /etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : kernel-ml-3.13.2-1.el6.elrepo.x86_64                                                               1/1 
  Verifying  : kernel-ml-3.13.2-1.el6.elrepo.x86_64                                                               1/1 

Installed:
  kernel-ml.x86_64 0:3.13.2-1.el6.elrepo                                                                              

Complete!
[root@localhost ~]# 
6. Reboot the server into the 3.13 kernel (MAKE SURE TO SELECT KERNEL IN GRUB MENU)
[root@localhost ~]# reboot

Broadcast message from root@localhost.localdomain
        (/dev/pts/0) at 3:33 ...

The system is going down for reboot NOW!

7. Login and verify the server kernel version
[root@localhost ~]# uname -r
3.13.2-1.el6.elrepo.x86_64
[root@localhost ~]# 

8. See that a new docker0 interface is created
[root@localhost ~]# ifconfig
docker0   Link encap:Ethernet  HWaddr A2:FA:1E:55:53:77  
          inet addr:172.17.42.1  Bcast:0.0.0.0  Mask:255.255.0.0
          inet6 addr: fe80::a0fa:1eff:fe55:5377/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:9 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 b)  TX bytes:1422 (1.3 KiB)

eth0      Link encap:Ethernet  HWaddr 08:00:27:D5:BC:A0  
          inet addr:192.168.1.111  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fed5:bca0/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:118 errors:0 dropped:0 overruns:0 frame:0
          TX packets:47 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:13818 (13.4 KiB)  TX bytes:7215 (7.0 KiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

[root@localhost ~]# 

9. Start the docker in daemon mode
[root@localhost ~]# docker -d
10. Verify the docker version
[root@localhost ~]# docker version
Client version: 0.7.6
Go version (client): go1.2
Git commit (client): bc3b2ec/0.7.6
Server version: 0.7.6
Git commit (server): bc3b2ec/0.7.6
Go version (server): go1.2
Last stable version: 0.8.0, please update docker
[root@localhost ~]# 

11. Update to 0.8 version (Optional Step)
[root@localhost ~]# ps auxww | grep docker
root      1008  0.0  1.3 338992  6788 ?        Sl   03:35   0:00 /usr/bin/docker -d
root      1357  0.0  0.1 103296   820 pts/0    S+   03:55   0:00 grep docker
[root@localhost ~]# kill -9 1008

[root@localhost ~]# yum install http://kojipkgs.fedoraproject.org//packages/docker-io/0.8.0/2.el6/x86_64/docker-io-0.8.0-2.el6.x86_64.rpm
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.aol.in
 * elrepo: mirror.smartmedia.net.id
 * epel: epel.mirror.net.in
 * extras: centos.aol.in
 * updates: centos.aol.in
Setting up Install Process
docker-io-0.8.0-2.el6.x86_64.rpm                                                               | 3.6 MB     00:05     
Examining /var/tmp/yum-root-7UK58w/docker-io-0.8.0-2.el6.x86_64.rpm: docker-io-0.8.0-2.el6.x86_64
Marking /var/tmp/yum-root-7UK58w/docker-io-0.8.0-2.el6.x86_64.rpm as an update to docker-io-0.7.6-2.el6.x86_64
Resolving Dependencies
--> Running transaction check
---> Package docker-io.x86_64 0:0.7.6-2.el6 will be updated
---> Package docker-io.x86_64 0:0.8.0-2.el6 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================
 Package                Arch                Version                  Repository                                  Size
======================================================================================================================
Updating:
 docker-io              x86_64              0.8.0-2.el6              /docker-io-0.8.0-2.el6.x86_64               19 M

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

Total size: 19 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating   : docker-io-0.8.0-2.el6.x86_64                                                                       1/2 
  Cleanup    : docker-io-0.7.6-2.el6.x86_64                                                                       2/2 
  Verifying  : docker-io-0.8.0-2.el6.x86_64                                                                       1/2 
  Verifying  : docker-io-0.7.6-2.el6.x86_64                                                                       2/2 

Updated:
  docker-io.x86_64 0:0.8.0-2.el6                                                                                      

Complete!

[root@localhost ~]# docker info
Containers: 0
Images: 0
Driver: devicemapper
 Pool Name: docker-253:0-110-pool
 Data file: /var/lib/docker/devicemapper/devicemapper/data
 Metadata file: /var/lib/docker/devicemapper/devicemapper/metadata
 Data Space Used: 291.5 Mb
 Data Space Total: 102400.0 Mb
 Metadata Space Used: 0.7 Mb
 Metadata Space Total: 2048.0 Mb
WARNING: No swap limit support
[root@localhost ~]# 

Go to http://docs.docker.io/en/latest/ and get started with docker.

Have Fun !

NOTE: If you were use http://www.hop5.in repository. Dont worry as the package upgrades are seamless due to the package name being same.

Saturday, October 19, 2013

Install HHVM 2.2.0 Final Release on Centos 6.4 (64-bit)

Facebook released HHVM 2.2.0 couple of days ago and made the package available on multiple distributions.

Setup hop5.in repo as mentioned in this blog post

1. Install the package using yum

[root@node1 x86_64]# yum install hiphop-php-2.2.0-1.el6.x86_64 -y

2. Check the version of newly installed package

[root@node1 x86_64]# hhvm --version
HipHop VM v2.2.0 (rel)
Compiler: 1382176880_483521803
Repo schema: 484929643_1382176880

3. Have fun with this new release :-)

Long list of changelog is available here

Thursday, September 19, 2013

Tuesday, September 10, 2013

Postgresql 9.3 and NoSQL Awesomeness on Fedora 19

Postgresql 9.3 was released yesterday. This document explains how to install postgresql 9.3 on Fedora 19 system and play with the built-in JSON support for the columns. (i.e the NOSQL Feature within a RDBMS database!)

1. Install Fedora 19 as you usually do

2. Setup PGDG Repository

[root@fallenangel ~]# yum install http://yum.postgresql.org/9.3/fedora/fedora-19-x86_64/pgdg-fedora93-9.3-1.noarch.rpm -y
oaded plugins: fastestmirror, langpacks, refresh-packagekit
pgdg-fedora93-9.3-1.noarch.rpm  | 5.1 kB  00:00:00     
Examining /var/tmp/yum-root-cjnqf8/pgdg-fedora93-9.3-1.noarch.rpm: pgdg-fedora93-9.3-1.noarch
Marking /var/tmp/yum-root-cjnqf8/pgdg-fedora93-9.3-1.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package pgdg-fedora93.noarch 0:9.3-1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved
Total size: 2.1 k
Installed size: 2.1 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : pgdg-fedora93-9.3-1.noarch         1/1 
  Verifying  : pgdg-fedora93-9.3-1.noarch                         1/1 

Installed:
  pgdg-fedora93.noarch 0:9.3-1
Complete!

3. Install postgresql-9.3
[root@fallenangel ~]# yum install postgresql93-server -y

4. Initialize the Postgresql database

[root@fallenangel ~]#  su - postgres
-bash-4.2$ env PGDATA=/var/lib/pgsql/9.3/data /usr/pgsql-9.3/bin/initdb
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /var/lib/pgsql/9.3/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
creating configuration files ... ok
creating template1 database in /var/lib/pgsql/9.3/data/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating collations ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
loading PL/pgSQL server-side language ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok
syncing data to disk ... ok

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    /usr/pgsql-9.3/bin/postgres -D /var/lib/pgsql/9.3/data
or
    /usr/pgsql-9.3/bin/pg_ctl -D /var/lib/pgsql/9.3/data -l logfile start

-bash-4.2$ 

5. Start the postgresql server

[root@fallenangel ~]# service postgresql-9.3 start
Redirecting to /bin/systemctl start  postgresql-9.3.service
[root@fallenangel ~]# 


6. Connect to the Server and create a test database

[root@fallenangel ~]# su - postgres
-bash-4.2$ createdb json

-bash-4.2$ psql json
psql (9.3.0)
Type "help" for help.

json=# create user json_user with password 'json_password';
CREATE ROLE
json=# grant all privileges on database json to json_user;
GRANT
json=# \q

7. Connect to the Server with newly created Username

[root@fallenangel ~]# psql -U json_user -d json
psql (9.3.0)
Type "help" for help.

8. Create a new table with JSON datatype in one of the columns

json=> create table "User" (
json(> id integer,
json(> details json
json(> );

CREATE TABLE
json=> insert into "User" (id, details) values (1, '{"uuid":1234, "name":"John Doe", "email": "John.Doe@acme.com", "status":"active"}');
INSERT 0 1

json=> insert into "User" (id, details) values (1, '{"uuid":1235, "name":"Tomcat", "email": "tomcat@acme.com", "status":"active", "phones":["+1 800 700 500", "+1 400 300 200"]}');
INSERT 0 1
json=> 
9. Now the SQL Queries using NoSQL dataset

1. Get the list of all UUIDs (embedded inside `details` column)

json=> select details->'uuid' as "uuid" from "User";
 uuid 
------
 1234
 1235
(2 rows)

2. Get the list of all Emails from "User" table

json=> select details->'email' as "email" from "User";
        email         
---------------------
 "John.Doe@acme.com"
 "tomcat@acme.com"
(2 rows)

3. Get the First Phone number (from the array of phones) from "User" table

json=> select details->'name' as "name", details->'phones'->0 as "uuid" from "User";
  name  |       uuid       
------------+------------------
 "John Doe" | 
 "Tomcat"   | "+1 800 700 500"
(2 rows)


Please be aware that JSON Implies UTF-8 Charset. There is no need to explicitly mention this.

More JSON functions in postgres-9.3 are available in this document.

LIMITATIONS: Currently, to update the column, we need to pass the entire json data instead of updating a single KEY inside JSON content.

For example, you might expect the following works, But it doesn't.

Update the 'name' key inside the json dataset.

json=> update "User" set details->'name' = 'John Doe II' where details->'name' = 'John Doe';

ERROR:  syntax error at or near "->"
LINE 1: update "User" set details->'name' = 'John Doe II' where deta..

It would be awesome if postgresql developers add such feature.