Thursday, June 29, 2006

My CUPS Printer...

After a long time i took the printout from suse in my office network .

When we were using suse 9.3 it worked without any problem. But one day ...............without any specific reason we couldnt take the printouts. After a long searchhhhhhhhhhh i got the solution today. That big solution is ...i have added my username under 'lp' group ;-)...

Actually some days before i couldnt hear the sounds in my home system ( that too suse ). After a number of posts with ilugc , i found the solution and got the sound by adding 'bala' user under 'audio' group. This experience only hits my mind for printer problem.

Now i can take the printouts...

technorati tags:, , , ,

Monday, June 26, 2006

Incremental Backup using Rsync and Hard links

Introduction :

Rsync is a program that behaves in much the same way that rcp does, but has many more options and uses the rsync remote-update protocol to greatly speed up file transfers when the destination file is being updated.
The rsync remote-update protocol allows rsync to transfer just the differences between two sets of files across the network connection, using an efficient checksum-search algorithm described in the technical report that accompanies this package.
Some of the additional features of rsync are:

* support for copying links, devices, owners, groups, and permissions
* exclude and exclude-from options similar to GNU tar
* a CVS exclude mode for ignoring the same files that CVS would ignore
* can use any transparent remote shell, including ssh or rsh
* does not require root privileges
* pipelining of file transfers to minimize latency costs
* support for anonymous or authenticated rsync daemons (ideal for mirroring)

Hard Link Concepts:

Hard links are similar to symlinks. They are normally created using the ln command but without the -s switch. A hard link is when 2 file entries point to the same inode and disk blocks. Unlike symlinks there isn't a file and a symlink but rather 2 links to the same file. If you delete either entry the other will remain and will still contain the data. Here is an example of both:

------- Symbolic Link Demo -------

% echo foo > x
% ln -s x y

% ls -li
38062 -rw-r--r-- 1 kmk users 4 Jul 25 14:28 x
38066 lrwxrwxrwx 1 kmk users 1 Jul 25 14:28 y -> x

% less y
foo


% rm x
% ls -li
38066 lrwxrwxrwx 1 kmk users 1 Jul 25 14:28 y -> x

% less y
y: No such file or directory



------- Hard Link Demo -------
% echo foo > x
% ln x y

% ls -li
38062 -rw-r--r-- 1 kmk users 4 Jul 25 14:28 x
38066 lrwxrwxrwx 1 kmk users 1 Jul 25 14:28 y

% less y
foo

% rm x
% ls -li
38066 lrwxrwxrwx 1 kmk users 1 Jul 25 14:28 y

% less y
foo


Recovering files from backups:

Because rsync doesn't put the backed up files into any kind of archive this is as simple as copying a file. Just find the file you need on the backup server and copy it to where you need it to be. If you are restoring it to another server just use scp to get it there.

Rotating backups

In order to get incremental backups we will use a special feature of the cp command that will copy an entire directory tree by making hard links of each file instead of actually duplicating them. First you count up how many existing backups there are and decide if there are too many. If so delete the oldest . Then you use cp -al to duplicate the most recent backup into a new directory with the current time stamp.


Monthly incremental for Repository using Rsync and Hard links.

#source directory for backup
source=/home/docs/

#target for backup
target=/inc_bak/document/monthly

#bakup directory name assignment
bakdir=$(date +%b_monthly_bak)

#rsync between source and target
rsync -arq --delete $source $target/base

#echo "Rsync Completed Sucessfully."

#If backup dir exist remove.
if [ -d $target/$bakdir ]; then
#echo "file exist so removed."
rm -fr $target/$bakdir ;
fi;

#Create hard link for base.
cp -alfr $target/base/* $target/$bakdir/

#echo "Hard Link Completed Successfully."

Description:

rsync -arq --delete $source $target/base

-a, --archive archive mode
-r, --recursive recurse into directories
--delete delete files that don't exist on sender
-q, --quiet suppress non-error messages

cp -alfr $target/base/* $target/$bakdir/

-a archive mode
-l only copy the link
-f force
-r recursively

Reference :

Home site for Rsync: http://rsync.samba.org/

Article for Rsync with Hard link :

http://www.sanitarium.net/golug/rsync_backups.html


technorati tags:, , , ,

Friday, June 23, 2006

CVS-Concurrent Versioning System

1.Introduction:

CVS is a version control system. Using it, you can record the history of your source files.

CVS started out as a bunch of shell scripts written by Dick Grune, posted to the newsgroup
comp.sources.unix in the volume 6 release of July, 1986. While no actual code from these shell
scripts is present in the current version of CVS much of the CVS conflict resolution algorithms
come from them.

n April, 1989, Brian Berliner designed and coded CVS. Jeff Polk later helped Brian
with the design of the CVS module and vendor branch support.

You can get CVS in a variety of ways, including free download from the Internet.
For more information on downloading CVS and other CVS topics, see:

http://www.cvshome.org/


2.CVS Installation:

Now a days Most of the linux distributions bundled with CVS packages.
If you want to upgrade or install , get the source code from the internet.
untar and compile as follow,

tar -xvzf <cvspack.tar.gz>

Inside cvspack dir,

./configure
make
make install


For detailed information read the INSTALL file.


3.CVS Repository Settings:

Create the user and group as cvs.

Give write permission to /home/cvs and ownership as cvs:cvs.

login as cvs and give

$ cvs init

Add the users under cvs group.

The directory being imported must have read permission by cvs otherwise
to avoid confusion chown as cvs:cvs for whole directory.

To specify about binary files, provide binary file details under CVSROOT/cvswrappers files as follow,

*.gif -k 'b'
*.png -k 'b'
*.tgz -k 'b'
*.doc -k 'b'
*.zip -k 'b'
*.pdf -k 'b'
*.so -k 'b'
*.o -k 'b'
*.a -k 'b'
*.psd -k 'b'
*.tiff -k 'b'
*.exe -k 'b'
*.jpg -k 'b'
*.ico -k 'b'
*.bmp -k 'b'
*.png -k 'b'
*.afm -k 'b'
*.jpeg -k 'b'
*.tif -k 'b'

For Binary files

There are two issues with using CVS to store binary files. The first is that
CVS by default converts line endings between the canonical form in which they
are stored in the repository (linefeed only), and the form appropriate to the operating
system in use on the client (for example, carriage return followed by line feed for Windows NT).

The second is that a binary file might happen to contain data which looks like a keyword
(see section Keyword substitution), so keyword expansion must be turned off.
The `-kb' option available with some CVS commands insures that neither line ending
conversion nor keyword expansion will be done.

$ cvs import -I ! -W "*.o -k 'b'" <module name> <vendor tag> <reltag>

-I name
Specify file names that should be ignored during import. You can use this option repeatedly.
To avoid ignoring any files at all (even those ignored by default), specify `-I !'.

-W spec
Specify file names that should be filtered during import. You can use this option repeatedly.
spec can be a file name pattern of the same type that you can specify in the `.cvswrappers' file.

-kb Insures that neither line ending conversion nor keyword expansion will be done.


In /etc/profile in server(for client side see remote repository section)

export EDITOR=/usr/bin/emacs
export CVSROOT=/home/cvs


4.Accessing Remote Repository using pserver (Password Authentication server).

From the Server side..........

Set /etc/xinet.d/cvs as

service cvspserver
{
port =2401
socket_type = stream
protocol =tcp
wait = no
user = root
passenv =PATH
group = cvs
server = /usr/bin/cvs
server_args =-f --allow-root=/home/cvs pserver
disable = no
}

In client side in /etc/profile add the following lines,

export CVSROOT=":pserver:x.x.x.x:2401/home/cvs"
export EDITOR="/usr/sbin/emacs"


x.x.x.x - Server IP Address

5.Read-only Permission

It is possible to grant read-only repository access to people using the password-authenticated server

There are two ways to specify read-only access for a user: by inclusion, and by exclusion.
"Inclusion" means listing that user specifically in the `$CVSROOT/CVSROOT/readers' file, which is simply a newline-separated list of users. Here is a sample `readers' file:

bala
muthu
seenu

"Exclusion" means explicitly listing everyone who has write access--if the file

$CVSROOT/CVSROOT/writers

exists, then only those users listed in it have write access, and everyone else has read-only access (of course, even the read-only users still need to be listed in the CVS `passwd' file). The `writers' file has the same format as the `readers' file.

If `readers' exists, and this user is listed in it, then she gets read-only access. Or if `writers' exists, and this user is NOT listed in it, then she also gets read-only access (this is true even if `readers' exists but she is not listed there). Otherwise, she gets full read-write access.

Thats it.....you successfully set the cvs repository for ur project.


6.Getting Repository

To get the repository login and give your passwd

$cvs login

To get the files checkout the project as follows,

$cvs checkout <module>


After checkout the module (project) if you want to add the binary files,

$ cvs add -kb -m"A test file" <bin_file>
$ cvs ci -m"First checkin; contains a keyword" kotest


If a file accidentally gets added without `-kb', one can use the cvs admin command to recover. For example:

$ cvs add -m"A test file" <bin_file>
$ cvs ci -m"First checkin; contains a keyword" <bin_file>
$ cvs admin -kb <bin_file>
$ cvs update -A <bin_file>
$ cvs commit -m "make it binary" <bin_file>


7.Script for Binary files

If you import large project with lot of binary files, enjoy with the following
automated script

#!/bin/bash

#Searching binary files and put that path in to forcvs.tmp
find * -exec file {} ';'|grep -v text|grep -v directory|grep -v Entries|grep -v Repository|grep -v Root|grep -v empty |grep -v Text| awk '{print $1}'|cut -d ":" -f1 >forcvs.tmp

#Reading line by line and specifying it as binary files.
cat forcvs.tmp | while read line;

do
{
echo $line

cvs admin -kb $line
cvs update -kb $line
cvs commit -m "binary files" $line
}
done


Run the above script inside the repository.


Errors and Solutions:

Problem : Connection Refused
Solution : Due to wrong ip or port.

Problem : Failed to open /home/bala/.cvspass for reading: No such file or directory.
: Fatal error aborting,
bala :no such user
Solution : Check whether the user exist and the home directories are created.

Problem : Authorization failed.
Solution : Add the user name in writers and passwd file.

Problem : Can not make the directory.. (while checkout)
Solution : Give Permission to the directory where u want to checkout.

Problem : cvs[init aborted]: can not make directory Emptydir :permission denied
Solution : logout and login again .

Problem : Lock problem while checkout ....
Solution : After first import change the mode of the files by the users under cvs group can
able to read the files.

technorati tags:, ,

APMP-ApachePhpMysqlPostgresql Installation

1.Introduction

This post describes the installation of PostgreSQL-8.0.3 , Mysql-4.1.12 , Apache-2.0.54 and PHP 5.0.5 . from the source code distribution.

Command details to open

#tar -xvzf <tar.gz file>
#tar -xvjf <tar.bz2 file>

x -Extract
v-Verbose
z-for gnu zip file
j-for bz file
f-use archieve file

1. PostgreSQL Installation.

$ ./configure
(Note:--without-readline
Prevents use of the Readline library. This disables command-line editing and history in psql, so it is not recommended.If the configuration stop and show the readline error,
use this option.)
$ gmake
$ su
$ gmake install
$ useradd postgres
$ mkdir /usr/local/pgsql/data
$ chown postgres /usr/local/pgsql/data
$ su - postgres
$ /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
$ /usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data >logfile 2>&1 &
$ /usr/local/pgsql/bin/createdb test
$ /usr/local/pgsql/bin/psql test8


2.Mysql Installation.

$ groupadd mysql
$ useradd -g mysql mysql
$ gunzip < mysql-VERSION.tar.gz | tar -xvf -
$ cd mysql-VERSION
$ ./configure --prefix=/usr/local/mysql
$ make
$ make install
$ cp support-files/my-medium.cnf /etc/my.cnf
$ cd /usr/local/mysql
$ bin/mysql_install_db --user=mysql
$ chown -R root .
$ chown -R mysql var
$ chgrp -R mysql .
$ bin/mysqld_safe --user=mysql &


3.Apache Installation

$ ./configure --prefix=PREFIX --enable-module=so
$ make
$ make install
$ PREFIX/bin/apachectl start


Replace PREFIX with the filesystem path under which
Apache should be installed. A typical installation
might use "/usr/local/apache2" for PREFIX (without the
quotes).

--enable-module=so This is for accept the modules as Shared Module.


4.PHP Installation.

$./configure --with-mysql=<mysql path>
--with-pgsql=<pgsql path>
--with-apxs2=<apx path>
--with-config-file-path=/usr/local/apache2/
--with-zlib

Mostly the paths will be

mysql path=/usr/local/mysql/
pgsql path=/usr/local/pgsql/
apx path= /usr/local/apache2/bin/apxs

Note:
--with-config-file-path=/usr/local/apache2/
This is used to set the path for php.ini.(if you want to change the default location (/etc/php.ini) use this option)

$ make
$ make install

If you decide to change your configure options after installation,
you only need to repeat the last three steps. You only need to
restart apache for the new module to take effect. A recompile of
Apache is not needed.

5.Configure Apache and php.ini

Setup your php.ini file:

$ cp php.ini-dist /usr/local/lib/php.ini

You may edit your .ini file to set PHP options.

Edit your httpd.conf to load the PHP module. The path on the right hand
side of the LoadModule statement must point to the path of the PHP
module on your system. The make install from above may have already
added this for you, but be sure to check.
For PHP 4:
LoadModule php4_module libexec/libphp4.so
For PHP 5:
LoadModule php5_module libexec/libphp5.so

Tell Apache to parse certain extensions as PHP. For example,
let's have Apache parse the .php extension as PHP. You could
have any extension(s) parse as PHP by simply adding more, with
each separated by a space. We'll add .phtml to demonstrate.

AddType application/x-httpd-php .php .phtml

It's also common to setup the .phps extension to show highlighted PHP
source, this can be done with:

AddType application/x-httpd-php-source .phps


Reference :


1.http://www.apache.org

2.http://dev.mysql.com

3.http://php.net

4.http://www.postgresql.org



technorati tags:, , , ,

Wednesday, June 21, 2006

PHP-Mysql extension

I have installed suse 10 with apache and php but i forgot to install mysql.

While working with project it gives

" mysql extension not installed"

error.

So later i installed php-mysql extension using yast. It automatically puts the

lib file mysql.so under

/usr/local/lib/php5/extensions directory.

This path is already there under php.ini file.

After restarting apache , my sites are working well.



technorati tags:, ,