#! /bin/bash ipaddlastnumber=$(ifconfig | grep 255.255.0.0 |awk '{ print $2}' | awk -F'.' '{print $4}') ## 1 ### nfs_node.txt ### Configuring compute nodes (NFS clients) ### reference: https://www.itzgeek.com/how-tos/linux/centos-how-tos/how-to-setup-nfs-server-on-centos-7-rhel-7-fedora-22.html #### default values. dont change ### HOSTNAME=compute-0-$ipaddlastnumber hostnamectl set-hostname $HOSTNAME #### default values. dont change ### ## 5. Doing NFS configuration in current node # Check NFS Share # Before mounting the NFS share, check the NFS shares available on the NFS server by running the following command on the NFS client. showmount -e 192.168.1.10 # Mount the shared directory in the NFS clients (the share directory in the frontend is supposed to be /export/share mkdir /share mount 192.168.1.10:/export/share /share #Verify the mounted share on the NFS client using mount command. mount | grep nfs #Also, you can use the df -hT command to check the mounted NFS share. df -hT #Create a file on the mounted directory to verify the read and write access on NFS share. touch /share/test_$HOSTNAME #If the above command returns no error, you have working NFS setup # To mount the shares automatically on every reboot, you would need to modify /etc/fstab file of your NFS client. cp /etc/fstab /etc/fstab.orig echo '192.168.1.10:/export/share /share nfs nosuid,rw,sync,hard,intr 0 0' >> /etc/fstab # Reload the entries in the modified /etc/fstab, by using the mount command: mount -av ### replace /etc/hosts file by that shared in /share/cluster/hosts, then add to hosts the identify of current node mv /etc/hosts /etc/hosts.orig ln -s /share/cluster/hosts /etc/ echo 192.168.1.$ipaddlastnumber $HOSTNAME.local $HOSTNAME c$ipaddlastnumber >> /share/cluster/hosts cat /share/cluster/hosts | sort | uniq > temp mv temp /share/cluster/hosts #### customize /etc/ssh in a fresh node, so that ssh can work seamlessly # edit /etc/ssh/ssh_config, so that it reads 'GSSAPIAuthentication no' # edit /etc/ssh/sshd_config, so that it reads 'GSSAPIAuthentication no \ UseDNS no' #edit /etc/resolv.conf, so that it reads 'search local \ nameserver 192.168.1.10'. This line could be overwritten when setting the eth0 using NetworkManager. #### end of customize /etc/ssh in a fresh node ### customize the root for the present node mkdir -p /state/partition1 chmod -R 777 /state/partition1 if [[ -e ~/.ssh/id_rsa.pub ]]; then echo "pub rsa exists. Will not creat any."; else ssh-keygen -t rsa; fi sh /share/apps/local/bin/gen_bashrc.txt source ~/.bashrc ### if the nfs mount has been successful at this stage, the node should be able to see the shared directory /share/apps/local/bin/ sh /share/apps/local/bin/gen_bashrc-root source ~/.bashrc # edit /etc/ssh/ssh_config, so that it reads 'GSSAPIAuthentication no' # edit /etc/ssh/sshd_config, so that it reads 'GSSAPIAuthentication no \ UseDNS no' cp /etc/ssh/sshd_config /etc/ssh/sshd_config.orig sed -i 's/GSSAPIAuthentication yes/GSSAPIAuthentication no/g' /etc/ssh/sshd_config sed -i 's/UseDNS yes/UseDNS no/g' /etc/ssh/sshd_config sed -i 's/GSSAPIAuthentication yes/GSSAPIAuthentication no/g' /etc/ssh/ssh_config sed -i 's/UseDNS yes/UseDNS no/g' /etc/ssh/ssh_config #### end of customize /etc/ssh in a fresh node rpm -ivh /share/apps/configrepo/sshpass-1.06-2.el7.x86_64.rpm #yum install -y epel-release sshpass basic_packages.txt