Hadoop Single Node Cluster是只以一台机器,建立hadoop环境,您仍然可以使用hadoop命令,只是无法发挥使用多台机器的威力。
因为只有一台服务器,所以所有功能都在一台服务器中,安装步骤如下:
1 安装JDK
2 设定 SSH 无密码登入
3 下载安装Hadoop
4 设定Hadoop环境变数
5 Hadoop组态档设定
6 建立与格式化HDFS目录
7 启动Hadoop
8 开启Hadoop Web接口
1.安装JDK
java -version
sudo apt-get update
sudo apt-get install default-jdk
java -version
update-alternatives --display java
2.设定 SSH
无密码登入
sudo apt-get install
sshsudo apt-get install rsync
ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
ll /home/hduser/.ssh
ll ~/.ssh
cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
3.下载安装Hadoop
wget http://ftp.twaren.net/Unix/Web/apache/hadoop/common/hadoop-2.6.0/hadoop-2.6.0.tar.gz
sudo tar -zxvf hadoop-2.6.0.tar.gz
sudo mv hadoop-2.6.0 /usr/local/hadoop
ll /usr/local/hadoop
4.设定Hadoop环境变数
修改~/.bashrc
sudo gedit ~/.bashrc
输入下列内容
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
export HADOOP_HOME=/usr/local/hadoop
export PATH=$PATH:$HADOOP_HOME/bin
export PATH=$PATH:$HADOOP_HOME/sbin
export HADOOP_MAPRED_HOME=$HADOOP_HOME
export HADOOP_COMMON_HOME=$HADOOP_HOME
export HADOOP_HDFS_HOME=$HADOOP_HOME
export YARN_HOME=$HADOOP_HOME
export HADOOP_COMMON_HOME=$HADOOP_HOME
export HADOOP_HDFS_HOME=$HADOOP_HOME
export YARN_HOME=$HADOOP_HOME
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
export HADOOP_OPTS="-Djava.library.path=$HADOOP_HOME/lib"
export JAVA_LIBRARY_PATH=$HADOOP_HOME/lib/native:$JAVA_LIBRARY_PATH
让~/.bashrc修改生效
source ~/.bashrc
5.修改Hadoop组态设定档
Step1 修改hadoop-env.sh
sudo gedit /usr/local/hadoop/etc/hadoop/hadoop-env.sh
输入下列内容:
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
Step2 修改core-site.xml
sudo gedit /usr/local/hadoop/etc/hadoop/core-site.xml
在之间,输入下列内容:
fs.default.name hdfs://localhost:9000
Step3 修改yarn-site.xml
sudo gedit /usr/local/hadoop/etc/hadoop/yarn-site.xml
在之间,输入下列内容:
yarn.nodemanager.aux-services
mapreduce_shuffle
yarn.nodemanager.aux-services.mapreduce.shuffle.class
org.apache.hadoop.mapred.ShuffleHandler
Step4 修改mapred-site.xml
sudo cp /usr/local/hadoop/etc/hadoop/mapred-site.xml.template /usr/local/hadoop/etc/hadoop/mapred-site.xml
sudo gedit /usr/local/hadoop/etc/hadoop/mapred-site.xml
在之间,输入下列内容:
mapreduce.framework.name
yarn
Step5 修改hdfs-site.xml
sudo gedit /usr/local/hadoop/etc/hadoop/hdfs-site.xml
在之间,输入下列内容:
dfs.replication3dfs.namenode.name.dirfile:/usr/local/hadoop/hadoop_data/hdfs/namenodedfs.datanode.data.dirfile:/usr/local/hadoop/hadoop_data/hdfs/datanode
6.建立与格式化HDFS 目录
sudo mkdir -p /usr/local/hadoop/hadoop_data/hdfs/namenode
sudo mkdir -p /usr/local/hadoop/hadoop_data/hdfs/datanode
sudo chown hduser:hduser -R /usr/local/hadoop
hadoop namenode -format
7.启动Hadoop
启动start-dfs.sh,再启动 start-yarn.sh
start-dfs.sh
start-yarn.sh
或
启动全部
start-all.sh
查看目前所执行的行程
jps
8.开启Hadoop ResourceManager
Web接口
Hadoop ResourceManager Web接口网址
http://localhost:8088/
9.NameNode HDFS Web接口
开启HDFS Web UI网址
http://localhost:50070/
安装代码命令来自《Python+Spark 2.0+Hadoop机器学习与大数据实战》
新浪微博 BigDataAI的博客