吐血整理,搭建了两遍,亲测可用!!!
我买的是阿里云2c4g的服务器,使用的是centos 7.7版本。在搭建过程中踩了不少坑,本篇文章希望对大家有用
uname-a
yumupdate
yuminstall-yyum-utilsdevice-mapper-persistent-datalvm2
sudoyum-config-manager--add-repohttps://download.docker.com/linux/centos/docker-ce.repo
cd/mntmkdirdockercddocker
yumlistdocker-ce--showduplicates|sort-r
yuminstalldocker-ce-18.06.3.ce
systemctlstartdockersystemctlenabledocker
dockerversion
cd/mntmkdirdockercddocker
wgethttps://mirrors.aliyun.com/docker-ce/linux/ubuntu/dists/新西兰在哪个洲bionic/pool/stable/amd64/containerd.io_1.2.6-3_amd64.debwgethttps://mirrors.aliyun.com/docker-ce/linux/ubuntu/dists/bionic/pool/stable/amd64/docker-ce-cli_19.03.9~3-0~ubuntu-bionic_amd64.debwgethttps://mirrors.aliyun.com/docker-ce/linux/ubuntu/dists/bionic/pool/stable/amd64/docker-ce_19.03.9~3-0~ubuntu-bionic_amd64.deb
sudodpkg-i*.deb
rvicedockerstart
dockerpullcentos
dockerimages
cd/mnt/dockermkdirsshcdsshvidockerfile
fromcentosmaintainerdysrunyuminstall-yopenssh-rversudorund-i's/upamyes/upamno/g'/etc/ssh/sshd_configrunyuminstall-yopenssh-clientsrunecho"root:1234"|chpasswdrunecho"rootall=(all)all">>/etc/sudoersrunssh-keygen-tdsa-f/etc/ssh/ssh_host_dsa_keyrunssh-keygen-trsa-f/etc/ssh/ssh_host_rsa_keyrunmkdir/var/run/sshdexpo22cmd["/usr/sbin/sshd","-d"]
保存并退出
dockerbuild-t="centos7-ssh".
dockerrun-d--name=centos7.sshcentos7-sshdockerrun-d--name=centos7.ssh2centos7-sshdockerrun-d--name=centos7.ssh3centos7-ssh
cd/mnt/dockermkdirhadoopcdhadoop
//下载hadoop,构建镜像时使用wgethttps://mirrors.bfsu.edu.cn/apache/hadoop/common/hadoop-2.9.2/hadoop-2.9.2.tar.gz//下载jdk,构建镜像时使用wget--no-cookies--no-check-certificate--header"cookie:gpw_e24=http%3a%2f%2fwww.oracle.com%2f;oraclelicen=accept-cu贺年图片rebackup-cookie""http://download.oracle.com/otn-pub/java/jdk/8u141-b15/336fa29ff2bb4ef291e347e091f7f4a7/jdk-8u141-linux-x64.tar.gz"
vidockerfile
fromcentos7-sshaddjdk-8u141-linux-x64.tar.gz/usr/local/runmv/usr/local/jdk1.8.0_141/usr/local/jdk1.8envjava_home/usr/local/jdk1.8envpath$java_home/bin:$pathaddhadoop-2.9.2.tar.gz/usr/localrunmv/usr/local/hadoop-2.9.2/usr/local/hadoopenvhadoop_home/usr/local/hadoopenvpath$hadoop_home/bin:$pathrunyuminstall-ywhichsudo
保存并退出
dockerbuild-t="hadoop".
dockerrun--namehadoop0--hostnamehadoop0-d-p-p50070:50070-p8088:8088hadoopdockerrun--namehadoop1--hostnamehadoop1-d-phadoopdockerrun--namehadoop2--hostnamehadoop2-d-phadoop
vim~/.bashrc
增加下面的配置
aliasll='ls-l'
保存退出
source~/.bashrc
yuminstallnet-toolsyuminstallvim
使用ifconfig命令查看自己的ip,改为自己服务器的ip
172.18.0.5hadoop0172.18.0.6hadoop1172.18.0.7hadoop2
rm-rf/etc/localtimeln-s/usr/share/zoneinfo/asia/shanghai/etc/localtime
在每台服务器上都执行以下命令,执行后会有多个输入提示,不用输入任何内容,全部直接回车即可
ssh-keygen
输入下面命令时,需要用到上面设置的密码1234
ssh-copy-id-i/root/.ssh/id_rsa-p22root@hadoop0ssh-copy-id-i/root/.ssh/id_rsa-p22root@hadoop1ssh-copy-id-i/root/.ssh/id_rsa-p22root@hadoop2
cd/usr/local/hadoopmkdirtmphdfsmkdirhdfs/datahdfs/name
vim/usr/local/hadoop/etc/hadoop/core-site.xml
在 块儿中添加:
<property><name>fs.defaultfs</name><value>hdfs://hadoop0:9000</value></property><property><name>hadoop.tmp.dir</name><value>file:/usr/local/hadoop/tmp</value></property><property><name>io.file.buffer.size</name><value>131702</value></property>
vim/usr/local/hadoop/etc/hadoop/hdfs-site.xml
在 块儿中添加:
<property><name>dfs.namenode.name.dir</name><value>file:/usr/local/hadoop/hdfs/name</value></property><property><name>dfs.datanode.data.dir</name><value>file:/usr/local/hadoop/hdfs/data</value></property><property><name>dfs.replication</name><value>2</value></property><property><name>dfs.namenode.condary.http-address</name><value>hadoop0:9001</value>菲律宾的文化</property><property><name>dfs.webhdfs.enabled</name><value>true</value></property>
这个文件默认不存在,需要从 mapred-site.xml.template 复制过来
cp/usr/local/hadoop/etc/hadoop/mapred-site.xml.template/usr/local/hadoop/etc/hadoop/mapred-site.xml
编辑文件
vim/usr/local/hadoop/etc/hadoop/mapred-site.xml
在 块儿中添加:
<property><name>mapreduce.framework.name</name><value>yarn</value></property><property><name>mapreduce.jobhistory.address</name><value>hadoop0:10020</value></property><property><name>mapreduce.jobhistory.webapp.address</name><value>hadoop0:19888</value></property>
vim/usr/local/hadoop/etc/hadoop/yarn-site.xml
在 块儿中添加:
<property><name>yarn.nodemanager.aux-rvices</name><value>mapreduce_shuffle</value></property><property><name>yarn.nodemanager.auxrvices.mapreduce.shuffle.class</name><value>org.apache.hadoop.mapred.shufflehandler</value></property><property><name>yarn.resourcemanager.address</name><value>hadoop0:80碳酸氢钠与盐酸反应32</value></property><property><name>yarn.resourcemanager.scheduler.address</name><value>hadoop0:8030</value></property><property><name>yarn.resourcemanager.resource-tracker.address</name><value>hadoop0:8031</value></property><property><name>yarn.resourcemanager.admin.address</name><value>hadoop0:8033</value></property><property><name>yarn.resourcemanager.webapp.address</name><value>hadoop0:8088</value></property>
vim/usr/local/hadoop/etc/hadoop/slaves
删除已有内容,添加:
hadoop1hadoop2
vim/usr/local/hadoop/etc/hadoop/hadoop-env.sh
找到 export java_home=${java_home},改为自己java_home的绝对路径
exportjava_home=/usr/local/jdk1.8
scp-r/usr/local/hadoophadoop1:/usr/localscp-r/usr/local/hadoophadoop2:/usr/local
在每台服务器上都执行:
vim~/.bashrc
增加内容
exportpath=$path:/usr/local/hadoop/bin:/usr/local/hadoop/sbin
保存退出,重新加载资源
source~/.bashrc
在master启动hadoop,从节点会自动启动
hdfsnamenode-format
hadoop-daemon.shstartnamenodehadoop-daemon.shstartdatanodestart-dfs.shstart-yarn.shmr-jobhistory-daemon.shstarthistoryrver
如果您使用的也是阿里云服务器,那需要在阿里云客户端调整安全组,阿里云默认只开放22端口,所以需要把50070、8088都开通
端口号.png
浏览器中访问:
http://服务器ip:50070/
图片1.png
http://服务器ip:8088/
hdfsdfs-mkdir-p/usr/local/hadoop/inputhdfsdfs-put/usr/local/hadoop/etc/hadoop/kms*.xml/usr/local/hadoop/input
http://服务器ip:50070/,在文件浏览页面查看
验证hdfs.png
hadoopjar/usr/local/hadoop/第三用英语怎么说share/hadoop/mapreduce/hadoop-mapreduce-examples-2.9.2.jargrep/usr/local/hadoop/input/usr/local/hadoop/output'dfs[a-z.]+'
验证mapreduce.png
本文发布于:2023-04-05 07:06:57,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/zuowen/8edd1a9bba93c091757b79778e73b012.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:阿里云端口开放无效(阿里云服务器80端口开启方法).doc
本文 PDF 下载地址:阿里云端口开放无效(阿里云服务器80端口开启方法).pdf
留言与评论(共有 0 条评论) |