您好,登录后才能下订单哦!
这篇文章主要介绍HDFS之伪分布式集群如何搭建,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!
1.安装前准备
1.1查看虚拟机ip [root@localhost ~]# ifconfig
得到hadoop01的ip:192.168.88.155
1.2修改ip映射关系
[root@localhost ~]# vi /etc/hosts
在里面添加如下记录,保存退出
192.168.88.155 hadoop01
1.3关闭防火墙
查看防护墙状态service iptables status
关闭service iptables stop
查看防火墙开机启动状态 chkconfig iptables --list
关闭开机启动 chkconfig iptables off
1.4安装JDK1.7参看另一篇文章
查看是否安装成功[root@localhost ~]# java -version
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) Client VM (build 24.79-b02, mixed mode)
出现以上信息表示安装成功
2.配置hadoop
2.1下载hadoop包
[root@localhost ~]# wget http://apache.fayea.com/hadoop/common/hadoop-1.2.1/hadoop-1.2.1.tar.gz
2.2解压
[root@localhost ~]# tar -zxvf hadoop-1.1.2.tar.gz -C /cloud/
2.3配置hadoop伪分布式(要修改4个文件)
第一个:hadoop-env.sh
[root@localhost cloud]# cd /cloud/hadoop-1.2.1/conf/
添加下面的字段export JAVA_HOME=/usr/lib/java/java-7-sun
第二个:core-site.xml
vim core-site.xml
<configuration>
<!-- destine HDFS's namenode address -->
<property>
<name>fs.default.name</name>
<value>hdfs://hadoop01:9000</value>
</property>
<!-- destine hadoop store directory when run the programe -->
<property>
<name>hadoop.tmp.dir</name>
<value>/cloud/hadoop-1.2.1/tmp</value>
</property>
</configuration>
第三个:hdfs-site.xml
vim hdfs-site.xml
<configuration>
<!-- configurate amout about HDFS fuben-->
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
</configuration>
第四个:mapred-site.xml
vim mapred-site.xml
<configuration>
<!-- 指定jobtracker地址 -->
<property>
<name>mapred.job.tracker</name>
<value>hadoop01:9001</value>
</property>
</configuration>
2.4将hadoop添加到环境变量
vim /etc/profile
export JAVA_HOME=/usr/lib/java/java-7-sun
export HADOOP_HOME=/cloud/hadoop-1.1.2
export PATH=$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin
source /etc/profile
2.5格式化HDFS
[root@localhost conf]# cd ../
[root@localhost hadoop-1.2.1]# cd bin
[root@localhost bin]# ./hadoop namenode -format
2.6启动hadoop
[root@localhost bin]# sh start-all.sh
2.7验证集群是否启动成功
2.7.1利用jps
[root@localhost sbin]# jps
12152 JobTracker
13835 Jps
11952 DataNode
12298 TaskTracker
11815 NameNode
12080 SecondaryNameNode
2.7.2利用netstat
[root@localhost sbin]# netstat -nltp
jpsActive Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 3605/portmap
tcp 0 0 0.0.0.0:851 0.0.0.0:* LISTEN 3637/rpc.statd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 3857/cupsd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 3964/sendmail: acce
tcp 0 0 :::50020 :::* LISTEN 11952/java
tcp 0 0 :::46087 :::* LISTEN 12080/java
tcp 0 0 ::ffff:192.168.88.155:9000 :::* LISTEN 11815/java
tcp 0 0 ::ffff:192.168.88.155:9001 :::* LISTEN 12152/java
tcp 0 0 :::50090 :::* LISTEN 12080/java
tcp 0 0 :::50060 :::* LISTEN 12298/java
tcp 0 0 :::50030 :::* LISTEN 12152/java
tcp 0 0 :::42256 :::* LISTEN 12152/java
tcp 0 0 ::ffff:127.0.0.1:42194 :::* LISTEN 12298/java
tcp 0 0 :::50070 :::* LISTEN 11815/java
tcp 0 0 :::48758 :::* LISTEN 11815/java
tcp 0 0 :::22 :::* LISTEN 3848/sshd
tcp 0 0 :::50010 :::* LISTEN 11952/java
tcp 0 0 :::50075 :::* LISTEN 11952/java
tcp 0 0 :::51163 :::* LISTEN 11952/java
还可以通过浏览器的方式验证
http://192.168.1.110:50070 (hdfs管理界面)
http://192.168.1.110:50030 (mr管理界面)
在这个文件中添加linux主机名和IP的映射关系
C:\Windows\System32\drivers\etc
3.配置ssh免登陆
生成ssh免登陆密钥
ssh-keygen -t rsa
执行完这个命令后,会生成两个文件id_rsa(私钥)、id_rsa.pub(公钥)
将公钥拷贝到要免登陆的机器上
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
4.配置ssh免登陆
生成ssh免登陆密钥
cd ~,进入到我的home目录
cd .ssh/
ssh-keygen -t rsa (四个回车)
执行完这个命令后,会生成两个文件id_rsa(私钥)、id_rsa.pub(公钥)
将公钥拷贝到要免登陆的机器上
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys(文件)
或
ssh-copy-id -i localhost
补充
(2)修改sshd_config文件
# vi /etc/ssh/sshd_config //开启以下内容
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
service sshd restart
ssh username@serverhost
以上是“HDFS之伪分布式集群如何搭建”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注亿速云行业资讯频道!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。