- 下载hadoop压缩包 http://hadoop.apache.org/releases.html
- 下载jdk 配置java环境
sudo mv jdk压缩包名 /usr/
cd /usr/
sudo tar xzvf jdk压缩包名
ls 可以看到解压出来的文件夹
sudo rm -rf jdk压缩包名 (删除压缩包)
sudo mv jdk文件夹名 jdk8 (重命名)
sudo vi ~/.bashrc (编辑文件内容如下)
export JAVA_HOME=/usr/jdk1.8
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$JAVA_HOME/bin:$PATH
export JRE_HOME=$JAVA_HOME/jre
source ~/.bashrc
java -version
javac -version(如下则成功)
3. 将hadoop安装包移动到/usr/下,解压缩,重命名为hadoop(同上)
4. 给hadoop授予权限
chown -R hadoop:hadoop hadoop
5.配置以下文件
//安装hadoop
sudo cp hadoop-2.6.0-cdh5.6.0.tar.gz /usr //复制hadoop到/usr目录下
cd /usr
sudo tar zxvf hadoop-2.6.0-cdh5.6.0.tar.gz //解压缩
ls
sudo mv hadoop-2.6.0-cdh5.6.0 hadoop //改名
ls -l
sudo chown -R hadoop:hadoop hadoop//修改hadoop文件夹所属的用户和组
//修改环境变量
vi ~/.bashrc
export HADOOP_INSTALL=/usr/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"
source ~/.bashrc
//配置hadoop环境变量
cd /usr/hadoop/etc/hadoop
vi hadoop-env.sh
#export JAVA_HOME=${JAVA_HOME}
export JAVA_HOME=/usr/jdk18
export HADOOP_PREFIX=/usr/hadoop
export HADOOP_OPTS="-Djava.library.path=$HADOOP_PREFIX/lib:$HADOOP_PREFIX/lib/native"
vi core-site.xml
<configuration>
<property>
<name>hadoop.tmp.dir</name>
<value>/usr/hadoop/tmp</value>
<description>Abase for other temporary directories.
</description>
</property>
<property>
<name>fs.defaultFS</name>
<value>hdfs://localhost:9000</value>
</property>
</configuration>
cp mapred-site.xml.template mapred-site.xml
vi mapred-site.xml
<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
</configuration>
vi yarn-site.xml
<configuration>
<!-- Site specific YARN configuration properties -->
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
</configuration>
vi hdfs-site.xml
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
<property>
<name>dfs.namenode.name.dir</name>
<value>file:/usr/hadoop/dfs/name</value>
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>file:/usr/hadoop/dfs/data</value>
</property>
</configuration>
hdfs namenode -format //格式化分布式存储系统hdfs
start-all.sh //启动hadoop服务
jps //查看hadoop服务启动是否正常
如下表示安装成功
hadoop@ubuntu:/usr/hadoop/etc/hadoop$ jps
2768 NameNode
3777 Jps
3449 NodeManager
3291 ResourceManager
2939 DataNode
3150 SecondaryNameNode
要注意的问题
1.权限问题,出现的问题大多是对相应文件夹没有读写权限的问题,使用chmod 指令进行授权
2.请注意报错信息和配置文件的准确性,配置文件中相关路径换成自己的路径