硬件環(huán)境:
網(wǎng)站設(shè)計制作過程拒絕使用模板建站;使用PHP+MYSQL原生開發(fā)可交付網(wǎng)站源代碼;符合網(wǎng)站優(yōu)化排名的后臺管理系統(tǒng);成都網(wǎng)站設(shè)計、成都網(wǎng)站建設(shè)收費合理;免費進行網(wǎng)站備案等企業(yè)網(wǎng)站建設(shè)一條龍服務(wù).我們是一家持續(xù)穩(wěn)定運營了十載的創(chuàng)新互聯(lián)網(wǎng)站建設(shè)公司。hddcluster1 10.0.0.197 redhat7
hddcluster2 10.0.0.228 centos7 這臺作為master
hddcluster3 10.0.0.202 redhat7
hddcluster4 10.0.0.181 centos7
軟件環(huán)境:
關(guān)閉所有防火墻firewall
openssh-clients
openssh-server
java-1.8.0-openjdk
java-1.8.0-openjdk-devel
hadoop-2.7.3.tar.gz
流程:
選定一臺機器作為 Master
在 Master 節(jié)點上配置 hadoop 用戶、安裝 SSH server、安裝 Java 環(huán)境
在 Master 節(jié)點上安裝 Hadoop,并完成配置
在其他 Slave 節(jié)點上配置 hadoop 用戶、安裝 SSH server、安裝 Java 環(huán)境
將 Master 節(jié)點上的 /usr/local/hadoop 目錄復(fù)制到其他 Slave 節(jié)點上
在 Master 節(jié)點上開啟 Hadoop
#節(jié)點的名稱與對應(yīng)的 IP 關(guān)系 [hadoop@hddcluster2 ~]$ cat /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 10.0.0.228 hddcluster2 10.0.0.197 hddcluster1 10.0.0.202 hddcluster3 10.0.0.181 hddcluster4
創(chuàng)建hadoop用戶 su # 上述提到的以 root 用戶登錄 useradd -m hadoop -s /bin/bash # 創(chuàng)建新用戶hadoop passwd hadoop #設(shè)置hadoop密碼 visudo #root ALL=(ALL) ALL 這行下面添加hadoop ALL=(ALL) ALL
#登錄hadoop用戶,安裝SSH、配置SSH無密碼登陸 [hadoop@hddcluster2 ~]$ rpm -qa | grep ssh [hadoop@hddcluster2 ~]$ sudo yum install openssh-clients [hadoop@hddcluster2 ~]$ sudo yum install openssh-server [hadoop@hddcluster2 ~]$cd ~/.ssh/ # 若沒有該目錄,請先執(zhí)行一次ssh localhost [hadoop@hddcluster2 ~]$ssh-keygen -t rsa # 會有提示,都按回車就可以 [hadoop@hddcluster2 ~]$ssh-copy-id -i ~/.ssh/id_rsa.pub localhost # 加入授權(quán) [hadoop@hddcluster2 ~]$chmod 600 ./authorized_keys # 修改文件權(quán)限 [hadoop@hddcluster2 ~]$ssh-copy-id -i ~/.ssh/id_rsa.pub hadoop@hddcluster1 [hadoop@hddcluster2 ~]$ssh-copy-id -i ~/.ssh/id_rsa.pub hadoop@hddcluster3 [hadoop@hddcluster2 ~]$ssh-copy-id -i ~/.ssh/id_rsa.pub hadoop@hddcluster4
#解壓hadoop文件到/usr/local/hadoop [hadoop@hddcluster2 ~]$sudo tar -zxf hadoop-2.7.3.tar.gz -C /usr/local/ [hadoop@hddcluster2 ~]$sudo mv /usr/local/hadoop-2.7.3 /usr/local/hadoop [hadoop@hddcluster2 ~]$sudo chown -R hadoop:hadoop /usr/local/hadoop cd /usr/local/hadoop ./bin/hadoop version #安裝java環(huán)境 [hadoop@hddcluster2 ~]$sudo yum install java-1.8.0-openjdk java-1.8.0-openjdk-devel [hadoop@hddcluster2 ~]$ rpm -ql java-1.8.0-openjdk-devel | grep '/bin/javac' /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.111-2.b15.el7_3.x86_64/bin/javac [hadoop@hddcluster2 ~]$ vim ~/.bashrc export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.111-2.b15.el7_3.x86_64 export HADOOP_HOME=/usr/local/hadoop export HADOOP_INSTALL=$HADOOP_HOME export HADOOP_MAPRED_HOME=$HADOOP_HOME export HADOOP_COMMON_HOME=$HADOOP_HOME export HADOOP_HDFS_HOME=$HADOOP_HOME export YARN_HOME=$HADOOP_HOME export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native export PATH=$PATH:$HADOOP_HOME/sbin:$HADOOP_HOME/bin export HADOOP_PREFIX=$HADOOP_HOME export HADOOP_OPTS="-Djava.library.path=$HADOOP_PREFIX/lib:$HADOOP_PREFIX/lib/native" #測試java環(huán)境 source ~/.bashrc java -version $JAVA_HOME/bin/java -version # 與直接執(zhí)行 java -version 一樣
#修改hadoop文件配置 [hadoop@hddcluster2 hadoop]$ pwd /usr/local/hadoop/etc/hadoop [hadoop@hddcluster2 hadoop]$ cat core-site.xml <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <!-- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. See accompanying LICENSE file. --> <!-- Put site-specific property overrides in this file. --> <configuration> <property> <name>fs.defaultFS</name> <value>hdfs://hddcluster2:9000</value> </property> <property> <name>hadoop.tmp.dir</name> <value>file:/usr/local/hadoop/tmp</value> <description>Abase for other temporary directories.</description> </property> </configuration> [hadoop@hddcluster2 hadoop]$ cat hdfs-site.xml <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <!-- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. See accompanying LICENSE file. --> <!-- Put site-specific property overrides in this file. --> <configuration> <property> <name>dfs.namenode.secondary.http-address</name> <value>hddcluster2:50090</value> </property> <property> <name>dfs.replication</name> <value>3</value> </property> <property> <name>dfs.namenode.name.dir</name> <value>file:/usr/local/hadoop/tmp/dfs/name</value> </property> <property> <name>dfs.datanode.data.dir</name> <value>file:/usr/local/hadoop/tmp/dfs/data</value> </property> </configuration> [hadoop@hddcluster2 hadoop]$ [hadoop@hddcluster2 hadoop]$ cat mapred-site.xml <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <!-- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. See accompanying LICENSE file. --> <!-- Put site-specific property overrides in this file. --> <configuration> <property> <name>mapreduce.framework.name</name> <value>yarn</value> </property> <property> <name>mapreduce.jobhistory.address</name> <value>hddcluster2:10020</value> </property> <property> <name>mapreduce.jobhistory.webapp.address</name> <value>hddcluster2:19888</value> </property> </configuration> [hadoop@hddcluster2 hadoop]$ [hadoop@hddcluster2 hadoop]$ cat yarn-site.xml <?xml version="1.0"?> <!-- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. See accompanying LICENSE file. --> <configuration> <!-- Site specific YARN configuration properties --> <property> <name>yarn.resourcemanager.hostname</name> <value>hddcluster2</value> </property> <property> <name>yarn.nodemanager.aux-services</name> <value>mapreduce_shuffle</value> </property> </configuration> [hadoop@hddcluster2 hadoop]$ [hadoop@hddcluster2 hadoop]$ cat slaves hddcluster1 hddcluster2 hddcluster3 hddcluster4
$cd /usr/local $sudo rm -r ./hadoop/tmp # 刪除 Hadoop 臨時文件 $sudo rm -r ./hadoop/logs/* # 刪除日志文件 $tar -zcf ~/hadoop.master.tar.gz ./hadoop # 先壓縮再復(fù)制 $cd ~ $scp ./hadoop.master.tar.gz hddcluster1:/home/hadoop $scp ./hadoop.master.tar.gz hddcluster3:/home/hadoop $scp ./hadoop.master.tar.gz hddcluster4:/home/hadoop
在salve節(jié)點上操作,安裝軟件環(huán)境并配置好.bashrc sudo tar -zxf ~/hadoop.master.tar.gz -C /usr/local sudo chown -R hadoop /usr/local/hadoop
[hadoop@hddcluster2 ~]$hdfs namenode -format # 首次運行需要執(zhí)行初始化,之后不需要 接著可以啟動 hadoop 了,啟動需要在 Master 節(jié)點上進行啟動命令: $start-dfs.sh $start-yarn.sh $mr-jobhistory-daemon.sh start historyserver 通過命令 jps 可以查看各個節(jié)點所啟動的進程。正確的話, 在 Master 節(jié)點上可以看到 NameNode、ResourceManager、SecondrryNameNode、JobHistoryServer 進程, 另外還需要在 Master 節(jié)點上通過命令 hdfs dfsadmin -report 查看 DataNode 是否正常啟動,如果 Live datanodes 不為 0 ,則說明集群啟動成功。 [hadoop@hddcluster2 ~]$ hdfs dfsadmin -report Configured Capacity: 2125104381952 (1.93 TB) Present Capacity: 1975826509824 (1.80 TB) DFS Remaining: 1975824982016 (1.80 TB) DFS Used: 1527808 (1.46 MB) DFS Used%: 0.00% Under replicated blocks: 0 Blocks with corrupt replicas: 0 Missing blocks: 0 Missing blocks (with replication factor 1): 0 ------------------------------------------------- Live datanodes (4): 也可以通過 Web 頁面看到查看 DataNode 和 NameNode 的狀態(tài):http://hddcluster2:50070/。如果不成功,可以通過啟動日志排查原因。
在 Slave 節(jié)點操作可以看到 DataNode 和 NodeManager 進程
測試hadoop分布式實例 首先創(chuàng)建 HDFS 上的用戶目錄: hdfs dfs -mkdir -p /user/hadoop 將 /usr/local/hadoop/etc/hadoop 中的配置文件作為輸入文件復(fù)制到分布式文件系統(tǒng)中: hdfs dfs -mkdir input hdfs dfs -put /usr/local/hadoop/etc/hadoop/*.xml input 通過查看 的DataNode 的狀態(tài)(占用大小有改變),輸入文件確實復(fù)制到了 DataNode 中。 接著就可以運行 MapReduce 作業(yè)了: hadoop jar /usr/local/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-examples-*.jar grep input output 'dfs[a-z.]+' 等待執(zhí)行完畢后的輸出結(jié)果:
hadoop啟動命令: start-dfs.sh start-yarn.sh mr-jobhistory-daemon.sh start historyserver hadoop關(guān)閉命令: stop-dfs.sh stop-yarn.sh mr-jobhistory-daemon.sh stop historyserver
PS:如果集群有一兩臺無法啟動的話,先嘗試一下刪除hadoop臨時文件
cd /usr/local
sudo rm -r ./hadoop/tmp
sudo rm -r ./hadoop/logs/*
然后執(zhí)行
hdfs namenode -format
再啟動
本文參考了一下網(wǎng)站并實驗成功:
http://www.powerxing.com/install-hadoop-cluster/
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機、免備案服務(wù)器”等云主機租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。
新聞名稱:hadoop&spark安裝(上)-創(chuàng)新互聯(lián)
網(wǎng)站地址:http://jinyejixie.com/article22/djsgcc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計公司、外貿(mào)網(wǎng)站建設(shè)、App開發(fā)、網(wǎng)站維護、定制網(wǎng)站、手機網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容