Showing posts with label Plain Server Task. Show all posts
Showing posts with label Plain Server Task. Show all posts

Tuesday, April 8, 2008

Steps for Kernel Upgrade

Following are steps to upgrade kernel on live servers.

1. Check current version of kernel on server using command uname -a, if
its 2.4 then download latest release for 2.4 please do not download 2.6
kernel.
You can download kernel from
http://www.kernel.org/pub/linux/kernel/v2.6/
if its 2.4 then http://www.kernel.org/pub/linux/kernel/v2.4/, you can
check latest stable release from http://www.kernel.org

2. wget kernel in /usr/local/src
3. untar it using tar -zxvf linux-2.x-xxxx
4. cd linux-2.x-x
5. make clean
6. make mrproper
7. If kernel is 2.4 then copy current version of config file from
/boot/config-’uname-r’ as .config in /usr/local/src/linux-2.x-xx, if
kernel is 2.6 then you do not need to make .config in current directory
8. make menuconfig, select and check if all required modules are
selected,
also make sure that your kernel supports multiple cpu
you can check it and select from processor type, if it displays support
for more then 2 kernel then you do not need to modify anything there.
9. save configuration and exit
10. make modules if kernel is 2.4 then need to run make dep before
running
make modules
11. make modules_install
12. make
13. if 2.4 kernel then need to run make bzImage and then make install,
you can directly run make install if kernel is 2.6
15. now make sure bootloader and modify default kernel accordingly
grubby –bootloader-probe if it displays grub then edit /etc/grub.conf
and
if its lilo then edit lilo.conf and make compiled kernel as default
kernel
16. If your boot loader is lilo then you need to run one more command
/sbin/lilo which will update lilo
17. now its time to reboot server

Postfix + ClamAV + MailScanner in OpenSuse 10.2

1) Install the anti virus software (Clamav) –> (here) http://rpm.pbone.net/
rpm -ivh clamav-db-0.88.2-1.i386.rpm
rpm -ivh clamav-devel-0.88.2-1.i386.rpm
rpm -ivh clamav-server-0.88.2-1.i386.rpm
rpm -ivh clamav-0.88.2-1.i386.rpm

/etc/init.d/clamd start

2. Once the anti-virus is install then we need to install the MailScanner software the RPM along with the source files can be found at
http://www.sng.ecs.soton.ac.uk/mailscanner/downloads.shtml

Now get ready to install the mailscanner, this is going to take a long time.

gzip -d MailScanner-4.46.2-2.rpm.tar.gz
tar -xvf MailScanner-4.46.2-2.rpm.tar
cd MailScanner-4.46.2-2
./install.sh

3. In your MailScanner.conf file in /etc/MailScanner, there are 5 settings you need to change. The settings are:

Run As User = postfix
Run As Group = postfix
Incoming Queue Dir = /var/spool/postfix/hold
Outgoing Queue Dir = /var/spool/postfix/incoming
MTA = postfix

4. You will need to ensure that the user “postfix” can write to

/var/spool/MailScanner/incoming and /var/spool/MailScanner/quarantine

chown postfix:postfix /var/spool/MailScanner/incoming
chown postfix:postfix /var/spool/MailScanner/quarantine

5. Edit file MailScanner.conf
Virus Scanners = clamav

6. Edit virus.scanners.conf
clamav /usr/lib/MailScanner/clamav-wrapper /var/lib/clamav

7. Now we need to edit the postfix main.cf file, go all the way to the bottom of the file and add the following
header_checks = regexp:/etc/postfix/header_checks

8. In the file /etc/postfix/header_checks add this line:
/^Received:/ HOLD

9. Set the servers to run on startup and then start them

chkconfig MailScanner on
chkconfig postfix on
chkconfig clamd on

/etc/init.d/Mailscanner start
/etc/init.d/postfix start
/etc/init.d/clamd start

Wednesday, March 19, 2008

How to create your own mysql package on freebsd or debian

If you need an updated mysql package for your system, but one isn't available in the format you need, you can compile your own. First go to dev.mysql.com and download the tar.gz package you want, eg:

wget http:///path/to/mysql-5.0.27.tar.gz
tar xvzf mysql-5.0.27.tar.gz
cd mysql-5.0.27

Then you need to configure mysql for your sytem. Type:

CFLAGS=-DHAVE_BROKEN_REALPATH ./configure --prefix=/usr/local/mysql --with-extra-charsets=all --enable-thread-safe-client --enable-local-infile --enable-assembler --with-named-z-libs=not-used --disable-shared --enable-static

If the configure succeeds, then you can compile it:

make
This will likely take a long time as mysql is very large. Once it finishes, to create the binary package, type:

./scripts/make_binary_distribution

This will assemble all binary files and scripts and put them into a tar.gz for you, which should be in the directory you're currently in:

server# ls -la *.tar.gz
-rw-r--r-- 1 root 100 23977052 Jul 31 2006 mysql-5.0.27-freebsd6.0-i386.tar.gz

The naming format will vary depending on the OS and version you're using. Feel free to make any additional customizations to the configure options, if you know what you're doing ;)

If you get the following error on Debian

checking for termcap functions library... configure: error: No curses/termcap library found

Type

apt-get install libncurses5-dev

How to bind a range of IP's in Debian based linux

Debian based linux

PROBLEM
I would like to bind all 5 of my usable IP's to the 'eth0' device

SOLUTION
Just define a new interface in /etc/network interfaces:

## Start
auto eth0
auto eth0:0
auto eth0:1
auto eth0:2
auto eth0:3

iface eth0 inet static
address 192.168.1.2
netmask 255.255.255.248
gateway 192.168.1.1

iface eth0:0 inet static
address 192.168.1.3
netmask 255.255.255.248
gateway 192.168.1.1

iface eth0:1 inet static
address 192.168.1.4
netmask 255.255.255.248

iface eth0:2 inet static
address 192.168.1.5
netmask 255.255.255.248

iface eth0:3 inet static
address 192.168.1.6
netmask 255.255.255.248
## End

Then you can reboot or use the commands below to bring the interfaces up without a reboot.

ifup eth0:0
ifup eth0:1
ifup eth0:2
ifup eth0:3
ifup eth0:4

On the next reboot they should automatically bind to the NIC.

How do I configure and manage system user quota on my RedHat server with no control panel?

To configure or manage user quotas on a RedHat server with no control panel installed, follow the steps below:
1. Understanding the user's quota file structure.
Below is an example of a user's quota file:
Disk quotas for user bob (uid 501):
Filesystem blocks soft hard inodes soft hard
/dev/hda2 1944 0 0 120 0 0

Each column represents the following(working from left to right):
* Filesystem - Linux filesystem that you are configuring quotas on for the specific user.
* Blocks - Number of blocks(Kilobytes) the user is currently using.
* Soft - The soft limit for the amount of blocks(Kilobytes) the user can use. The soft limit can be surpassed up the hard limit, but only for a specified grace period which is also configurable.
* Hard - The hard limit for the amount of blocks(Kilobytes) the user can use. The hard limit is the maximum limit that can be used by the user and cannot be surpassed.
* Inodes - Number of inodes the user is currently using. An inode is used for every file or directory on a linux filesystem. Limiting the number of inodes is usually not as important to most system administrators as limiting block usage, however it isn't a bad idea to limit a user's inode usage too as a filesystem can run out of inodes(which will deny the server from creating any new files or directories).
* Soft - The soft limit for the amount of inodes the user can use. The soft limit can be surpassed up to the hard limit, but only for a specified grace periond which can be changed.
* Hard - The hard limit for the amount of inodes the user can use. The hard limit is the maximum limit that can be used by the user and cannot be surpassed.

2. Defining or editing the quota limits for a user.

To define or edit a user's quota limits on your RedHat server, use this command:
edquota -u
example: edquota -u bob
After executing the edquota command, it will bring up the specified user's quota file(shown in step 1) in the popular editor 'vi'(for more information on how to use vi, please see our knowledgebase article pertaining to such). Change the soft/hard limits for the user's block and inode usage as you see fit. Setting any of the user's limits to '0' provides unlimited usage for that particular setting. Once you are finished setting the user's limits, save and exit the file which will instate the new settings immediately.

3. Viewing a user's quota limits.

To view the changes you've just made or to view any user's current quota limits, use the command below:
quota -u
example: quota -u bob
Also, to see a summary of all of your system user's quota usage, use this command:
repquota -a

How do I enable quotas on my RedHat server with no control panel?

As the root user, edit file /etc/fstab to add qualifier "usrquota" or "grpquota" to the partition you want quotas enabled for as shown below:
/dev/hda2 /home ext3 defaults,usrquota,grpquota 1 1


This enables user and group quotas support on the /home file system.
You can finish initializing quota support by simply rebooting your server. If a reboot isn't a viable option at the moment, you can also follow the instructions listed below:
1. Remount changed filesystems
To remount a specific filesystem: mount -o remount (ex. mount -o remount /dev/hda2)
2. Create aquota.user and aquota.group for quota accounting.
To create the aquota.user and aquota.group files which keep track of quotas, run the following command:
quotacheck -vguma
This command may take awhile to run as it scans any quota enabled filesystems to build the quota accounting files.
3. Enable quota account process.
To enable the quota accounting process which keeps tabs on user/group usage activity as it occurs and updates the aquota.user and aquota.group files, run this command:
quotaon -av
Your linux filesystem(s) should now be quota-enabled.

Your linux filesystem(s) is now quota enabled.

Friday, March 14, 2008

How to bind a range of IP's on BSD based hosts ( FreeBSD, OpenBSD )

First login to your FreeBSD host as a 'non-root' user. You should have an account in the 'wheel' group that you can do this with. Once you have logged in run the following commands to switch users to 'root'
su -
Password:
server#
The prompt should have a # in it now meaning you are the 'root' user.
Now run these commands.
ee /etc/rc.conf
Using 192.168.1.3 - 192.168.1.6 as an example
ifconfig_fxp0="inet 192.168.1.2 netmask 255.255.255.248"
ifconfig_fxp0_alias0="inet 192.168.1.3 netmask 255.255.255.255"
ifconfig_fxp0_alias1="inet 192.168.1.4 netmask 255.255.255.255"
ifconfig_fxp0_alias2="inet 192.168.1.5 netmask 255.255.255.255"
ifconfig_fxp0_alias3="inet 192.168.1.6 netmask 255.255.255.255"
Note that changes to the '_aliasNN' and also the 'netmask' changes to '255.255.255.255' from '255.255.255.248'. The IP's will not work unless you use a '255.255.255.255' netmask for the alias IP's.
Once you have added the enteries to your file you need to press 'ESC' and then select the 'Save File' option. You can then reboot the server and the IP's will be bound and ready to use.
You can also use 'ifconfig' on the command line to add them without a reboot.
Please see the following man pages for more information.
man ifconfig
man rc.conf
man netstat

How to bind a range of IP's in Debian based linux

Just define a new interface in /etc/network interfaces:

## Start

auto eth0

auto eth0:0

auto eth0:1

auto eth0:2

auto eth0:3

iface eth0 inet static

address 192.168.1.2

netmask 255.255.255.248

gateway 192.168.1.1

iface eth0:0 inet static

address 192.168.1.3

netmask 255.255.255.248

gateway 192.168.1.1

iface eth0:1 inet static

address 192.168.1.4

netmask 255.255.255.248

iface eth0:2 inet static

address 192.168.1.5

netmask 255.255.255.248

iface eth0:3 inet static

address 192.168.1.6

netmask 255.255.255.248

## End

Then you can reboot or use the commands below to bring the interfaces up without a reboot.

ifup eth0:0

ifup eth0:1

ifup eth0:2

ifup eth0:3

ifup eth0:4

On the next reboot they should automatically bind to the NIC.

How to bind a range of IP's in Redhat based linux

How to bind a range of IP's in Linux.
This method is used by Redhat Linux based servers
(Centos/RedhatEnterprise/FedoraCore).
Create a file called /etc/sysconfig/network-scripts/ifcfg-eth0-range0
And in the file place these 3 lines but change the IP's to match YOUR assigned range.
##Start
IPADDR_START=67.18.xxx.xxx
IPADDR_END=67.18.xxx.xxx
CLONENUM_START=0
# Example IPADDR_START=67.18.333.440
# Example IPADDR_END=67.18.333.444
# Example CLONENUM_START=0
## END
The CLONENUM_START should be the number at which the alias interfaces should start. If you add your 5 IP's to this server and then want to bind a second set of IP's you create a second file named 'ifcfg-eth0-range1' and change the CLONENUM_START to match the last interface alias. IE 'eth0:5' = CLONENUM_START=5
After you have created the above file execute the command 'service network restart' and your IP's will be all setup.
*CPANEL NOTE*Please do not use this method of binding additional IPs if you are using Cpanel. Bind the IPs through the Cpanel interface.

Tuesday, March 4, 2008

How do I connect to my NAS backup?

Network Backup is a simple Network Attached Storage (NAS) array that can be directly accessed over Ethernet using standard IP protocols such as SAMBA/CIFS and FTP. Network Backup needs to be accessed from within your server.
You have to first log into the server.Once you are logged in simply ftp into the NAS.You will be given the IP address in the initial NAS installation ticket.If you are unable to find the ticket please feel free to contact us.
You can actually mount your drive to the NAS. To do so please do the following:
==============================================

On a UNIX System:
Assuming you have already installed SAMBA, issue the following command:
smbmount //ip address/username mountpoint -o username=username
For example: smbmount //123.456.789/cXXXX /mnt/backup -o username=cXXXXX
Samba will prompt you for your password. This will attach your service to themount point defined on the command line as though it was a local disk.
==============================================
Windows 2003 Server:
Open Windows Explorer.On the Tools Menu, click Map Network DriveSelect a drive letter.Place "\\ip address\username" in the Path line;
For example \\123.456.789\cXXXXXClick the "Reconnect at logon" checkbox.Click OK.Login to the share with the username and password provided.Click the "Remember password" checkbox.Click OK.
This will attach your NAS Backup service to the driveletter you selected. At this point, the Backup service operates likea drive directly connected to your server. Simply copy the files youwish to archive into the drive letter you have mapped to your NAS Backup service.

Saturday, March 1, 2008

NTFS

1) Find the exact matching distribution in the kernel-module-ntfs dists at:
http://www.linux-ntfs.org/content/view/128/64/
(must match the answer to uname -r)

# uname -r
2.6.9-55.ELsmp

If you get the above you need to download (kernel-module-ntfs-2.6.9-55.ELsmp-2.1.20-0.rr.10.0.i686.rpm)
http://prdownloads.sourceforge.net/linux-ntfs/kernel-module-ntfs-2.6.9-55.ELsmp-2.1.20-0.rr.10.0.i686.rpm

# get http://prdownloads.sourceforge.net/linux-ntfs/kernel-module-ntfs-2.6.9-55.ELsmp-2.1.20-0.rr.10.0.i686.rpm

2) Install the RPM using
# rpm -ihv kernel-module-ntfs-2.6.9-55.ELsmp-2.1.20-0.rr.10.0.i686.rpm
PrĂ©paration… ########################################### [100%]
1:kernel-module-ntfs-2.6.########################################### [100%]

# /sbin/modprobe ntfs
# dmesg|grep NTFS
NTFS driver 2.1.22 [Flags: R/W MODULE].

That’s better, almost done…

3) Now check the drive which you want to mount using "fdisk -l"

# fdisk -l

Disk /dev/sda: 251.0 GB, 251000193024 bytes
255 heads, 63 sectors/track, 30515 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 1318 10482412+ 83 Linux
/dev/sda3 1319 2623 10482412+ 83 Linux
/dev/sda4 2624 30515 224042490 5 Extended


Disk /dev/sdb: 251.0 GB, 251000193024 bytes
1 heads, 63 sectors/track, 7781504 cylinders
Units = cylinders of 63 * 512 = 32256 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 * 2 7781071 245103705 7 HPFS/NTFS

Here you see /dev/sdb1 as the NTFS partition.

4) Now to mount the NTFS partition /dev/sdb1

# cd /
# mkdir windows
# mount -t ntfs -o nls=utf8 /dev/sdb1 /windows
# cd /windows

And you are done the NTFS partition is mounted as /windows