Saturday, May 17, 2008

How To Setup Subversion Replication on CentOS5?

If you want to setup two subversion server , one master and another as read only slave with password and acl protected so keep reading. Let's suppose you have two subversion server , as below...

SVN-M(master)
Hostname: svn-m.example.com
IPAddress: 10.10.10.1/24

SVN-S (slave)
Hostname: svn-s.example.com
IPAddess: 10.10.10.2/24


Setup yum repository:

Download any one RPM according to your OS and system architecture .....

(for RHEL5 32 bit version)
wget http://dag.wieers.com/rpm/packages/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm rpm -Uvh rpmforge-release-0.3.6-1.el5.rf.i386.rpm

OR

(for RHEL5 64 bit version)
wget http://dag.wieers.com/rpm/packages/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm
rpm -Uvh rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm

Setup Master SVN Server:

1) Install Apache Webserver and Subversion .

yum install httpd httpd-devel subversion mod_dav_svn -y


2) Create SVN Repository:

I like fsfs filesystem based SVN repository over BDB based . To know more difference between fsfs and BDB go through following article

http://svnbook.red-bean.com/en/1.1/ch05.html#svn-ch-5-sect-1.3

(Read "
Repository Data-Stores" section )

mkdir -p /var/www/svn ( -p to create parent directory if it doesn't exist)

svnadmin create --fs-type=fsfs /var/www/svn/repos

Note:check httpd.conf User and Group section to know user and group by which apache is running as follows and then change owner and group owner according to that )

grep ^User /etc/httpd/conf/httpd.conf

OutPut: User apache

grep ^Group /etc/httpd/conf/httpd.conf

OutPut: Group apache

chown -R apache:apache /var/www/svn/repos


3) Configure Apache Webserver for Master subversion:

Enable name based virtual hosting in

vi /etc/httpd/conf/httpd.conf

NameVirtualHost *:80


vi /etc/httpd/conf.d/subversion.conf
-------------------------------------------------------------------------------------------------------------------------------------
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so

<VirtualHost *:80>
ServerName svn-m.example.com
<Location /repos>
DAV svn

SVNPath /var/www/svn/repos
AuthType Basic
AuthName "Authorization Realm"
AuthUserFile /var/www/svn/.htpasswd
AuthzSVNAccessFile /etc/svn-acl-conf
Require valid-user

</Location>
</VirtualHost>
-------------------------------------------------------------------------------------------------------------------------------------


4) Create SVN user :

htpasswd -cm /var/www/svn/.htpasswd test

Note: -c to create file first time and -m for md5 hashed password. Don't use -c second time while creating user otherwise it will overwrite existing file.

5) Create Subversion Access control list file for Master:

vi /etc/svn-acl-conf
-------------------------------------------------------------------------------------------------------------------------------------
[repos:/]
administrator = rw
* = r
-------------------------------------------------------------------------------------------------------------------------------------
Note: Only administrator can write to repository and everyone else can only read to repository.

6) Create SVN Repository Layout:

mkdir -p /tmp/productname/{trunk,stable,branches,releases}

svn import /tmp/productname/ file:///var/www/svn/repos/productname -m "Creating Productname Layout"

To know more about SVN Repository Layout , Please go through following link...

http://svnbook.red-bean.com/en/1.4/svn.tour.importing.html#svn.tour.importing.layout


Now make host entry as follows in /etc/hosts on client side and point http://svn-m.example.com/repos in your browser and you will get username password box.Now login by previously created usernane.

10.10.10.1 svn-m.example.com

Here your master SVN server is ready...... :)


Setup Slave SVN Server:

Step 1 and 2 same as Master.

3) Configure Apache Webserver for Slave subversion:

Enable name based virtual hosting in

vi /etc/httpd/conf/httpd.conf

NameVirtualHost *:80


vi /etc/httpd/conf.d/subversion.conf
-------------------------------------------------------------------------------------------------------------------------------------
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so

<VirtualHost *:80>
ServerName svn-s.example.com

<Location /repos>
DAV svn

SVNPath /var/www/svn/repos
AuthType Basic
AuthName "Authorization Realm"
AuthUserFile /var/www/svn/.htpasswd
AuthzSVNAccessFile /etc/svn-acl-conf
Require valid-user

</Location>
</VirtualHost>


-------------------------------------------------------------------------------------------------------------------------------------
4) Step 4 is same as master

5) Create Subversion Access control list file for Slave:
-------------------------------------------------------------------------------------------------------------------------------------
[repos:/]
svnmirror = rw
* = r
-------------------------------------------------------------------------------------------------------------------------------------
Imp Note: Please don't give write access to anyother user than svnmirror , only svnmirror should be able to write on slave no one else.

6) Make Mirror Repository Revision Properties Modifiable by Synchronizing User:

cd /var/www/svn/repos/hooks
vi pre-revprop-change
-------------------------------------------------------------------------------------------------------------------------------------
#!/bin/sh

USER="$3"

if [ "$USER" = "svnmirror" ]; then exit 0; fi

echo "Only the svnmirror user may change revision properties as this is a read-only, mirror repository." >&2

exit 1
-------------------------------------------------------------------------------------------------------------------------------------

7) Create svnmirror user on master

htpasswd -bm /var/www/svn/.htpasswd svnmirror svn


Note: -b option is used to supply password on command line, here svnmirror user password is "svn". You can just remove -b option can type when it will ask for password.

8)
Register mirror repository for synchronization

svnsync initialize file:///var/www/svn/repos http://svn-m.example.com/repos --username=svnmirror

It will ask svnmirror password that we created on master in our case this is "svn"

If everything is configured properly, you should see some output like this

Copied properties for revision 0.

Now we have registered our svn-s , slave i.e. mirror repository with master repository , now we should do initial synchronization so that mirror (slave) and master repository are synchronized .

svnsync synchronize file:///var/www/svn/ repos --username=svnmirror

you should see output like this.

Committed revision 1.
Copied properties for revision 1.

9) Create SVN user on Slave:

htpasswd -bm /var/www/svn/.htpasswd svnslavetest svnslavetest
Now make host entry in /etc/hosts on client side and point your http://svn-s.example.com/repos in your browser.You should get username and password pop-up just use previously created username and password

UserName: svnslavetest
Password: svnslavetest

10.10.10.2 svn-s.example.com

9) Automate Synchronization with cron

vi /etc/crontab

*/5 * * * * root svnsync synchronize file:///var/www/svn/ repos --username=svnmirror --password=svn > /tmp/svnsync.log

Now every 5 minute mirror repository will synchronize with master.

cool :)

Please send me your feedback and suggestions.

Thanks

Tuesday, May 1, 2007

How To Play Mp3 and Video in Ubuntu

If you want to enjoy linux sound and video player, so this is may be right place for you. I am going to tell you exactly how will you play mp3 and video in Ubuntu Linux

If you like xmms so simply go to

Applications ->Add/Remove Programs




Click on Sound & Video , then select xmms from Application section and click Ok.

Now it will install xmms with mp3 decoder , now enjoy your favorite mp3 songs in Ubuntu , How simple is playing MP3 in linux.

If you want to watch your favorite movie in Ubuntu , its very simple Just do following.

Go to , Applications -> Add/Remove Program




You will get this type of screen once again select Sound & Video , now select
GStreamer extra plugins and GStreamer ffmpeg video plugin after that click on Apply and then OK.

Now enjoy your favorite movie's in Ubuntu Linux. Following Format's are supported.....

mp3, sid, mpeg1-2,4 , AC-3, wmv, asf , mpeg, divx, DVD (without encryption)