08 February 2012

Heartbeat

Heartbeat


Heartbeat is clustering solution which is apart of the Linux High Availability project developed to increase reliability, availability and serviceability of systems. The program sends out heartbeat packets to other members of the the heartbeat node. If a node fails to respond to a packet, then it is assumed that it is dead, all services are killed on that server and another node takes over its services.

Provides support for: web servers, mail servers, database servers, firewalls, routers/switches, DNS/DHCP, and proxy servers. Nodes can be setup so that they are logically using the same IP address so for the user the heartbeat cluster is transparent.

Installation and Configuration

Before installing hearbeat, there are some local changes that need to be performed.

Add IP addresses in /etc/hosts on all host clusters

vim /etc/hosts

127.0.0.1 localhost
192.168.1.2 nausicaa.anandhacorp.net
192.168.1.3 serfina.anandhacorp.net
Manually configure network device which will be used for hearbeat: /etc/sysconfig/network-scripts/ifcfg-eth0

vim /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
IPADDR=192.168.1.2
GATEWAY=192.168.1.10
BOOTPROTO=static
ONBOOT=yes
Install heartbeat using yum on fedora this will install all the dependancies required.

Installing manually using rpm require the following

rpm -ivh heartbeat-pils-1.2.2-8.rh.el.3.0.i386.rpm
rpm -ivh heartbeat-stonith-1.2.2-8.rh.el.3.0.i386.rpm
rpm -ivh heartbeat-1.2.2-8.rh.el.3.0.i386.rpm

We need to edit the configuration file /etc/ha.d/ha.cf. Note: this file may not exisit by default.
this files lists the clusters in the network and the configuration settings for them.

vim /etc/ha.d/ha.cf auto_failback on
debugfile /var/log/ha-debug
#
# File to write other messages to
#
logfile /var/log/ha-log
#
# Facility to use for syslog()/logger
#
logfacility local0
#
# keepalive: how many seconds between heartbeats
#
keepalive 2
#
# deadtime: seconds-to-declare-host-dead
#
deadtime 10
# What interfaces to heartbeat over?
#
bcast eth0
#
#
node nausicaa.anandhacorp.net
node serfina.anandhacorp.net
#

This configuration can be copied to all nodes

Generate authkey: /etc/ha.d/authkeys

The authkey contains pre-shared secrets used for mutual cluster node authentication. It should only be readable by root and follows this format: num is a simple key index, starting with 1. Usually, you will only have one key in your authkeys file. algorithm is the signature algorithm being used. You may use either md5 or sha1; the use of crc (a simple cyclic redundancy check, not secure) is not recommended. secret is the actual authentication key. You may create an authkeys file, using a generated secret, with the following shell hack:


( echo -ne "auth 1\n1 sha1 "; dd if=/dev/urandom bs=512 count=1 | openssl md5 ) > /etc/ha.d/authkeys

chmod the file to 600

Configure the resource file - this file specifies the services the cluster will run

vim /etc/ha.d/haresource

nausicaa.anandhacorp.net IPaddr::192.168.1.4 httpd smb

Included are httpd, smb and dhcpd. These services must be the exact same spelling as those daemons under /etc/rc.d/init.d

configure the same on second node, when services on both nodes are started an IP alias is created eth0:0 the primary node

start heartbeat

/etc/rc.d/init.d/heartbeat start

If you power down the primary node, the secondary node should automatically take over all services, add take on the IP alias eth0:0 192.168.1.4

Back to Resources

13 January 2012

How to Install Ruby 1.9.2 and Rails 3.0 on Ubuntu 10.10

How to Install Ruby 1.9.2 and Rails 3.0 on Ubuntu 10.10


Step 1: apt-get install aptitude

#aptitude update
#aptitude install build-essential git-core curl
#bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer ) #echo '[[ -s "/usr/local/rvm/src/rvm/scripts/rvm" ]] "/usr/local/rvm/src/rvm/scripts/rvm"' >> ~/.bashrc
#rvm notes
#rvm requirements
#apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion
#rvm install 1.9.2
#rvm --default use 1.9.2
#gem install rails
#cd /var/www/
#rails new myapp
#rails server
#apt-get install nodejs


http://localhost:3000
http://www.youtube.com/watch?v=NmWYZVUln4E&feature=player_embedded#!

How to Install Ruby 1.9.2 and Rails 3.0 on Ubuntu 10.10

How to Install Ruby 1.9.2 and Rails 3.0 on Ubuntu 10.10

24 June 2010

Installing Subversion on Ubuntu server

Installing Subversion on Ubuntu server

$sudo apt-get install subversion libapache2-svn

Creating the repository:

$svnadmin create /path/to/repo

You will also need to uncomment the settings in /etc/apache2/mods-available/dav_svn.conf


# Uncomment this to enable the repository,
DAV svn

# Set this to the path to your repository
SVNParentPath /var/lib/svn


Creating the user auth file:

$cd /ets/apache2
$sudo touch dav_svn.conf

$htpasswd /etc/apache2/dav_svn.conf user1
Enter new passwd
Reenter passwd

And test using the svn client.
svn URL - svn://ipaddress/path/to/repo

Keywords: Subversion, svn installing on ubuntu.

14 May 2010

Trac on Ubuntu 8.04 Server.

Trac on Ubuntu ¶

These instructions were tested with a fresh install of 8.04, and installs Trac 0.11.

Also see TracInstallPlatforms, TracInstall, TracOnUbuntu, Ubuntu-Trac, hardy, cgi.

For a full tutorial to get SVN + Trac 0.11 running on Ubuntu with multiple projects view this link.
OS Installation ¶

You can have a Ubuntu instance running on a real hardware or virtual machine session using VMWare or VirtualBox.
The Ubuntu machine info ¶

me@ubuntu:~$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=8.04
DISTRIB_CODENAME=hardy
DISTRIB_DESCRIPTION="Ubuntu 8.04.1"
me@ubuntu:~$


Trac 0.11 Installation ¶
1. Install Software Packages ¶

To install Trac on your system, install apache, setuptools and some libraries:

sudo apt-get install apache2 libapache2-mod-python \
libapache2-svn python-setuptools subversion python-subversion
sudo easy_install Trac

If you want to install Bitten for trac ¶

# Needed for bitten's trac 10.4 compatiblity.
sudo apt-get install python-clearsilver
# Needed for bitten unitest.
sudo easy_install http://darcs.idyll.org/~t/projects/figleaf-latest.tar.gz


2. Create the Trac Environments Directory ¶

You'll need a directory for Trac's environments to live that should be writable by the default Apache user:

sudo mkdir /var/lib/trac
sudo chown www-data:www-data /var/lib/trac

3. Setup Apache2 ¶

Next, create a new Apache-2 virtualhost, and paste the text below into the file:

sudo vi /etc/apache2/sites-available/trac


ServerAdmin webmaster@localhost
ServerName trac.example.com
DocumentRoot /var/www
ErrorLog /var/log/apache2/error.trac.log
CustomLog /var/log/apache2/access.trac.log combined


SetHandler mod_python
PythonInterpreter main_interpreter
PythonHandler trac.web.modpython_frontend
PythonOption TracEnvParentDir /var/lib/trac
PythonOption TracUriRoot /projects
PythonOption PYTHON_EGG_CACHE /tmp


# use the following for one authorization for all projects
# (names containing "-" are not detected):

AuthType Basic
AuthName "trac"
AuthUserFile /etc/apache2/dav_svn.passwd
Require valid-user




Now, disable the default virtualhost, enable the Trac virtualhost, and restart Apache2:

sudo a2dissite default
sudo a2ensite trac
sudo /etc/init.d/apache2 reload

4. Creating Environments ¶
SVN ¶

I installed my Subversion repository at /var/lib/svn/YourProjectNameHere. So I did a quick starting config of subversion with the following commands:

sudo mkdir /var/lib/svn
sudo svnadmin create /var/lib/svn/YourProjectNameHere

Some permissions changes and an apache restart are now needed:

sudo chown -R www-data /var/lib/svn
sudo chown -R www-data /var/lib/trac
sudo /etc/init.d/apache2 reload

References: Commands populate files into SVN repository
Mercurial ¶

An alternate solution is to use mercurial. if this case, do not setup any SVN (of course), indicate hg as the type of version control tool and the folder were your mercurial is. You will also need the mercurial plugin Trac Mercurial and the lastest version of mercurial from the backports
Trac ¶

I put my trac environment at /var/lib/trac/YourProjectNameHere. Of course you could use any other path or name - something a little more descriptive of your project would probably be a good idea. First I ran these commands:

sudo mkdir /var/lib/trac
sudo trac-admin /var/lib/trac/YourProjectNameHere initenv
sudo chown -R www-data /var/lib/trac

The "trac-admin" command shown above prompted me to enter:

* the project name (YourProjectNameHere)
* the path to svn repository (/var/lib/svn/YourProjectNameHere)

... then it prints out a bunch of stuff. If there are no errors you should now be able to surf to your Trac site at http://servername/projects

For more complex mod_python configs, see TracModPython
5. get subversion running as well ¶

You will also need to uncomment the settings in /etc/apache2/mods-available/dav_svn.conf


# Uncomment this to enable the repository,
DAV svn

# Set this to the path to your repository
SVNParentPath /var/lib/svn


6. Add some plugins to have a usable system ¶

There are still some software dependency issue need to be resolved using apt-get. Lots of Trac plugins depened on system software like htmldoc,enscript. Check your trac.log to see the complaining when depeneded software not installed.
Install more apt-get package for trac plugins later ¶

sudo apt-get install build-essential graphviz
sudo apt-get install htmldoc
sudo apt-get install enscript

Using Easy_install to install more Trac plugins ¶

Before running these commands, I had to run...

sudo easy_install -U setuptools

... to fix an error about "unexpected HTML" when trying to install from svn source.

sudo easy_install http://svn.edgewall.org/repos/genshi/trunk/
sudo easy_install http://trac-hacks.org/svn/accountmanagerplugin/trunk
sudo easy_install http://trac-hacks.org/svn/customfieldadminplugin/0.11
sudo easy_install http://trac-hacks.org/svn/eclipsetracplugin/tracrpcext/0.10
sudo easy_install http://trac-hacks.org/svn/iniadminplugin/0.11
sudo easy_install http://trac-hacks.org/svn/masterticketsplugin/0.11
sudo easy_install http://trac-hacks.org/svn/pagetopdfplugin/0.10/
sudo easy_install http://trac-hacks.org/svn/progressmetermacro/0.11
sudo easy_install http://trac-hacks.org/svn/ticketdeleteplugin/0.11
sudo easy_install http://trac-hacks.org/svn/tracwysiwygplugin/0.11
sudo easy_install http://wikinotification.ufsoft.org/svn/trunk

7. what one should probably do different than described here ¶

sudo chown www-data /etc/apache2/dav_svn.passwd

with Ubuntu 9.04 (it seems 8.10+ would require it) a modification is required in section 3

change to

Testing ¶
Make sure trac's password file is writable by www-data user ¶

me@ubuntu:~$ ls -l /etc/apache2/dav_svn.passwd
-rw-r--r-- 1 www-data root 21 2008-09-23 21:03 /etc/apache2/dav_svn.passwd
me@ubuntu:~$


Check the trac install directories layout ¶

me@ubuntu:~$ tree -as /var/lib/trac/
/var/lib/trac/
`-- [ 4096] YourProjectNameHere
|-- [ 98] README
|-- [ 27] VERSION
|-- [ 4096] attachments
|-- [ 4096] conf
| |-- [ 7025] trac.ini
| |-- [ 4755] trac.ini.new
| `-- [ 4187] trac.ini.sample
|-- [ 4096] db
| |-- [ 349184] trac.db
| `-- [ 324608] trac.db.21.bak
|-- [ 4096] htdocs
|-- [ 4096] log
| `-- [ 84562] trac.log
|-- [ 4096] plugins
| `-- [ 4096] TracWebAdmin-0.1.2dev-py2.5.egg
| |-- [ 4096] EGG-INFO
| | |-- [ 278] PKG-INFO
| | |-- [ 335] SOURCES.txt
| | |-- [ 1] dependency_links.txt
| | |-- [ 218] entry_points.txt
| | |-- [ 1] not-zip-safe
| | `-- [ 9] top_level.txt
| `-- [ 4096] webadmin
| |-- [ 523] __init__.py
| |-- [ 218] __init__.pyc
| |-- [ 1594] basics.py
| |-- [ 1682] basics.pyc
| |-- [ 4096] htdocs
| | |-- [ 4096] css
| | | `-- [ 1900] admin.css
| | |-- [ 4096] img
| | | |-- [ 218] collapsed.png
| | | `-- [ 227] expanded.png
| | `-- [ 4096] js
| | `-- [ 1286] admin.js
| |-- [ 3930] logging.py
| |-- [ 3133] logging.pyc
| |-- [ 2659] perm.py
| |-- [ 2585] perm.pyc
| |-- [ 9247] plugin.py
| |-- [ 8720] plugin.pyc
| |-- [ 4096] templates
| | |-- [ 954] admin.cs
| | |-- [ 685] admin_basics.cs
| | |-- [ 2961] admin_component.cs
| | |-- [ 2202] admin_enum.cs
| | |-- [ 1669] admin_log.cs
| | |-- [ 3898] admin_milestone.cs
| | |-- [ 1521] admin_perm.cs
| | |-- [ 3167] admin_plugin.cs
| | `-- [ 2901] admin_version.cs
| |-- [ 16312] ticket.py
| |-- [ 13250] ticket.pyc
| |-- [ 5579] web_ui.py
| `-- [ 6505] web_ui.pyc
|-- [ 4096] snapshots
`-- [ 4096] templates
`-- [ 151] site.html

17 directories, 42 files
me@ubuntu:~$


See the installed plugins in .egg format ¶

me@ubuntu:~$ ls -d /usr/lib/python2.5/site-packages/*.egg
/usr/lib/python2.5/site-packages/Bitten-0.6dev_r559-py2.5.egg
/usr/lib/python2.5/site-packages/Genshi-0.5.1-py2.5-linux-i686.egg
/usr/lib/python2.5/site-packages/Genshi-0.6dev_r960-py2.5-linux-i686.egg
/usr/lib/python2.5/site-packages/IniAdmin-0.2-py2.5.egg
/usr/lib/python2.5/site-packages/Trac-0.11.1-py2.5.egg
/usr/lib/python2.5/site-packages/TracAccountManager-0.2.1dev_r3857-py2.5.egg
/usr/lib/python2.5/site-packages/TracCustomFieldAdmin-0.2-py2.5.egg
/usr/lib/python2.5/site-packages/TracExtendedXmlRpc-0.1-py2.5.egg
/usr/lib/python2.5/site-packages/TracMasterTickets-2.1.3-py2.5.egg
/usr/lib/python2.5/site-packages/TracPageToPDF-0.2-py2.5.egg
/usr/lib/python2.5/site-packages/TracProgressMeterMacro-0.1-py2.5.egg
/usr/lib/python2.5/site-packages/TracTicketDelete-2.0-py2.5.egg
/usr/lib/python2.5/site-packages/TracWebAdmin-0.1.2dev-py2.5.egg
/usr/lib/python2.5/site-packages/TracWikiNotification-0.2.0-py2.5.egg
/usr/lib/python2.5/site-packages/TracWysiwyg-0.2_r4214-py2.5.egg
me@ubuntu:~$



keywords: trac on ubuntu, trac

17 March 2010

How do i upgrade the PHP 5.1 to 5.2..

# rpm -qa |grep php

php-common-5.1.6-15.el5.i386
php-cli-5.1.6-15.el5.i386
php-5.1.6-15.el5.i386
php-pdo-5.1.6-15.el5.i386
php-bcmath-5.1.6-15.el5.i386
php-ldap-5.1.6-15.el5.i386
php-devel-5.1.6-15.el5.i386
php-gd-5.1.6-15.el5.i386
php-xml-5.1.6-15.el5.i386
php-mbstring-5.1.6-15.el5.i386
php-mysql-5.1.6-15.el5.i386
php-dba-5.1.6-15.el5.i386


wget -q -O - http://www.atomicorp.com/installers/atomic |sh

# yum update

#yum update php*

Once yum has completed restart Apache:

# service httpd restart

To verify the update is working create a simple testing.php in your www directory with the following source code:



Conclusion

You should now have PHP 5.2.6 running on CentOS 5.3 32-bit.

# rpm -qa |grep php

php-cli-5.2.6-2.el5s2
php-mbstring-5.2.6-2.el5s2
php-devel-5.2.6-2.el5s2
php-pdo-5.2.6-2.el5s2
php-gd-5.2.6-2.el5s2
php-dba-5.2.6-2.el5s2
php-common-5.2.6-2.el5s2
php-bcmath-5.2.6-2.el5s2
php-xml-5.2.6-2.el5s2
php-pear-1.5.1-2.el5s2
php-ldap-5.2.6-2.el5s2
php-5.2.6-2.el5s2
php-mysql-5.2.6-2.el5s2


# php -v

PHP 5.2.6 (cli) (built: Sep 15 2008 20:42:05)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies

To HIDE the Directory listing in the apache

How to disable directories from browsing or indexing to hide images, and other files from visitors. This give you total control of your web folders to block unwanted viewing using .htaccess files with Apache
Disable or Enable Directory Browsing or Indexing in .htaccess file

Browsing or indexing is an option that allows the contents of a directory to be displayed in the browser when the directory does not contain an index page.

For example, if you make an http call to a directory such as http://yourdomain.com/images/, it would list all the images in that directory without the need for an html page with links.

We will need to create a blank file called “.htaccess”. You can name it “htaccess.txt” while your editing it, then rename the file to “.htaccess” after the file is on your web server.
Disable Directory Browsing or Indexing

Type or copy and past the following line of text in to your blank file.
Note: I add the work “All” so that every folder in that directory follows the same rule.

Options All -Indexes
IndexIgnore *.gif *.jpg *.png *.swf

Enable Directory Browsing or Indexing

You can reactivate it by adding the following line to your .htaccess file:

Options +Indexes

Once this is added, the directory will fully index again.