1. 程式人生 > >hadoop偽分布式模式下安裝及運行

hadoop偽分布式模式下安裝及運行

ram linux .sh gre 卸載 def href sha path

一 . 安裝JDK

查詢目前系統的JDK: rpm -qa|grep jdk.

卸載JDK yum -y remove xx

tar -xzvf jdk-7u80-linux-x64.tar.gz

配置環境變量: vim /etc/profile

export JAVA_HOME=/opt/softwares/jdk1.7.0_80

export PATH=$PATH:$JAVA_HOME/bin

source /etc/profile

驗證安裝 java -version

二 . 配置偽分布式 hadoop

tar -zxvf hadoop-2.6.5.tar.gz

修改配置文件

1. hadoop-env.sh hadoop要用的環境變量

export JAVA_HOME=/opt/softwares/jdk1.7.0_80

2. 修改core-site.xml hadoop core的配置項

<?xml version="1.0" encoding="UTF-8"?>

<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>

<property>
<name>fs.defaultFS</name>

<value>hdfs://localhost:9000</value>
</property>
</configuration>

3. 修改 hdfs-site.xml.hdfs守護進程的配置項

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

<configuration>
<property>
<name>dfs.replication</name>

<value>1</value>
</property>
</configuration>

4. 修改mapred-site.xml mapreduce的配置項

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
</configuration>

5. 修改yarn-site.xml yarn守護進程的配置項

<?xml version="1.0"?>

<configuration>

<!-- Site specific YARN configuration properties -->
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
</configuration>

6. 修改mapred-env.sh和yarn-env.sh文件

export JAVA_HOME=/opt/softwares/jdk1.7.0_80

三 、運行wordcount程序

bin/hdfs namenode -format sbin/hadoop-daemon.sh start namenode sbin/hadoop-daemon.sh start datanode jps sbin/yarn-daemon.sh start resourcemanager sbin/yarn-daemon.sh start nodemanager bin/hdfs dfs -mkdir -p /user/hadoopuser/mapreduce/wordcount/input bin/hdfs dfs -put wcinput/wc.input /user/hadoopuser/mapreduce/wordcount/input/ bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.6.5.jar wordcount /user/hadoopuser/mapreduce/wordcount/input/ /user/hadoopuser/mapreduce/wordcount/output

hadoop偽分布式模式下安裝及運行