前提条件:
安装jdk-6u18
实现目的:
1. 创建目录和用户
mkdir /app/hadoop
usergroup hadoop
useradd licz -ghadoop -d /app/hadoop
chownlicz:hadoop /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_keysauthorized_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_keysnticket1:~/.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_keysnticket2:~/.ssh/authorized_keys
[licz@server123 ~]$ scp ~/.ssh/authorized_keysnticket3:~/.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
--测试
[licz@server123~]$ hadoop dfs -ls /user/hive
Found 1 items
drwxr-xr-x - licz supergroup 0 2014-02-10 11:25/user/hive/warehouse