Selasa, 09 Agustus 2022

 

Install Latest Apache, MariaDB 10.1 and PHP on RHEL/CentOS 7/6

 

Regardless of the distribution, the above commands return the list of packages in the currently enabled repositories that include the word php in the package name and / or the description.

Here are the packages that we will install. Please keep in mind that MySQL connectors (PHP, Perl, Python, Java, etc.) will work unchanged with MariaDB as both systems use the same client protocol and the client libraries are binary compatible.

  1. MariaDB/MySQL (php-mysql) – a dynamic shared object that will add MariaDB support to PHP.
  2. PostgreSQL (php-pgsql) – PostgreSQL database support for PHP.
  3. MongoDB (php-pecl-mongo) – An interface for communicating with the MongoDB database in PHP.
  4. Generic (php-pdo) – A dynamic shared object that will add a database access abstraction layer to PHP.
  5. Memcache (php-pecl-memcache) – Memcached is a caching daemon designed especially for dynamic web applications to decrease database load by storing objects in memory.
  6. Memcached (php-pecl-memcached) – An extension that uses the libmemcached library to provide API for communicating with memcached servers.
  7. GD (php-gd) – A dynamic share object that adds support for using the gd graphics library to PHP.
  8. XML (php-xml) – A dynamic shared objects that adds support to PHP for manipulating XML documents.
  9. MBString (php-mbstring) – An extension to handle multi-byte string in PHP applications.
  10. MCrypt (php-mcrypt) – A Mcrypt library for PHP scripts.
  11. APC (php-pecl-apcu) – APC module used to optimize and cache PHP code.
  12. CLI (php-cli) – Command-line interface for PHP.
  13. PEAR (php-pear) – Application Repository framework for PHP.

Install Apache 2.4, MariaDB/MySQL 5.5 & PHP 5.5/5.6 on RHEL 7/6CentOS 7/6 and Fedora 18-24

Step 1: Installing Remi Repository

Remi is a repository where you can find the latest versions of the PHP stack (full featured) for installation in the Fedora and Enterprise Linux distributions.

On RHEL/CentOS 7

# yum update && yum install epel-release
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
------ For RHEL 7 Only ------
# subscription-manager repos --enable=rhel-7-server-optional-rpms

On RHEL/CentOS 6

# yum update && yum install epel-release
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
------ For RHEL 6 Only ------
# subscription-manager repos --enable=rhel-6-server-optional-rpms

On Fedora 24-22

------ For Fedora 24 ------
# wget http://rpms.remirepo.net/fedora/remi-release-24.rpm
# dnf install remi-release-24.rpm
------ For Fedora 23 ------
# wget http://rpms.remirepo.net/fedora/remi-release-23.rpm
# dnf install remi-release-23.rpm
------ For Fedora 22 ------
# wget http://rpms.remirepo.net/fedora/remi-release-22.rpm
# dnf install remi-release-22.rpm

On Fedora 21-18

Other Fedora versions (21 and below) are no longer being maintained or supported. You can, however, enable the repository by changing the version number in the command above. For example, to enable the Remi repository in a Fedora 20 server, do:

------ For Fedora 21 ------
wget http://rpms.remirepo.net/fedora/remi-release-21.rpm
yum install remi-release-21.rpm
------ For Fedora 20 ------
wget http://rpms.remirepo.net/fedora/remi-release-20.rpm
yum install remi-release-20.rpm
------ For Fedora 19 ------
wget http://rpms.remirepo.net/fedora/remi-release-19.rpm
yum install remi-release-19.rpm
------ For Fedora 18 ------
wget http://rpms.remirepo.net/fedora/remi-release-18.rpm
yum install remi-release-18.rpm

Step 2: Enabling the Remi Repository

Now you make sure that remi repository is enabled and all set to install chosen PHP version, to do this openremi.repo file and make sure the line set to enabled=1 as instructed below, in order to install PHP 5.5 or5.6.

[remi]
name=Remi's RPM repository for Enterprise Linux 6 - $basearch
#baseurl=http://rpms.remirepo.net/enterprise/6/remi/$basearch/
mirrorlist=http://rpms.remirepo.net/enterprise/6/remi/mirror
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

Now if you want to install PHP 5.5 or PHP 5.6, just set the line enabled=1 in sections [remi-php55] and [remi-php56] to install as instructed below.

[remi-php55]
name=Remi's PHP 5.5 RPM repository for Enterprise Linux 6 - $basearch
#baseurl=http://rpms.remirepo.net/enterprise/6/php55/$basearch/
mirrorlist=http://rpms.remirepo.net/enterprise/6/php55/mirror
# NOTICE: common dependencies are in "remi-safe"
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
[remi-php56]
name=Remi's PHP 5.6 RPM repository for Enterprise Linux 6 - $basearch
#baseurl=http://rpms.remirepo.net/enterprise/6/php56/$basearch/
mirrorlist=http://rpms.remirepo.net/enterprise/6/php56/mirror
# NOTICE: common dependencies are in "remi-safe"
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

Step 3: Installing Apache, MariaDB/MySQL, and PHP

In latest RHEL/CentOS 7 distribution, MariaDB is a drop-in replacement for MySQL and in RHEL/CentOS 6MySQL remains same and you’re not allowed to install MariaDB on RHEL/CentOS 6 from default repository, but you can install MariaDB using official MariaDB repository.

For MariaDB Installation on RHEL/CentOS 7 and Fedora 18-24

To enable the MariaDB repository on RHEL/CentOS 7 distributions, create a file named/etc/yum.repos.d/mariadb.repo with the following contents:

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

Note: As i said above, you can also install MariaDB on RHEL/CentOS 6 using official MariaDB repository as stated above.

After enabling MariaDB repository, then do:

------ On RHEL/CentOS 7 ------
# yum --enablerepo=remi install httpd MariaDB-client MariaDB-server php php-common
------ On Fedora 22-24 ------
# dnf --enablerepo=remi install httpd MariaDB-client MariaDB-server php php-common
------ On 18-21 ------
# yum --enablerepo=remi install httpd MariaDB-client MariaDB-server php php-common

For MySQL Installation on RHEL/CentOS 6

# yum --enablerepo=remi install httpd mysql mysql-server php php-common

Step 4: Installing PHP Modules

------ On RHEL/CentOS 7/6 and Fedora 18-21 ------
# yum --enablerepo=remi install php-mysqlnd php-pgsql php-pecl-mongo php-pdo php-pecl-memcache php-pecl-memcached php-gd php-xml php-mbstring php-mcrypt php-pecl-apcu php-cli php-pear
------ On Fedora 24-22 ------
# dnf --enablerepo=remi install php-mysqlnd php-pgsql php-pecl-mongo php-pdo php-pecl-memcache php-pecl-memcached php-gd php-xml php-mbstring php-mcrypt php-pecl-apcu php-cli php-pear

Step 5: Enable/Start Apache and MySQL/MariaDB

On SystemD – RHEL/CentOS 7 and Fedora 24-18

------ Enable Apache and MariaDB on Boot ------
# systemctl enable httpd
# systemctl enable mariadb
------ Start Apache and MariaDB ------
# systemctl start httpd
# systemctl start mariadb

On SysVinit- RHEL/CentOS 6

------ Enable Apache and MySQL on Boot ------
# chkconfig --levels 235 httpd on
# chkconfig --levels 235 mysqld on
------ Start Apache and MySQL ------
# /etc/init.d/httpd start
# /etc/init.d/mysqld start

Step 6: Verifying PHP 5.5 or 5.6

Let’s stick with the classic way of testing PHP. Create a file called info.php under /var/www/html and add the following lines of code to it.

The phpinfo() function shows a great deal of information about the current PHP installation:

?php
// Show all information, defaults to INFO_ALL
phpinfo();
// Show just the module information.
// phpinfo(8) yields identical results.
phpinfo(INFO_MODULES);
?>

 



Sabtu, 05 Februari 2022

Server World - Build Everything on your mind

Click ==>  server-world.info



Jumat, 17 Desember 2021

Kickstart-Server CentOS 7.9_x86_64 For Apache Hadoop®

A. Prepare Kickstart Server environment

 1. Install all the required packages through yum

     yum install syslinux xinetd tftp-server dhcp httpd deltarpm python-deltarpm createrepo yum-utils

2. Create folder/directory and copy pxelinux.0

     mkdir /var/lib/tftpboot/pxelinux.cfg
     mkdir /var/lib/tftpboot/centos7
 
     cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/

3. Open the xinetd settings to enable tftp server
    vi /etc/xinetd.d/tftp
   # at line 14 change the parameter from yes to no.
        Disable=no

4. Restart the service to apply the settings made
    systemctl restart xinetd 

5. Set the service to start with each subsequent system reboots
    systemctl enable xinetd

6. Open the file and configure edit the DHCP Server
    vi /etc/dhcp/dhcpd.conf

#### vi /etc/dhcp/dhcpd.conf ###
Allow booting;
Allow bootp;
authoritative;
### Subnet definition hostname kickstart  server ###
ddns-update-style interim;
subnet 192.168.111.0 netmask 255.255.255.0 {
range dynamic-bootp 192.168.111.30 192.168.111.130;
option broadcast-address 192.168.111.255;
option routers 192.168.111.2;
filename "pxelinux.0";
next-server 192.168.111.80;
#use-host-decl-names on;
}
#### Client Node ###
host master01.kopi.com {
hardware ethernet 00:0C:29:33:9A:F2;
fixed-address 192.168.111.81;
option subnet-mask 255.255.255.0;
option routers 192.168.111.2;
option host-name "master01.kopi.com";
filename "pxelinux.0";
}
host master02.kopi.com {
hardware ethernet 00:0C:29:B0:74:AB;
fixed-address 192.168.111.82;
option subnet-mask 255.255.255.0;
option routers 192.168.111.2;
option host-name "master02.kopi.com";
filename "pxelinux.0";
}
host worker01.kopi.com {
hardware ethernet 00:0C:29:58:E8:B8;
fixed-address 192.168.111.83;
option subnet-mask 255.255.255.0;
option routers 192.168.111.2;
option host-name "worker01.kopi.com";
filename "pxelinux.0";
}
host worker02.kopi.com {
hardware ethernet 00:0C:29:CF:37:CE;
fixed-address 192.168.111.84;
option subnet-mask 255.255.255.0;
option routers 192.168.111.2;
option host-name "worker02.kopi.com";
filename "pxelinux.0";
}
host worker03.kopi.com {
hardware ethernet 00:0C:29:AE:A3:EF;
fixed-address 192.168.111.85;
option subnet-mask 255.255.255.0;
option routers 192.168.111.2;
option host-name "worker03.kopi.com";
filename "pxelinux.0";
}


7. Restart the service and make it permanent
    systemctl restart dhcpd
    systemctl enable dhcpd

8.
Create folder/directory
 

    mkdir -p /var/www/html/centos7.9
    mkdir -p /var/www/html/centos7.9/ks

9. Insert your CentOS 7. DVD + Mount it to /mnt
    mount /dev/sr0 /mnt

10. Check the contents to see if it is properly mounted
    ls -al /mnt/

11. copy all DVD the contents to the /var/www/html/centos7.9 directory & updates

    shopt -s dotglob
    cp -apvrf /mnt/* /var/www/html/centos7.9/     
 
     
sudo reposync -g -l -d -m --repoid=updates --newest-only --download-metadata --download_path=/var/www/html/

    createrepo /var/www/html/updates

    eject

12. Copy the vmlinuz and initrd.img files to the tftpboot directory
    cp /var/www/html/centos7.9/images/pxeboot/vmlinuz /var/lib/tftpboot/centos7 

    cp /var/www/html/centos7.9/images/pxeboot/initrd.img /var/lib/tftpboot/centos7

13. Copy the menu file
    cp /usr/share/syslinux/menu.c32 /var/lib/tftpboot/

14. Prepare the boot menu.
    vi /var/lib/tftpboot/pxelinux.cfg/default

default menu.c32
prompt 0
timeout 100

menu title === PXE-CentOS7.9-Boot Menu===
label 1
menu label ^ 1) CentOS 7.9.2009
kernel centos7/vmlinuz
append initrd=
centos7/initrd.img ks=http://192.168.111.80/ks/ks.cfg

15. Prepare the httpd server

    vi /etc/httpd/conf/httpd.conf
        Listen 192.168.111.80:80

    vi /etc/hosts
       192.168.111.80     kickserver    kickserver.customer.com

    vi /etc/httpd/conf.d/welcome.conf
        <LocationMatch "^/+$">
        Options +Indexes

     systemctl restart httpd
    systemctl enable httpd

    iptables -F; iptables -L
    systemctl stop iptables; systemctl disable iptables 
    systemctl stop firewalld;systemctl disable firewalld


    vi /etc/selinux/config
     SELINUX=disable
 

reboot

after that you can login and run cli (pls, verify with a local repository "updates")

yum update

reboot

(pls, verify your booting with a new kernel version 3.10.0-1160.80.1.el7)

Selasa, 01 Oktober 2013

RESTORE with Clonezilla and error "Kernel Panic" special instruction for Centos 5.x



1. Boot any linux-dvd room with ”similiar" architecture (i386 or x86_64)

2. press F5 or type-in linux rescue

3. pres enter...enter

4. # chroot /mnt/sysimage

5. # cd /boot and then # ls -al

6. # mv initrd-2.6.18-238.el5PAE.img initrd-2.6.18-238.el5PAE.img.BACKUP

7. # mkinitrd /boot/initrd-2.6.18-238.el5PAE.img 2.6.18-238.el5PAE

8. # grub-install /dev/sda

9. disconnect linux-dvd

10. exit

11. exit

12. Success booting but X-windows error......select OK an then select No

13. login with Normal Terminal root/P@ssw0rd

14. Install vmware tools (VM > Guest > Install/Upgrade Vmware Tools)

15. see w/ #dmesg (location drive ex. /dev/sdc)

16. # mount /dev/sdc /mnt

17. # cd /mnt/VMware...tab

18. # cp VMware...tar.gz /tmp

19. #cd /tmp

20. # gunzip VMware....tab

21  # tar -xvf VMware..tar

22. # cd vmware-..tab

23. # ./vminstall-..tab

24. all instruction press ENTER...ENTER (for default)

25. ...choose resolution 11 (800x600)

26. reboot


27. wow...success w/x-windows GUI

28. shutdown and change MAC-Address on vmware edit setting. (match the physical server)

Minggu, 09 Juni 2013

Clear DRACstore SUN STORAGE 2540

Changes

A disk in a single-disk RAID-0 volume group failed and was replaced.

Cause

A failed disk in a single-disk RAID-0 volume group was replaced without first deleting the volumes it contained or re-initializing the VDisk, leading to an inconsistent or corrupted state of the internal configuration database.
In case of a disk failure in a single-disk RAID-0 volume group, all volumes in the volume group must be deleted or the volume group wiped clean via the Initialize VDisk option of the Service Advisor before carrying out the disk replacement.

Solution

It seems the only way to get rid of the missing (ghost) volume in this situation is to wipe the configuration and recreate it. Please contact the Oracle support to get assistance from an engineer.


Instructions :
  1. Connect Putty with Serial Cable - Baudrate 38400 , Flow Control: None
  2. Send "Break"
  3. Press ESC, twice/2x
  4. enter password to access shell : (call me if you can) y2llojp
  5. -> sysWipe
  6. press enter
  7. Disconnect Serial.
  8. Set the array name to its original value via CAM broswer http://localhost:6789

Minggu, 03 Februari 2013

LVM - How to Create a Partition in Linux

This is a short tutorial that explains how to create an LVM in Linux. Let's get started.

I have got 2 hard disks of 2GB size each -

# fdisk -l 2>/dev/null | grep '/dev/sd[a-b]'
Disk /dev/sda: 2147 MB, 2147483648 bytes
Disk /dev/sdb: 2147 MB, 2147483648 bytes

The following steps will show you how to create logical volumes on these hard disks.

Step 1: Prepare the disks


If you are using entire disks for creating logical volumes, then make sure they are raw disks. ie they should not contain any partitions.


If you are using individual partitions on a disk for LVM, then you should open fdisk (or another partitioning tool) and set each partition as type "Linux LVM" - 0x8e, so that they can be recognized by the LVM system.


Step 2: Initialize the disks to be used as a physical volume


To initialize the disks to be used as a physical volume, you use pvcreate.

# pvcreate /dev/sda
Writing physical volume data to disk "/dev/sda"
Physical volume "/dev/sda" successfully created

# pvcreate /dev/sdb
Writing physical volume data to disk "/dev/sdb"
Physical volume "/dev/sdb" successfully created

Now use lvmdiskscan to verify that the hard disks have been properly initialized.

# lvmdiskscan
/dev/sda  [ 2.00 GiB] LVM physical volume
...
/dev/sdb  [ 2.00 GiB] LVM physical volume
...
2 disks
2 LVM physical volume whole disks
0 LVM physical volumes


Step 3: Create the volume group


To create a volume group, you run the vgcreate as follows.

# vgcreate vg_sda /dev/sda
Volume group "vg_sda" successfully created

# vgcreate vg_sdb /dev/sdb
Volume group "vg_sdb" successfully created

This creates a volume group descriptor at the start of each disk.


Step 4: Create the logical volumes


Logical volumes can be classified into 3 types -


  1. Linear volumes
  2. Stripped volumes, and
  3. Mirrored volumes


Logical volumes are similar to partitions in hard disks - only better.

Use lvcreate command to create a logical volume.

Lets create a single linear logical volume within each of the volume groups that was created.

# lvcreate --extents 100%FREE --name lv_sda vg_sda
Logical volume "lv_sda" created

# lvcreate --extents 100%FREE --name lv_sdb vg_sdb
Logical volume "lv_sdb" created

In the above commands, --extents gives the number of logical extents to allocate for the new logical volume. Here we have specified the number as the percentage of the free space in the volume group.


lvcreate takes a lot of options. Do check its man page to know more.


Step 5: Verify your work


Lastly, you should scan all disks for logical volumes and volume groups. For this you use the tools - vgscan and lvscan respectively.

# vgscan
Reading all physical volumes. This may take a while...
Found volume group "vg_sdb" using metadata type lvm2
Found volume group "vg_sda" using metadata type lvm2

and scan the logical volumes on all the disks ...

# lvscan
ACTIVE  '/dev/vg_sdb/lv_sdb'  [2.00 GiB] inherit
ACTIVE  '/dev/vg_sda/lv_sda'  [2.00 GiB] inherit

The logical volumes are included in the /dev directory in the format /dev/vg/lv where vg is volume group name, and lv is logical volume name. In our case it will be -

/dev/vg_sda/lv_sda and /dev/vg_sdb/lv_sdb.

Run lvdisplay to see the details of the logical volumes that were created.

# lvdisplay
  --- Logical volume ---
  LV Name                /dev/vg_sdb/lv_sdb
  VG Name                vg_sdb
  LV UUID                ytRveJ-ZCsD-gIXd-Uzfl-UOeO-8CYF-xdXb72
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                2.00 GiB
  Current LE             511
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:3
   
  --- Logical volume ---
  LV Name                /dev/vg_sda/lv_sda
  VG Name                vg_sda
  LV UUID                gTG0Sy-TiF9-3bmF-C7U5-FlqJ-TbZG-eYULtf
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                2.00 GiB
  Current LE             511
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:2

From here on, you can access the logical volumes the same way you access physical disks. All the commands such as for mounting disks, creating file systems, formatting and so on will work on the logical volumes as well.


What to do next


Before you start using the logical volumes to store your files, you have to do 2 things, namely -


  1. Format the logical volume, and
  2. Mount the logical volume in a suitable location.

First lets format the logical volumes

Formating the logical volume involves creating a file system on it. You use the mke2fs command to create a file system.

# mkfs.ext4 /dev/vg_sda/lv_sda

and for the second logical volume ...

# mkfs.ext4 /dev/vg_sdb/lv_sdb

Now lets mount the logical volumes in a suitable location.

Mounting the first logical volume at /mnt/volume-a

# mkdir /mnt/volume-a
# mount -t ext4 /dev/vg_sda/lv_sda /mnt/volume-a

and mounting the second logical volume at /mnt/volume-b

# mkdir /mnt/volume-b
# mount -t ext4 /dev/vg_sdb/lv_sdb /mnt/volume-b


If you want to automatically mount the logical volume(s) each time you boot into Linux, you will have to enter the appropriate line in the /etc/fstab file as well.


List of LVM Commands


To recap, following are the LVM commands we have used to create logical volumes in Linux.

pvcreate - Initializes physical volume for later use by logical volume manager (LVM).

lvmdiskscan - Scan for all devices visible to LVM.

vgcreate - Create a volume group.

lvcreate - Create a logical volume in an existing volume group.

vgscan - Scan all disks for volume groups and rebuild caches.

lvscan - Scan all disks for logical volumes.

lvdisplay - Display attributes (information) of all logical volumes.

There are many more LVM commands that accomplish other tasks. However, these set of LVM commands should get you started on creating an LVM in Linux.

Sabtu, 26 Januari 2013

Bonding RHEL Steps

make sure it contains all interfaces you have in the system and don't configure bond0 inside !
cat /etc/udev/rules.d/70-persistent-net.rules
==========================================================
Firstly, disable network manager if NM is running.
chkconfig NetworkManager off
service NetworkManager stop
===========================================================
vi /etc/modprobe.d/bonding.conf
alias bond0 bonding
alias bond1 bonding
============================================================
vi /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE="bond0"
TYPE="Ethernet"
BROADCAST="10.128.57.255"
GATEWAY="10.128.57.1"
IPADDR="10.128.57.48"
NETMASK="255.255.255.0"
DEFROUTE="yes"
ONBOOT="yes"
USERCTL="no"
BONDING_OPTS="mode=1 miimon=100"

vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
USERCTL="no"
ONBOOT="yes"
MASTER="bond0"
SLAVE="yes"
BOOTPROTO="none"

vi /etc/sysconfig/network-scripts/ifcfg-eth4
DEVICE="eth4"
USERCTL="no"
ONBOOT="yes"
MASTER="bond0"
SLAVE="yes"
BOOTPROTO="none"

==========================================================
vi /etc/sysconfig/network-scripts/ifcfg-bond1
DEVICE="bond1"
TYPE="Ethernet"
BROADCAST="192.168.10.255"
GATEWAY="192.168.10.1"
IPADDR="192.168.10.18"
NETMASK="255.255.255.0"
DEFROUTE="no"
ONBOOT="yes"
USERCTL="no"
BONDING_OPTS="mode=1 miimon=100"

vi /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE="eth1"
USERCTL="no"
ONBOOT="yes"
MASTER="bond1"
SLAVE="yes"
BOOTPROTO="none"

vi /etc/sysconfig/network-scripts/ifcfg-eth5
DEVICE="eth5"
USERCTL="no"
ONBOOT="yes"
MASTER="bond1"
SLAVE="yes"
BOOTPROTO="none"
===========================================================
DEFROUTE ifcfg-eth2 and ifcfg-eth3 changes "yes" to "no"
DEFROUTE=no
===========================================================
ifconfig bond0 up
ifconfig bond1 up
modprobe bonding
==========================================================
service network restart
cat /proc/net/bonding/bond0
cat /proc/net/bonding/bond1

ethtool eth0
ethtool eth1
==========================================================

Rabu, 09 Januari 2013

BlogJet

"Computers are incredibly fast, accurate and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination."

-- Albert Einstein --

Selasa, 08 Januari 2013

Kickstart-Server RHEL6.2_x86_64 Step-by-steps


A. Create Local Repository (yum local)
1. mount REDHAT EL6 DVD IN TO /mnt
mount /dev/cdrw /mnt

2. copy rpms from Packages directory into /opt/source/repo
cd /media/"RHEL_6.2 x86_64 Disc 1"/Packages
mkdir -p /opt/source/repo
cp -rpv * /opt/source/repo
3. Install repocreate utility rpm installation
rpm -ivh deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm python-deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm createrepo-0.9.8-4.el6.noarch.rpm
4. cd /opt/source/repo
createrepo `pwd`
2293/3596 - xz-libs-4.999.9-0.3.beta.20091007git.el6.x86_64.rpm

5. vi /etc/yum.conf
"# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d"
[base-local]
name=RHEL6 $releasever - $basearch
failovermethod=priority
baseurl=file:///opt/source/repo
enabled=1
gpgcheck=0


6. check your current local repository
yum repolist



B. Prepare Kickstart-Server
1. Install all the required packages through yum
yum install syslinux xinetd tftp-server dhcp httpd

2. mkdir /var/lib/tftpboot/pxelinux.cfg
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
 

3. Open the xinetd settings to enable tftp server
vi /etc/xinetd.d/tftp
# at line 14 change the parameter from yes to no.
Disable=no


4. Restart the service to apply the settings made
service xinetd restart

5. set the service to start with each subsequent system reboots
chkconfig xinetd on

6. Open the file and configure the DHCP Server
vi /etc/dhcp/dhcpd.conf


# Here the next.sever parameter is the address of the kickstart server.
# Subnet definition Global Option
# WARNING = accomodate MAC ADDRESS (hardware ethernet) and IPADDR (fixed address)
Allow booting;
Allow bootp;
authoritative;

# Subnet definition
ddns-update-style interim;
subnet 10.128.57.0 netmask 255.255.255.0 {
range dynamic-bootp 10.128.57.107 10.128.57.110;
option broadcast-address 10.128.57.255;
option routers 10.128.57.1;
filename "pxelinux.0";
next-server 10.128.57.100;
}

host grid-compute-7 {
hardware ethernet 00:50:56:99:E0:61;
fixed-address 10.128.57.39;
option subnet-mask 255.255.255.0;
option routers 10.128.57.1;
option host-name "grid-compute-7";
filename "pxelinux.0";
}
host grid-compute-8 {
hardware ethernet 00:50:56:99:E0:62;
fixed-address 10.128.57.49;
option subnet-mask 255.255.255.0;
option routers 10.128.57.1;
option host-name "grid-compute-8";
filename "pxelinux.0";
}

7. Restart the service and make it permanent
service dhcpd restart
chkconfig dhcpd on


8. Make some required directories
mkdir -p /var/www/html/rhel
mkdir -p /var/lib/tftpboot/rhel6

9. Insert your RHEL 6.2 DVD + Mount it to /mnt
df -h
/media/RHEL_6.2 x86_64 Disc 1

10. Check the contents to see if it is properly mounted
cd /media/"RHEL_6.2 x86_64 Disc 1"

11. copy all the contents to the /var/www/html/rhel directory
cp –arv /media/RHEL_6.2 x86_64 Disc 1/* /var/www/html/rhel

12. After the file copy operation eject the DVD
eject cdrom

12. Copy the vmlinuz and initrd.img files to the tftpboot directory
cp /var/www/html/rhel/images/pxeboot/vmlinuz /var/lib/tftpboot/rhel6
cp /var/www/html/rhel/images/pxeboot/initrd.img /var/lib/tftpboot/rhel6

13. Copy the menu file
cp /usr/share/syslinux/menu.c32 /var/lib/tftpboot/

14. Prepare the boot menu.
vi /var/lib/tftpboot/pxelinux.cfg/default

timeout 100
default menu.c32
menu title === Hell-Me-Kickstart ===
label 1
menu label ^ 1) RedHat Enterprise Linux
kernel rhel6/vmlinuz
append initrd=rhel6/initrd.img ks=http://10.128.57.100/ks/ks.cfg

15. Prepare the httpd server
vi /etc/httpd/conf/httpd.conf

Listen 10.128.57.100:80

service httpd restart
(ignore the fully qualified domain name error if it occurs.)
chkconfig httpd on


vi /etc/hosts
10.128.57.100 kick-server

16. Prepare nfs server
vi /etc/exports
/var/www/html/ks *(rw,no_root_squash)
/var/www/html/rhel *(rw,no_root_squash)

service nfs restart
chkconfig nfs on

exportfs

/var/www/html/ks
/var/www/html/rhel

chkconfig iptables off

disable selinux
vi /etc/selinux/config
SELINUX=disable

shutdown -r now




C. Prepare Kickstart Config (ks.cfg)

1. Make the directory and copy the kickstart file to it
2. And make the kickstart file globally read only (chmod 644)
mkdir -p /var/www/html/ks
mkdir -p /var/www/html/ks/logs
3. vi /var/www/html/ks
#platform=x86, AMD64, or Intel EM64T
#version=RHEL6.2_x86_64
# Firewall configuration
firewall --disabled
# Install OS instead of upgrade
install
# Use NFS or http installation media
#nfs --server=10.128.57.100 --dir=/var/www/html/rhel
url --url http://10.128.57.100/rhel
# Root password indosat01
rootpw --iscrypted $1$nWgsJGK8$DAjPcF813tgBCqskYMzdQ0
# System authorization information
auth --useshadow --passalgo=sha512
# Use graphical install
#text
graphical
# Run the Setup Agent on first boot
firstboot --enable
# System keyboard
keyboard us
# System language
lang en_US
# SELinux configuration
selinux --disabled
# Installation logging level
logging --level=info
# Reboot after installation
reboot
# System timezone
timezone --isUtc Asia/Jakarta
# Network information
network --bootproto=dhcp --device=eth0 --onboot=on
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all
# Disk partitioning information
part /boot/efi --asprimary --fstype="vfat" --size=200
part /boot --asprimary --fstype="ext4" --size=500
part pv.01 --size=1 --grow
#
volgroup vg_gridcompute --pesize=4096 pv.01
#
logvol / --fstype="ext4" --name=lv_root --vgname=vg_gridcompute --size=10240
logvol swap --fstype="swap" --name=lv_swap --vgname=vg_gridcompute --size=800
logvol /home --fstype="ext4" --name=lv_home --vgname=vg_gridcompute --size=512
logvol /tmp --fstype="ext4" --name=lv_tmp --vgname=vg_gridcompute --size=900
logvol /var --fstype="ext4" --name=lv_var --vgname=vg_gridcompute --size=5120
bootloader --location=mbr --driveorder=sda --append="nomodeset rhgb quiet"

%packages
@backup-server
@additional-devel
@base
@basic-desktop
@compat-libraries
@debugging
@desktop-platform
@development
@directory-client
@fonts
@general-desktop
@graphical-admin-tools
@internet-browser
@large-systems
@legacy-unix
@legacy-x
@network-file-system-client
@network-tools
@nfs-file-server
@performance
@perl-runtime
@print-client
@remote-desktop-clients
@server-platform
@server-platform-devel
@system-management-snmp
@tex
@x11
glibc-utils
iptraf
mtools
pax
python-dmidecode
qt-mysql
qt-odbc
qt-postgresql
qt3-MySQL
qt3-ODBC
qt3-PostgreSQL
rdesktop
spice-client
spice-xpi
system-config-kickstart
system-config-lvm
tigervnc
tsclient
vinagre
xorg-x11-xdm
xterm
libxcb.i686
nss-softokn-freebl.i686
libcap.i686
cracklib.i686
libXau.i686
libXpm.i686
compat-libstdc++-33.i686
db4.i686
libattr.i686
libX11.i686
libselinux.i686
pam.i686
glibc.i686
libgcc.i686
audit-libs.i686
glibc-devel.i686
libstdc++.i686
libXp.i686
libXp.x86_64
libXext.i686
libxcb.i686
ksh.x86_64
%end
#======================================================

%post
# And so begins the post-install section.
# this is currently in a chroot to / on the
# new file system.
# Various variables I like to set first to use later
(
# I run everything in this, so I can log it
/bin/echo "Welcome to $HOSTNAME Server " > /etc/motd
# One way of adding to files
cat >> /etc/sysctl.conf << EOF
#Semaphore Limits SEMMSL SEMMNS SEMOPM SEMMNI
kernel.sem = 250 256000 32 1024
EOF
# Another way of inputing to files
echo 'root soft nofile 10240' >> /etc/security/limits.conf
echo 'root hard nofile 10240' >> /etc/security/limits.conf
echo 'root soft nproc -1' >> /etc/security/limits.conf
echo 'root hard nproc -1' >> /etc/security/limits.conf
# Add a user if you like
useradd -m -u 98 -d /home/ibm ibm
echo ibm | passwd ibm --stdin
# setup bonding runing script network_config.sh + hostfile.csv
# (placed both file on /var/www/html/ks)

mount -t nfs -o nolock 10.128.57.100:/var/www/html/ks /mnt
chmod 777 /mnt/network_config.sh
/mnt/network_config.sh
# Here doing some system settings
# Setup hosts file
cat > /etc/hosts << EOF
#127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
#::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

10.128.57.39 grid-compute-7
10.128.57.49 grid-compute-8
EOF
# setup NTP Client
echo 'server 10.10.100.5' >> /etc/ntp.conf
echo 'server 10.2.2.67' >> /etc/ntp.conf
# Turn some services on and off and mkdir
/sbin/chkconfig ip6tables off
/sbin/chkconfig iptables off
/sbin/chkconfig ntpd on
/sbin/chkconfig postfix off

/bin/mkdir -p /opt/oracle
/bin/mkdir -p /etl_prod
/bin/mkdir -p /etl_prod/backup
/bin/mkdir -p /etl_prod/etl_dataset
/bin/mkdir -p /etl_prod/source
/bin/mkdir -p /etl_prod/app
/bin/mkdir -p /etl_prod/etl_scratch

) > /tmp/kickstart-install.log 2>&1
# The aforementioned log.
%end

D. script "network_config.sh"
1. vi /var/www/html/ks/network_config.sh

# cat network_config.sh
#!/bin/bash
DEBUG=off
IFCONFIG=/sbin/ifconfig
NIC_FILE_DIR=/etc/sysconfig/network-scripts/
GW_FILE=/etc/sysconfig/network
HOST_FILE=/etc/hosts
DNS_FILE=/etc/resolv.conf
DOMAIN_LIST="no.domain.com"
####
## function readHostFile
## reads $HOST_MAP_FILE for specific network information about this host
## return 1 on error, 0 on success
## options can be in any order (nic, gw, or bond), broadcast and network address are calculated based on ip and mask
## calls functions to generate Gateway ($GW_FILE), Hosts ($HOST_FILE), and ifcfg ($NIC_FILE_DIR/ifcfg-{nic})
##
## host_map_file format
## {host},nic={eth#} ip mask [?primary],gw={gw_ip},bond={bond#} {nic1} {nic2} {ip} {mask},domain={dns_server},{dns_server}
## e.g. server1,nic=eth0 192.168.1.1 255.255.255.0,gw=192.168.0.1,nic=bond0 eth1 eth2 192.168.0.10 255.255.255.0 1,dns=192.168.0.254 192.168.1.254
####
readHostFile() {
if [ -e $HOST_MAP_FILE ]
then
# override default DOMAIN_LIST if it exists
DOMAIN_TMP=$(cat $HOST_MAP_FILE | grep -wi "DOMAINSEARCH" | cut -f2 -d =)
if [ ! -z "$DOMAIN_TMP" ]
then
log info "Domain search list found -- $DOMAIN_TMP"
DOMAIN_LIST="$DOMAIN_TMP"
else
log info "Domain search not found, using defaults -- $DOMAIN_LIST"
fi

# parse the file for this host exactly (-w) and case insensitive
HOST_INFO=$(cat $HOST_MAP_FILE | grep -wi `hostname`)
# check to see there was an entry for this host
if [ -z "$HOST_INFO" ]
then
log warning "Host information for `hostname` was not found in HOST_MAP_FILE"
return 1
fi
log notify "Host information found for `hostname` in $HOST_MAP_FILE"
log notify "Host info is $HOST_INFO"
# parse HOST_INFO
IFS=$','
for entry in $HOST_INFO
do
log debug "Working on entry $entry"
KEY=`echo $entry | cut -f1 -d =`
VALUE=`echo $entry | cut -f2 -d =`
case "$KEY" in
nic)
log debug "nic is specified -- $VALUE"
NIC=`echo $VALUE | cut -f1 -d " "`
if [ ${#NIC} -eq 12 ]
then
# we are working with a MAC address
NIC=$(getNIC $NIC)
fi
IPADDR=`echo $VALUE | cut -f2 -d " "`
MASK=`echo $VALUE | cut -f3 -d " "`
PRIMARY=`echo $VALUE | cut -f4 -d " "`
BROADCAST=$(getBroadcastAddress $IPADDR $MASK)
NETWORK=$(getNetworkAddress $IPADDR $MASK)
# MAC address for this card
MAC=$(getMAC $NIC)

if [ -z $NIC ]
then
log error "Missing NIC information aborting file creation"
else
log info "Values for NIC $NIC - MAC $MAC - IP $IPADDR - NetMask $MASK - Broadcast $BROADCAST - Network $NETWORK"
genIPFile $NIC $MAC $IPADDR $MASK $BROADCAST $NETWORK
fi

if [ "$PRIMARY" == 1 ]
then
genHostFile $IPADDR
fi
;;
bond)
#nic=bond0 eth1 eth2 192.168.0.10 255.255.255.0 1
log debug "bond is specified -- $VALUE"
BOND=`echo $VALUE | cut -f1 -d " "`
NIC1=`echo $VALUE | cut -f2 -d " "`
if [ ${#NIC1} -gt 12 ]
then
# we are working with a MAC address
NIC1=$(getNIC $NIC1)
fi
NIC2=`echo $VALUE | cut -f3 -d " "`
if [ ${#NIC2} -gt 12 ]
then
# we are working with a MAC address
NIC2=$(getNIC $NIC2)
fi
IPADDR=`echo $VALUE | cut -f4 -d " "`
MASK=`echo $VALUE | cut -f5 -d " "`
BROADCAST=$(getBroadcastAddress $IPADDR $MASK)
NETWORK=$(getNetworkAddress $IPADDR $MASK)

log info "Values for BOND $BOND - NIC1 $NIC1 - NIC2 $NIC2 - IP $IPADDR - NetMask $MASK - Broadcast $BROADCAST - Network $NETWORK"
genBondFile $BOND $NIC1 $NIC2 $IPADDR $MASK $BROADCAST $NETWORK

if [ "$PRIMARY" == 1 ]
then
genHostFile $IPADDR
fi
;;
gw)
log debug "Gateway value - $VALUE"
genGWFile $VALUE
;;
dns)
log debug "DNS is specified -- $VALUE"
genDNSFile "$VALUE"
esac
done
else
log warning "Hostfile $HOST_MAP_FILE does not exist"
return 1
# configure eth0 as static based on the current DHCP address
fi
}

####
## function getNIC {mac_addr}
## returns eth# based on MAC address
####
getNIC() {
local RAW_MAC=$1
# a properly formatted MAC address is 00:10:20:30:40:50 (17 characters)
if [ ${#RAW_MAC} -ne 17 ]
then
# assume the user didn't put in : marks
COUNT=0
# in case this is IPv6 loop for the entire raw mac length
while [ $COUNT -lt ${#RAW_MAC} ]
do
if [ $COUNT -eq 0 ]
then
SEARCH_MAC=${RAW_MAC:$COUNT:2}
else
SEARCH_MAC="$SEARCH_MAC:${RAW_MAC:$COUNT:2}"
fi
COUNT=$(($COUNT + 2))
done
else
SEARCH_MAC=$RAW_MAC
fi

# return eth# for a specific MAC
local NIC=`$IFCONFIG -a | grep -i $SEARCH_MAC | awk '{print $1}'`
if [ -z $NIC ]
then
log error "Network interface was not found for nic $SEARCH_MAC, this interface will not be configured correctly"
log error "ifconfig output is \n`$IFCONFIG -a`"
else
log info "NIC $SEARCH_MAC found as $NIC"
fi
echo $NIC
}

####
## function genBondFile {bond#} {nic1} {nic2} {ip} {mask} {broadcast} {network}
## nic=bond0 eth0 eth1 192.168.0.10 255.255.255.0
## nic=eth0 192.168.0.10 255.255.255.0 192.168.0.254 192.168.0.0
####
genBondFile() {
local BOND=$1
local NIC1=$2
local NIC2=$3
local IP=$4
local MASK=$5
local BROADCAST=$6
local NETWORK=$7
local BOND_FILE=${NIC_FILE_DIR}ifcfg-$BOND
local NIC1_FILE=${NIC_FILE_DIR}ifcfg-$NIC1
local NIC2_FILE=${NIC_FILE_DIR}ifcfg-$NIC2

log info "Creating Bond file $BOND_FILE"
echo "DEVICE=$BOND" > $BOND_FILE
echo "BOOTPROTO=none" >> $BOND_FILE
echo "ONBOOT=yes" >> $BOND_FILE
echo "NETWORK=$NETWORK" >> $BOND_FILE
echo "NETMASK=$MASK" >> $BOND_FILE
echo "IPADDR=$IP" >> $BOND_FILE
echo "BROADCAST=$BROADCAST" >> $BOND_FILE
echo "USERCTL=no" >> $BOND_FILE
echo "BONDING_OPTS=\"mode=1 miimon=300 primary=$NIC1\"" >> $BOND_FILE

log info "Creating network file $NIC1_FILE"
echo "DEVICE=$NIC1" > $NIC1_FILE
echo "BOOTPROTO=none" >> $NIC1_FILE
echo "HWADDR=$(getMAC $NIC1)" >> $NIC1_FILE
echo "ONBOOT=yes" >> $NIC1_FILE
echo "MASTER=$BOND" >> $NIC1_FILE
echo "SLAVE=yes" >> $NIC1_FILE
echo "USERCTL=no" >> $NIC1_FILE

log info "Creating network file $NIC2_FILE"
echo "DEVICE=$NIC2" > $NIC2_FILE
echo "BOOTPROTO=none" >> $NIC2_FILE
echo "HWADDR=$(getMAC $NIC2)" >> $NIC2_FILE
echo "ONBOOT=yes" >> $NIC2_FILE
echo "MASTER=$BOND" >> $NIC2_FILE
echo "SLAVE=yes" >> $NIC2_FILE
echo "USERCTL=no" >> $NIC2_FILE

log info "Modifying modprobe.conf file /etc/modprobe.d/bonding.conf"
echo "alias $BOND bonding" >> /etc/modprobe.d/bonding.conf
}

####
## function getMAC {nic}
## gets the MAC address for a given interface using ifconfig
####
getMAC() {
HWINFO=`$IFCONFIG $1 | grep HWaddr` # eth0 Link encap:Ethernet HWaddr 00:50:56:9C:1B:00
if [ $? -ne 0 ]
then
log error "Cannot find MAC address for interface $1"
# return nothing to the calling process
echo " "
else
# return the MAC address
echo $HWINFO | awk '{print $5}'
fi
}

####
## function genDomainFile {nameserver} {nameserver} {etc}
## creates a basic DNS file for nameserver entries
####
genDNSFile() {
log info "Creating DNS file $DNS_FILE"
OldIFS=$IFS
IFS=" "
> $DNS_FILE
# create search entries
echo "search $DOMAIN_LIST" >> $DNS_FILE
# create server entries
for dnsEntry in $1
do
echo "nameserver $dnsEntry" >> $DNS_FILE
done
IFS=$OldIFS
}
####
## function genHostFile {local_ip}
## creates a basic hosts file with loopback and this host
####
genHostFile() {
local IP=$1
log info "Creating host file $HOST_FILE"
echo "127.0.0.1 localhost.localdomain localhost" > $HOST_FILE
echo "$IP `hostname`" >> $HOST_FILE

}

####
## function genGWFile {gateway_ip}
## create the default route file including default RedHat values
####
genGWFile() {
local GW=$1
log info "Creating gateway file $GW_FILE"
echo "NETWORKING=yes" > $GW_FILE
echo "NETWORKING_IPV6=no" >> $GW_FILE
echo "HOSTNAME=`hostname`" >> $GW_FILE
echo "GATEWAY=$GW" >> $GW_FILE
}

####
## function genIPFile {nic} {mac} {ip} {mask} {broadcast} {network}
## create the IP Address file (ifcfg-eth{x})
## e.g. nic=eth0 00:50:56:9C:1B:00 192.168.0.10 255.255.255.0 192.168.0.254 192.168.0.0
####
genIPFile() {
local NIC=$1
local MAC=$2
local IP=$3
local MASK=$4
local BROADCAST=$5
local NETWORK=$6
local IP_FILE=${NIC_FILE_DIR}ifcfg-${NIC}

log info "Creating network file $IP_FILE"
echo "DEVICE=$NIC" > $IP_FILE
echo "BOOTPROTO=static" >> $IP_FILE
echo "BROADCAST=$BROADCAST" >> $IP_FILE
echo "HWADDR=$MAC" >> $IP_FILE
echo "IPADDR=$IP" >> $IP_FILE
echo "NETMASK=$MASK" >> $IP_FILE
echo "NETWORK=$NETWORK" >> $IP_FILE
log debug "----------- ifcfg-$NIC file -----------"
log debug "\n`cat $IP_FILE`"
log debug "----------------------"
}

####
## function getNetworkAddress
## calculates the network address given an ip and subnet mask
## converts the ip and mask into an array and does a bitwise and for each element
####
getNetworkAddress() {
OldIFS=$IFS
IFS=.
typeset -a IP_Array=($1)
typeset -a MASK_Array=($2)
IFS=$OldIFS
echo $((${IP_Array[0]} & ${MASK_Array[0]})).$((${IP_Array[1]} & ${MASK_Array[1]})).$((${IP_Array[2]} & ${MASK_Array[2]})).$((${IP_Array[3]} & ${MASK_Array[3]}))
}

####
## function getBroadcastAddress
## calculates the broadcast address given an ip and subnet mask
## converts the ip and mask into an array and does a bitwise or (|) against an XOR (^)
####
getBroadcastAddress() {
OldIFS=$IFS
IFS=.
typeset -a IP_Array=($1)
typeset -a MASK_Array=($2)
IFS=$OldIFS
echo $((${IP_Array[0]} | (255 ^ ${MASK_Array[0]}))).$((${IP_Array[1]} | (255 ^ ${MASK_Array[1]}))).$((${IP_Array[2]} | (255 ^ ${MASK_Array[2]}))).$((${IP_Array[3]} | (255 ^ ${MASK_Array[3]})))
}

####
## function readDHCPAddress
## reads information currently running and writes it out as a static IP entry
####
readDHCPAddress() {
log info "Host information was not found for this server, copying information from running configuration (DHCP)"
# the grep will grab two lines of output and merge them together
# eth0 Link encap:Ethernet HWaddr 00:50:56:9C:1B:00
# inet addr:192.168.0.10 Bcast:192.168.0.254 Mask:255.255.255.0
HWINFO=`$IFCONFIG | grep -A 1 -i hwaddr`
NIC=`echo $HWINFO | cut -f1 -d " "`
MAC=`echo $HWINFO | cut -f5 -d " "`
for i in $HWINFO
do
case "$i" in
addr:*)
IP=`echo $i | cut -f2 -d :`
;;
Bcast:*)
BROADCAST=`echo $i | cut -f2 -d :`
;;
Mask:*)
MASK=`echo $i | cut -f2 -d :`
;;
esac
done
NETWORK=$(getNetworkAddress $IP $MASK)
log debug "DHCP information is NIC $NIC - MAC $MAC - IP $IP - MASK $MASK - BROADCAST $BROADCAST - NETWORK $NETWORK"
genIPFile $NIC $MAC $IP $MASK $BROADCAST $NETWORK
genHostFile $IP
GATEWAY=`netstat -rn | grep -w UG | awk '{print $2}'`
genGWFile $GATEWAY
}

####
## function log
## logs activities to the screen, a file, or both
####
log() {
LOG_TYPE="$1"
LOG_MSG="$2"
TIME=`date +'%H:%M:%S %Z'`
# specify the log file only once
if [ ! -d /mnt/logs ]
then
mkdir ${/mnt}/logs
fi
if [ -z $LOG_FILE ]
then
LOG_FILE="/mnt/logs/network_config-`hostname`-`date +%Y%m%d-%H%M%S`"
fi
if [ $LOG_TYPE == "error" ]
then
echo -e "$TIME - **ERROR** - $LOG_MSG" >> $LOG_FILE
elif [ $LOG_TYPE == "debug" ]
then
if [ $DEBUG == "on" ]
then
echo -e "DEBUG - $LOG_MSG" >> "$LOG_FILE"
fi
elif [ $LOG_TYPE == "warning" ]
then
echo -e "$TIME - **WARNING** - $LOG_MSG" >> $LOG_FILE
else
echo -e "$TIME - $LOG_MSG" >> "$LOG_FILE"
fi
}

# read source directory from command line. This is where we will read the hostfile.csv and output logs to
SOURCE_DIR=$1
HOST_MAP_FILE=/mnt/hostfile.csv

readHostFile
if [ $? -ne 0 ]
then
readDHCPAddress
fi





D. script "hostfile.csv"
1.vi /var/www/html/ks/hostfile.csv
#Format -- server_name,[bond|nic] eth# [eth#] IP MASK Primary,gw={gateway},dns={dns1 dns2 etc}
# as long as the server name comes first, the order of the rest doesn't really matter
# Primary is used to determine which interface should be placed in the host file
# an example with multiple bonded interfaces.
# an example with one bond using MAC addresses
server2,bond=bond0 0050569c25e5 0050569c6cbd 192.168.0.11 255.255.255.0 1,gw=192.168.0.1,dns=192.168.0.254 192.168.1.254


grid-compute-7,bond=bond0 eth0 eth1 10.128.57.39 255.255.255.0 1,gw=10.128.57.1
grid-compute-8,bond=bond0 eth0 eth1 10.128.57.49 255.255.255.0 1,gw=10.128.57.1