目录
环境
java环境安装
检查java环境
安装java
1、下载jdk8
2、解压jdk
3、配置环境变量
4、使环境变量生效
5、验证java环境
6、环境变量拷至bashrc
hadoop安装
dfs
下载hadoop
创建input、output目录
修改配置文件
尝试ssh连接
创建key
格式化文件系统
启动
浏览web接口
创建需要的hdfs目录
复制input文件到分布式文件系统
运行一些提供的案例
从分布式文件系统复制output文件到本地
停止dfs
yarn
修改配置文件
启动ResourceManager daemon and NodeManager daemon
浏览web接口
运行一个MapReduce
停止
OS:openeuler-20.03-LTS-SP2
SSH:MOBA
Java:jdk1.8.0_341
[root@localhost ~]# java -version
-bash: java: command not found
wget https://download.oracle.com/otn/java/jdk/8u341-b10/424b9da4b48848379167015dcc250d8d/jdk-8u341-linux-aarch64.tar.gz
tar -zxvf openjdk1.8.0_341_linux-aarch64_bin.tar.gz
mv jdk1.8.0_341/ jdk1.8
vim /etc/profile
export JAVA_HOME=/opt/jdk1.8
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:%JAVA_HOME%/lib/dt.jar:%JAVA_HOME%/lib/tools.jar
source /etc/profile
[root@localhost hadoop-3.3.4]# java -version
java version "1.8.0_341"
Java(TM) SE Runtime Environment (build 1.8.0_341-b10)
Java HotSpot(TM) 64-Bit Server VM (build 25.341-b10, mixed mode)
vim /etc/bashrc
export JAVA_HOME=/opt/jdk1.8
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:%JAVA_HOME%/lib/dt.jar:%JAVA_HOME%/lib/tools.jar
wget https://dlcdn.apache.org/hadoop/common/hadoop-3.3.4/hadoop-3.3.4.tar.gz
vi etc/hadoop/hadoop-env.sh
export JAVA_HOME=/opt/jdk1.8
mkdir input
cp etc/hadoop/*.xml input
bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-3.3.4.jar grep input output 'dfs[a-z.]+'
cat output/*
core-site.xml文件
vi etc/hadoop/core-site.xml
fs.defaultFS
hdfs://localhost:9000
hdfs-site.xml文件
vi etc/hadoop/hdfs-site.xml
dfs.replication
1
ssh localhost
ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
chmod 0600 ~/.ssh/authorized_keys
bin/hdfs namenode -format
sbin/start-dfs.sh
http://你的ip:9870/
bin/hdfs dfs -mkdir /user
bin/hdfs dfs -mkdir /user/
bin/hdfs dfs -mkdir /input
bin/hdfs dfs -mkdir /output
bin/hdfs dfs -put etc/hadoop/*.xml /input
bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-3.3.4.jar grep input output 'dfs[a-z.]+'
bin/hdfs dfs -get output output
cat output/*
或者
bin/hdfs dfs -cat output/*
sbin/stop-dfs.sh
mapred-site.xml文件
vi etc/hadoop/mapred-site.xml
mapreduce.framework.name
yarn
mapreduce.application.classpath
$HADOOP_MAPRED_HOME/share/hadoop/mapreduce/*:$HADOOP_MAPRED_HOME/share/hadoop/mapreduce/lib/*
yarn-site.xml文件
vi etc/hadoop/yarn-site.xml
yarn.nodemanager.aux-services
mapreduce_shuffle
yarn.nodemanager.env-whitelist
JAVA_HOME,HADOOP_COMMON_HOME,HADOOP_HDFS_HOME,HADOOP_CONF_DIR,CLASSPATH_PREPEND_DISTCACHE,HADOOP_YARN_HOME,HADOOP_HOME,PATH,LANG,TZ,HADOOP_MAPRED_HOME
sbin/start-yarn.sh
http://你的ip:8088/
进入MapReduce目录
cd /opt/hadoop-3.3.4/share/hadoop/mapreduce/
向hadoop集群写入5个128MB文件进行DFSIO测试
../../../bin/hadoop jar hadoop-mapreduce-client-jobc lient-3.3.4-tests.jar TestDFSIO -write -nrFiles 5 -filesize 128MB
sbin/stop-yarn.sh
随手记