1. 程式人生 > >Centos7下安裝Cloudera Manager以及Hadoop

Centos7下安裝Cloudera Manager以及Hadoop

安裝Hadoop(CM)

警告: 在執行以下命令時,如果出現ssh相關命令(此處只記錄了一次),則需要在操作機器上向每臺機器都發起一次,如:

cat ip-mapping | ssh hd-26 'cat - >> /etc/hosts' 
cat ip-mapping | ssh hd-27 'cat - >> /etc/hosts' 
cat ip-mapping | ssh hd-28 'cat - >> /etc/hosts' 
cat ip-mapping | ssh hd-29 'cat - >> /etc/hosts' 
cat ip-mapping
| ssh hd-30 'cat - >> /etc/hosts'

提示: 1. ip-mapping 檔案的內容為 10.x.x.x hd-26 等,2. 可以將其改為指令碼,在指令碼中同時向其他機器進行SSH操作

安裝前準備

系統設定

提示 此處涉及關閉防火牆、配置hosts、以及關閉selinux等操作 故使用root並對root進行免密登入;執行以下命令的機器為10.8.177.29
1. 免密登入

# 此命令有等待輸入的地方回車即可
ssh-keygen

# 此命令需要輸入一次目標主機的密碼
ssh-copy-id -i .ssh
/id_rsa.pub 10.8.177.26 ssh-copy-id -i .ssh/id_rsa.pub 10.8.177.27 ssh-copy-id -i .ssh/id_rsa.pub 10.8.177.28 ssh-copy-id -i .ssh/id_rsa.pub 10.8.177.29 ssh-copy-id -i .ssh/id_rsa.pub 10.8.177.30
  1. 配置hosts
#生成對映關係 也可以採用 vi 編輯錄入
echo -e "10.8.177.26 hd-26\
\n10.8.177.27 hd-27 \
\n10.8.177.28 hd-28 \
\n10.8.177.29 hd-29 \
\n10.8.177.30 hd-30 \ \n10.8.177.31 hd-31" >> ip-mapping # 追加至目標機器的hosts檔案中 cat ip-mapping | ssh hd-26 'cat - >> /etc/hosts'
  1. 關閉防火牆
ssh hd-26 "systemctl stop firewalld; chkconfig firewalld off;"
  1. 關閉selinux
ssh hd-26 "setenforce 0; sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config;"
  1. yum源配置 [此處配置為阿里雲的提供的源]
ssh hd-26 "\
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup;\
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo;\
yum clean all; yum makecache"
  1. 安裝JDK
# 先解除安裝自帶的OpenJdk
ssh hd-26 "rpm -e --nodeps java-1.7.0-openjdk-headless-1.7.0.51-2.4.5.5.el7.x86_64; \
rpm -e --nodeps java-1.7.0-openjdk-1.7.0.51-2.4.5.5.el7.x86_64;"

# 安裝JDK
scp jdk-8u77-linux-x64.tar.gz hd-26:/usr/local/
ssh hd-28 "cd /usr/local; tar xf jdk-8u77-linux-x64.tar.gz;rm -rf jdk-8u77-linux-x64.tar.gz;"

# 配置環境變數
ssh hd-30 '\
 echo "export JAVA_HOME=/usr/local/jdk1.8.0_77" >> /etc/profile;\
 echo "export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH" >> /etc/profile;\
 echo "export CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar" >> /etc/profile;\
 source /etc/profile;'
  1. 安裝NTP服務
yum -y install ntp

#配置29 vi /etc/ntp.conf
restrict 10.8.177.0 mask 255.255.0.0 nomodify notrap
server 210.72.145.44 prefer
server 202.112.10.36
server 59.124.196.83
server 127.0.0.1
fudge 127.0.0.1 stratum 10

#配置其他機器
restrict 10.8.177.29  nomodify notrap
server 10.8.177.29
server 127.0.0.1
fudge 127.0.0.1 stratum 10

#重啟/設定開機啟動/校正時間
ssh hd-26 "systemctl restart ntpd;chkconfig ntpd on;ntpdate -u 10.8.177.29"
  1. 安裝mysql
#解除安裝自帶的MariaDB(mysql社群版本)
rpm -e --nodeps mariadb-libs-5.5.35-3.el7.x86_64

#安裝mysql
rpm -ivh MySQL-server-5.6.29-1.el7.x86_64.rpm 
rpm -ivh MySQL-devel-5.6.29-1.el7.x86_64.rpm
rpm -ivh MySQL-client-5.6.29-1.el7.x86_64.rpm

cp /usr/share/mysql/my-default.cnf /etc/my.cnf
/usr/bin/mysql_install_db

#如果出現無許可權的錯誤執行
cd /var/lib/mysql/mysql; chmod +x *

cat /root/.mysql_secret  #檢視root賬號密碼
  1. 禁用頁面壓縮
ssh hd-26 "echo never > /sys/kernel/mm/transparent_hugepage/defrag"

安裝CM

  1. 解壓CM
tar xf cloudera-manager-centos7-cm5.7.5_x86_64.tar.gzip -C /opt
  1. 拷貝mysql jar
cp /usr/share/java/mysql-connector-java.jar /opt/cm-5.7.5/share/cmf/lib/
  1. 建立使用者
useradd --system --home=/opt/cm-5.7.5/run/cloudera-scm-server --no-create-home --shell=/bin/false --comment "cloudera SCM user" cloudera-scm
  1. 設定server_host
vi /opt/cm-5.7.5/etc/config.ini
server_host=hd-29
  1. 初始化資料庫
#登入後執行
create database hive DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
create database amon DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
create database hue DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
create database oozie DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
create database reports DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
grant all privileges on *.* to 'root'@'%' identified by 'HollyCRM' with grant option;
grant all privileges on *.* to 'root'@'localhost' identified by 'HollyCRM' with grant option;
grant all privileges on *.* to 'root'@'hd-29' identified by 'HollyCRM' with grant option;
flush privileges;

# 初始化cmf
/opt/cm-5.7.5/share/cmf/schema/scm_prepare_database.sh mysql scp -hd-29 -uroot -pHollyCRM --scm-host hd-29 scm scm scm
  1. 分發Cloudera Manager至其他節點
# 如果這樣傳送慢的話,可以將其壓縮後傳送
scp -r /opt/cm-5.7.5/ hd-26:/opt/ 
  1. 其他節點建立SCM使用者
ssh hd-26 "useradd --system \
--home=/opt/cm-5.7.5/run/cloudera-scm-server/ \
--no-create-home --shell=/bin/false \ 
--comment "Cloudera SCM User" cloudera-scm"
  1. 修改VM配置
ssh hd-29 "\
echo 0 > /proc/sys/vm/swappiness; \
sysctl -w vm.swappiness=0; \
echo 'vm.swappiness=0' >> /etc/sysctl.conf "

8.拷貝CDH-parcel包

此處需要下載parcel、parcel.sha1、mainifset.json;只需要在hd-29 (CM-server)下即可;

cp CDH-5.7.5-1.cdh5.7.5.p0.3-el7.parcel /opt/cloudera/parcel-repo
cp CDH-5.7.5-1.cdh5.7.5.p0.3-el7.parcel.sha1 /opt/cloudera/parcel-repo
cp manifest.json /opt/cloudera/parcel-repo
cd /opt/cloudera/parcel-repo
mv CDH-5.7.5-1.cdh5.7.5.p0.3-el7.parcel.sha1 CDH-5.7.5-1.cdh5.7.5.p0.3-el7.parcel.sha
  1. 啟動CM-server服務
/opt/cm-5.7.5/etc/init.d/cloudera-scm-server start
  1. 啟動CM-agent服務
ssh hd-26 "/opt/cm-5.7.5/etc/init.d/cloudera-scm-agent start"
  1. 訪問
http://hd-29:7180/cmf

安裝CDH-HADOOP

登入CM頁面,按照嚮導進行安裝

相關頁面