hadoop搭建

一、前期准备

  1.1 静态ip,请查看虚拟机安装不放呢

  1.2 hostname 以及 hosts文件修改

cat /etc/hostname
 不同的机器设置不同的名字
cat /etc/hosts
192.168.0.110 kyle1
192.168.0.111 kyle2
192.168.0.112 kyle3

  1.3 jdk安装(请见 https://www.cnblogs.com/KyleXu/p/9974962.html

  1.4 SSH免密码登陆

cd ~/.ssh/   # 如果不存在,执行一下 ssh localhost 就好了

# 生成密钥
ssh-keygen -t rsa  (一路回车)

Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:cvlMVKUdaY41l+IiSS2qAO9el9xGg/5MGZT554uhE0o root@kyle1
The key's randomart image is:
+---[RSA 2048]----+
|          + ..o..|
| .       * o +=o.|
|  o     = = o=oo |
|   o   o O o.o.  |
|  . . = S * +    |
|   . o E X . .   |
|  . . o * = o .  |
|   .   . = . .   |
|          .      |
+----[SHA256]-----+

# 导入公钥
cat id_rsa.pub >> authorized_keys 

# 另外两台机器上执行完毕之后,将另外两台机器的id_rsa.pub 粘贴到 第一台机器的 authorized_keys 里

# 将authorized_keys分发到另外两台机器上
scp authorized_keys root@kyle2:.ssh/authorized_keys 

# 测试
ssh kyle3

  1.5 关闭防火墙

systemctl stop firewalld.service
systemctl disable firewalld.service

 

 

二、下载

wget http://mirrors.hust.edu.cn/apache/hadoop/common/hadoop-2.8.5/hadoop-2.8.5.tar.gz

 

tar -zxvf hadoop-2.8.5.tar.gz -C /usr/local/

  

三、hadoop master节点配置

  配置hadoop的配置文件core-site.xml,hdfs-site.xml,mapred-site.xml,yarn-site.xml,slaves(都在/usr/local/hadoop-2.8.5/etc/hadoop )文件夹下

  3.1 core-site.xml

<configuration>
    <property>
    <name>fs.default.name</name>
    <value>hdfs://kyle1:9000</value>
  </property>
  <property>
    <name>hadoop.tmp.dir</name>
    <value>file:/usr/local/hadoop-2.8.5/tmp</value>
  </property>
</configuration>

  3.2 hdfs-site.xml

<configuration>
  <property>
    <name>dfs.replication</name>
    <value>2</value>
  </property>
  <property>
    <name>dfs.namenode.name.dir</name>
    <value>file:/usr/local/hadoop-2.8.5/dfs/name</value>
  </property>
  <property>
    <name>dfs.datanode.data.dir</name>
    <value>file:/usr/local/hadoop-2.8.5/dfs/data</value>
  </property>
  <property>
    <name>dfs.namenode.secondary.http-address</name>
    <value>kyle1:9001</value>
  </property>
    <property>
    <name>dfs.webhdfs.enabled</name>
    <value>true</value>
  </property>
</configuration>

  3.3  mapred-site.xml

cp mapred-site.xml.template mapred-site.xml

vim mapred-site.xml

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

  3.4 yarn-site.xml

NOTE: 第一个hostname是配置yarn主节点的域名,需要根据自己的情况配置

     <property>
    <name>yarn.resourcemanager.hostname</name>
    <value>kyle1</value>
  </property>
  <property>
    <name>yarn.nodemanager.aux-services</name>
    <value>mapreduce_shuffle</value>
  </property>

  3.5 slaves 

kyle2
kyle3

  3.6 hadoop-env.sh (/usr/local/hadoop-2.8.5/etc/hadoop)

export JAVA_HOME=/usr/local/java/jdk1.8.0_191

  

四、其他机器配置

scp -r hadoop-2.8.5 root@kyle2:/usr/local/
scp -r hadoop-2.8.5 root@kyle3:/usr/local/

 

五、配置环境变量

## hadoop
export HADOOP_HOME=/usr/local/hadoop-2.8.5
export PATH=$HADOOP_HOME/sbin:$PATH

  

六、格式化节点。

bin/hdfs namenode -format

 

七、启动

# 启动hdfs
sbin/start-dfs.sh

# 启动yarn
sbin/start-yarn.sh 

 

八、查看进程

[root@kyle1 hadoop-2.8.5]# jps
6634 SecondaryNameNode
2251 QuorumPeerMain
6478 NameNode

 

九、网页查看

http://kyle1:50070  (hdfs地址)

http://kyle1:8088 (yarn地址)

 

转载于:https://www.cnblogs.com/KyleXu/p/9985968.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值