#####################
#!/bin/sh
#####################
#配置IP地址(192.168.220.22 192.168.220.2需替换)
echo "IPADDR=192.168.220.22" >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo "NETMASK=255.255.255.0" >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo "GATEWAY=192.168.220.2" >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo "DNS1=202.101.172.35" >> /etc/sysconfig/network-scripts/ifcfg-eth0
sed -i -e "s/^ONBOOT=.*/ONBOOT=yes/g" -e "s/^BOOTPROTO=.*/BOOTPROTO=static/g" /etc/sysconfig/network-scripts/ifcfg-eth0
service network restart
#安装vim
yum -y install vim
echo "#########################"
echo "vim install success!"
#创建hadoop用户
if cat /etc/passwd |awk -F : '{print $1}' |grep hadoop >/dev/null 2>&1
then
echo "User hadoop already exists!"
else
useradd hadoop
echo "123456" | passwd --stdin hadoop
echo "hadoop create success!"
echo "#########################"
#sed -i '/^root/a\hadoop ALL=(ALL) ALL' /etc/sudoers
fi
#增加映射关系(192.168.220.22 hadoop2替换)
echo "192.168.220.22 hadoop2" >> /etc/hosts
echo "#########################"
echo "maped ip success!"
#修改主机名称(hadoop2替换)
sed -i -e '/^HOSTNAME=/h ' -e '$G' -e 's/HOSTNAME=/#HOSTNAME=/' /etc/sysconfig/network
sed -i "s/^HOSTNAME=.*/HOSTNAME=hadoop2/g" /etc/sysconfig/network
service network restart
echo "#########################"
echo "up host success!"
#关闭防火墙
service iptables stop
chkconfig --level 3 iptables off
echo "#########################"
echo "iptables stop success!"
#创建/cloud目录,并修改权限
mkdir /cloud
chown -R hadoop:hadoop /cloud
echo "#########################"
echo "mkdir /cloud success!"
查看centos版本
cat /etc/redhat-release
uname -a 可显示电脑以及操作系统的相关信息
cat /proc/version,说明正在运行的内核版本
cat /etc/issue, 显示的是发行版本信息