在每台机器上创建hadoop用户组合hadoop用户
1:创建用户组:groupadd hadoop
2:创建用户: useradd -g hadoop hadoop
3:修改密码: passwd hadoop
vi /etc/sysconfig/network //重启后生效
HOSTNAME=Master
vi /etc/hosts
添加内容如下:
Master 10.10.10.213
Slave1 10.10.10.214
Slave2 10.10.10.215
bin/hadoop namenode -format //格式化namenode,第一次启动服务前执行的操作,以后不需要执行
bin/start-all.sh //启动hadoop
1)hbase-env.sh
export JAVA_HOME=/usr/lib/java/jdk1.6.0_25 //JDK的安装目录
export HBASE_CLASSPATH=/home/hadoop/hadoop-1.0.3/conf //hadoop的安装目录
export HBASE_MANAGES_ZK=true
2)hbase-site.xml
<configuration>
<property>
<name>hbase.rootdir</name>
<value>hdfs://Master:9000/hbase</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>hbase.zookeeper.property.clientPort</name>
<value>2181</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>Master</value>
</property>
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/home/hadoop/temp/zookeeper</value>
</property>
<property>
<name>dfs.support.append</name>
<value>true</value>
</property>
</configuration>
(3)regionservers
Slave1
Slave2
在IE中输入以下地址可以查看hadoop集群环境的启动状态:
http://192.168.131.16:50070
http://192.168.131.16:8088
HDFS中常用到的命令
1、hadoop fs
hadoop fs -ls /
hadoop fs -lsr
hadoop fs -mkdir /user/hadoop
hadoop fs -put a.txt /user/hadoop/
hadoop fs -get /user/hadoop/a.txt /
hadoop fs -cp src dst
hadoop fs -mv src dst
hadoop fs -cat /user/hadoop/a.txt
hadoop fs -rm /user/hadoop/a.txt
hadoop fs -rmr /user/hadoop/a.txt
hadoop fs -text /user/hadoop/a.txt
hadoop fs -copyFromLocal localsrc dst 与hadoop fs -put功能类似。
hadoop fs -moveFromLocal localsrc dst 将本地文件上传到hdfs,同时删除本地文件。
2、hadoop fsadmin
hadoop dfsadmin -report
hadoop dfsadmin -safemode enter | leave | get | wait
hadoop dfsadmin -setBalancerBandwidth 1000
3、hadoop fsck
4、start-balancer.sh
七、 常见故障
7.1、重启Regionserver及Zookeeper
1、datanode 宕机了,如何重启:
hadoop-daemon.sh start datanode
2、regionserver挂了,如何重启:
${HBASE_HOME}/bin/hbase-daemon.sh start regionserver