本文共 5793 字,大约阅读时间需要 19 分钟。
注意:这里使用单个 master。 但是,这个单个 master 在 Alluxio 集群中存在单点故障(SPOF),即如果该机器或进程不可用,整个集群将不可用。
采用 3 台虚拟机
主机名 | IP地址 | 角色 |
---|---|---|
node1 | 192.168.xxx.xx1 | master |
node2 | 192.168.xxx.xx2 | worker |
node3 | 192.168.xxx.xx3 | worker |
软件 | 版本 |
---|---|
JDK | jdk1.8.0_281 |
HADOOP | hadoop-2.7.3 |
ALLUXIO | alluxio-2.1.0 |
三台虚拟机可以互相免密登录
完全分布式安装
以上配置安装参考:
在 node1 上,下载、解压、配置环境变量:
[root@node1 opt]# tar -zxvf alluxio-2.1.0-bin.tar.gz[root@node1 opt]# lsalluxio-2.1.0 alluxio-2.1.0-bin.tar.gz hadoop-2.7.3[root@node1 opt]# vi /etc/profile[root@node1 opt]# source /etc/profile [root@node1 opt]# cat /etc/profile # /etc/profile...export JAVA_HOME=/opt/jdk1.8.0_281export HADOOP_HOME=/opt/hadoop-2.7.3export ALLUXIO_HOME=/opt/alluxio-2.1.0export PATH=.:$HADOOP_HOME/bin:$JAVA_HOME/bin:$ALLUXIO_HOME/bin:$PATH
将 /etc/profile
文件分发到其他三个节点,并执行 source /etc/profile
[root@node1 opt]# scp /etc/profile node2:/etc.....[root@node1 opt]# source /etc/profile
配置配置文件:
[root@node1 conf]# pwd/opt/alluxio-2.1.0/conf[root@node1 conf]# cat alluxio-site.properties ...alluxio.master.hostname=node1alluxio.master.mount.table.root.ufs=hdfs://node1:9000/alluxio[root@node1 conf]# cat mastersnode1[root@node1 conf]# cat workersnode2node3node4[root@node1 conf]# cat alluxio-env.shexport JAVA_HOME=/opt/jdk1.8.0_281
将配置文件复制到所有其他 Alluxio 节点:
# 要在各个节点安装RSYNC:yum -y install RSYNC[root@node1 alluxio-2.1.0]# bin/alluxio copyDir conf/RSYNC'ing /opt/alluxio-2.1.0/conf to masters...node1RSYNC'ing /opt/alluxio-2.1.0/conf to workers...node2node3node4
将 Alluxio 挂载到本地磁盘
[root@node1 alluxio-2.1.0]# bin/alluxio-mount.sh Mount workers
检查 Alluxio 运行环境
[root@node1 alluxio-2.1.0]# bin/alluxio validateEnv master[root@node1 alluxio-2.1.0]# bin/alluxio validateEnv workers
在 node1 节点上,使用以下命令进行格式化
# 在首次启动Alluxio之前,必须先格式化[root@node1 alluxio-2.1.0]# bin/alluxio formatExecuting the following command on all worker nodes and logging to /opt/alluxio-2.1.0/logs/task.log: /opt/alluxio-2.1.0/bin/alluxio formatWorkerWaiting for tasks to finish...All tasks finishedExecuting the following command on all master nodes and logging to /opt/alluxio-2.1.0/logs/task.log: /opt/alluxio-2.1.0/bin/alluxio formatJournalWaiting for tasks to finish...All tasks finished
在 node1 节点上,使用以下命令启动 Alluxio 集群
[root@node1 alluxio-2.1.0]# bin/alluxio-start.sh all[root@node1 alluxio-2.1.0]# jps1809 NameNode2082 ResourceManager57514 AlluxioMaster57836 AlluxioJobMaster59004 Jps58317 AlluxioProxy[root@node2 opt]# jps30433 AlluxioWorker1988 NodeManager1815 DataNode30585 AlluxioJobWorker30762 AlluxioProxy31165 Jps1902 SecondaryNameNode
浏览器输入 http://node1:19999/
查看 web 界面
测试:
[root@node1 alluxio-2.1.0]# bin/alluxio fs mkdir /testSuccessfully created directory /test[root@node1 alluxio-2.1.0]# bin/alluxio fs ls /drwxr-xr-x root root 0 NOT_PERSISTED 04-02-2021 14:20:06:985 DIR /test# 在 Alluxio 中读写示例文件[root@node1 alluxio-2.1.0]# bin/alluxio runTests# 挂载目录下查看[root@node1 alluxio-2.1.0]# hadoop fs -ls /alluxioFound 1 itemsdrwxr-xr-x - root root 0 2021-04-02 14:21 /alluxio/default_tests_files
再次在 web 查看
问题一:安装 2.5.0 版本时,出现 No Under File System Factory found for: hdfs://node1:9000/alluxio/underFSStorage
错误。
问题二:执行 alluxio-start.sh all
命令重新启动 Alluxio 后,AlluxioWorker 进程启动失败,出现 WARN RetryUtils - Failed to load cluster default configuration with master (attempt 16): alluxio.exception.status.UnavailableException: Failed to handshake with master node1:19998 to load cluster default configuration values: UNAVAILABLE: io exception
。执行 alluxio-start.sh all Mount
则成功启动。
将 Alluxio Client 的 Jar 包包含在各个 MapReduce 节点的 classpaths 中。
[root@node1 ~]# cd /opt/alluxio-2.1.0/client/[root@node1 client]# lsalluxio-2.1.0-client.jar presto[root@node1 client]# cp alluxio-2.1.0-client.jar /opt/hadoop-2.7.3/share/hadoop/mapreduce/[root@node1 client]# scp alluxio-2.1.0-client.jar node2:/opt/hadoop-2.7.3/share/hadoop/mapreduce/.....
在 node1 节点上,将以下两个属性添加到 core-site.xml 文件中
fs.alluxio.impl alluxio.hadoop.FileSystem The Alluxio FileSystem (Hadoop 1.x and 2.x) fs.AbstractFileSystem.alluxio.impl alluxio.hadoop.AlluxioFileSystem The Alluxio AbstractFileSystem (Hadoop 2.x)
在 node1 节点上,修改 hadoop-env.sh 文件中的 $HADOOP_CLASSPATH
[root@node1 hadoop]# cat hadoop-env.sh.....export HADOOP_CLASSPATH=/opt/alluxio-2.1.0/client/alluxio-2.1.0-client.jar:${HADOOP_CLASSPATH}.....
将上述修改的 core-site.xml 和 hadoop-env.sh 文件分发到其他节点
[root@node1 hadoop]# scp hadoop-env.sh node2:/opt/hadoop-2.7.3/etc/hadoop/.....[root@node1 hadoop]# scp core-site.xml node2:/opt/hadoop-2.7.3/etc/hadoop/.....
检查 MapReduce 与 Alluxio 的集成
[root@node1 alluxio-2.1.0]# integration/checker/bin/alluxio-checker.sh mapreduce.....***** Integration test passed. *****
在 Alluxio 中加入输入文件,在 Alluxio 目录中运行:
[root@node1 ~]# alluxio fs copyFromLocal wc.txt /Copied file:///root/wc.txt to /[root@node1 ~]# alluxio fs cat /wc.txtaabbaacc[root@node1 ~]# alluxio fs ls /-rw-r--r-- root root 12 PERSISTED 04-03-2021 21:58:56:558 100% /wc.txt
运行一个 WordCount 的 MapReduce 作业
[root@node1 ~]# hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.3.jar wordcount \alluxio://node1:19998/wc.txt \alluxio://node1:19998/wc-out
查看结果
[root@node1 ~]# alluxio fs ls /wc-out-rw-r--r-- root root 0 PERSISTED 04-03-2021 22:01:52:905 100% /wc-out/_SUCCESS-rw-r--r-- root root 15 PERSISTED 04-03-2021 22:01:51:718 100% /wc-out/part-r-00000[root@node1 ~]# alluxio fs cat /wc-out/part-r-00000aa 2bb 1cc 1
转载地址:http://nhkbz.baihongyu.com/