This topic describes how to access JindoFileSystem (JindoFS) from a Filesystem in Userspace (FUSE) client. FUSE allows you to use JindoFS in block storage mode and cache mode (only JFS Scheme supported).
Prerequisites
Background information
FUSE is a method provided by the Linux kernel to mount a file system. You can use
a FUSE client to map files in a JindoFS cluster to a local disk. Then, you can directly
access data in the JindoFS cluster without the need to use the hadoop fs -ls jfs://<namespace>/
command.
Mount a directory
Note Perform the following steps on each node of the cluster in sequence.
Read and write files
The following example shows how to read data from and write data to files in Python:
- Write data to a file in Python. Create a write.py script file, which contains the following content:
#!/usr/bin/env python36 with open("/mnt/jfs/test/test.txt",'w',encoding = 'utf-8') as f: f.write("my first file\n") f.write("This file\n\n") f.write("contains three lines\n")
- Read data from a file in Python. Create a read.py script file, which contains the following content:
#!/usr/bin/env python36 with open("/mnt/jfs/test/test.txt",'r',encoding = 'utf-8') as f: lines = f.readlines() [print(x, end = '') for x in lines]
Run the following command to read the data that is written to the test.txt file:[hadoop@emr-header-1 ~]$ ./read.py
The following information is returned:my first file This file
Unmount FUSE
Note Perform the following steps on each node of the cluster in sequence.