Monday, March 1, 2010

nis

root@ns ~]#
yum -y install ypserv


[root@ns ~]#
ypdomainname server-linux.info

// set domain name

[root@ns ~]#
vi /etc/sysconfig/network


NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=ns.server-linux.info
GATEWAY=192.168.0.1
NISDOMAIN=server-linux.info
// add at the bottom of file


[root@ns ~]#
vi /var/yp/Makefile


# MERGE_PASSWD=true|false
MERGE_PASSWD=
false
// line 42: change

#
# MERGE_GROUP=true|false
MERGE_GROUP=
false
// line 46: change

#
all: passwd
shadow
group hosts rpc services netid protocols
// line 109: add


[root@ns ~]#
vi /var/yp/securenets


host
127.0.0.1

255.255.255.0
192.168.0.0


// create a directory for web site automatically when a user is added in the system

[root@ns ~]#
mkdir /etc/skel/public_html

[root@ns ~]#
chmod 711 /etc/skel/public_html


// create a directory for email automatically when a user is added in the system

[root@ns ~]#
mkdir -p /etc/skel/Maildir/cur

[root@ns ~]#
mkdir -p /etc/skel/Maildir/new

[root@ns ~]#
mkdir -p /etc/skel/Maildir/tmp

[root@ns ~]#
chmod -R 700 /etc/skel/Maildir/


[root@ns ~]#
useradd cent

[root@ns ~]#
passwd cent

Changing password for user cent.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.

[root@ns ~]#
/usr/lib/yp/ypinit -m

At this point, we have to construct a list of the hosts which will run NIS servers. ns.server-linux.info is in the list of NIS server hosts. Please continue to add the names for the other hosts, one per line. When you are done with the list, type a .
next host to add: ns.server-linux.info
next host to add:
// push Ctrl + D keys

The current list of NIS servers looks like this:

ns.server-linux.info

Is this correct? [y/n: y]
y
// input 'y' and push Enter key

We need a few minutes to build the databases...
Building /var/yp/server-linux.info/ypservers...
Running /var/yp/Makefile...
gmake[1]: Entering directory `/var/yp/server-linux.info'
Updating passwd.byname...
Updating passwd.byuid...
Updating group.byname...
Updating group.bygid...
Updating hosts.byname...
Updating hosts.byaddr...
Updating rpc.byname...
Updating rpc.bynumber...
Updating services.byname...
Updating services.byservicename...
Updating netid.byname...
Updating protocols.bynumber...
Updating protocols.byname...
Updating mail.aliases...
gmake[1]: Leaving directory `/var/yp/server-linux.info'

ns.server-linux.info has been set up as a NIS master server.

Now you can run ypinit -s ns.server-linux.info on all slave server.

[root@ns ~]#
/etc/rc.d/init.d/portmap start

Starting portmap:
[ OK ]

[root@ns ~]#
/etc/rc.d/init.d/ypserv start

Starting YP server services:
[ OK ]

[root@ns ~]#
/etc/rc.d/init.d/yppasswdd start

Starting YP passwd service:
[ OK ]

[root@ns ~]#
chkconfig portmap on

[root@ns ~]#
chkconfig ypserv on

[root@ns ~]#
chkconfig yppasswdd on


// It's neccessary to update NIS database with following way if new user is added again

[root@ns ~]#
cd /var/yp

[root@ns yp]#
make

Sunday, February 28, 2010

LVM setup

* The LVM is not currently configured or in used. Having say that, this is the LVM tutorial if you’re going to setup LVM from the ground up on a production Linux server with a new SATA / SCSI hard disk.

* Without a luxury server hardware, I tested this LVM tutorial on PC with the secondary hard disk dedicated for LVM setup. So, the Linux dev file of secondary IDE hard disk will be /dev/hdb (or /dev/sdb for SCSI hard disk).

* This guide is fully tested in Red Hat Enterprise Linux 4 with Logical Volume Manager 2 (LVM2) run-time environment (LVM version 2.00.31 2004-12-12, Library version 1.00.19-ioctl 2004-07-03, Driver version 4.1.0)!


How to setup Linux LVM in 3 minutes at command line?

1. Login with root user ID and try to avoid using sudo command for simplicity reason.

2. Using the whole secondary hard disk for LVM partition:
fdisk /dev/hdb

At the Linux fdisk command prompt,
1. press n to create a new disk partition,
2. press p to create a primary disk partition,
3. press 1 to denote it as 1st disk partition,
4. press ENTER twice to accept the default of 1st and last cylinder – to convert the whole secondary hard disk to a single disk partition,
5. press t (will automatically select the only partition – partition 1) to change the default Linux partition type (0×83) to LVM partition type (0×8e),
6. press L to list all the currently supported partition type,
7. press 8e (as per the L listing) to change partition 1 to 8e, i.e. Linux LVM partition type,
8. press p to display the secondary hard disk partition setup. Please take note that the first partition is denoted as /dev/hdb1 in Linux,
9. press w to write the partition table and exit fdisk upon completion.


3. Next, this LVM command will create a LVM physical volume (PV) on a regular hard disk or partition:
pvcreate /dev/hdb1

4. Now, another LVM command to create a LVM volume group (VG) called vg0 with a physical extent size (PE size) of 16MB:
vgcreate -s 16M vg0 /dev/hdb1

Be properly planning ahead of PE size before creating a volume group with vgcreate -s option!

5. Create a 400MB logical volume (LV) called lvol0 on volume group vg0:
lvcreate -L 400M -n lvol0 vg0

This lvcreate command will create a softlink /dev/vg0/lvol0 point to a correspondence block device file called /dev/mapper/vg0-lvol0.

6. The Linux LVM setup is almost done. Now is the time to format logical volume lvol0 to create a Red Hat Linux supported file system, i.e. EXT3 file system, with 1% reserved block count:
mkfs -t ext3 -m 1 -v /dev/vg0/lvol0

7. Create a mount point before mounting the new EXT3 file system:
mkdir /mnt/vfs

8. The last step of this LVM tutorial – mount the new EXT3 file system created on logical volume lvol0 of LVM to /mnt/vfs mount point:
mount -t ext3 /dev/vg0/lvol0 /mnt/vfs


To confirm the LVM setup has been completed successfully, the df -h command should display these similar message:

/dev/mapper/vg0-lvol0 388M 11M 374M 3% /mnt/vfs

Some of the useful LVM commands reference:

vgdisplay vg0

To check or display volume group setting, such as physical size (PE Size), volume group name (VG name), maximum logical volumes (Max LV), maximum physical volume (Max PV), etc.

pvscan

To check or list all physical volumes (PV) created for volume group (VG) in the current system.

vgextend

To dynamically adding more physical volume (PV), i.e. through new hard disk or disk partition, to an existing volume group (VG) in online mode. You’ll have to manually execute vgextend after pvcreate command that create LVM physical volume (PV).