一、java1.8 下载及安装
首先下载jdk1.8版本到下载文件夹
下载地址 http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
cp jdk-8u65-linux-x64.tar.gz usr/lib/jvm
tar -xzvf jdk-8u25-linux-x64.tar.gz
mv jdk1.8.0_25 java
安装完成,然后配置环境变量
gedit ~/.bashrc
将下面代码直接复制在最后:
export JAVA_HOME=/usr/lib/jvm/java
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
二、hadoop2.7.1下载及安装
下载地址
http://116.77.75.206:83/1Q2W3E4R5T6Y7U8I9O0P1Z2X3C4V5B/www.apache.org/dyn/closer.cgi/hadoop/common/hadoop-2.7.1/hadoop-2.7.1.tar.gz
cp hadoop-2.7.1.tar.gz /usr/localtar -xzvf *.tag.gz
mv hadoop-2.7.1 hadoop
配置环境变量
gedit ~/.bashrc
将下面代码直接复制在最后
#HADOOP VARIABLES START
export HADOOP_INSTALL=/usr/local/hadoop
export PATH=$PATH:$HADOOP_INSTALL/bin
export PATH=$PATH:$HADOOP_INSTALL/sbin
export HADOOP_MAPRED_HOME=$HADOOP_INSTALL
export HADOOP_COMMON_HOME=$HADOOP_INSTALL
export HADOOP_HDFS_HOME=$HADOOP_INSTALL
export YARN_HOME=$HADOOP_INSTALL
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_INSTALL/lib/native
export HADOOP_OPTS="-Djava.library.path=$HADOOP_INSTALL/lib"
#HADOOP VARIABLES END
加一个 hadoop 用户
代码:
sudo addgroup hadoop
sudo adduser -ingroup hadoop hadoop
sudo chown -R hadoop:hadoop /usr/local/hadoop*
sudo su - hadoop
ssh-keygen -t rsa -P ""
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
sudo mkdir /usr/local/hadoop/tmp
给hadoop用户添加权限,打开/etc/sudoers文件;
sudo gedit /etc/sudoers
按回车键后就会打开/etc/sudoers文件了,给hadoop用户赋予root用户同样的权限。
在root
hadoop
修改 /usr/local/hadoop/etc/hadoop/hadoop-env.sh 在 export JAVA_HOME=${JAVA_HOME} 行前面插入如下内容
代码:
export JAVA_HOME=/usr/lib/jvm/java
export HADOOP_CONF_DIR=/usr/local/hadoop/etc/hadoop
修改 /usr/local/hadoop/etc/hadoop/core-site.xml 在 后面增加
代码:
- <configuration>
- <property>
- <name>fs.default.name</name>
- <value>hdfs://localhost:9000</value>
- </property>
- <property>
- <name>hadoop.tmp.dir</name>
- <value>/usr/local/hadoop/tmp</value>
- </property>
- </configuration>
格式化 hadoop
代码:
/usr/local/hadoop/bin/hadoop namenode -format
启动 hadoop
代码:
/usr/local/hadoop/sbin/start-all.sh
# 停止 hadoop
#/usr/local/hadoop/sbin/stop-all.sh
测试 hadoop
代码:
/usr/local/hadoop/bin/hadoop fs -df
退出 hadoop 用户
exit
--------------------------------------
三、HBASE下载及安装
1 安装:
下载地址: http://apache.fayea.com/hbase/
sudo mvhbase-1.1.2 /usr/local/
cd /usr/local/
sudo ln -s hbase-hbase-1.1.2/ hbase
(或者
sudo chown -R hadoop:hadoop hbase*
2 配置:
代码:
sudo su - hadoop
编辑 /usr/local/hbase/conf/hbase-env.sh 找到 export JAVA_HOME 的行,在后面插入:
代码:
export JAVA_HOME=/usr/lib/jvm/java
export HBASE_HOME=/usr/local/hbase
编辑 /usr/local/hbase/conf/hbase-site.xml 在 行后面插入:
代码:
<property> <name>hbase.rootdir</name> <value>hdfs://master:9000/hbase</value> </property>
<property> <name>dfs.replication</name> <value>1</value> </property>
3 启动:
代码:
/usr/local/hbase/bin/start-hbase.sh
4 测试:
代码:
/usr/local/hbase/bin/hbase shell
hbase(main):001:0> status
#/usr/local/hbase/bin/stop-hbase.sh
在使用./sbin/start-dfs.sh或./sbin/start-all.sh启动时会报出这样如下警告:
Java HotSpot(TM) 64-Bit Server VM warning: You have loaded library /usr/local/hadoop-2.2.0/lib/native/libhadoop.so.1.0.0 which might have disabled stack guard. The VM will try to fix the stack guard now.
....
Java: ssh: Could not resolve hostname Java: Name or service not known
HotSpot(TM): ssh: Could not resolve hostname HotSpot(TM): Name or service not known
64-Bit: ssh: Could not resolve hostname 64-Bit: Name or service not known
....
这个问题的错误原因会发生在64位的操作系统上,原因是从官方下载的hadoop使用的本地库文件(例如lib/native /libhadoop.so.1.0.0)都是基于32位编译的,运行在64位系统上就会出现上述错误。解决方法之一是在64位系统上重新编译 hadoop,另一种方法是在hadoop-env.sh和yarn-env.sh中添加如下两行:
export HADOOP_COMMON_LIB_NATIVE_DIR=${HADOOP_PREFIX}/lib/native
export HADOOP_OPTS="-Djava.library.path=$HADOOP_PREFIX/lib"
ubuntu中: