赞
踩
hadoop 有三种部署方式
本地模式:
伪分布式模式:
集群模式:
系统环境: Cnetos7 64 位
Hdaoop版本: Apache Hdaoop hadoop-2.7.2.tar.gz
Jdk版本: jdk-8u211-linux-x64.tar.gz
连接失效可在评论区留言
[root@iZm5e3ig3sqqnu6j02pjn9Z ~]# wget http://archive.apache.org/dist/hadoop/common/hadoop-2.7.2/hadoop-2.7.2.tar.gz
这里以普通用户进行登录,需要root权限时,命令前加sudo
问题:
如果 sudo 提示错误信息
:用户没有在 sudoers 中
xx is not in the sudoers file. This incident will be reported.
解决:
[qg@iZm5e3ig3sqqnu6j02pjn9Z ~]$ su
Password:
[root@iZm5e3ig3sqqnu6j02pjn9Z qg]# vi /etc/sudoers
[root@iZm5e3ig3sqqnu6j02pjn9Z qg]# su qg
集群中每一个主机名与一个ip相对应,便于集群业务管理,使得集群中主机可以互相通过主机名进行访问
1.4.1 sudo vi /etc/sysconfig/network 修改配置
[qg@iZm5e3ig3sqqnu6j02pjn9Z ~]$ sudo vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=hdaoop01
1.4.2 使配置文件生效:
[qg@iZm5e3ig3sqqnu6j02pjn9Z ~]$ sudo hostname hdaoop01
[qg@iZm5e3ig3sqqnu6j02pjn9Z ~]$ exit
再登录,主机名已经改变
[qg@hdaoop01 ~]$
1.4.3 建立主机名与主机ip映射
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
#本机ip 主机名
192.168.x.x hadoop01
[qg@hdaoop01 ~]$ ping hadoop01
PING hadoop01 (172.31.51.134) 56(84) bytes of data.
64 bytes from iZm5e3ig3sqqnu6j02pjn9Z (172.31.51.134): icmp_seq=1 ttl=64 time=0.021 ms
xftp,FileZilla…
[qg@hdaoop01 hadoop]$ tar -zxvf jdk-linux-8u211-x64.tar.gz [qg@hdaoop01 hadoop]$ ll total 397512 -rw-r--r-- 1 root root 212046774 Feb 21 22:41 hadoop-2.7.2.tar.gz drwxr-xr-x 7 qg qg 4096 Apr 2 2019 jdk1.8.0_211 -rw-rw-r-- 1 qg qg 194990602 Feb 22 10:10 jdk-linux-8u211-x64.tar.gz [qg@hdaoop01 hadoop]$ cd jdk1.8.0_211/ [qg@hdaoop01 jdk1.8.0_211]$ ll total 26000 drwxr-xr-x 2 qg qg 4096 Apr 2 2019 bin -r--r--r-- 1 qg qg 3244 Apr 2 2019 COPYRIGHT drwxr-xr-x 3 qg qg 4096 Apr 2 2019 include -rw-r--r-- 1 qg qg 5213268 Mar 14 2019 javafx-src.zip drwxr-xr-x 5 qg qg 4096 Apr 2 2019 jre drwxr-xr-x 5 qg qg 4096 Apr 2 2019 lib -r--r--r-- 1 qg qg 44 Apr 2 2019 LICENSE drwxr-xr-x 4 qg qg 4096 Apr 2 2019 man -r--r--r-- 1 qg qg 159 Apr 2 2019 README.html -rw-r--r-- 1 qg qg 424 Apr 2 2019 release -rw-r--r-- 1 qg qg 21105019 Apr 2 2019 src.zip -rw-r--r-- 1 qg qg 112748 Mar 14 2019 THIRDPARTYLICENSEREADME-JAVAFX.txt -r--r--r-- 1 qg qg 149725 Apr 2 2019 THIRDPARTYLICENSEREADME.txt # 测试是否安装成功 [qg@hdaoop01 jdk1.8.0_211]$ cd bin/ [qg@hdaoop01 bin]$ ./java -version java version "1.8.0_211" Java(TM) SE Runtime Environment (build 1.8.0_211-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode)
2.3.1 修改配置文件 sudo vi /etc/profile
[qg@hdaoop01 jdk1.8.0_211]$ sudo vi /etc/profile
2.3.2 设置全局环境变量
# JAVA_HOME=java 安装目录
export JAVA_HOME=/home/qg/opt/hadoop/jdk1.8.0_211
export PATH=$PATH:$JAVA_HOME/bin
2.3.3 使配置生效
[qg@hdaoop01 jdk1.8.0_211]$ source /etc/profile
# 测试环境变量是配置成功
[qg@hdaoop01 jdk1.8.0_211]$ java -version
[qg@hdaoop01 hadoop]$ tar -zxvf hadoop-2.7.2.tar.gz [qg@hdaoop01 hadoop]$ ll total 397516 drwxr-xr-x 9 qg qg 4096 Jan 26 2016 hadoop-2.7.2 -rw-r--r-- 1 root root 212046774 Feb 21 22:41 hadoop-2.7.2.tar.gz drwxr-xr-x 7 qg qg 4096 Apr 2 2019 jdk1.8.0_211 -rw-rw-r-- 1 qg qg 194990602 Feb 22 10:10 jdk-linux-8u211-x64.tar.gz [qg@hdaoop01 hadoop]$ cd hadoop-2.7.2 [qg@hdaoop01 hadoop-2.7.2]$ ll total 52 drwxr-xr-x 2 qg qg 4096 Jan 26 2016 bin drwxr-xr-x 3 qg qg 4096 Jan 26 2016 etc drwxr-xr-x 2 qg qg 4096 Jan 26 2016 include drwxr-xr-x 3 qg qg 4096 Jan 26 2016 lib drwxr-xr-x 2 qg qg 4096 Jan 26 2016 libexec -rw-r--r-- 1 qg qg 15429 Jan 26 2016 LICENSE.txt -rw-r--r-- 1 qg qg 101 Jan 26 2016 NOTICE.txt -rw-r--r-- 1 qg qg 1366 Jan 26 2016 README.txt drwxr-xr-x 2 qg qg 4096 Jan 26 2016 sbin drwxr-xr-x 4 qg qg 4096 Jan 26 2016 share [qg@hdaoop01 hadoop-2.7.2]$
[qg@hdaoop01 ~]$ cd /home/qg/opt/hadoop/hadoop-2.7.2/etc/hadoop/ [qg@hdaoop01 hadoop]$ ll total 152 -rw-r--r-- 1 qg qg 4436 Jan 26 2016 capacity-scheduler.xml -rw-r--r-- 1 qg qg 1335 Jan 26 2016 configuration.xsl -rw-r--r-- 1 qg qg 318 Jan 26 2016 container-executor.cfg -rw-r--r-- 1 qg qg 774 Jan 26 2016 core-site.xml -rw-r--r-- 1 qg qg 3670 Jan 26 2016 hadoop-env.cmd -rw-r--r-- 1 qg qg 4224 Jan 26 2016 hadoop-env.sh -rw-r--r-- 1 qg qg 2598 Jan 26 2016 hadoop-metrics2.properties -rw-r--r-- 1 qg qg 2490 Jan 26 2016 hadoop-metrics.properties -rw-r--r-- 1 qg qg 9683 Jan 26 2016 hadoop-policy.xml -rw-r--r-- 1 qg qg 775 Jan 26 2016 hdfs-site.xml -rw-r--r-- 1 qg qg 1449 Jan 26 2016 httpfs-env.sh -rw-r--r-- 1 qg qg 1657 Jan 26 2016 httpfs-log4j.properties -rw-r--r-- 1 qg qg 21 Jan 26 2016 httpfs-signature.secret -rw-r--r-- 1 qg qg 620 Jan 26 2016 httpfs-site.xml -rw-r--r-- 1 qg qg 3518 Jan 26 2016 kms-acls.xml -rw-r--r-- 1 qg qg 1527 Jan 26 2016 kms-env.sh -rw-r--r-- 1 qg qg 1631 Jan 26 2016 kms-log4j.properties -rw-r--r-- 1 qg qg 5511 Jan 26 2016 kms-site.xml -rw-r--r-- 1 qg qg 11237 Jan 26 2016 log4j.properties -rw-r--r-- 1 qg qg 951 Jan 26 2016 mapred-env.cmd -rw-r--r-- 1 qg qg 1383 Jan 26 2016 mapred-env.sh -rw-r--r-- 1 qg qg 4113 Jan 26 2016 mapred-queues.xml.template -rw-r--r-- 1 qg qg 758 Jan 26 2016 mapred-site.xml.template -rw-r--r-- 1 qg qg 10 Jan 26 2016 slaves -rw-r--r-- 1 qg qg 2316 Jan 26 2016 ssl-client.xml.example -rw-r--r-- 1 qg qg 2268 Jan 26 2016 ssl-server.xml.example -rw-r--r-- 1 qg qg 2250 Jan 26 2016 yarn-env.cmd -rw-r--r-- 1 qg qg 4567 Jan 26 2016 yarn-env.sh -rw-r--r-- 1 qg qg 690 Jan 26 2016 yarn-site.xml
3.2.1 修改 hadoop-env.sh 配置文件
[qg@hdaoop01 hadoop]$ vi hadoop-env.sh
3.2.2 修改 core-site.xml 配置文件
[qg@hdaoop01 hadoop]$ vi core-site.xml
<configuration> <!-- 指定 使用哪种文件系统--> <property> <name>fs.defaultFS</name> <!-- 使用hdfs分布式系统--> <!-- hdfs系统地址 hdfs://hdfs集群主节点名称:9000(默认端口号)--> <!--因为是伪分布式,所有节点在同一台机子上,故节点名称为主机名--> <value>hdfs://hadoop01:9000</value> </property> <!-- 指定hadoop进程工作目录,hadoop运行时产生文件的存储路径--> <property> <name>hadoop.tmp.dir</name> <!--数据放在hadoop 的安装目录下是/tmp下--> <value>/home/qg/opt/hadoop/hadoop-2.7.2/tmp/</value> </property> </configuration>
3.2.3 修改 hdfs-site.xml 配置文件
[qg@hdaoop01 hadoop]$ vi hdfs-site.xml
<configuration>
<!-- 设置hdfs副本数量:-->
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
</configuration>
3.2.4 修改mapred-site.xml.template 配置
[qg@hdaoop01 hadoop]$ mv mapred-site.xml.template mapred-site.xml
[qg@hdaoop01 hadoop]$ vi mapred-site.xml
<configuration>
<!-- 通知框架mappreduce使用YARN -->
<!-- 使得mappreduce 在资源调度集群(yarn)上跑-->
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
</configuration>
3.2.5 修改yarn-site.xml 配置
[qg@hdaoop01 hadoop]$ vi yarn-site.xml
<configuration>
<!-- 配置yarn 集群主节点,因为是伪分布式,所以是本机-->
<property>
<name>yarn.resourcemanager.hostname</name>
<value>hadoop01</value>
</property>
<!-- reducer取数据的方式是mapreduce_shuffle -->
<!-- nodemanager 从节点 -->
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
</configuration>
3.3.1 修改配置文件 sudo vi /etc/profile
[qg@hdaoop01 jdk1.8.0_211]$ sudo vi /etc/profile
3.3.2 设置全局环境变量
# HADOOP_HOME=hadoop 安装目录
export HADOOP_HOME=/home/qg/opt/hadoop/hadoop-2.7.2
export PATH=$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin
3.3.3 使配置生效
[qg@hdaoop01 ~]$ source /etc/profile
# 测试环境变量是配置成功
[qg@hdaoop01 ~]$ hadoop version
Hadoop 2.7.2
Subversion https://git-wip-us.apache.org/repos/asf/hadoop.git -r b165c4fe8a74265c792ce23f546c64604acf0e41
Compiled by jenkins on 2016-01-26T00:08Z
Compiled with protoc 2.5.0
From source with checksum d0fda26633fa762bff87ec759ebe689c
This command was run using /home/qg/opt/hadoop/hadoop-2.7.2/share/hadoop/common/hadoop-common-2.7.2.jar
hadoop namenode -format
[qg@hdaoop01 ~]$ hadoop namenode -format
[qg@hdaoop01 ~]$ start-dfs.sh
Starting namenodes on [hadoop01]
hadoop01: starting namenode, logging to
localhost: starting datanode, logging to
starting secondarynamenode, logging to
[qg@hdaoop01 current]$ jps
11057 SecondaryNameNode
10712 NameNode
10873 DataNode
11166 Jps
[qg@hdaoop01 current]$ start-yarn.sh
starting resourcemanager,logging to
localhost: starting nodemanager, logging to
[qg@hdaoop01 hadoop-2.7.2]$ jps
12049 Jps
11057 SecondaryNameNode
11426 ResourceManager
10712 NameNode
10873 DataNode
11738 NodeManager
SSH 登录验证有两种方式: 1.密码认证 2.密钥认证
密钥认证:
假如有两台主机 test01, test02
1.密钥分发:
1) test01 生成一对密钥: 公钥,私钥
2) test01 将公钥复制一份给test02
3)test02 将test01的公钥放入到授权列表文件中
2.密钥认证:
1) test01 请求登录 test02
eg: ssh 用户名@test02
2) test02 查看授权文件列表中是否有test01的公钥
3) 如果test02 有test01 的公钥, test02会用公钥加密一串随机字符串,发送给test01
4) test01收到test02发送过来的字符串后, 用私钥解密,然后将解密结果发送给test02
5) test02 将收到test01 发送的解密结果和自己发送的随机字符串进行比对,如果一致,则通过验证
[qg@hdaoop01 ~]$ ssh-keygen -t rsa [qg@hdaoop01 ~]$ cd /home/qg/.ssh/ [qg@hdaoop01 .ssh]$ ll total 12 -rw------- 1 qg qg 1679 Feb 23 11:09 id_rsa -rw-r--r-- 1 qg qg 393 Feb 23 11:09 id_rsa.pub -rw-r--r-- 1 qg qg 524 Feb 22 14:03 known_hosts [qg@hdaoop01 .ssh]$ ssh-copy-id hadoop01 /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/qg/.ssh/id_rsa.pub" /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys qg@hadoop01's password: # 输入免密 [qg@hdaoop01 .ssh]$ ll total 16 -rw------- 1 qg qg 393 Feb 23 11:15 authorized_keys -rw------- 1 qg qg 1679 Feb 23 11:09 id_rsa -rw-r--r-- 1 qg qg 393 Feb 23 11:09 id_rsa.pub -rw-r--r-- 1 qg qg 524 Feb 22 14:03 known_hosts
测试免密登录:
[qg@hdaoop01 .ssh]$ start-dfs.sh Starting namenodes on [hadoop01] hadoop01: starting namenode, logging to /home/qg/opt/hadoop/hadoop-2.7.2/logs/hadoop-qg-namenode-hdaoop01.out hadoop01: starting datanode, logging to /home/qg/opt/hadoop/hadoop-2.7.2/logs/hadoop-qg-datanode-hdaoop01.out Starting secondary namenodes [0.0.0.0] 0.0.0.0: starting secondarynamenode, logging to /home/qg/opt/hadoop/hadoop-2.7.2/logs/hadoop-qg-secondarynamenode-hdaoop01.out [qg@hdaoop01 .ssh]$ start-yarn.sh starting yarn daemons starting resourcemanager, logging to /home/qg/opt/hadoop/hadoop-2.7.2/logs/yarn-qg-resourcemanager-hdaoop01.out hadoop01: starting nodemanager, logging to /home/qg/opt/hadoop/hadoop-2.7.2/logs/yarn-qg-nodemanager-hdaoop01.out [qg@hdaoop01 .ssh]$ jps 31715 NodeManager 31059 NameNode 31368 SecondaryNameNode 32027 Jps 31198 DataNode 31583 ResourceManager
[qg@hdaoop01 hadoop-2.7.2]$ vi /home/qg/opt/hadoop/hadoop-2.7.2/etc/hadoop/slaves
#localhost 默认值
hadoop01
[qg@hdaoop01 hadoop]$ sudo firewall-cmd --zone=public --add-port=50070/tcp --permanent
success
[qg@hdaoop01 hadoop]$ sudo firewall-cmd --zone=public --add-port=50075/tcp --permanent
success
[qg@hdaoop01 hadoop]$ sudo firewall-cmd --reload
success
[qg@hdaoop01 hadoop]$ sudo firewall-cmd --zone=public --list-ports
50070/tcp 50075/tcp
5.1.1 ip地址访问
5.1.2 主机名+端口 号访问
[qg@hdaoop01 hadoop]$ sudo firewall-cmd --zone=public --add-port=8088/tcp --permanent
success
[qg@hdaoop01 hadoop]$ sudo firewall-cmd --reload
success
[qg@hdaoop01 hadoop]$ sudo firewall-cmd --zone=public --list-ports
50070/tcp 8088/tcp
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。