1. 配置系统环境

主机名,ssh互信,环境变量等

本文略去jdk安装,请将datanode的jdk安装路径与/etc/hadoop/hadoop-evn.sh中的java_home保持一致,版本hadoop2.7.5

修改/etc/sysconfig/network

然后执行命令
hostname 主机名
这个时候可以注销一下系统,再重登录之后就行了

[root@localhost ~]# hostname
localhost.localdomain
[root@localhost ~]# hostname -i
:: 127.0.0.1
[root@localhost ~]#
[root@localhost ~]# cat /etc/sysconfig/network
# Created by anaconda
NETWORKING=yes
HOSTNAME=slave2
GATEWAY=192.168.48.2
# oracle-rdbms-server-11gR2-preinstall : Add NOZEROCONF=yes
NOZEROCONF=yes
[root@localhost ~]# hostname slave2
[root@localhost ~]# hostname
slave2
[root@localhost ~]# su - hadoop
Last login: Sat Feb :: CST on pts/
[hadoop@slave2 ~]$ su - root

建datanode目录并改所有者

(此处的具体路径值,请参照namenode中/usr/hadoop/hadoop-2.7.5/etc/hadoop/hdfs-site.xml,core-site.xml中的dfs.name.dir,dfs.data.dir,dfs.tmp.dir等)

Su - root

# mkdir -p /usr/local/hadoop-2.7.5/tmp/dfs/data

# chmod -R 777 /usr/local/hadoop-2.7.5/tmp

# chown -R hadoop:hadoop /usr/local/hadoop-2.7.5

[root@slave2 ~]# mkdir -p /usr/local/hadoop-2.7./tmp/dfs/data
[root@slave2 ~]# chmod -R /usr/local/hadoop-2.7./tmp
[root@slave2 ~]# chown -R hadoop:hadoop /usr/local/hadoop-2.7.
[root@slave2 ~]# pwd
/root
[root@slave2 ~]# cd /usr/local/
[root@slave2 local]# ll
total
drwxr-xr-x. root root Mar bin
drwxr-xr-x. root root Jun etc
drwxr-xr-x. root root Jun games
drwxr-xr-x hadoop hadoop Feb : hadoop-2.7.
drwxr-xr-x. root root Jun include
drwxr-xr-x. root root Jun lib
drwxr-xr-x. root root Jun lib64
drwxr-xr-x. root root Jun libexec
drwxr-xr-x. root root Jun sbin
drwxr-xr-x. root root Dec share
drwxr-xr-x. root root Jun src
[root@slave2 local]#

ssh互信,即实现 master-->slave2免密码

master:

[root@hadoop-master ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.48.129 hadoop-master
192.168.48.132 slave1
192.168.48.131 slave2
[hadoop@hadoop-master ~]$ scp /usr/hadoop/.ssh/authorized_keys hadoop@slave2:/usr/hadoop/.ssh
The authenticity of host 'slave2 (192.168.48.131)' can't be established.
ECDSA key fingerprint is 1e:cd:d1:3d:b0:5b:62:45:a3:63:df:c7:7a:0f:b8:7c.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'slave2,192.168.48.131' (ECDSA) to the list of known hosts.
hadoop@slave2's password:
authorized_keys
[hadoop@hadoop-master ~]$ ssh hadoop@slave2
Last login: Sat Feb 24 18:27:33 2018
[hadoop@slave2 ~]$
[hadoop@slave2 ~]$ exit
logout
Connection to slave2 closed.
[hadoop@hadoop-master ~]$

2. 修改namenode节点的slave文件,增加新节点信息

[hadoop@hadoop-master hadoop]$ pwd
/usr/hadoop/hadoop-2.7.5/etc/hadoop
[hadoop@hadoop-master hadoop]$ vi slaves
slave1
slave2

3. 在namenode节点上,将hadoop-2.7.3复制到新节点上,并在新节点上删除data和logs目录中的文件

Master

[hadoop@hadoop-master ~]$ scp -R hadoop-2.7.5 hadoop@slave2:/usr/hadoop

Slave2
[hadoop@slave2 hadoop-2.7.5]$ ll
total 124
drwxr-xr-x 2 hadoop hadoop 4096 Feb 24 14:29 bin
drwxr-xr-x 3 hadoop hadoop 19 Feb 24 14:30 etc
drwxr-xr-x 2 hadoop hadoop 101 Feb 24 14:30 include
drwxr-xr-x 3 hadoop hadoop 19 Feb 24 14:29 lib
drwxr-xr-x 2 hadoop hadoop 4096 Feb 24 14:29 libexec
-rw-r--r-- 1 hadoop hadoop 86424 Feb 24 18:44 LICENSE.txt
drwxrwxr-x 2 hadoop hadoop 4096 Feb 24 14:30 logs
-rw-r--r-- 1 hadoop hadoop 14978 Feb 24 18:44 NOTICE.txt
-rw-r--r-- 1 hadoop hadoop 1366 Feb 24 18:44 README.txt
drwxr-xr-x 2 hadoop hadoop 4096 Feb 24 14:29 sbin
drwxr-xr-x 4 hadoop hadoop 29 Feb 24 14:30 share
[hadoop@slave2 hadoop-2.7.5]$ pwd
/usr/hadoop/hadoop-2.7.5
[hadoop@slave2 hadoop-2.7.5]$ rm -R logs/*

4. 启动新datanode的datanode和nodemanger进程

先确认namenode和当前的datanode中,etc/hoadoop/excludes文件中无待加入的主机,再进行下面操作

[hadoop@slave2 hadoop-2.7.]$ sbin/hadoop-daemon.sh start datanode
starting datanode, logging to /usr/hadoop/hadoop-2.7./logs/hadoop-hadoop-datanode-slave2.out
[hadoop@slave2 hadoop-2.7.]$ sbin/yarn-daemon.sh start nodemanager
starting datanode, logging to /usr/hadoop/hadoop-2.7./logs/yarn-hadoop-datanode-slave2.out
[hadoop@slave2 hadoop-2.7.]$
[hadoop@slave2 hadoop-2.7.]$ jps
DataNode
NodeManager
Jps
[hadoop@slave2 ~]$

5、在NameNode上刷新节点

[hadoop@hadoop-master ~]$ hdfs dfsadmin -refreshNodes
Refresh nodes successful
[hadoop@hadoop-master ~]$sbin/start-balancer.sh

6. 在namenode查看当前集群情况,

确认节点已经正常加入

[hadoop@hadoop-master hadoop]$ hdfs dfsadmin -report
Configured Capacity: (54.63 GB)
Present Capacity: (14.42 GB)
DFS Remaining: (14.42 GB)
DFS Used: ( KB)
DFS Used%: 0.00%
Under replicated blocks:
Blocks with corrupt replicas:
Missing blocks:
Missing blocks (with replication factor ): -------------------------------------------------
Live datanodes (2): Name: 192.168.48.131:50010 (slave2)
Hostname: 183.221.250.11
Decommission Status : Normal
Configured Capacity: 38588669952 (35.94 GB)
DFS Used: 8192 (8 KB)
Non DFS Used: 36887191552 (34.35 GB)
DFS Remaining: 1701470208 (1.58 GB)
DFS Used%: 0.00%
DFS Remaining%: 4.41%
Configured Cache Capacity: 0 (0 B)
Cache Used: 0 (0 B)
Cache Remaining: 0 (0 B)
Cache Used%: 100.00%
Cache Remaining%: 0.00%
Xceivers: 1
Last contact: Thu Mar 01 19:36:33 PST 2018 Name: 192.168.48.132: (slave1)
Hostname: slave1
Decommission Status : Normal
Configured Capacity: (18.70 GB)
DFS Used: ( KB)
Non DFS Used: (5.86 GB)
DFS Remaining: (12.84 GB)
DFS Used%: 0.00%
DFS Remaining%: 68.67%
Configured Cache Capacity: ( B)
Cache Used: ( B)
Cache Remaining: ( B)
Cache Used%: 100.00%
Cache Remaining%: 0.00%
Xceivers:
Last contact: Thu Mar :: PST [hadoop@hadoop-master hadoop]$

7动态删除datanode

7.1配置NameNode的hdfs-site.xml,

适当减小dfs.replication副本数,增加dfs.hosts.exclude配置

[hadoop@hadoop-master hadoop]$ pwd
/usr/hadoop/hadoop-2.7./etc/hadoop
[hadoop@hadoop-master hadoop]$ cat hdfs-site.xml
<configuration>
<property>
<name>dfs.replication</name>
<value></value>
</property>
<property>
<name>dfs.name.dir</name>
<value>/usr/local/hadoop-2.7./tmp/dfs/name</value>
</property>
<property>
<name>dfs.data.dir</name>
<value>/usr/local/hadoop-2.7./tmp/dfs/data</value>
</property>
<property>
<name>dfs.hosts.exclude</name>
<value>/usr/hadoop/hadoop-2.7.5/etc/hadoop/excludes</value>
</property> </configuration>

7.2在namenode对应路径(/etc/hadoop/)下新建excludes文件,

并写入待删除DataNode的ip或域名

[hadoop@hadoop-master hadoop]$ pwd
/usr/hadoop/hadoop-2.7.5/etc/hadoop
[hadoop@hadoop-master hadoop]$ vi excludes
####slave2
192.168.48.131[hadoop@hadoop-master hadoop]$

7.3在NameNode上刷新所有DataNode

hdfs dfsadmin -refreshNodes
sbin/start-balancer.sh

7.4在namenode查看当前集群情况,

确认信节点已经正常删除,结果中已无slave2

[hadoop@hadoop-master hadoop]$ hdfs dfsadmin -report 

或者可以在web检测界面(ip:50070)上可以观测到DataNode逐渐变为Dead。

http://192.168.48.129:50070/

在datanode项,Admin state已经由“In Service“变为”Decommissioned“,则表示删除成功

7.5停止已删除的节点相关进程

[hadoop@slave2 hadoop-2.7.]$ jps
Jps
DataNode
NodeManager
[hadoop@slave2 hadoop-2.7.]$ sbin/hadoop-daemon.sh stop datanode
stopping datanode
[hadoop@slave2 hadoop-2.7.]$ sbin/yarn-daemon.sh stop nodemanager
stopping nodemanager
[hadoop@slave2 hadoop-2.7.]$ jps
Jps
[hadoop@slave2 hadoop-2.7.]$

8恢复已删除节点

执行7.2 中删除相关信息,然后4,5,6即可

hadoop动态添加删除节点datanode及恢复的更多相关文章

  1. Hadoop动态加入/删除节点(datanode和tacktracker)

    大体,正确的做法是首选的配置文件,然后开始详细机对应的进程/停止操作. 网上一些资料说在调整配置文件的时候,优先使用主机名而不是IP进行配置. 总的来说加入/删除DataNode和TaskTracke ...

  2. js实现网页收藏功能,动态添加删除网址

    <html> <head> <title> 动态添加删除网址 </title> <meta charset="utf-8"&g ...

  3. jquery动态添加删除div--事件绑定,对象克隆

    我想做一个可以动态添加删除div的功能.中间遇到一个问题,最后在manong123.com开发文摘 版主的热心帮助下解答了(答案在最后) 使用到的jquery方法和思想就是:事件的绑定和销毁(unbi ...

  4. 编辑 Ext 表格(一)——— 动态添加删除行列

    一.动态增删行 在 ext 表格中,动态添加行主要和表格绑定的 store 有关, 通过对 store 数据集进行添加或删除,就能实现表格行的动态添加删除.   (1) 动态添加表格的行  gridS ...

  5. 【实践】js 如何实现动态添加文本节点

    对于我这个js 小白来说 今天鼓起勇气做起了邮箱认证这个特效 但是这次不是想说如何实现这这个特效而是想记录一下特效当中的某个部分 那就是向元素节点动态添加文本节点 百度了一下动态添加文本节点的方式 是 ...

  6. 用Javascript动态添加删除HTML元素实例 (转载)

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  7. jQuery动态添加删除CSS样式

    jQuery框架提供了两个CSS样式操作方法,一个是追加样式addClass,一个是移除样式removeClass,下面通过一个小例子讲解用法. jQuery动态追加移除CSS样式 <!DOCT ...

  8. mongodb replica set 添加/删除节点方法--http://www.ii123.com/jc/bc/bczh/258948.html

    replica set多服务器主从,添加,删除节点,肯定会经常遇到的.下面详细说明一下,添加,删除节点的2种方法. 一,利用rs.reconfig,来添加,删除节点 1,添加节点  代码如下   re ...

  9. MongoDB添加删除节点

    副本集添加删除节点 sharding添加删除节点 先将节点设置为hidden,再remove

随机推荐

  1. ALGO-151_蓝桥杯_算法训练_6-2递归求二进制表示位数

    记: 进制转换 AC代码: #include <stdio.h> #define K 2 int main(void) { ; scanf("%d",&n); ...

  2. Lucene 4.0 正式版发布,亮点特性中文解读[转]

    http://blog.csdn.net/accesine960/article/details/8066877 2012年10月12日,Lucene 4.0正式发布了(点击这里下载最新版),这个版本 ...

  3. [转][layui]table 的一个BUG

    转换静态表格,一直只能显示 10 行,研究发现解决方法有两个:1.参数里: limit: 30, 添加参数以确保显示更多行2.修改 table.js 里面的 F.prototype.config ,添 ...

  4. jenkins+git 构建项目

    首先先参照了网上几篇文章 http://blog.csdn.net/kefengwang/article/details/54233584 https://www.liaoxuefeng.com/ar ...

  5. Python3中的赋值操作、浅拷贝与深拷贝

    一:关于赋值操作与浅拷贝 1.变量的赋值 首先以一个例子来说明一下:定义变量a = 1,使b = a.开始的情况下打印a与b都为1(显而易见,哈哈) 但是接下来,我们做一下改动,令 a = 222,再 ...

  6. java使用freemarker模板导出word(带有合并单元格)文档

    来自:https://blog.csdn.net/qq_33195578/article/details/73790283 前言:最近要做一个导出word功能,其实网上有很多的例子,但是我需要的是合并 ...

  7. [UE4]反射

    1.根据名字获得类(C++支持,蓝图本身不支持但可以通过工厂模式模拟) 国外大神提供的封装好的C++实现: https://github.com/getsetgames/BlueprintReflec ...

  8. Centos7.3安装部署Zabbix3.4.15(成功可用)

    1.Xshell 远程连接到Centos7.3.连接centos 系统后,首先关闭防火墙和SELINUX,如不关闭会各种拦截,网页访问等故障,容易造成蛋疼哦.#systemctl stop firew ...

  9. 封装GridSearchCV的训练包

    import xgboost as xgb from sklearn.model_selection import GridSearchCV from sklearn.metrics import m ...

  10. 安装MySQL_Python时出现is not a supported wheel on this platform.

    MySQL-Python 数据库驱动安装 pip install mysql_python失败 不支持windows操作系统 解决: 自行下载安装 下载网站 http://www.lfd.uci.ed ...