Hadoop 添加数据节点(datanode)

前提条件:

安装jdk-6u18

 

实现目的:

在hadoop集群中添加一个新增数据节点。

 

 

1. 创建目录和用户

mkdir -p /app/hadoop

groupadd hadoop

useradd licz -g hadoop -d /app/hadoop

chown licz:hadoop /app/hadoop

passwd licz

注:如果出现下面的问题

[root@dbserver22 ~]# su - licz
-bash-3.2$ 

解决办法:

cp -a /etc/skel/. /app/hadoop 


2. 修改环境变量

[licz@server123 ~]$ vi .bash_profile

 

PATH=$PATH:$HOME/bin

export LANG=zh_CN

export PATH

unset USERNAME

 

export HADOOP_HOME=/app/hadoop/hadoop-1.2.1

export JAVA_HOME=/usr/java/jdk1.6.0_18

export HIVE_HOME=/app/hadoop/hive-0.11.0

 

export PIG_HOME=/app/hadoop/pig-0.12.0

export PIG_CLASSPATH=/app/hadoop/pig-0.12.0/conf

 

PATH=$JAVA_HOME/bin:$PATH:$HOME/bin:$HADOOP_HOME/bin:$PIG_HOME/bin:$HIVE_HOME/bin

 

export PATH

 

export HADOOP_HOME_WARN_SUPPRESS=1

 

 

 

3. 修改host文件,添加服务器

[root@server123 ~]# vi /etc/hosts

10.1.32.91             nticket1

10.1.32.93             nticket2

10.1.32.95             nticket3

10.1.5.123             server123

 

同样在其它各节点都添加新的server123服务器

 

4. 配置ssh免密码连入

步骤为:

->在新节点上生成自己的密钥

->把原集群中的密钥复制添加到新节点的密钥当中

->再把新节点上的新密钥复制(覆盖)到原集群中的新节点

 

--首先,为了避免误操作,操作之前要先备份原集群的密钥文件

[licz@nticket1 .ssh]$ cp authorized_keys authorized_keys.bak

 

[licz@server123 ~]$ ssh-keygen -t rsa

[licz@server123 ~]$ cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys

 

[licz@server123 ~]$ ssh nticket1 cat ~/.ssh/authorized_keys >> ~/.ssh/authorized_keys

 

[licz@server123 ~]$ scp ~/.ssh/authorized_keys nticket1:~/.ssh/authorized_keys

[licz@server123 ~]$ ssh nticket1 date

2014年 02月 12日 星期三 11:31:08 CST

[licz@nticket1 .ssh]$ ssh server123 date

三  2月 1211:25:57 CST 2014

 

--同样把新新密钥复制(覆盖)到原集群中的新节点

[licz@server123 ~]$ scp ~/.ssh/authorized_keys nticket2:~/.ssh/authorized_keys

[licz@server123 ~]$ scp ~/.ssh/authorized_keys nticket3:~/.ssh/authorized_keys

 

5. 修改hadoop配置文件

--在各节点修改hadoop的配置文件

[licz@nticket1 conf]$ vi slaves

nticket2

nticket3

server123

 

6. 安装hadoop

--把集群中的hadoop复制到新节点

[licz@nticket2~]$ scp -r hadoop-1.2.1/server123:/app/hadoop

 

7. 在新节点上启动datanode和tasktracker

[licz@server123~]$ hadoop-daemon.sh start datanode

startingdatanode, logging to /app/hadoop/hadoop-1.2.1/libexec/../logs/hadoop-licz-datanode-server123.out

[licz@server123~]$ hadoop-daemon.sh start tasktracker

startingtasktracker, logging to /app/hadoop/hadoop-1.2.1/libexec/../logs/hadoop-licz-tasktracker-server123.out

 

--测试安装成功

[licz@server123 ~]$ jps

18356 DataNode

18517 TaskTracker

18780 Jps

 

 

 

8. 进行block块的均衡

--在hdfs-site.xml中增加设置balance的带宽,默认只有1M:

<property>

   <name>dfs.balance.bandwidthPerSec</name>

    <value>10485760</value>

    <description>

        Specifies the maximum bandwidth thateach datanode can utilize for the balancing purpose in term of the number ofbytes per second.

    </description>

</property>

 

运行以下命令:

[licz@server123conf]$ start-balancer.sh -threshold 5

startingbalancer, logging to /app/hadoop/hadoop-1.2.1/libexec/../logs/hadoop-licz-balancer-server123.out

Time Stamp               Iteration#  Bytes Already Moved  Bytes Left To Move  Bytes Being Moved
2014-2-20 17:55:14                0                 0 KB            14.12 GB           14.06 GB

 

--测试

[licz@server123~]$ hadoop dfs -ls /user/hive

Found 1 items

drwxr-xr-x   - licz supergroup          0 2014-02-10 11:25/user/hive/warehouse


[licz@nticket1 ~]$ hadoop dfsadmin -report
Configured Capacity: 2588293705728 (2.35 TB)
Present Capacity: 2027166097408 (1.84 TB)
DFS Remaining: 2026681536512 (1.84 TB)
DFS Used: 484560896 (462.11 MB)
DFS Used%: 0.02%
Under replicated blocks: 9
Blocks with corrupt replicas: 0
Missing blocks: 0


-------------------------------------------------
Datanodes available: 3 (3 total, 0 dead)


Name: 10.1.32.95:50010
Decommission Status : Normal
Configured Capacity: 1041225043968 (969.72 GB)
DFS Used: 242110464 (230.89 MB)
Non DFS Used: 102109831168 (95.1 GB)
DFS Remaining: 938873102336(874.39 GB)
DFS Used%: 0.02%
DFS Remaining%: 90.17%
Last contact: Fri Feb 14 09:49:02 CST 2014




Name: 10.1.32.93:50010
Decommission Status : Normal
Configured Capacity: 1041225043968 (969.72 GB)
DFS Used: 242143232 (230.93 MB)
Non DFS Used: 57774628864 (53.81 GB)
DFS Remaining: 983208271872(915.68 GB)
DFS Used%: 0.02%
DFS Remaining%: 94.43%
Last contact: Fri Feb 14 09:49:02 CST 2014




Name: 10.1.5.123:50010
Decommission Status : Normal
Configured Capacity: 505843617792 (471.1 GB)
DFS Used: 307200 (300 KB)
Non DFS Used: 401243148288 (373.69 GB)
DFS Remaining: 104600162304(97.42 GB)
DFS Used%: 0%
DFS Remaining%: 20.68%
Last contact: Fri Feb 14 09:49:03 CST 2014

 

展开阅读全文

没有更多推荐了,返回首页