问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501

hadoop 如果增加新的从节点,有哪些是需要做的?基于hadoop的开发有哪些...

发布网友 发布时间:2022-05-06 09:31

我来回答

2个回答

懂视网 时间:2022-05-06 21:05

之前已经有了namenode和datanode1,现在要新增节点datanode2 第一步:修改将要增加节点的主机名 hadoop@datanode1:~$ vim /etc/hostname datanode2 第二步:修改host文件 hadoop@datanode1:~$ vim /etc/hosts 192.168.8.4 datanode2 127.0.0.1 localhost 127.0

之前已经有了namenode和datanode1,现在要新增节点datanode2
第一步:修改将要增加节点的主机名
hadoop@datanode1:~$ vim /etc/hostname
datanode2
第二步:修改host文件
hadoop@datanode1:~$ vim /etc/hosts
192.168.8.4 datanode2
127.0.0.1 localhost
127.0.1.1 ubuntu
192.168.8.2 namenode
192.168.8.3 datanode1
192.168.8.4 datanode2(增加了这个)

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
第三步:修改ip

第四步:重启
第五步:ssh免密码配置
1.生成密钥
hadoop@datanode2:~$ ssh-keygen -t rsa -P ""
Generating public/private rsa key pair.
Enter file in which to save the key (/home/hadoop/.ssh/id_rsa):
/home/hadoop/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Your identification has been saved in /home/hadoop/.ssh/id_rsa.
Your public key has been saved in /home/hadoop/.ssh/id_rsa.pub.
The key fingerprint is:
34:45:84:85:6e:f3:9e:7a:c0:f1:a4:ef:bf:30:a6:74 hadoop@datanode2
The key's randomart image is:
+--[ RSA 2048]----+
| *= |
| o. |
| .o |
| .=.. |
| oSB |
| + o |
| .+E. |
| . +=o |
| o+..o. |
+-----------------+
2.把公钥传给namenode
hadoop@datanode2:~$ cd ~/.ssh
hadoop@datanode2:~/.ssh$ ls
authorized_keys id_rsa id_rsa.pub known_hosts
hadoop@datanode2:~/.ssh$ scp ./id_rsa.pub hadoop@namenode:/home/hadoop
hadoop@namenode's password:
id_rsa.pub 100% 398 0.4KB/s 00:00
3.把公钥追加到authorized_keys
hadoop@namenode:~/.ssh$ cat ../id_rsa.pub >> authorized_keys
hadoop@namenode:~/.ssh$ cat authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDuOOD8R7OfNSUhGPZhQWCfC0yTeM6+txWSo3LiJjEWZbH512ymKIEiNRjCzTiRjLEqWGadAPVbip3jLuOHFpk89v7D6q8QH4ilBjLtsaVxmhb77w3yGrXlHJ8+g3QtS8VmjGEyZ86oeM5F9UM8F8QmK9mxXOWhqt3xvufetr7o7acV3APEHH1hvvkFImim2sT/iNi/Nxsch176byUS6y86gOTgznVH8OIx8MDmdKSLjqWPSCTrpvXPESlZvpLm4YSN2cYoKaxcedaynzOhXgAC0GLdq1k07eFmerUwpBT+xTzTRJPquYawK+MPf6+lnLm89u+bewdBZLdunCKhbCK3 hadoop@ubuntu3
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCssQnDzo5uhPn93bVqj+nEpzgQBipc1WgasOeFQV7ljyNlFHhOPVS6G3oHpvSrbjg3aK1MqxmCw0VokuuO5eoHwqh0alQw46eEmunzrnwuhhFpAU9V4t7LJ5pYuxZOioXbsJKxCetOY6G2lKRmyk2Z/MIMpPW+UFebt150+oYXcKKYSBBJoLmThH3bWW2CesAokIe8gCQ3rIYsHfA8rNuwxEnrL8fC2XlWODTahjHD5bymBO4rd3uiJxuTv7/r243t0hrimjhJ7uUIyPcIRYDchPmmO9DFVEBtYloLmqQQs/ZOxDiX7GF+YK7KC7Ayo1kL8VuwP90dqIhpaJmP96zV hadoop@ubuntu2
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDbeTMrOtMZ8gurJyzoSVFpJbtXzUYDElXJcfm0O+FRpigxoIePPHiQc5vi7kabnLSiEv+94YDMclxZpXFjR0TXz6IJOVdPxFPqovY+GzrYVXEXj3HhbBWKC4sFUvGFGSZr8rM3R5OE2wYIZzOKdX9c6Ak5uIE7BUSuXzaiFctYXIvu37TObYZ44vDQGv9/mPsqP4Qnyx4czTLD1VmOeUHA5iQTKLt4K0HNE3i+a3mEEBMxBwETUI/6dcmvTxjEe7cy48YPadr5UT0/xgTub/OdmkBfvfT6fPDVlHtRP5jQiFapFyzL/BXiObqkSlrJbLKWTczS8J6SfsKWsSZfOPzL hadoop@datanode2
4.把公钥传给其节点
hadoop@namenode:~$ scp ./.ssh/authorized_keys hadoop@datanode1:/home/hadoop/.ssh/authorized_keys
authorized_keys 100% 1190 1.2KB/s 00:00
hadoop@namenode:~$ scp ./.ssh/authorized_keys hadoop@datanode2:/home/hadoop/.ssh/authorized_keys
authorized_keys 100% 1190 1.2KB/s 00:00
5.一个错误

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

@ WARNING: UNPROTECTED PRIVATE KEY FILE! @

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

Permissions 0644 for '/home/jiangqixiang/.ssh/id_dsa' are too open.

It is recommended that your private key files are NOT accessible by others.

This private key will be ignored.

bad permissions: ignore key: /home/youraccount/.ssh/id_dsa 解决方法:

chmod 700 id_rsa

第六步:修改namenode的配置文件

hadoop@namenode:~$ cd hadoop-1.2.1/conf

hadoop@namenode:~/hadoop-1.2.1/conf$ vim slaves

datanode1

datanode2

第七步:负载均衡

hadoop@namenode:~/hadoop-1.2.1/conf$ start-balancer.sh

Warning: $HADOOP_HOME is deprecated.

starting balancer, logging to /home/hadoop/hadoop-1.2.1/libexec/../logs/hadoop-hadoop-balancer-namenode.out

以下摘自其他博客

1)如果不balance,那么cluster会把新的数据都存放在新的node上,这样会降低Map Reduce的工作效率

2)threshold是平衡阈值,默认是10%,值越低各节点越平衡,但消耗时间也更长

/app/hadoop/bin/start-balancer.sh -threshold 0.1

3)在namenode的配置文件 hdfs-site.xml 可以加上balance的带宽(默认值就是1M):

  dfs.balance.bandwidthPerSec

  1048576

  

    Specifies the maximum amount of bandwidth that each datanode

    can utilize for the balancing purpose in term of

    the number of bytes per second.

  

第八步:测试是否有效

1.启动hadoop

hadoop@namenode:~/hadoop-1.2.1$ start-all.sh

Warning: $HADOOP_HOME is deprecated.

starting namenode, logging to /home/hadoop/hadoop-1.2.1/libexec/../logs/hadoop-hadoop-namenode-namenode.out

datanode2: starting datanode, logging to /home/hadoop/hadoop-1.2.1/libexec/../logs/hadoop-hadoop-datanode-datanode2.out

datanode1: starting datanode, logging to /home/hadoop/hadoop-1.2.1/libexec/../logs/hadoop-hadoop-datanode-datanode1.out

namenode: starting secondarynamenode, logging to /home/hadoop/hadoop-1.2.1/libexec/../logs/hadoop-hadoop-secondarynamenode-namenode.out

starting jobtracker, logging to /home/hadoop/hadoop-1.2.1/libexec/../logs/hadoop-hadoop-jobtracker-namenode.out

datanode2: starting tasktracker, logging to /home/hadoop/hadoop-1.2.1/libexec/../logs/hadoop-hadoop-tasktracker-datanode2.out

datanode1: starting tasktracker, logging to /home/hadoop/hadoop-1.2.1/libexec/../logs/hadoop-hadoop-tasktracker-datanode1.out

hadoop@namenode:~/hadoop-1.2.1$

2.错误

运行wordcount程序时出现错误

hadoop@namenode:~/hadoop-1.2.1$ hadoop jar hadoop-examples-1.2.1.jar wordcount in out

Warning: $HADOOP_HOME is deprecated.

14/09/12 08:40:39 ERROR security.UserGroupInformation: PriviledgedActionException as:hadoop cause:org.apache.hadoop.ipc.RemoteException: org.apache.hadoop.mapred.SafeModeException: JobTracker is in safe mode

at org.apache.hadoop.mapred.JobTracker.checkSafeMode(JobTracker.java:5188)

at org.apache.hadoop.mapred.JobTracker.getStagingAreaDir(JobTracker.java:3677)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at org.apache.hadoop.ipc.RPC$Server.call(RPC.java:587)

at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:1432)

at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:1428)

at java.security.AccessController.doPrivileged(Native Method)

at javax.security.auth.Subject.doAs(Subject.java:415)

at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1190)

at org.apache.hadoop.ipc.Server$Handler.run(Server.java:1426)

org.apache.hadoop.ipc.RemoteException: org.apache.hadoop.mapred.SafeModeException: JobTracker is in safe mode

at org.apache.hadoop.mapred.JobTracker.checkSafeMode(JobTracker.java:5188)

at org.apache.hadoop.mapred.JobTracker.getStagingAreaDir(JobTracker.java:3677)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at org.apache.hadoop.ipc.RPC$Server.call(RPC.java:587)

at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:1432)

at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:1428)

at java.security.AccessController.doPrivileged(Native Method)

at javax.security.auth.Subject.doAs(Subject.java:415)

at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1190)

at org.apache.hadoop.ipc.Server$Handler.run(Server.java:1426)

at org.apache.hadoop.ipc.Client.call(Client.java:1113)

at org.apache.hadoop.ipc.RPC$Invoker.invoke(RPC.java:229)

at org.apache.hadoop.mapred.$Proxy2.getStagingAreaDir(Unknown Source)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at org.apache.hadoop.io.retry.RetryInvocationHandler.invokeMethod(RetryInvocationHandler.java:85)

at org.apache.hadoop.io.retry.RetryInvocationHandler.invoke(RetryInvocationHandler.java:62)

at org.apache.hadoop.mapred.$Proxy2.getStagingAreaDir(Unknown Source)

at org.apache.hadoop.mapred.JobClient.getStagingAreaDir(JobClient.java:1309)

at org.apache.hadoop.mapreduce.JobSubmissionFiles.getStagingDir(JobSubmissionFiles.java:102)

at org.apache.hadoop.mapred.JobClient$2.run(JobClient.java:942)

at org.apache.hadoop.mapred.JobClient$2.run(JobClient.java:936)

at java.security.AccessController.doPrivileged(Native Method)

at javax.security.auth.Subject.doAs(Subject.java:415)

at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1190)

at org.apache.hadoop.mapred.JobClient.submitJobInternal(JobClient.java:936)

at org.apache.hadoop.mapreduce.Job.submit(Job.java:550)

at org.apache.hadoop.mapreduce.Job.waitForCompletion(Job.java:580)

at org.apache.hadoop.examples.WordCount.main(WordCount.java:82)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at org.apache.hadoop.util.ProgramDriver$ProgramDescription.invoke(ProgramDriver.java:68)

at org.apache.hadoop.util.ProgramDriver.driver(ProgramDriver.java:139)

at org.apache.hadoop.examples.ExampleDriver.main(ExampleDriver.java:64)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at org.apache.hadoop.util.RunJar.main(RunJar.java:160)

解决方法:

hadoop@namenode:~/hadoop-1.2.1$ hadoop dfsadmin -safemode leave

Warning: $HADOOP_HOME is deprecated.

Safe mode is OFF

3.再次测试

hadoop@namenode:~/hadoop-1.2.1$ hadoop jar hadoop-examples-1.2.1.jar wordcount in out

Warning: $HADOOP_HOME is deprecated.

14/09/12 08:48:26 INFO input.FileInputFormat: Total input paths to process : 2

14/09/12 08:48:26 INFO util.NativeCodeLoader: Loaded the native-hadoop library

14/09/12 08:48:26 WARN snappy.LoadSnappy: Snappy native library not loaded

14/09/12 08:48:28 INFO mapred.JobClient: Running job: job_201409120827_0003

14/09/12 08:48:29 INFO mapred.JobClient: map 0% reduce 0%

14/09/12 08:48:47 INFO mapred.JobClient: map 50% reduce 0%

14/09/12 08:48:48 INFO mapred.JobClient: map 100% reduce 0%

14/09/12 08:48:57 INFO mapred.JobClient: map 100% reduce 33%

14/09/12 08:48:59 INFO mapred.JobClient: map 100% reduce 100%

14/09/12 08:49:02 INFO mapred.JobClient: Job complete: job_201409120827_0003

14/09/12 08:49:02 INFO mapred.JobClient: Counters: 30

14/09/12 08:49:02 INFO mapred.JobClient: Job Counters

14/09/12 08:49:02 INFO mapred.JobClient: Launched reduce tasks=1

14/09/12 08:49:02 INFO mapred.JobClient: SLOTS_MILLIS_MAPS=27285

14/09/12 08:49:02 INFO mapred.JobClient: Total time spent by all reduces waiting after reserving slots (ms)=0

14/09/12 08:49:02 INFO mapred.JobClient: Total time spent by all maps waiting after reserving slots (ms)=0

14/09/12 08:49:02 INFO mapred.JobClient: Rack-local map tasks=1

14/09/12 08:49:02 INFO mapred.JobClient: Launched map tasks=2

14/09/12 08:49:02 INFO mapred.JobClient: Data-local map tasks=1

14/09/12 08:49:02 INFO mapred.JobClient: SLOTS_MILLIS_REDUCES=12080

14/09/12 08:49:02 INFO mapred.JobClient: File Output Format Counters

14/09/12 08:49:02 INFO mapred.JobClient: Bytes Written=48

14/09/12 08:49:02 INFO mapred.JobClient: FileSystemCounters

14/09/12 08:49:02 INFO mapred.JobClient: FILE_BYTES_READ=104

14/09/12 08:49:02 INFO mapred.JobClient: HDFS_BYTES_READ=265

14/09/12 08:49:02 INFO mapred.JobClient: FILE_BYTES_WRITTEN=177680

14/09/12 08:49:02 INFO mapred.JobClient: HDFS_BYTES_WRITTEN=48

14/09/12 08:49:02 INFO mapred.JobClient: File Input Format Counters

14/09/12 08:49:02 INFO mapred.JobClient: Bytes Read=45

14/09/12 08:49:02 INFO mapred.JobClient: Map-Reduce Framework

14/09/12 08:49:02 INFO mapred.JobClient: Map output materialized bytes=110

14/09/12 08:49:02 INFO mapred.JobClient: Map input records=2

14/09/12 08:49:02 INFO mapred.JobClient: Reduce shuffle bytes=110

14/09/12 08:49:02 INFO mapred.JobClient: Spilled Records=18

14/09/12 08:49:02 INFO mapred.JobClient: Map output bytes=80

14/09/12 08:49:02 INFO mapred.JobClient: Total committed heap usage (bytes)=248127488

14/09/12 08:49:02 INFO mapred.JobClient: CPU time spent (ms)=8560

14/09/12 08:49:02 INFO mapred.JobClient: Combine input records=9

14/09/12 08:49:02 INFO mapred.JobClient: SPLIT_RAW_BYTES=220

14/09/12 08:49:02 INFO mapred.JobClient: Reduce input records=9

14/09/12 08:49:02 INFO mapred.JobClient: Reduce input groups=7

14/09/12 08:49:02 INFO mapred.JobClient: Combine output records=9

14/09/12 08:49:02 INFO mapred.JobClient: Physical memory (bytes) snapshot=322252800

14/09/12 08:49:02 INFO mapred.JobClient: Reduce output records=7

14/09/12 08:49:02 INFO mapred.JobClient: Virtual memory (bytes) snapshot=1042149376

14/09/12 08:49:02 INFO mapred.JobClient: Map output records=9

hadoop@namenode:~/hadoop-1.2.1$ hadoop fs -cat out/*

Warning: $HADOOP_HOME is deprecated.

heheh 1

hello 2

it's 1

ll 1

the 2

think 1

why 1

cat: File does not exist: /user/hadoop/out/_logs

热心网友 时间:2022-05-06 18:13

首先需要配置conf下的几个配置文件,像你在配置其他节点时一样,也可以直接把其他节点的配置文件直接copy过来。安装jdk,配置ssh无密码登陆。然后在conf/slave下面将你新添加的从节点的主机号,完成从节点的添加。追问conf/slave的操作是只用在主节点上进行吗?

追答嗯,对的

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
南京5号线开通最新消息南京5号线 终于来了!长沙地铁3号线、5号线正式通车试运行! 如何辅导四年级语文小学在家里 如何自学风水入门 标题新闻标题 酱香型白酒有哪些?酱香型白酒的特点和品牌 58同城要人脸识别怎么办 童年受伤的孩子长大后怎么补救? ...上有三十五头,下有九十四足,问鸡、兔各有几何?你能解答这道古_百度... 今有鸡兔同笼上有35个头下有94只脚问鸡兔各有多少只 企业股权转让需要的材料有什么 公司股权转让需要什么文件资料 ipad,home键按不了,是坏了还是失灵了,有没有什么可以自己修复的办法? 怎样在电脑上同时登陆两个 怎么同时登陆两个 潘粤明在《鬼吹灯之龙岭迷窟》这部电视剧里面的表现如何? 潘粤明、张雨绮、姜超《鬼吹灯之龙岭迷窟》花絮合集五 《鬼吹灯之龙岭迷窟》鹧鸪哨和了尘大师为什么带外国人托马斯进墓?_百 ... word的文本框为什么变成这样? 为什么杀生丸还涂红色的眼影啊?? 怎么画眼影好看? 如何在WORD 2003 中设置下列的文本框三维阴影格式? 电脑上装了流氓输入法:快速拼音,没有地方卸载,也不能删除,删除是灰色的,怎么彻底卸载这个快速拼音? 有一部动漫介绍很多小知识 word2003文本框中建立的三维效果图怎么取消啊。 美瞳一定要化眼妆才有效果吗 一个手机如何同时登录两个? 一个手机怎么才能同时登2个? 同一个苹果手机怎么同时登录两个 金士顿硬盘 hadoop增加一个结点只要配置namenode节点到datanode节点的ssh互信吗... 炖猪大骨头头的家常做法大全怎么做好吃视 hadoop节点替换怎么做 c++中,直接用重写就是了,为什么有时候非要用重定义(覆盖)?不都是子类重新定义父类相同名称的函数吗? Java中重载(Overload)和重写(Override)的定义 被胶带粘过地方怎么能弄干净? vb.net的重写和重载是什么? Java里面的重载和重写怎么区别? java:方法重载和方法重写的区别 怎么区分 java 重载 覆盖 重写 三个概念 计算机黑色三角形符号是什么意思 电脑主板三角形标志是什么牌子 电脑出现三角形图标一会噗呲一声自动关机 电脑显示黄色三角形图标里边有一个黑色惊叹号咋回事 为什么我的电脑右下角出一个三角形图标(在QQ那个附近)里面一个黑感叹号 显示C盘损坏且无法读取 惠普25i是dc调光吗 hp 8730w怎样看 是否DC 屏 HP DC7900 CMT机子,winxp系统,如何设置 DP口 及VGA 口双显示器输出,是不是BIOS还要设置? HP有DC屏 lenovo你有什么~~~ 现有电脑HP dc7600 装迈创G450MMs接3张22寸屏,打开俩通达信股市行情再开两网页,机器就跑不动了。