CentOS6.5基於ROOT使用者的HDFS偽分散式部署(a Single Node Cluster)

13545163656發表於2018-05-15

hadoop部署

單機               --無程式
偽分散式部署   -- 程式存在+1節點   開發
叢集部署         -- 程式存在+n階段   開發/生產

#hadoop解壓
[root@hadoop001 software]# tar -xzvf hadoop-2.8.1.tar.gz
[root@hadoop001 software]# chown -R root:root hadoop-2.8.1

[root@hadoop001 hadoop-2.8.1]# ll
drwxrwxr-x. 2 root root  4096 Jun  2  2017 bin                -- 執行命令shell
drwxrwxr-x. 3 root root  4096 Jun  2  2017 etc                -- 配置檔案                 
drwxrwxr-x. 2 root root  4096 Jun  2  2017 include
drwxrwxr-x. 3 root root  4096 Jun  2  2017 lib                  -- 庫
drwxrwxr-x. 2 root root  4096 Jun  2  2017 libexec
-rw-rw-r--. 1 root root 99253 Jun  2  2017 LICENSE.txt
-rw-rw-r--. 1 root root 15915 Jun  2  2017 NOTICE.txt
-rw-r--r--. 1 root root  1366 Jun  2  2017 README.txt
drwxrwxr-x. 2 root root  4096 Jun  2  2017 sbin                -- 啟動和關閉hadoop                 
drwxrwxr-x. 4 root root  4096 Jun  2  2017 share              --  jar

#hadoop全域性環境變數
[root@hadoop001 hadoop-2.8.1]# vim /etc/profile
export HADOOP_HOME=/opt/software/hadoop-2.8.1
export PATH=$HADOOP_HOME/bin:$PROTOC_HOME/bin:$FINDBUGS_HOME/bin:$MAVEN_HOME/bin:$JAVA_HOME/bin:$PATH

[root@hadoop001 hadoop-2.8.1]# source /etc/profile
[root@hadoop001 hadoop-2.8.1]# which hadoop
/opt/software/hadoop-2.8.1/bin/hadoop

[root@hadoop001 bin]# rm -rf *.cmd
[root@hadoop001 sbin]# rm -rf *.cmd

#配置core-site檔案

點選(此處)摺疊或開啟

  1. [root@hadoop001 hadoop]# vim core-site.xml
    <
    configuration>
  2.     <property>
  3.         <name>fs.defaultFS</name>
  4.         <value>hdfs://localhost:9000</value>    --HDFD埠和路徑
  5.     </property>
  6. </configuration>

  7. [root@hadoop001 hadoop]# vim hdfs-site.xml:
  8. <configuration>
  9.     <property>
  10.         <name>dfs.replication</name>
  11.         <value>1</value>             -- 叢集主機數量
  12.     </property>
  13. </configuration>
  14. <configuration>

#本機ssh驗證配置
[root@hadoop001 hadoop]# cd ~
[root@hadoop001 ~]# cd .ssh
[root@hadoop001 .ssh]# ll
total 0
[root@hadoop001 ~]# rm -rf .ssh
[root@hadoop001 ~]# ssh-keygen
[root@hadoop001 ~]# cd .ssh
[root@hadoop001 .ssh]# ll
total 8
-rw-------. 1 root root 1675 May 14 23:38 id_rsa
-rw-r--r--. 1 root root  396 May 14 23:38 id_rsa.pub
[root@hadoop001 .ssh]# cat id_rsa.pub >> authorized_keys
[root@hadoop001 .ssh]# ll
total 12
-rw-r--r--. 1 root root  396 May 14 23:40 authorized_keys
-rw-------. 1 root root 1675 May 14 23:38 id_rsa
-rw-r--r--. 1 root root  396 May 14 23:38 id_rsa.pub

#第一次必須操作,本機修改過埠
[root@hadoop001 ~]# ssh localhost date
ssh: connect to host localhost port 22: Connection refused
[root@hadoop001 ~]# ssh -p2222 localhost date
The authenticity of host '[localhost]:2222 ([::1]:2222)' can't be established.
RSA key fingerprint is 09:b9:67:65:cb:e6:ca:31:5d:33:6c:3b:92:9e:c2:1a.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[localhost]:2222' (RSA) to the list of known hosts.
Mon May 14 23:42:37 EDT 2018

#格式化HDFS檔案系統
[root@hadoop001 ~]# which hdfs
/opt/software/hadoop-2.8.1/bin/hdfs
[root@hadoop001 ~]# hdfs namenode -format

#啟動HDFS檔案系統
[root@hadoop001 sbin]# /opt/software/hadoop-2.8.1/sbin/start-dfs.sh
Starting namenodes on [localhost]
localhost: ssh: connect to host localhost port 22: Connection refused
localhost: ssh: connect to host localhost port 22: Connection refused
Starting secondary namenodes [0.0.0.0]
0.0.0.0: ssh: connect to host 0.0.0.0 port 22: Connection refused
#解決port 22錯誤

[root@hadoop000 hadoop]# vi  hadoop-env.sh

新增:export HADOOP_SSH_OPTS="-p 2222"

#解決 ERROR:JAVA_HOME
[root@hadoop000 hadoop]# vi  hadoop-env.sh
export JAVA_HOME=/usr/java/jdk1.8.0_45


#啟動OK
[root@hadoop001 sbin]# /opt/software/hadoop-2.8.1/sbin/start-dfs.sh
[root@hadoop001 hadoop]# /opt/software/hadoop-2.8.1/sbin/start-dfs.sh
Starting namenodes on [localhost]
localhost: starting namenode, logging to /opt/software/hadoop-2.8.1/logs/hadoop-root-namenode-hadoop001.out
localhost: starting datanode, logging to /opt/software/hadoop-2.8.1/logs/hadoop-root-datanode-hadoop001.out
Starting secondary namenodes [0.0.0.0]
0.0.0.0: starting secondarynamenode, logging to /opt/software/hadoop-2.8.1/logs/hadoop-root-secondarynamenode-hadoop001.out

#檢測與啟動
[root@hadoop000 hadoop-2.8.1]# jps
16243 Jps
15943 DataNode
5127 Launcher
16139 SecondaryNameNode
15853 NameNode
 
 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31441024/viewspace-2154526/,如需轉載,請註明出處,否則將追究法律責任。

相關文章