本安装方式为伪分布式,和完全分布式大同小异。
1. 环境设置
a. ssh免密钥登录
进入用户home目录的.ssh文件夹,执行 ssh-keygen -t rsa,然后执行 cat id_rsa.pub >> authorized_keys
b. 配置主机名
vi /etc/sysconfig/network
c. 修改Hosts
192.168.10.10 hadoop-master
2.配置环境变量
export JAVA_HOME=/opt/binary/jdk1.7.0_60
export HADOOP_HOME=/opt/binary/hadoop-2.2.0
export MAVEN_HOME=/opt/binary/apache-maven-3.2.1
export PROTOC_HOME=/opt/protoc
export PATH=$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin:$MAVEN_HOME/bin:$PROTOC_HOME/bin
3. 建立相关目录
mkdir -p dfs/name
mkdir -p dfs/data
mkdir -p temp
4. 配置hadoop
hadoop-env.sh
export JAVA_HOME=/opt/binary/jdk1.7.0_60
yarn-env.sh
export JAVA_HOME=/opt/binary/jdk1.7.0_60
core-site.xml
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://hadoop-master:9000</value>
</property>
<property>
<name>io.file.buffer.size</name>
<value>131072</value>
</property>
<property>
<name>hadoop.tmp.dir</name>
<value>file:/opt/data/temp</value>
</property>
<property>
<name>hadoop.proxyuser.hadoop.hosts</name>
<value>*</value>
</property>
<property>
<name>hadoop.proxyuser.hadoop.groups</name>
<value>*</value>
</property>
</configuration>
hdfs-site.xml
<configuration>
<property>
<name>dfs.namenode.secondary.http-address</name>
<value>hadoop-master:9001</value>
</property>
<property>
<name>dfs.namenode.name.dir</name>
<value>/opt/data/dfs/name</value>
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>/opt/data/dfs/data</value>
</property>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
</configuration>
yarn-site.xml
<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
</configuration>
slaves
hadoop-master
5. hdfs格式化
hdfs namenode -format
6. 启动
./start-all.sh