Its been a long time since I have posted an entry. It has been a very busy year and more about that in a later post. Finally I had some time to try out new versions of Linux and new OSS technologies.
I started to learn by installing the latest version of CentOS 7. CentOS closely follows RHEL 7 and coming from SLES 11 and older CentOS 6.5, I saw many new changes which are pretty interesting.
New commands to learn immediately as I started navigating:
systemctl
firewall-cmd
I admit that I missed my favorite files in /etc/init.d and looking at new location of /etc/systemd/system/multi-user.target.wants/ will take me a while to get used to.
firewall-cmd actually was more welcome considering how hard I found to remember the exact rule syntax of iptables.
There is new Grub2 but honestly lately I do not even worry about it (which is a good thing). Apart from that I see XFS is the new default file system and LVM now has snapshot support for Ext4 and XFS and many more.
However the biggest draw for me was the support for Linux Containers. As a Sun alumni, I was always draw to the battle of who did containers first and no longer worry about it, but as BSD Jails progressed to Solaris Containers to now the hottest technology: Docker container, it sure has its appeal.
In order to install docker however you need the "Extras" CentOS 7 repository enabled. However docker is being updated faster so the "Extras" repository is getting old at 1.3 with the latest out (as of last week) is Docker 1.5. To get Docker 1.5 you will need to enable "virt7-testing" repository on CentOS 7
I took a shortcut to just create a file /etc/yum.repos.d/virt7-testing.repo with the following contents in it.
I started to learn by installing the latest version of CentOS 7. CentOS closely follows RHEL 7 and coming from SLES 11 and older CentOS 6.5, I saw many new changes which are pretty interesting.
New commands to learn immediately as I started navigating:
systemctl
firewall-cmd
I admit that I missed my favorite files in /etc/init.d and looking at new location of /etc/systemd/system/multi-user.target.wants/ will take me a while to get used to.
firewall-cmd actually was more welcome considering how hard I found to remember the exact rule syntax of iptables.
There is new Grub2 but honestly lately I do not even worry about it (which is a good thing). Apart from that I see XFS is the new default file system and LVM now has snapshot support for Ext4 and XFS and many more.
However the biggest draw for me was the support for Linux Containers. As a Sun alumni, I was always draw to the battle of who did containers first and no longer worry about it, but as BSD Jails progressed to Solaris Containers to now the hottest technology: Docker container, it sure has its appeal.
In order to install docker however you need the "Extras" CentOS 7 repository enabled. However docker is being updated faster so the "Extras" repository is getting old at 1.3 with the latest out (as of last week) is Docker 1.5. To get Docker 1.5 you will need to enable "virt7-testing" repository on CentOS 7
[virt7-testing]
name=virt7-testing
baseurl=http://cbs.centos.org/repos/virt7-testing/x86_64/os/
enabled=1
gpgcheck=0
Then I was ready to install docker as follows
# yum install docker
I did find that it actually does not start the daemon immediately, so using the new systemctl command I enabled and then started the daemon
# systemctl enable docker
# systemctl start docker
We now have the setup ready. However what good is the setup unless you have something to demonstrate quickly. This is where I see Docker winning over other container technology and probably their differentiator. There is an "AppStore" for the container images available to download images. Of course you need a login to access the Docker Hub as it is called at http://hub.docker.com (which is for free fortunately).
# docker login
To login to the hub and now you are ready to get new images.
I have uploaded two images for the demonstration for today
1. A Standard Postgres 9.4 image
2. A DVDStore benchmark application image based on kit from http://linux.dell.com/dvdstore/
To download the images is as simple as pull
# docker pull jkshah/postgres:9.4
# docker pull jkshah/dvdstore
Now lets see on how to deploy them.
For PostgreSQL 9.4 since it is a database it will require storage for "Persistent Data" so first we make a location on the host that can be used for storing the data.
# mkdir /hostpath/pgdata
SELinux is enabled by default on CentOS 7 which means there is an additional step required to make the location read/write from Linux containers
# chcon -Rt svirt_sandbox_file_t /hostpath/pgdata
Now we will create a container as a daemon which will map the container port to host port 5432 and setup a database with a username and password that we set. (Please do not use secret as password :-) )
# docker run -d -p 5432:5432 --name postgres94 -v /hostpath/pgdata:/var/lib/postgresql/data -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=secret -t jkshah/postgres:9.4
Here now if you check /hostpath/pgdata you will see the database files on the host.
Now lets deploy an application using this database container.
# docker run -d -p 80:80 -–name dvdstore2 -–link postgres94:ds2db –-env DS2DBINIT=1 jkshah/dvdstore
The above command starts another container based on the DVDStore image which expects a database "ds2db" defined which is satisfied using the link option to link the database container created earlier. The application container also intiailizes the database so it is ready to serve requests at port 80 of the host.
This opens up new avenues to now benchmark your PostgreSQL hardware easily. (Wait the load test driver code is still on Windows :-( )
3 comments:
I recently explored CentOS, and I must say it left a lasting impression on me. The stability and reliability of this operating system are truly commendable. I appreciate how CentOS provides a robust platform for various server-related tasks.
The extensive support and vibrant community around CentOS make troubleshooting and finding solutions a breeze. The regular updates and security patches give me confidence in its long-term viability for server environments.Please write about Full Stack Web Develoment in future.
Best Article about centOS. I am currently doing Full Stack Course and wanted to host my project on Lunux server. This is best article.
I recently set up CentOS 7 with Docker and Postgres to run the DVDStore kit, and everything is working smoothly. The setup provides an efficient environment for testing and development. If you're looking to integrate a Cricket ID provider into your application, this stack offers a reliable and scalable foundation. Highly recommend it for sports-related apps!
Post a Comment