Pages

Thursday, January 30, 2014

Keepalived Vs Heartbeat Difference

A nice explanation highlighting the difference between the keepalived and heartbeat

http://www.formilux.org/archives/haproxy/1003/3259.html

Tuesday, January 21, 2014

Jenkins as a Centralized Cron Server/Dashboard

h3.  Jenkins

{quote}Jenkins is an open source continuous integration tool written in Java.

Jenkins provides continuous integration services for software development. It is a server-based system running in a servlet container such as Apache Tomcat. It supports SCM tools including CVS, Subversion, Git, Mercurial, Perforce, Clearcase and RTC, and can execute Apache Ant and Apache Maven based projects as well as arbitrary shell scripts and Windows batch commands. The primary developer of Jenkins is Kohsuke Kawaguchi.[3] Released under the MIT License, Jenkins is free software.[4]
Builds can be started by various means, including being triggered by commit in a version control system, scheduling via a cron-like mechanism, building when other builds have completed, and by requesting a specific build URL.{quote}


h3. features :

h5. History :

Jenkins can be configured to retain logs of jobs that it has run. So You have full visibility of what's happening with your system.

Centralized management
With Jenkins you can manage all your imortant cron  jobs centrally.You can also export all Jenkins jobs as XML and check it into a repository.

Alert only if the Jobs fails :
If you enable email for Cron , You end up with too much of emails and eventully end up ignoring them. Jenkins on other hand can be configured to alert only when a particular job fails ie. a job exits with return code other than 0.
In addition you can use the awesome Jenkins Text Finder plugin which allows you to specify words or regular expressions to look for in console output. They can be used to mark a "job" unstable. F

h5. Job dependency :

With Jenkins you can trigger one job only after the first one completes successfully. Creating a well known Dependacy structure and rely on it.

h5. Test immediately :

With Jenkins you can click Build Now and job will run immediately. Where in Cron you have wait for the specified schedule to execute.

h5. Quick  setup

Setting up jobs is easy.




h3. Pros/Cons :

* Backup and restoration becomes very handy.
* We can control the access to Jenkins based on LDAP role.
* Can have multi node Jenkins setup for failover.
* We can schedule the cron job's with dependency i.e. start job B once Job A completes
* Each Job have its history preserved , when did it last run , when failed etc.
* The output of  each job is also captured.
* we can have email alert if the job fails.
* We must have ssh trust between Jenkins server and the target hosts.
* Need to research further.

h3. Implementation method

* h5. Jenkins External Monitor - ( Using your Existing Cron )

# Make Sure the `Jenkins External Monitor Job` plugin is installed.
# Add a New Job in Jenkins, with a type 'Monitor an external job' ( Pick a relevent and name and provide the brief description )
# Now on the remote server
# Make sure the Java is installed
# export the JENKINS_HOME variable JENKINS_HOME=http://host1:8080  ( You can add this info in your .bashrc or Crontab as well )
# If the security on Jenkins server is enabled and only authorized users can run a Job, then JENKINS_HOME should be:
             export JENKINS_HOME=http://user_id:password@host1:8080
# Copy below files from Jenkins server to the remote server in /root/jenkins direcorty
{code} jenkins-core-*.jar remoting-*.jar ant-[1-9]*.jar commons-io-[1-9]*.jar  commons-lang-[0-9]*.jar jna-posix-*.jar xstream-*.jar {code}

# Add below 2 lines to your crontab
        {code}
export JENKINS_HOME=http://user_id:password@host1:8080
* * * * * export JENKINS_HOME=$JENKINS_HOME; java -jar /root/jenkins/jenkins-core-*.jar "Job_Name_In_Jenkins" /path_to/script 2>&1 > /dev/null
        {code}

* h5. Jenkins SSH
# Make Sure the `Jenkins SSH` plugin is installed
# Add the remote hosts details in “Manage Jenkins” –> “Configure System” -> “SSH remote hosts” -> “Add“ ( fill in the details)
# Add new Job in Jenkins , with a type “Build a free-style software project”  ( Pick a relevent and name and provide the brief description )
# Now add in the details for this Job
# Source Code Management ->None
# Build Triggers -> Build periodically -> Schedule -> put a cron schedule
# Build Environment -> Execute shell script on remote host using ssh -> Select the Site added already in above step.
# provide the Pre build script and Post build script , rest all configurations are up to your own requirement.


----

h3. Another proposed solution: Tron

{quote}Tron is a centralized system for managing periodic batch processes and services across a cluster{quote}

h4. The good...

* Manage dependencies between batch process
* A centralized configuration for batches which run on many machines
* Start and restart services running on many machines
* Monitor and report on batch process and services

h4. Tron Architecture

* Tron is a python daemon that executes Jobs or Services across multiple Nodes.
* It is powered by SSH. Meaning Tron just needs to be installed in one centralized location and configured to remotely execute commands.
* Tron manages executing Jobs based on predefined schedules. It resolves dependencies between other jobs in a work flow. It maintains the history of job runs for later reporting. It has a flexible system for monitoring job failures.
* State and job output (stdout/stderr) are stored on disk to avoid loss due to machine failure.
* Tron communicates with command line tools, web interface, or whatever else you can dream up via a REST API.

!http://yelp.typepad.com/.a/6a00d83452b44469e20134871f25c7970c-pi|border=1!

h4. [Tron homepage|https://github.com/Yelp/Tron/wiki]
----

Friday, January 3, 2014

How to install zoner in Centos6

Zoner  is DNS zone management web application built in Python.

{code}

yum install python-setuptools.noarch

easy_install TurboGears

Download the python-tgexpandingformwidget-0.1.3-5.el5ipa.src.rpm in /opt

wget http://ftp.pbone.net/mirror/ftp.redhat.com/pub/redhat/linux/enterprise/5Server/en/RHEIPA/SRPMS/python-tgexpandingformwidget-0.1.3-5.el5ipa.src.rpm


rpm -ivh /opt/python-tgexpandingformwidget-0.1.3-5.el5ipa.src.rpm

cd /root/rpmbuild/SOURCES

tar -xvzf TGExpandingFormWidget-0.1.3.tar.gz

python  setup.py install

Download the TGBooleanFormWidget-0.1.egg in /opt

wget http://cleaver.cnx.rice.edu/eggs_directory/TGBooleanFormWidget/TGBooleanFormWidget-0.1.egg#

 easy_install TGBooleanFormWidget-0.1.egg

cd /opt

wget http://peak.telecommunity.com/dist/ez_setup.py

python ez_setup.py -Zf http://peak.telecommunity.com/snapshots/ RuleDispatch

***If you face any error for python.h file install python-devel.x86_64 ( yum install python-devel.x86_64 )

 easy_install easyzone

easy_install dnspython

Finally install zoner -- easy_install zoner

***  python-formencode is dependency so install it ( yum install  python-formencode)



Now configure it --

cd /usr/lib/python2.6/site-packages/zoner-1.4.1-py2.6.egg

cp config/sample-prod.cfg zoner.cfg

Now edit the zoner.cfg and change the parameters

yum install MySQL-python.x86_64


 tg-admin --config=zoner.cfg sql create


zoner_users -c zoner.cfg add


Finally, start the Zoner application:  $ zoner zoner.cfg

Point your browser at http://localhost:8080/ (or the appropriate host/port as per your configuration) and you should be able to login.

Want to run the service other then 8080 port add the below lines in the zoner.cfg 

server.socket_host = "0.0.0.0"
server.socket_port = 9090