#! /bin/bash ### centos6_nodes_part1. It contains node-dependent contents. ### This is an supplimentary script to centos6_frontend. You should refer centos6_frontend before running this script. ### At this stage the nodes may not be connected to the internet yet. You may need to first download this script into a pen drive and then copy the script from pendrive to the nodes one by one. ### This script sets up the ip of the nodes by making changes to Network configuration such as assign IP address, change DNS server etc. It will also do other necessary stuffs as well. ### Instruction: To configre a node, copy this script into a pendrive, transfer and run it in each node in turn. (Note: To configure the ip for frontend, run the separate script file centos6_frontend downloadable from http://www2.fizik.usm.my/configrepo/howto/CENTOS6/ in the frontend. A more detailed instruction can be found there.) # Important IPs: # The ip of the frontend via eth0 is: 10.1.1.1 # The ip of node1,node2,node3, ... via eth0 are: 10.1.255.231, 10.1.255.232, 10.1.255.233, ... # 1, 2 are host-dependent. It's content is slightly different when configuring a different node. # 1. # IMPORATANT: This part is hostname-dependent. Make sure that the hostname is appropriately modified. That is, # for node2, # echo 'IPADDR=10.1.255.232' >> /etc/sysconfig/network-scripts/ifcfg-eth0 # for node3, # echo 'IPADDR=10.1.255.233' >> /etc/sysconfig/network-scripts/ifcfg-eth0 # ... # The following code will replace the ifcfg-eht0 of a node with the desired content. The original ifcfg-eth0 will be saved as ifcfg-eth0.orig. Remember to modify IPADRR appropriately. ############################################################ mv /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0.orig touch /etc/sysconfig/network-scripts/ifcfg-eth0 grep UUID /etc/sysconfig/network-scripts/ifcfg-eth0.orig > /etc/sysconfig/network-scripts/ifcfg-eth0 grep HWADDR /etc/sysconfig/network-scripts/ifcfg-eth0.orig > /etc/sysconfig/network-scripts/ifcfg-eth0 echo 'DEVICE=eth0' >> /etc/sysconfig/network-scripts/ifcfg-eth0 echo 'BOOTPROTO=static' >> /etc/sysconfig/network-scripts/ifcfg-eth0 echo 'DHCPCLASS=' >> /etc/sysconfig/network-scripts/ifcfg-eth0 echo 'NETMASK=255.255.0.0' >> /etc/sysconfig/network-scripts/ifcfg-eth0 echo 'NM_CONTROLLED=yes' >> /etc/sysconfig/network-scripts/ifcfg-eth0 echo 'ONBOOT=yes' >> /etc/sysconfig/network-scripts/ifcfg-eth0 echo 'IPADDR=10.1.255.231' >> /etc/sysconfig/network-scripts/ifcfg-eth0 echo 'DNS1=10.1.1.1' >> /etc/sysconfig/network-scripts/ifcfg-eth0 echo 'DNS2=10.202.1.27' >> /etc/sysconfig/network-scripts/ifcfg-eth0 echo 'DNS3=10.202.1.6' >> /etc/sysconfig/network-scripts/ifcfg-eth0 ############################################################ # 2. # IMPORATANT: This part is hostname-dependent. Make sure that the hostname is appropriately modified. That is, # for node2, # echo 'HOSTNAME=node2.local' >> /etc/sysconfig/network # for node3, # echo 'HOSTNAME=node3.local' >> /etc/sysconfig/network # for node4, # echo 'HOSTNAME=node4.local' >> /etc/sysconfig/network # ... # /etc/sysconfig/network file in a node should has a typical content like ############################################################ #NETWORKING=yes #GATEWAY=10.1.1.1 #HOSTNAME=nodeX.local ############################################################ # The following code will replace the /etc/sysconfig/network file with the desired content. The original netowork file will be saved as network.orig. Remember to modify HOSTNAME appropriately. ############################################################ mv /etc/sysconfig/network /etc/sysconfig/network.orig touch /etc/sysconfig/network echo 'NETWORKING=yes' >> /etc/sysconfig/network echo 'GATEWAY=10.1.1.1' >> /etc/sysconfig/network echo 'HOSTNAME=node1.local' >> /etc/sysconfig/network ############################################################ # Restart networking in a node by enter following command: /etc/init.d/network restart #3. # Everynode will be automatically added an user named common. Creat /home/common/nfs immediately. useradd common usermod -a -G users common passwd common mkdir /home/common/nfs # 4. # Now configure the DNS entry for a node. The DNS is defined in /etc/resolv.conf file. # A typical content of /etc/resolv.conf of a frontend looks something like ############################################################ #nameserver 10.1.1.1 #search local usm.my ############################################################ # The following code will replace the /etc/resolv.conf file of the frontend with the desired content. The original netowork file, if exist, will be saved as /etc/resolv.conf.orig ############################################################ mv /etc/resolv.conf /etc/resolv.conf.orig touch /etc/resolv.conf echo 'nameserver 10.1.1.1' >> /etc/resolv.conf echo 'search local' >> /etc/resolv.conf # 5. # The file /etc/ssh/sshd_config in the frontend and nodes is modified to allow passwordless ssh mv /etc/ssh/sshd_config /etc/ssh/sshd_config.orig sed 's/GSSAPIAuthentication.*$/GSSAPIAuthentication no/g' < /etc/ssh/sshd_config.orig > /etc/ssh/sshd_config echo 'UseDNS no' >> /etc/sshd_config /etc/init.d/sshd restart # 5.5 restart network service network restart # 6. Mount the exported folder from frontend in the node by using the following command: mount 10.1.1.1:/home/common/nfs /home/commom/nfs echo '10.1.1.1:/home/common/nfs /home/common/nfs nfs defaults 0 0' >> /etc/fstab reboot