######################################################################### # File Name: installCDH.sh # Author: cwalet # mail: cwalet@163.com # Created Time: Thu 13 Mar 2014 09:58:38 AM CST ######################################################################### #!/bin/bash cmVersion=5 isCentOS=$(lsb_release -a | grep CentOS | grep Description | cut -d" " -f3) #根据系统版本选择安装源 test -z "$isCentOS" && exit 1 echo $isCentOS | grep 5 && osVersion=5 || osVersion=6 yumConf="/etc/yum.repos.d/cloudera.repo" echo " [cloudera-cdh$cmVersion] name=Cloudera's Distribution for Hadoop, Version $cmVersion baseurl= http://archive.cloudera.com/cdh$cmVersion/redhat/$osVersion/x86_64/cdh/$cmVersion/ gpgkey = http://archive.cloudera.com/cdh$cmVersion/redhat/$osVersion/x86_64/cdh/RPM-GPG-KEY-cloudera gpgcheck = 1 [cloudera-cm$cmVersion] name=Cloudera's Distribution for Hadoop, Version $cmVersion baseurl= http://archive.cloudera.com/cm$cmVersion/redhat/$osVersion/x86_64/cm/$cmVersion/ gpgkey = http://archive.cloudera.com/cm$cmVersion/redhat/$osVersion/x86_64/cm/RPM-GPG-KEY-cloudera gpgcheck = 1 " > $yumConf yum clean all yum update #根据YUM源创建本地YUM仓库 yum -y install createrepo yum-utils cd /tmp reposync -r cloudera-cm$cmVersion reposync -r cloudera-cdh$cmVersion rm -rf cloudera-cdh$cmVersion/repodata cloudera-cm$cmVersion/repodata createrepo cloudera-cdh$cmVersion createrepo cloudera-cm$cmVersion DocumentRoot=$(cat /etc/httpd/httpd.conf | grep DocumentRoot | grep -v "#" | head -1 | cut -d" " -f2) mv cloudera-cdh$cmVersion cloudera-cm$cmVersion $DocumentRoot service httpd start read -t 5 -p "please input namenode ip: " NAME_NODE if [ -z "$NAME_NODE" ]; then NAME_NODE=$(ifconfig eth0 | grep "inet addr:" | cut -d: -f2 | awk '{print $1}') fi sed -ie '/^gpgkey/d' -e "s/^baseurl=.*cdh.*$/baseurl=http:\/\/$NAME_NODE\/cloudera-cdh$cmVersion/g" -e "s/^baseurl=.*cm.*$/baseurl=http:\/\/$NAME_NODE\/cloudera-cm$cmVersion/g" $yumConf yum clean all yum update yum -y install cloudera-manager-* /etc/init.d/cloudera-scm-server-db start /etc/init.d/cloudera-scm-server start /etc/init.d/cloudera-scm-agent start echo "$NAME_NODE:7180"