日期:2014-05-16 浏览次数:20369 次
引自:http://hi.baidu.com/dekar/blog/item/f5c034efcf080e5778f055a6.html
?
一 机器
192.168.0.203 hd203: hadoop namenode & hbase HMaster
192.168.0.204 hd204: hadoop datanode & hbase HRegionServer & zookeeper
192.168.0.205 hd205: hadoop datanode & hbase HRegionServer & zookeeper
192.168.0.206 hd206: hadoop datanode & hbase HRegionServer & zookeeper
192.168.0.202 hd202: hadoop second namenode & hbase HMaster
共 5 台机器 (生产环境需要把zookeeper单独安装)
二 操作系统和软件版本
1 操作系统:CentOS release 5.6 (Final)x64,关闭防火墙
2 相关软件:
jdk-6u24-linux-x64.bin
hadoop-0.20.2-cdh3u0.tar.gz
hbase-0.90.1-cdh3u0.tar.gz
zookeeper-3.3.3-cdh3u0.tar.gz
三 安装
1 安装jdk (所有机器)
mkdir /usr/java
mv jdk-6u24-linux-x64.bin /usr/java
chmod 744 jdk-6u24-linux-x64.bin
./jdk-6u24-linux-x64.bin
ln -s jdk1.6.0_24 default
2 建立集群平台用户 (所有机器)
useradd cbcloud
passwd cbcloud 密码设为123456
3 编辑/etc/hosts (所有机器)
192.168.0.203 hd203
192.168.0.204 hd204
192.168.0.205 hd205
192.168.0.206 hd206
192.168.0.202 hd202
4 hd203登录集群所有机器免密码设置 (hd203)
su - cbcloud
ssh登录本机也要免密码 如下设置
?$ ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
?$ cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
将hd203上的id_dsa.pub 文件追加到所有机器的cbcloud用户的authorized_keys文件内
细节不在详述
ssh 所有机器 第一次需要确认一下
5 安装hadoop
5.1 建立目录 (所有机器)
mkdir /home/cbcloud/hdtmp
mkdir /home/cbcloud/hddata
mkdir /home/cbcloud/hdconf
chown -R cbcloud:cbcloud 以上目录
tar zxvf hadoop-0.20.2-cdh3u0.tar.gz -C /home/cbcloud
cd /home/cbcloud
mv hadoop-0.20.2-cdh3u0 hadoop
chown -R cbcloud:cbcloud hadoop/
5.2 配置环境变量 vi /etc/profile (所有机器)
export JAVA_HOME=/usr/java/default
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export PATH=$JAVA_HOME/bin:$JAVA_HOME/lib:$JAVA_HOME/jre/bin:$PATH:$HOME/bin
export HADOOP_HOME=/home/cbcloud/hadoop
export HADOOP_CONF_DIR=/home/cbcloud/hdconf
export PATH=$PATH:$HADOOP_HOME/bin
把hadoop的配置文件目录从源目录拿出来,方便以后升级hadoop
mv hadoop的conf目录内文件到/home/cbcloud/hdconf内
5.3 编辑 hadoop 配置文件 core-site.xml
加入
<configuration>
<property>
<name>fs.default.name</name>
<value>hdfs://hd203:9000</value>
</property>
<property>
? <name>fs.checkpoint.dir</name>
? <value>/home/cbcloud/hdtmp/dfs/namesecondary</value>
? <description>Determines where on the local filesystem the DFS secondary
????? name node should store the temporary images to merge.
????? If this is a comma-delimited list of directories then the image is
????? replicated in all of the directories for redundancy.
? </description>
</property>
<property>
? <name>fs.checkpoint.period</name>
? <value>60</value>
? <description>Determines where on the local filesystem the DFS secondary
????? name node should store the temporary images to merge.
????? If this is a comma-delimited list of directories then the image is
????? replicated in all of the directories for redundancy.
? </description>
</property>
5.4 编辑hdfs-site.xml
加入
<property>
?????? <name>dfs.replication</name>
?????? <value>3</value>
??? </property>
<property>
?????? <name>dfs.data.dir</name>
?????? <value>/home/cbcloud/hddata</value>
??? </property>
??? <property>
?????? <name>hadoop.tmp.dir</name>
?????? <value>/home/cbcloud/hdtmp/</value>
??? </property>
<property>
??? <name>dfs.balance.bandwidthPerSec</name>
??? <value>10485760</value>
</proper