Archive for the ‘CentOS’ Category

This is a list of handy MySQL commands that I use frequently.

Below when you see # it means from the unix shell. When you see mysql> it means from a MySQL prompt after logging into MySQL.

To login (from unix shell) use -h only if needed.
# [mysql dir]/bin/mysql -h hostname -u root -p

Create a database on the sql server.
mysql> create database [databasename];

List all databases on the sql server.
mysql> show databases;

Switch to a database.
mysql> use [db name];

To see all the tables in the db.
mysql> show tables;

To see database’s field formats.
mysql> describe [table name];

To delete a db.
mysql> drop database [database name];

To delete a table.
mysql> drop table [table name];

Show all data in a table.
mysql> SELECT * FROM [table name];

Returns the columns and column information pertaining to the designated table.
mysql> show columns from [table name];

Show certain selected rows with the value “whatever”.
mysql> SELECT * FROM [table name] WHERE [field name] = "whatever";

Show all records containing the name “Bob” AND the phone number ‘3444444′.
mysql> SELECT * FROM [table name] WHERE name = "Bob" AND phone_number = '3444444';

Show all records not containing the name “Bob” AND the phone number ‘3444444′ order by the phone_number field.
mysql> SELECT * FROM [table name] WHERE name != "Bob" AND phone_number = '3444444' order by phone_number;

Show all records starting with the letters ‘bob’ AND the phone number ‘3444444′.
mysql> SELECT * FROM [table name] WHERE name like "Bob%" AND phone_number = '3444444';

Show all records starting with the letters ‘bob’ AND the phone number ‘3444444′ limit to records 1 through 5.
mysql> SELECT * FROM [table name] WHERE name like "Bob%" AND phone_number = '3444444' limit 1,5;

Use a regular expression to find records. Use “REGEXP BINARY” to force case-sensitivity. This finds any record beginning with a.
mysql> SELECT * FROM [table name] WHERE rec RLIKE "^a";

Show unique records.
mysql> SELECT DISTINCT [column name] FROM [table name];

Show selected records sorted in an ascending (asc) or descending (desc).
mysql> SELECT [col1],[col2] FROM [table name] ORDER BY [col2] DESC;

Return number of rows.
mysql> SELECT COUNT(*) FROM [table name];

Sum column.
mysql> SELECT SUM(*) FROM [table name];

Join tables on common columns.
mysql> select lookup.illustrationid, lookup.personid,person.birthday from lookup left join person on lookup.personid=person.personid=statement to join birthday in person table with primary illustration id;

Creating a new user. Login as root. Switch to the MySQL db. Make the user. Update privs.
# mysql -u root -p
mysql> use mysql;
mysql> INSERT INTO user (Host,User,Password) VALUES('%','username',PASSWORD('password'));
mysql> flush privileges;

Change a users password from unix shell.
# [mysql dir]/bin/mysqladmin -u username -h hostname.blah.org -p password 'new-password'

Change a users password from MySQL prompt. Login as root. Set the password. Update privs.
# mysql -u root -p
mysql> SET PASSWORD FOR 'user'@'hostname' = PASSWORD('passwordhere');
mysql> flush privileges;

Recover a MySQL root password. Stop the MySQL server process.
Start again with no grant tables.
Login to MySQL as root.
Set new password.
Exit MySQL and restart MySQL server.
# /etc/init.d/mysql stop
# mysqld_safe --skip-grant-tables &
# mysql -u root
mysql> use mysql;
mysql> update user set password=PASSWORD("newrootpassword") where User='root';
mysql> flush privileges;
mysql> quit
# /etc/init.d/mysql stop
# /etc/init.d/mysql start

Set a root password if there is on root password.
# mysqladmin -u root password newpassword

Update a root password.
# mysqladmin -u root -p oldpassword newpassword

Allow the user “bob” to connect to the server from localhost using the password “passwd”. Login as root. Switch to the MySQL db. Give privs. Update privs.
# mysql -u root -p
mysql> use mysql;
mysql> grant usage on *.* to bob@localhost identified by 'passwd';
mysql> flush privileges;

Give user privilages for a db. Login as root. Switch to the MySQL db. Grant privs. Update privs.
# mysql -u root -p
mysql> use mysql;
mysql> INSERT INTO db (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv) VALUES ('%','databasename','username','Y','Y','Y','Y','Y','N');
mysql> flush privileges;

or

mysql> grant all privileges on databasename.* to username@localhost;
mysql> flush privileges;

To update info already in a table.
mysql> UPDATE [table name] SET Select_priv = 'Y',Insert_priv = 'Y',Update_priv = 'Y' where [field name] = 'user';

Delete a row(s) from a table.
mysql> DELETE from [table name] where [field name] = 'whatever';

Update database permissions/privilages.
mysql> flush privileges;

Delete a column.
mysql> alter table [table name] drop column [column name];

Add a new column to db.
mysql> alter table [table name] add column [new column name] varchar (20);

Change column name.
mysql> alter table [table name] change [old column name] [new column name] varchar (50);

Make a unique column so you get no dupes.
mysql> alter table [table name] add unique ([column name]);

Make a column bigger.
mysql> alter table [table name] modify [column name] VARCHAR(3);

Delete unique from table.
mysql> alter table [table name] drop index [colmn name];

Load a CSV file into a table.
mysql> LOAD DATA INFILE '/tmp/filename.csv' replace INTO TABLE [table name] FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' (field1,field2,field3);

Dump all databases for backup. Backup file is sql commands to recreate all db’s.
# [mysql dir]/bin/mysqldump -u root -ppassword --opt >/tmp/alldatabases.sql

Dump one database for backup.
# [mysql dir]/bin/mysqldump -u username -ppassword --databases databasename >/tmp/databasename.sql

Dump a table from a database.
# [mysql dir]/bin/mysqldump -c -u username -ppassword databasename tablename > /tmp/databasename.tablename.sql

Restore database (or database table) from backup.
# [mysql dir]/bin/mysql -u username -ppassword databasename < /tmp/databasename.sql

Create Table Example 1.
mysql> CREATE TABLE [table name] (firstname VARCHAR(20), middleinitial VARCHAR(3), lastname VARCHAR(35),suffix VARCHAR(3),officeid VARCHAR(10),userid VARCHAR(15),username VARCHAR(8),email VARCHAR(35),phone VARCHAR(25), groups VARCHAR(15),datestamp DATE,timestamp time,pgpemail VARCHAR(255));

Create Table Example 2.
mysql> create table [table name] (personid int(50) not null auto_increment primary key,firstname varchar(35),middlename varchar(50),lastnamevarchar(50) default 'bato');

Read the rest of this entry »

The following is a simple (and very row) init script for Symantec Backup Exec Agent for Linux.

I wrote it because I really hate to execute script not registered with chkconfig on a production systems.

I’ve added the “status” function by checking if an executable called “beremote” is listening on 10000/tcp on IPv4 on the localhost.

If you are planning to run ralus on a different TCP port, please fix the script.

The following is the script :


#!/bin/sh
#
# RALUS Control Script
# chkconfig: 2345 99 01
# Description: Here is a little startup/shutdown script for RedHat/CentOS systems
#
# Author : Riccardo Riva
#
# description: Symantec Backup Exec Linux Agent Init Script
#
# Source function library.
. /etc/rc.d/init.d/functions

RETVAL=0

# See how we were called.

if [ ! -d /opt/VRTSralus ]
then
 echo "Symantec Backup Exec Remote Agent missing /opt/VRTSralus             [FAILED]"
 exit 1
fi

if [ ! -d /etc/VRTSralus ]
then
 echo "Symantec Backup Exec Remote Agent missing /etc/VRTSralus             [FAILED]"
 exit 1
fi

if [ ! -d /var/VRTSralus ]
then
 echo "Symantec Backup Exec Remote Agent missing /var/VRTSralus             [FAILED]"
 exit 1
fi

CMD="$1"

case "$CMD" in
'start')
 if [ -x /opt/VRTSralus/bin/beremote ]
 then
 echo -n "Starting Symantec Backup Exec Remote Agent "
 rm -f /var/VRTSralus/ralus.pid
 rm -f /var/VRTSralus/ralus.errpid
 /opt/VRTSralus/bin/beremote >/var/VRTSralus/beremote.service.log 2>/var/VRTSralus/beremote.service.log &
 PIDWAIT=30
 while [ "$PIDWAIT" != "0" ]
 do
 if [ -f /var/VRTSralus/ralus.pid ]
 then
 PIDWAIT=0
 else
 PIDWAIT=$(($PIDWAIT-1))
 echo -n "."
 sleep 1;
 fi
 if [ -f /var/VRTSralus/ralus.errpid ]
 then
 PIDWAIT=0
 fi
 done
 if [ -f /var/VRTSralus/ralus.pid ]
 then
 RETVAL=0
 else
 RETVAL=1
 fi
 echo
 else
 RETVAL=1
 fi
 if [ "$RETVAL" = "0" ]
 then
 echo "Starting Symantec Backup Exec Remote Agent:                              [  OK  ]"
 else
 echo "Starting Symantec Backup Exec Remote Agent:                              [FAILED]"
 fi
 ;;
'stop')
 if [ -f /bin/grep ]
 then
 PID=`/bin/ps -e | /bin/grep beremote | /bin/sed -e 's/^  *//' -e 's/ .*//'`
 else
 PID=`/usr/bin/ps -e | /usr/bin/grep beremote | /usr/bin/sed -e 's/^  *//' -e 's/ .*//'`
 fi

 if [ "${PID}" != "" ]
 then
 echo -n "Stopping Symantec Backup Exec Remote Agent "
 if [ -f /bin/pkill ]
 then
 /bin/pkill -15 beremote
 else
 /usr/bin/pkill -15 beremote
 fi
 RETVAL=$?

 PIDWAIT=15
 while [ "$PIDWAIT" != "0" ]
 do
 if [ -f /var/VRTSralus/ralus.pid ]
 then
 PIDWAIT=0
 RETVAL=0
 else
 PIDWAIT=$(($PIDWAIT-1))
 echo -n "."
 sleep 1;
 fi
 done
 echo
 rm -f /var/VRTSralus/ralus.pid
 rm -f /var/VRTSralus/ralus.errpid
 else
 RETVAL=1
 fi

 if [ "$RETVAL" = "0" ]
 then
 echo "Stopping Symantec Backup Exec Remote Agent:                              [  OK  ]"
 else
 echo "Stopping Symantec Backup Exec Remote Agent:                              [FAILED]"
 fi
 ;;
'restart')
 $0 stop
 $0 start
 RETVAL=1
 ;;

'status')
 if [ $(netstat -tulpan | grep beremote |grep 0.0.0.0:10000 | wc -l) -eq 1 ];
 then
 echo "Symantec Backup Exec Remote Agent running and listening on tcp port 10000"
 else
 echo "Symantec Backup Exec Remote Agent not running"
 fi
 ;;

*)
 echo "Symantec Backup Exec Remote Agent for Linux/Unix Servers"
 echo "Usage: VRTSralus.init { start | stop | restart | status}"
 RETVAL=1
 ;;
esac

exit $RETVAL

#
# -- End of file

You should download the file here : http://www.riccardoriva.com/shared-files/ralus_init_script.sh

Hope this help

Bye
Riccardo

Print This Post Print This Post

If you use Postgrey (and you should do it) on your mail servers and you want to have some statistics on the amount of greylisted messages and other information, you should find useful the following script.

The scripts assume that you have installed Postgrey (http://postgrey.schweikert.ch/) on RHEL (http://www.redhat.com) or CentOS (http://www.centos.org).
If you are using other distros you may fix some path problems.

Create a file called “greylisting_statistics.sh” in your “/usr/local/bin” folder with the following content :

#!/bin/sh

LOGFILE=/tmp/greylist-statistics
YOURMAIL=you@yourdomain.com

echo -n "Total amount of GreyListed messages" > $LOGFILE
cat /var/log/maillog | /usr/sbin/postgreyreport --delay=300 >> $LOGFILE
echo -ne  "\n" >> $LOGFILE
echo -ne  "-------------------------------------\n" >> $LOGFILE
echo -ne  "-------------------------------------\n" >> $LOGFILE
echo -n "Get only the top 20 sources getting greylisted out" >> $LOGFILE
cat /var/log/maillog | postgreyreport | awk '{print $1}' | sort | uniq -c | sort -nr | head -n20 >> $LOGFILE
echo -ne  "\n" >> $LOGFILE
echo -ne  "-------------------------------------\n" >> $LOGFILE
echo -ne  "-------------------------------------\n" >> $LOGFILE
echo -n "Get a list of the top 20 email address that the greylisted sources are sending email to"  >> $LOGFILE
cat /var/log/maillog | postgreyreport | awk '{print $4}'  | sort  | uniq -c | sort -nr | head -n20
echo -ne  "\n" >> $LOGFILE
echo -ne  "-------------------------------------\n" >> $LOGFILE
echo -ne  "-------------------------------------\n" >> $LOGFILE

cat $LOGFILE | mail -s "Greylisting Statistics of `hostname` for `date +%Y-%m-%d`" $YOURMAIL
#--- End of file ---

Assign to it the correct ownership and permission by running :

chmod 700 /usr/local/bin/greylisting_statistics.sh
chown root:root /usr/local/bin/greylisting_statistics.sh

Schedule the execution using “crontab -e” and adding the following line to have a daily based statistics :

59 23 * * * /usr/local/bin/greylisting_statistics.sh

Hope this help

Bye
Riccardo

Print This Post Print This Post

This simple How-To will explain a raw and dirt method to daemonize to http manager for ARECA Raid Controller.

If you have this controller on your system you should find in the bundled CD-ROM the following folder :

root
PACKAGES -> Linux -> CLI -> version -> i386 -> cli32

PACKAGES -> Linux -> CLI -> version -> x86-64 -> cli32

PACKAGES -> Linux -> HTTP -> version.x.y.x -> i386 -> archttp32

PACKAGES -> Linux -> HTTP -> version.x.y.x -> x86-64 -> archttp32

Create a folder in your /usr/local folder called “areca” e and create into it two folders called “http” and “cli”
Copy the “cli32″ and “archttp32″ executable file that match your architecture (i386 or x86-64) in the specified folder, so you should have something similar :

[root@relay ~]# ls -lahR /usr/local/areca/
/usr/local/areca/:
total 20K
drwxr-xr-x  4 root root 4.0K Feb 12 10:28 .
drwxr-xr-x 13 root root 4.0K Feb 12 10:26 ..
dr-xr-xr-x  2 root root 4.0K Feb 12 10:27 cli
dr-xr-xr-x  2 root root 4.0K Feb 12 10:42 http

/usr/local/areca/cli:
total 1.6M
dr-xr-xr-x 2 root root 4.0K Feb 12 10:27 .
drwxr-xr-x 4 root root 4.0K Feb 12 10:28 ..
-r-xr-xr-x 1 root root 1.6M Dec 26  2008 cli32

/usr/local/areca/http:
total 1.6M
dr-xr-xr-x 2 root root 4.0K Feb 12 10:42 .
drwxr-xr-x 4 root root 4.0K Feb 12 10:28 ..
-r-xr-xr-x 1 root root 1.6M Dec 26  2008 archttp32
-rw-r--r-- 1 root root   91 Feb 12 10:42 archttpsrv.conf

Create a new file called “areca” in your /etc/init.d folder with the following content :

#!/bin/sh
#
# Startup script for the ARECA RAID CONTROLLER HTTP Monitor
#
# chkconfig: 2345 62 38
# description: HTTP Tools to monitor and manage ARECA RAID Controller
#
# processname: archttp32
# config: none
# lockfile: /var/lock/subsys/archttp32
#
# Author: Riccardo Riva
# WebSite: http://www.riccardoriva.com
#
# This script is realeased under the terms of the GPL.
#====================================================================

# Source function library
. /etc/init.d/functions

RETVAL=0

start() {
echo -n $"Starting ARECA HTTP Manager: "
daemon /usr/local/areca/http/archttp32 2>&1>/dev/null &
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/archttp32
return $RETVAL
}

stop() {
echo -n $"Stopping ARECA HTTP Manager: "
killproc archttp32
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/archttp32
return $RETVAL
}

restart() {
stop
start
}

reload() {
echo -n $"Reloading ARECA HTTP Manager: "
killproc archttp32 -ALRM
RETVAL=$?
echo
return $RETVAL
}

case "$1" in
start)
start
;;
stop)
stop
;;
status)
status archttp32
;;
restart)
restart
;;
condrestart)
[ -f /var/lock/subsys/archttp32 ] && restart || :
;;
reload)
reload
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
exit 1
esac

exit $?
#---End of file---

Assing to it the right permission and ownership

chmod 755 /etc/init.d/areca
chown root:root /etc/init.d/areca

You should also place in the executable file folder the configuration file, called “archttp32srv.conf” with the following content :

[GENERAL]
BindingIp=0.0.0.0
HTTPPort=81
SMTPPort=25
ScanPci=YES
ScanRs232=NO
ScanInband=NO
ConnInfo=NO

[MAIL]
Server=MAIL.SERVER.IP.ADDRESS # Please Change ME
Sender=SENDERNAME # Please Change ME
SenderMail=SENDERMAIL # Please Change ME
Account=
Password=
MailToName1=RECEIVERNAME # Please Change ME
MailToName2=
MailToName3=
MailToName4=
MailAddr1=RECEIVERMAIL # Please Change ME
MailAddr2=
MailAddr3=
MailAddr4=
EvtLevel=3
NotifyForNoEvent=NO

[SNMP]
TrapIp1=SNMP.SERVER.IP.ADDRESS # Please Change ME
TrapIp2=0.0.0.0
TrapIp3=0.0.0.0
TrapPort1=162
TrapPort2=162
TrapPort3=162
Community=public
EvtLevel=3

And configure it for startup at boot time.

chkconfig areca on

I know it very dirt, but I had no time left to search a better way, maybe in the future.

Hope this help

Bye
Riccardo

Print This Post Print This Post

In this tutorial I will describe how setup a complete mail server for relaying mail to another server, for example an IMAP server or an Exchange, tipically this machine will be placed in a DMZ network and will be reachable from internet.
I will explain how to install and configure :

- Postgrey : to do GreyListing on incoming mails and avoid SPAM.
- Postfix : to receive mails for local or remote mailboxes and do some checks for trash mail using RBL and internal options.
- Amavisd-New : to scan incoming mails form Viruses and SPAM.
- Clamd : to avoid Amavisd-new virus scan.
- Spamassassin : to avoid amavisd-new SPAM scan with Razor, Pyzor and DCC.
- Altermime : to add a disclaimer (both text and html) for the outgoing mail.
- Cyrus-Sasl : to enable sasl authentication for road warriors.
- Fetchmail : to eventually fetch the mail from another mail server.
- Apache : to create a reverse proxy to reach a webmail service on the internal web server.

I’ll describe all steps needed to install it on RHEL or CentOS because the steps are identical for both distributions and because are my favourites ones.
I’m assuming you’re going to install a 64bit operating system, but if you choose to install the 32bit version pay only attention for some packages to fit your architecture.

First of all you have to install you operating systems. I’ll not explain this process because it’s very simple, but I’ll suggest you to NOT customize the system during the installation procedure, it will be done later.

At the first reboot, disable both Selinux and Firewall, then reboot again and login to your system as user root.

Read the rest of this entry »

This post will explain how to create users and mailboxes for Zarafa.

I’ve tested it with CentOS 5.4 X86_64 and Zarafa 6.30.9 but it will fit with nearly all installation.

First of all you have to create a test file with all the users you want to create, providing the following information :

  • username
  • password
  • email address
  • name
  • surname

For example :

johndoe   password    johndoe@example.com    John    Doe
janedoe    password   janedoe@example.com     Jane     Doe

Save the text file whatever you want.

The following is the shell script that read your text file and create all Zarafa users.

If you use the script, all the users will not be administrator, so you have to create manually and administrator.


#!/bin/bash
# Written by Matteo Predieri - m.predieri_AT_damsistemi_DOT_it
# Written by Riccardo Riva - r.riva_AT_damsistemi_DOT_it
#
# Simple and raw script to create zarafa users and mailboxes from a test file
#
# The full fill-in of the text file is mandatory
# So fill in both "Name" and "Surname" with the following syntax
#
# username    password    email    name    surname
#

USERS_LIST=/tmp/userlists.txt
ZARAFA_CMD=/usr/bin/zarafa-admin
LOGFILE=/tmp/zara_user_creation.log

echo "Zarafa User Creation Log" > $LOGFILE
what="user";

for item in $( cat $USERS_LIST ); do

 if [ $what = "user" ]; then
 user=$item;
 what="passwd";
 else
 if [ $what = "passwd" ]; then
 passwd=$item;
 what="email";
 else
 if [ $what = "email" ]; then
 email=$item;
 what="name";
 else
 if [ $what = "name" ]; then
 name=$item;
 what="surname";
 else
 surname=$item;

 echo "Result in creating User: $user, with password: $passwd, with email address: $email with Full Name: $name $surname :" >> $LOGFILE
 FULLNAME="'$name $surname'"
 $ZARAFA_CMD -c $user -p $passwd -e $email -f "$FULLNAME" -a0 >> $LOGFILE
 echo -ne  "-------------------------------\n" >> $LOGFILE
 what="user";
 fi

 fi
 fi

 fi
done

# --- End of file ---

You’ve done.

Hope this help

Bye
Riccardo

Print This Post Print This Post

Very often it happens that I must give support to a colleague or a customer on a Linux machine.

It’s very difficult to spell all bash command I will use to check which could be the problem, especially by phone.

When I discover “screen” it was a revelation.

With screen http://www.gnu.org/software/screen/screen.html you should share a linux session with other people.

You should use screen by simply ask to the user you want to assist to type on the console the following command :

screen

So if you can connect to the machine (even with ssh) you should run the following command :

screen -x

to share the same bash session.

Hope this help

Bye

Riccardo

Print This Post Print This Post

This simple post will show how to configure Ethernet Bonding on two (or more) network interfaces on RHEL 5 or CentOS 5.
I’ve tested this configuration on a CentOS 5.2 with kernel 2.6.18-92.1.22.el5 as you could see below :

uname -a

Linux serverlab.riccardoriva.local 2.6.18-92.1.22.el5 #1 SMP Tue Dec 16 11:57:43 EST 2008 x86_64 x86_64 x86_64 GNU/Linux

cat /etc/redhat-release
CentOS release 5.2 (Final)

If you want to create a bonding on two interface (i.e. eth0 and eth1) you should do the following :

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

# Bonding eth0 to bond0
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=NO

Edit /etc/sysconfig/network-scripts/ifcfg-eth1

# Bonding eth1 to bond0
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=NO

Copy /etc/sysconfig/network-scripts/ifcfg-eth1 to /etc/sysconfig/network-scripts/ifcfg-bond0 to keep the same file permission by executing the following commands :

cd /etc/sysconfig/network-scripts
copy ifcfg-eth1 ifcfg-bond0

Edit /etc/sysconfig/network-scripts/ifcfg-bond0

ifcfg-bond0
DEVICE=bond0
BOOTPROTO=none
ONBOOT=yes
NETWORK=10.100.100.0
NETMASK=255.255.255.0
IPADDR=10.100.100.1
USERCTL=NO

Edit /etc/modprobe.conf adding the following line :

alias bond0 bonding

Reboot your system to let modules be loaded or load it manually with the following command :

insmod bond0 bonding

If you haven’t rebooted your system, restart your network with the following command :

/etc/init.d/network restart

You should check if bonding is working you should look at /proc/net/bonding/bond0 with the following command :

cat /proc/net/bonding/bond0

and you should see something similar to the following :

Ethernet Channel Bonding Driver: v3.2.4 (January 28, 2008)

Bonding Mode: load balancing (round-robin)
MII Status: up
MII Polling Interval (ms): 0
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth0
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00:15:17:88:5a:3c

Slave Interface: eth1
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00:15:17:88:5a:3d

You’ve done

Hope this help

Bye
Riccardo

Print This Post Print This Post

In some situation you may want to avoid loading a Linux driver module automatically . For example:

- In some cases buggy driver causes kernel BUG or system fault on load so you just want to avoid the problem.

- If your system connected without a diskette / floppy drive; kernel will try to load floppy driver – disable floppy driver or module.

The Linux kernel get module information on boot from /etc/modprobe.conf file and /etc/modprobe.d/* file(s).

If you are using RHEL or CentOS do the following :

open your /etc/modprobe.conf file and turn of auto loading using following syntax:

alias driver-name off

If you are using Debian or Ubuntu do the following :

open /etc/modprobe.d/blacklist file and add driver name using following syntax:

blacklist driver-name

Reboot your system and use lsmod command to show the status of modules in the Linux Kernel.

Hope this help

Bye
Riccardo

Print This Post Print This Post

This simple init script is for daemonize freshclam (Clamd Antivirus Updater) on RHEL or CentOS.

Create a brand new file called freshclam in /etc/init.d/ with the following content :


#!/bin/sh
#
# Startup script for the Clam AntiVirus Update Tool
#
# chkconfig: 2345 62 38
# description: freshclam is an update daemon for Clam AV database.
#
# processname: freshclam
# config: /etc/freshclam.conf
# pidfile: /var/run/clamav/freshclam.pid
#
# Author: Riccardo Riva
# WebSite: http://www.riccardoriva.com
#
# This script is realeased under the terms of the GPL.
#====================================================================

# Source function library
. /etc/init.d/functions

# Get network config
. /etc/sysconfig/network

test -f /etc/freshclam.conf || exit 0

RETVAL=0

start() {
echo -n $"Starting freshclam: "
daemon /usr/bin/freshclam -d -p /var/run/clamav/freshclam.pid
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/freshclam
return $RETVAL
}

stop() {
echo -n $"Stopping freshclam: "
killproc freshclam
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/run/clamav/freshclam.pid /var/lock/subsys/freshclam
return $RETVAL
}

restart() {
stop
start
}

reload() {
echo -n $"Reloading DB: "
killproc freshclam -ALRM
RETVAL=$?
echo
return $RETVAL
}

case "$1" in
start)
start
;;
stop)
stop
;;
status)
status freshclam
;;
restart)
restart
;;
condrestart)
[ -f /var/lock/subsys/freshclam ] && restart || :
;;
reload)
reload
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
exit 1
esac

exit $?

Assign to it corect ownership and permission :

chown root:root /etc/init.d/freshclam
chmod 755 /etc/init.d/freshclam

Test if the scripts works correctly on your system with the following commands :

service freshclam start
service freshclam stop
service freshclam restart
service freshclam reload
service freshclam condstart

If all works fine you should add freshclam to the automatic startup services with the following command :

chkconfig freshclam on

Hope this help
Bye
Riccardo

Print This Post Print This Post

This post will assume you just have a fully functional working mail server and you want do download all emails from some mailboxes located on another mail server, tipically located on your service provider’s one.
This post guide will guide you to install and configure fetchmail and use it with your RHEL 5 or newer, you should use all the following information also with CentOS without change any line, but you shoud adapt it to every Linux distribution.
Most likely you want to setup fetchmail to download your domain mailbox over pop3 and inject into Postfix (or whatever you use as MTA).

To install fetchmail use the following :

yum install fetchmail -y

You should decide how to use fetchmail :

* as a daemon
* as a cron scheduled task

Read the rest of this entry »

This post will explain how to configure a backup MX server for queuing mail for two (or more) domains if the primary mail server of those domains become unreachable.
I’ve tested this configuration for relaying mail to Microsoft Exchange, Postfix, QMail, Sendmail, Lotus Domino, Merak and other less common mail server without any kind of problems.

You could use Red Hat Enterprise Linux (RHEL) or CentOS without change an line of the following configuration, but with small adjustement you can use this how to to any linux distribution.

I’ve used Postfix as mail server, because for me it’s the best, and Amavisd-New, Clamd and SpamAssassin for checking Virus and Spam on relaying mail.

This post assume you have two queuing for two domains “yourdomain.com” and “yourdomain.net”.
This post assume that you have a primary mail server (MX with preference 10) for “yourdomain.com” with IP 111.111.111.111 and a primary mail server (MX with preference 10) for “yourdomain.com” with IP 111.222.222.222 and you want to use a server with IP 222.222.222.222 for queuing mail of both domains.

Read the rest of this entry »

This post will explain how to configure a relay server to put on a DMZ network for relay mail for two domains, and use two mail server on the internal network.
This configuration will be useful to not publish your SMTP server (Linux, Exchange, Lotus Domino or whatever you have) directly on internet, and keep it in your internal network, and publish a relay server for security purpose.
I’ve tested this configuration for relaying mail to Microsoft Exchange, Postfix, QMail, Sendmail, Lotus Domino, Merak and other less common mail server without any kind of problems.

You could use Red Hat Enterprise Linux (RHEL) or CentOS without change an line of the following configuration, but with small adjustement you can use this how to to any linux distribution.

I’ve used Postfix as mail server, because for me it’s the best, and Amavisd-New, Clamd and SpamAssassin for checking Virus and Spam on relaying mail.

This post assume you have two internal network 192.168.1.0/24 and 192.168.2.0/24 and you have a mail server for yourdomain.com on the 192.168.1 network and another mail server for yourdomain.net on 192.168.2 network.

In particular the yourdomain.com mail server have 192.168.1.4/24 and yourdomain.net mail server have 192.168.2.1/24.

This post will also explain how to configure a simple SMTP authentication based on sasl to authenticate external user directly on the relay server and permit them to send mail to any ther domain using it.

Read the rest of this entry »

This article assume you have two system with RHEL 5.2 X86_64 installed and you want to create a cluster to have High Availability for some services (in this article Apache Web Server).

This article also assume that you have a shared storage accessible from the two system, as for example a Storage Area Network (SAN) Fibre Channel oer iSCSI and you have free space on it.
Read the rest of this entry »

At today, RedHat does not have a native iSCSI target for RHEL5.2, so if you’re tired to use some other products like OpenFiler or similar, you could install it from source. Today (January, 25th 2009) there’s iSCSI target version 0.4.17 so you could use it.

All the following how-to is based on a RHEL 5.2 X86_64 installed from DVD and not updated.

Read the rest of this entry »

This post will explain hot-to configure a unique IP Address on multiple NICs (Phisical or Virtual) on RedHat Linux (or Fedora).

This post assume you have a 192.168.1.0/24 network and that you want to assign 192.168.1.1/24 to your system.

Read the rest of this entry »

This post will explain hot-to configure multiple IP Address on ONE nic (Phisical or Virtual) on RedHat Linux (or Fedora).

This post assume you have a 192.168.1.0/24 network and that you want to assign 192.168.1.1/24 and 192.168.1.2/24 to your system.

Read the rest of this entry »

The following is a very simple init script for Oracle on Red Hat Enterprise Linux.
I’m using it successfully in RHEL 5.2 but you can use it on other systems, only double check the various path.

#!/bin/sh
#
# ORACLE Control Script
# chkconfig: 3 80 20
#
# Description: Here is a little startup/shutdown script for Oracle 10g on RedHat systems
#
# Author : Riccardo Riva
#
# Source LSB function library.
[ -f /lib/lsb/init-functions ] && . /lib/lsb/init-functions

#Assuming have Oracle installed on :
# /oracle/product/10.2.0/db1
ORACLE_HOME=/oracle/product/10.2.0/db_1

#Assuming have “oracle” user
ORACLE_OWNER=oracle

# Edit this with your DB instance name
ORACLE_DB=DB_INSTANCE_NAME

if [ ! -f $ORACLE_HOME/bin/dbstart ]
then
echo “Oracle startup: cannot start”
exit
fi

case “$1″ in
’start’)
# Start the Oracle databases:
su – $ORACLE_OWNER -c “$ORACLE_HOME/bin/lsnrctl start”
su – $ORACLE_OWNER -c $ORACLE_HOME/bin/dbstart
;;
’stop’)
# Stop the Oracle databases:
su – $ORACLE_OWNER -c $ORACLE_HOME/bin/dbshut
su – $ORACLE_OWNER -c “$ORACLE_HOME/bin/lsnrctl stop”
;;
’status’)
if su -l $ORACLE_OWNER -c “${ORACLE_HOME}/bin/tnsping ${ORACLE_DB} >/dev/null 2>&1″
then
exit 0
else
exit 1
fi

;;
esac

Create this script and put it in your /etc/init.d/ directory

Make this script excutable

Use “chkconfig” to set the startup or the shutdown for this script in the desired runlevels.

Hope this help avoid wasting time

Bye
Riccardo

Some days ago I had to install an Oracle 10.2.0 x64 on system with Red Hat Enterprise Linux 5.2 x64.

I found some problem, and the following is the prerequisites and some tricks to make the setup process works.

Prerequisites packages :

binutils-2.17.50.0.6-2.el5
compat-gcc-34-3.4.6-4
compat-gcc-34-c++-3.4.6-4
compat-libstdc++-33-3.2.3-61
compat-libstdc++-33-3.2.3-61(i386)
control-center-2.16.0-14.el5
gcc-4.1.1-52.el5
gcc-c++-4.1.1-52.el5
gdbm-1.8.0-26.2.1
glibc-2.5-12
glibc-common-2.5-12
glibc-devel-2.5-12
glibc-devel-2.5-12(i386)
libgcc-4.1.1-52.el5(i386)
libgcc-4.1.1-52.el5(x86_64)
libgnome-2.16.0-6.el5
libstdc++-devel-3.4.3-22.1
libXp-1.0.0-8.i386
libXp-1.0.0-8.x64
make-3.81-1.1
sysstat-7.0.0-3.el5.x86_64.rpm
util-linux-2.13-0.44.e15.x86_64

Tricks
- Make sure to put in your /etc/hosts the ip address and the name and FQDN name of your server as the folowing example :
192.168.1.1 server.myfactory.local server

- Make sure you have SELINUX disabled, using the following command :
cat /etc/selinux/config | grep SELINUX

- Create some necessary user and group :
groupadd oinstall
groupadd dba
groupadd oper
useradd –g oinstall –G dba oracle

- Assing a password to “oracle” user and don’t forget to assign it a usfeul shell, because you must login with “oracle” to an X-Session to run the installer.

Setup Procedure

After checking all the above, you must login as “oracle” to an X-Session (local or remote as you prefer) and run the following command :
runInstaller -ignoreSysPrereqs

You must use “-ignoreSysPrereqs” because RHEL5 is not in the operative system supported list.
This is not a problem, and you could use that option to avoid installer exit with a warning.

If all prerequisites and tricks is fine, you could now procede with Oracle installation.

Hope this help someone avoid wasting time.

Bye
Riccardo

Print This Post Print This Post

Here is the code for an advanced startup/shutdown script for JBoss.

I’m using it with JBoss 3.2.6 on a RHEL 5.2 Advanced Platform, and all works well.

I’ve added the “status” function for use it in a cluster suite and a new function to check if Oracle DB Server is up and running, otherwise JBoss doesn’t deploy well all developers files.

When you use “start” function, the script use a simple “tnsping” based function that loop into themselves until Oracle is not fully working and then sleep other 10 seconds to start JBoss.

JBoss startup/shutdown script with Oracle Support

Hope this help
Bye
Riccardo

Print This Post Print This Post
Contacts
Look at me at Linkedin Follow me on Twitter
My Flickr Albums My Facebook profile My YouTube Videos
SkypeMe My Linux Counter GMail me
Search
Google Search
Categories
Tag Cloud 3D
FeedBurner RSS

Visitors
Locations of visitors to this page
VMware related Blogs
The following are Blog sites with feeds I personally follow. When I'll have some spare time I will complete all Feed and Twitter links.