本次安裝選用的是Cloudera Hadoop CDH 5.2.3版本,Cent OS 6.6 的系統,安裝流程為非常的不專業。僅供記錄,勿參考。
一、安裝前準備
1、更新系統
yum update
2、安裝JDK
A、下載並安裝RPM包
cd /usr/local/src
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u75-b13/jdk-7u75-linux-x64.rpm"
rpm -ivh jdk-7u75-linux-x64.rpm
注意事項,由於Oracle有Cookie驗證,所以不能直接使用 wget http://download.oracle.com/otn-pub/java/jdk/7u75-b13/jdk-7u75-linux-x64.rpm 直接下載,需要採用上述類比Cookie的方式。
注意:不要使用JDK 1.8 會存在相容性問題
B、配置環境變數
建立軟連結(便於後期升級SDK)
ln -s /usr/java/jdk1.7.0_75 /usr/java/latest
添加環境變數
vim /etc/profile
在profile檔案下面追加寫入下面資訊:
export JAVA_HOME=/usr/java/latest
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
儲存退出,執行:
source /etc/profile
3、 梳理安裝內容
準備好了三台虛擬機器,IP地址分別為:
192.168.150.136
192.168.150.137
192.168.150.138
4、系統配置
A、關閉IPV6
vim /etc/sysctl.conf
在檔案中追加如下內容:
#disable ipv6
net.ipv6.conf.all.disable_ipv6=1
net.ipv6.conf.default.disable_ipv6=1
net.ipv6.conf.lo.disable_ipv6=1
重新整理設定檔,使其生效
sysctl -p
確認ipv6是否已經禁用
cat /proc/sys/net/ipv6/conf/all/disable_ipv6
B、關閉防火牆
setenforce 0 #臨時禁用,不需要重啟
iptables -F #清空iptables
vim /etc/sysconfig/selinux #修改SELINUX=disabled
chkconfig iptables off #重啟後永久失效
查看防火牆是否有關閉:
/etc/init.d/iptables status
chkconfig --list
可以看到ip6tables還有開著,執行:
chkconfig ip6tables off
C、hostname的設定
vim /etc/sysconfig/network
將檔案中的HOSTNAME=localhost.localdomain,修改為HOSTNAME=h1.hadoop,依次類推。使用命令hostname檢查設定使用已經更新,返回的結果還是localhost.localdomain
[root@localhost qw]# hostname
localhost.localdomain
解決方案是使用hostname命令再重新設定一遍:
hostname h1.hadoop
D、hosts的修改
vim /etc/hosts
192.168.150.136 h1.hadoop
192.168.150.137 h2.hadoop
192.168.150.138 h3.hadoop
E、時鐘同步
這裡選擇 h1.hadoop 節點為時鐘同步伺服器,其他節點為用戶端同步時間到該節點。在設定時鐘同步前,需要先設定好時區。先看一下機器的時區是否是對的:
date -R
如果不是”+8000”,則要修改時區,
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
安裝ntp:
yum install ntp
修改 h1.hadoop 上的設定檔 /etc/ntp.conf
vim /etc/ntp.conf
修改內容為:
# restrict default kod nomodify notrap nopeer noquery
# restrict -6 default kod nomodify notrap nopeer noquery
restrict default nomodify
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
restrict 192.168.150.0 mask 255.255.255.0 nomodify notrap
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
server 127.127.1.0
fudge 127.127.1.0 stratum 10
啟動 ntp:
service ntpd start
設定開機啟動:
chkconfig ntpd on
用戶端設定(設定每小時同步一次時間)
vim /etc/crontab
新增如下內容:
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
1 * * * * root ntpdate h1.hadoop && hwclock -w
F、SSH無密碼驗證配置
建立hadoop使用者以便使用專有使用者執行相關操作
groupadd hadoop
useradd -g hadoop hadoop
passwd hadoop
因為Hadoop運行過程需要遠端管理Hadoop的守護進程,NameNode節點需要通過SSH(Secure Shell)串連各個DataNode節點,停止或啟動他們的進程,所以SSH必須是沒有密碼的,所以我們要把NameNode節點和DataNode節點配製成無密碼通訊,同理DataNode也需要配置無密碼連結NameNode節點。在每一台機器上配置:
在每一台機器上配置:
vim /etc/ssh/sshd_config
修改如下內容:
RSAAuthentication yes # 啟用 RSA 認證,
PubkeyAuthentication yes # 啟用公開金鑰私密金鑰配對認證方式
給每天機器添加RSA認證:
su hadoop
ssh-keygen -t rsa -P ''
h1.hadoop上操作
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
scp /home/hadoop/.ssh/authorized_keys h2.hadoop:/home/hadoop/.ssh/authorized_keys
scp /home/hadoop/.ssh/authorized_keys h3.hadoop:/home/hadoop/.ssh/authorized_keys
h2.hadoop上操作
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
scp /home/hadoop/.ssh/authorized_keys h1.hadoop:/home/hadoop/.ssh/authorized_keys
scp /home/hadoop/.ssh/authorized_keys h3.hadoop:/home/hadoop/.ssh/authorized_keys
h3.hadoop上操作
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
scp /home/hadoop/.ssh/authorized_keys h1.hadoop:/home/hadoop/.ssh/authorized_keys
scp /home/hadoop/.ssh/authorized_keys h2.hadoop:/home/hadoop/.ssh/authorized_keys
每台伺服器執行:
chmod 400 ~/.ssh/authorized_keys
進行測試
ssh h2.hadoop
G、搭建本地Yum源
新開一台機器,搭建Tegine環境,進行如下設定:
vim /usr/local/nginx/conf/nginx.conf
location / {
root /usr/local/nginx/html; //指定實際目錄絕對路徑;
autoindex on; //通過設定開啟tengine的瀏覽目錄功能
autoindex_exact_size off;
autoindex_localtime on;
}
重啟服務
service nginx restart
下載相應的源:
cd /usr/local/nginx/html
wget http://archive.cloudera.com/cdh5/repo-as-tarball/5.3.2/cdh5.3.2-centos6.tar.gz
wget http://archive-primary.cloudera.com/cm5/repo-as-tarball/5.3.2/cm5.3.2-centos6.tar.gz
tar zxvf cdh5.3.2-centos6.tar.gz
開啟http://192.168.150.128/cdh/ 就可以看到解壓的內容。
使用本地源的方法非常的簡單:
vim /etc/yum.repos.d/cloudera-cdh5.repo
添加如下內容:
[cloudera-cdh5]
# Packages for Cloudera's Distribution for Hadoop, Version 5, on RedHat or CentOS 6 x86_64
name=Cloudera's Distribution for Hadoop, Version 5
baseurl=http://192.168.150.128/cdh/5.3.2/
enabled=1
gpgcheck = 0
添加完畢後就可以使用 yum install xxx 進行安裝了~