CDH安装脚本

脚本一

#!/bin/bash

#修改hosts名称和节点的ip地址
hostname="master"
master="192.168.1.7"
slave1="192.168.1.8"
slave2="192.168.1.9"
slave3="192.168.1.10"
slave4="192.168.1.11"


#追加主机名到host
#echo $hostname >> /etc/sysconfig/network
#修改network中内容
sed -i -e 's|HOSTNAME=localhost.localdomain|HOSTNAME='$hostname'|' /etc/sysconfig/network
if [ $? -eq 0 ]
then
echo "修改主机名成功,请开机后使用uname -a测试"
else
echo "修改主机名失败"
exit 1
fi

echo "$master master" >> /etc/hosts
echo "$slave1 slave1" >> /etc/hosts
echo "$slave2 slave2" >> /etc/hosts
echo "$slave3 slave3" >> /etc/hosts
echo "$slave4 slave4" >> /etc/hosts
if [ $? -eq 0 ]
then
echo "添加host名称成功"
else
echo "添加host名称失败"
exit 1
fi

ping -c 3 master
if [ $? -eq 0 ]
then
echo "ping[master]成功"
else
echo "ping[master]失败"
exit 1
fi
ping -c 3 slave1
if [ $? -eq 0 ]
then
echo "ping[slave1]成功"
else
echo "ping[slave1]失败"
exit 1
fi
ping -c 3 slave2
if [ $? -eq 0 ]
then
echo "ping[slave2]成功"
else
echo "ping[slave2]失败"
exit 1
fi
ping -c 3 slave3
if [ $? -eq 0 ]
then
echo "ping[slave3]成功"
else
echo "ping[slave3]失败"
exit 1
fi
ping -c 3 slave4
if [ $? -eq 0 ]
then
echo "ping[slave4]成功"
else
echo "ping[slave4]失败"
exit 1
fi


sed -i -e 's|SELINUX=enforcing|SELINUX=disabled|' /etc/selinux/config
if [ $? -eq 0 ]
then
echo "成功关闭selinux,请重启后使用 /usr/sbin/sestatus -v 测试"
else
echo "关闭selinux失败"
exit 1
fi

service iptables stop 
chkconfig iptables off
service iptables status

yum -y install ntp

chkconfig ntpd on
if [ $? -eq 0 ]
then
echo "安装ntp服务成功,准备重启。。。"
else
echo "安装ntp服务失败"
exit 1
fi

reboot

脚本二

#!/bash/bin
echo "正在检查ntp服务,selinux服务,iptables服务。。。"

service ntpd status 
/usr/sbin/sestatus -v 
service iptables status

cp cloudera-manager.repo /etc/yum.repos.d/
if [ $? -eq 0 ]
then
echo "移动cloudera-manager.repo成功"
else
echo "移动失败,请检查路径!!!"
fi

yum clean all
if [ $? -eq 0 ]
then
echo "清理缓存成功"
else
echo "清理失败。。"
fi

echo "正在检查cloudera源。。。"
yum list | grep cloudera

cd rpms
echo "准备安装rpms包。。。"
yum -y install *.rpm
if [ $? -eq 0 ]
then
echo "安装rpm成功"
else
echo "安装失败"
fi

echo "准备移动Parcel包"
cd ..
cd Parcel
cp * /opt/cloudera/parcel-repo
if [ $? -eq 0 ]
then
echo "移动Parcel包成功"
else
echo "移动Parcel包失败"
fi

cd ..
chmod +x ./cloudera-manager-installer.bin
if [ $? -eq 0 ]
then
echo "赋权限cloudera-manager-installer.bin成功"
else
echo "赋权限cloudera-manager-installer.bin失败"
fi

echo "开始移动mysql驱动"
cp mysql-connector-java.jar /usr/share/java/
if [ $? -eq 0 ]
then
echo "移动mysql驱动成功"
else
echo "移动mysql驱动失败"
fi

cd /etc/cloudera-scm-server/
mv db.properties db.properties.bak
if [ $? -eq 0 ]
then
echo "修改配置文件成功,请进入安装包目录执行cloudera-manager-installer.bin开始安装!"
else
echo "修改配置文件失败"
fi

你可能感兴趣的:(大数据)