https://gitee.com/pingfanrenbiji/alluxio.git
https://docs.alluxio.io/os/user/stable/cn/deploy/Running-Alluxio-On-Docker.html
通过docker方式在本地部署
docker network create alluxio_nw
docker run -d --rm \
-p 19999:19999 \
-p 19998:19998 \
--net=alluxio_nw \
--name=alluxio-master \
-e ALLUXIO_JAVA_OPTS=" \
-Dalluxio.master.hostname=alluxio-master \
-Dalluxio.master.mount.table.root.ufs=/opt/alluxio/underFSStorage" \
-v /tmp/alluxio_ufs:/opt/alluxio/underFSStorage \
alluxio/alluxio master
docker run -d --rm \
-p 29999:29999 \
-p 30000:30000 \
--net=alluxio_nw \
--name=alluxio-worker \
--shm-size=3971.64MB \
-v /tmp/alluxio_ufs:/opt/alluxio/underFSStorage \
-e ALLUXIO_JAVA_OPTS=" \
-Dalluxio.worker.memory.size=3971.64MB \
-Dalluxio.master.hostname=alluxio-master \
-Dalluxio.worker.hostname=alluxio-worker" \
alluxio/alluxio worker
注1: shm-size和alluxio.worker.memory.size 具体多少 根据日志报错知道
Caused by: java.lang.IllegalStateException: tmpfs is smaller than the configured size: tmpfs size: 1024.00MB, configured size: 3971.64MB
注2:
大数据文件系统、必须明确开放master容器两个端口19999和19998和worker容器端口29999和30000。否则,客户端将无法与master和worker进行通信
http://127.0.0.1:19999/overview
./bin/alluxio fs mkdir /alluxiotest
docker cp /Users/mengfanxiao/Documents/work/code/simple-alluxio/README.MD 52f831088dd8:/opt/alluxio-2.3.0
./bin/alluxio fs copyFromLocal /opt/alluxio-2.3.0/README.MD /alluxiotest/
注:jar pom版本必须要和部署的alluxio版本一致
我部署的是 2.3.0版本的alluxio
java api依赖的版本号如下
<dependency>
<groupId>org.alluxio</groupId>
<artifactId>alluxio-core-client-fs</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>org.alluxio</groupId>
<artifactId>alluxio-core-common</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>com.codahale.metrics</groupId>
<artifactId>metrics-core</artifactId>
<version>3.0.0</version>
</dependency>
内存文件名。我在这块耽误了至少一下午时间 我用的是1.8版本的pom 去访问 2.3.0版本的alluxio 😂
至于为什么用1.8版本的 因为我百度了下 看到有一位网友用的1.8版本的 殊不知 人家部署的alluxio也是1.8版本的 。
因为版本不兼容的问题 会导致各种各样的问题 然后再去解决这些问题 肯定处理不好呀 因为本质是版本不兼容 所以这块浪费了一些时间
这里要反思下工作方法的问题
##读取默认配置
AlluxioProperties alluxioProperties=ConfigurationUtils.defaults();
##设置操作用户
alluxioProperties.set(PropertyKey.SECURITY_LOGIN_USERNAME, "alluxio");
AlluxioConfiguration alluxioConf = new InstancedConfiguration(alluxioProperties);
##目标文件
AlluxioURI inputPath = new AlluxioURI("/alluxiotest/README.MD");
##输出文件
AlluxioURI outputPath = new AlluxioURI("/alluxiotest/hello.txt");
##创建文件系统实例
FileSystem fileSystem = FileSystem.Factory.create(alluxioConf);
##打开目标文件
FileInStream is = fileSystem.openFile(inputPath);
CreateFilePOptions options = CreateFilePOptions.newBuilder().setWriteType(WritePType.CACHE_THROUGH).setRecursive(true).build();
##生成输出文件并上传到文件系统
FileOutStream os = fileSystem.createFile(outputPath, options);
IOUtils.copy(is, os);
is.close();
os.close();
查看操作结果
alluxio应用。注: 代码有一个设置操作用户的步骤
如果不设置会报错
Caused by: alluxio.exception.status.PermissionDeniedException: Permission denied: user=mengfanxiao, access=-w-, path=/alluxiotest/hello.txt: failed at alluxiotest, inode owner=alluxio, inode group=alluxio, inode mode=rwxr-xr-x
因为上面的代码是要获取文件 如果当前用不没有获取权限的话 会爆粗
查看目标文件的所属用户
./bin/alluxio fs ls /
内存文件,所以将当前操作用户设置为 alluxio
alluxioProperties.set(PropertyKey.SECURITY_LOGIN_USERNAME, "alluxio");
sudo vim /private/etc/hosts
添加
127.0.0.1 alluxio-worker
dscacheutil -flushcache
版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。
工作时间:8:00-18:00
客服电话
电子邮件
admin@qq.com
扫码二维码
获取最新动态