1. 程式人生 > >Hadoop2.7.4完全分布式集群構建實戰總結

Hadoop2.7.4完全分布式集群構建實戰總結

apply 節點 tools conn cti status reduce 總結 exp

配置Linux環境
配置好各虛擬機的網絡(采用NAT聯網模式)
通過Linux圖形界面進行修改(桌面版本Centos):進入Linux圖形界面 -> 右鍵點擊右上方的兩個小電腦 -> 點擊Edit connections-> 選中當前網絡System eth0 -> 點擊edit按鈕 -> 選擇IPv4 -> method選擇為manual ->點擊add按鈕 -> 添加IP:192.168.1.101 子網掩碼:255.255.255.0 網關:192.168.1.1 -> apply
修改配置文件方式
????????????? vi /etc/sysconfig/network-scripts/ifcfg-eth0

????????????? DEVICE="eth0"

????????????? BOOTPROTO="static"?????????????? ###

????????????? HWADDR="00:0C:29:3C:BF:E7"

????????????? IPV6INIT="yes"

????????????? NM_CONTROLLED="yes"

????????????? ONBOOT="yes"

????????????? TYPE="Ethernet"

????????????? UUID="ce22eeca-ecde-4536-8cc2-ef0dc36d4a8c"

????????????? IPADDR="192.168.1.101"?????????? ###

????????????? NETMASK="255.255.255.0"????????? ###

????????????? GATEWAY="192.168.1.1"??????????? ###

修改各個虛擬機主機名
????????????? vi /etc/sysconfig/network

????????????? NETWORKING=yes

????????????? HOSTNAME=node-1???

修改主機名和IP的映射關系
????????????? vi /etc/hosts

????????????? 192.168.1.101 node-1

????????????? 192.168.1.102 node-2

????????????? 192.168.1.103 node-3

關閉防火墻
????????????? #查看防火墻狀態

????????????? service iptables status

????????????? #關閉防火墻

????????????? service iptables stop

????????????? #查看防火墻開機啟動狀態

????????????? chkconfig iptables --list

????????????? #關閉防火墻開機啟動

????????????? chkconfig iptables off

配置ssh免登陸
?????? ??? #生成ssh免登陸密鑰

?????? ssh-keygen -t rsa (四個回車)

?????? 執行完這個命令後,會生成兩個文件id_rsa(私鑰)、id_rsa.pub(公鑰)

?????? 將公鑰拷貝到要免密登陸的目標機器上

?????? ssh-copy-id node-2

?????? ssh-copy-id node-3

同步集群時間
?????? ???? 常用的手動進行時間的同步

????????????? date -s "2018-03-03 03:03:03"

?????? ???? 或者網絡同步:

????????????? yum install ntpdate

????????????? ntpdate cn.pool.ntp.org

安裝JDK並配置環境變量
上傳jdk
????????????? rz jdk-8u65-linux-x64.tar.gz

解壓jdk
????????????? tar -zxvf jdk-8u65-linux-x64.tar.gz -C /root/apps

將java添加到環境變量中
????????????? vim /etc/profile

????????????? #在文件最後添加

????????????? export JAVA_HOME=/root/apps/jdk1.8.0_65

????????????? export PATH=$PATH:$JAVA_HOME/bin

????????????? export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

????????????? #刷新配置

????????????? source /etc/profile

安裝hadoop2.7.4
上傳hadoop的安裝包到服務器
?????? ???? hadoop-2.7.4-with-centos-6.7.tar.gz

解壓安裝包
?????? ???? tar zxvf hadoop-2.7.4-with-centos-6.7.tar.gz

?????? ?? ??註意:hadoop2.x的配置文件目錄:$HADOOP_HOME/etc/hadoop

配置hadoop的核心配置文件
配置文件hadoop-env.sh
vi hadoop-env.sh

export JAVA_HOME=/root/apps/jdk1.8.0_65

配置文件core-site.xml
說明:指定HADOOP所使用的文件系統schema(URI),HDFS的主節點(NameNode)地址

<property>

?????? ?????? <name>fs.defaultFS</name>

?????? ?????? <value>hdfs://node-1:9000</value>

</property>

說明:指定hadoop運行時產生文件的存儲目錄,默認/tmp/hadoop-${user.name} -->

<property>

?????? ?????? <name>hadoop.tmp.dir</name>

?????? ?????? <value>/home/hadoop/hadoop-2.4.1/tmp</value>

</property>

配置文件hdfs-site.xml?

?????? ?????? dfs.replication ?????? ?????? 2 ?????? ????? dfs.namenode.secondary.http-address ? ??? ??????node-2:50090 配置文件mapred-site.xml mv mapred-site.xml.template mapred-site.xml vi mapred-site.xml ?????? ?????? mapreduce.framework.name ?????? ?????? yarn 配置文件yarn-site.xml ?????? ????? yarn.resourcemanager.hostname ?????? ????? node-1 ?????? ?????? yarn.nodemanager.aux-services ?????? ????? mapreduce_shuffle 配置文件slaves,裏面寫上從節點所在的主機名字 vi slaves node-1 node-2 node-3 將hadoop添加到環境變量 ?????? vim /etc/proflie export JAVA_HOME=/root/apps/jdk1.8.0_65 export HADOOP_HOME=/root/apps/hadoop-2.7.4 ?????? export PATH=$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin ?????? source /etc/profile 格式化namenode(本質是對namenode進行初始化) ?????? hdfs namenode -format (hadoop namenode -format) 啟動hadoop,驗證是否啟動成功 ?????? 先啟動HDFS ?????? sbin/start-dfs.sh ?????? 再啟動YARN ?????? sbin/start-yarn.sh ?????? 使用jps命令驗證 ?????? 27408 NameNode ?????? 28218 Jps ?????? 27643 SecondaryNameNode?? (secondarynamenode) ?????? 28066 NodeManager ?????? 27803 ResourceManager ?????? 27512 DataNode ?????? http://192.168.1.101:50070 (HDFS管理界面) ?????? http://192.168.1.101:8088 (MR管理界面)

Hadoop2.7.4完全分布式集群構建實戰總結