Wednesday, July 17, 2013

How to configure Kickstart Server

Install & Configure PXE Boot Server with Kickstart

1] Install syslinux & tftp-server
[root@server ~]# yum install tftp-server

 2] Enable syslinux at boot time
[root@server ~]# vim /etc/xinetd.d/tftp
edit the line no. 14
disable = no
:wq

3] Start service
[root@server ~]# service xinetd start
[root@server ~]# chkconfig xientd on

4] Install FTP service
[root@server ~]# yum install vsftpd

5] Start vsftpd
[root@server ~]# service vsftpd start
[root@server ~]# chkconfig vsftpd on

6] Install syslinux, require boot loader
[root@server ~]# yum install syslinux

7] Copy the needed files from syslinux to the tftpboot directory
[root@server ~]# cp -rvp /usr/share/syslinux/{pxelinux.0,menu.c32,memdisk,mboot.c32,chain.c32} /var/lib/tftpboot/

8] Create the directory for your PXE menus
[root@server ~]# mkdir /var/lib/tftpboot/pxelinux.cfg

9] Create different directory for each PXE image
[root@server ~]# mkdir –p /var/lib/tftpboot/images/centos6

10] Mount CD/DVD and copy it to FTP public directory
[root@server ~]# mount /dev/cdrom /mnt
[root@server ~]# cp -rvp /mnt/* /var/ftp/pub/
[root@server ~]# umount /mnt

11] Copy vmlinuz and initrd.img from FTP public directory
[root@server ~]# cp -rvp /var/ftp/pub/images/pxeboot/{initrd.img,vmlinuz} /var/lib/tftpboot/images/centos6/

12] Instal DHCP server
[root@server ~]# yum install dhcp

13] Configure DHCP server. Add following lines to your /etc/dhcp/dhcpd.conf
[root@server ~]# vi /etc/dhcp/dhcpd.conf
option domain-name "anup.co.in";
option domain-name-servers 192.168.1.1;
default-lease-time 600;
max-lease-time 7200;

allow booting;
allow bootp;
next-server 192.168.1.1;
filename “/pxelinux.0”;

subnet 192.168.1.0 netmask 255.255.255.0 {
        range dynamic-bootp 192.168.1.100 192.168.1.200;
    option routers 192.168.1.1;
}

14] Start dhcp service
[root@server ~]# service dhcpd start
[root@server ~]# chkconfig dhcpd on

15] Create a menu for PXE server for os selection on PXE loading
[root@server ~]#  vi /var/lib/tftpboot/pxelinux.cfg/default

default menu.c32
prompt 0
timeout 50

MENU TITLE ANUP PXE Menu

LABEL CentOS 6.4 (Final)
MENU LABEL CentOS-6.4
KERNEL images/centos6/vmlinuz
append vga=normal initrd=images/centos6/initrd.img ramdisk_size=32768
ks=ftp://192.168.1.1/pub/ks.cfg

16] Now create KickStart file in FTP public directory
[root@server ~]# vi /var/ftp/pub/ks.cfg

#It starts the installation process
Install
#configure a connection to a FTP server to locate installation files
url --url ftp://192.168.1.1/pub/
#setup language and keyboard
lang en_US.UTF-8
keyboard us
#Get network info from DHCP server
network --device eth0 bootproto dhcp
#setup encrypted root password, you can take out the encrypted password from /etc/shadow file
rootpw --iscrypted $6$NF6F/Yng442eA8oL$c/sHM
#setup firewall and open ssh port 22
firewall --service=ssh
#sets up the Shadow Password Suite
#(--enableshadow), the SHA 512 bit encryption algorithm for password encryption
#(--passalgo=sha512), and authentication with any existing fingerprint reader.
authconfig --enableshadow --passalgo=sha512 --enablefingerprint
#The selinux directive can be set to --enforcing, --permissive, or --disabled
selinux --enforcing
#setup timezone
timezone America/Toronto
#The default bootloader is GRUB. It should normally be installed on the Master
#Boot Record (MBR) of a hard drive. You can include a --driveorder switch to specify
#the drive with the bootloader and an --append switch to specify commands for
#the kernel.
bootloader --location=mbr --driveorder=sda --append=”crashkernel=auto rhgb quiet”
#Clear the Master Boot Record
zerombr yes
#This directive clears all volumes on the sda hard drive. If it hasn’t been used before,
#--initlabel initializes that drive.
clearpart --all --drives=sda --initlabel
#Changes are required in the partition (part) directives that follow.
part /boot --fstype=ext4 --size=500
part / --fstype=ext4 --size=27500
part swap --size=1000
part /home --fstype=ext4 --size=1000
#reboot machine
reboot
#skip answers to the First Boot process
firstboot --disable

 Test the PXE server:
* Make changes in the BIOS settings and boot client machine from network. OR just press F12 to boot from network.

Saturday, July 13, 2013

Install and Configure NRPE in CentOS

 Install NRPE on Linux


NRPE is called as ‘Nagios Remote Plugin Executere’. NRPE allows nagios server
to remotely execute nagios commands or plugins on other Linux/Unix machines. NRPE is also available windows servers.
Following document shows you how to install NRPE, I am installing it on CentOS 6.4

1] Install NRPE required packages.

[root@server ~]# yum install openssl-devel gcc xinetd make

2] NRPE runs under the user "nagios", so let's add that user.

[root@server ~]# useradd nagios

3] Download and install Nagios-plugins.

[root@server downloads]# wget https://nagios-plugins.org/download/nagios-plugins-2.0.tar.gz

[root@server downloads]# tar -xvzf nagios-plugins-2.0.tar.gz

[root@server downloads]# cd nagios-plugins-2.0

[root@server nagios-plugins-2.0]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios

[root@server nagios-plugins-2.0]# make install

4] Assign nagios user ownership to nagios commands.

[root@server nagios-plugins-2.0]# chown -R nagios:nagios /usr/local/nagios/libexec


5] Install and configure NRPE nagios client.

[root@server downloads]# wget http://downloads.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz?r=&ts=1363788540&use_mirror=hivelocity

[root@server downloads]# tar -xvzf nrpe-2.15.tar.gz

[root@server downloads]# cd nrpe-2.15.tar.gz

[root@server downloads]# ./configure --enable-ssl

[root@server nrpe-2.15]# make all

[root@server nrpe-2.15]# make install-plugin

[root@server nrpe-2.15]# make install-daemon

[root@server nrpe-2.15]# make install-daemon-config

[root@server nrpe-2.15]# make install-xinetd

6] Add following line at the end of file for NRPE in /etc/services

[root@server ~]# vi /etc/services
nrpe            5666/tcp                # NRPE

7] NRPE will run under xinetd daemon. So update xinetd file.

[root@server ~]# vi /etc/xinetd.d/nrpe

# default: on
# description: NRPE (Nagios Remote Plugin Executor)
service nrpe
{
        flags           = REUSE
        socket_type     = stream
        port             = 5666
        wait            = no
        user            = nagios
        group           = nagios
        server          = /usr/local/nagios/bin/nrpe
        server_args     = -c /usr/local/nagios/etc/nrpe.cfg --inetd
        log_on_failure  += USERID
        disable         = no
        only_from       = 127.0.0.1 192.168.1.1 --> [ Your Nagios Server IP ]
}

8] Star/Restart xinetd service.

[root@server ~]# service xinetd start

[root@server ~]# chkconfig xinetd on