Mounting a Parallel File System
Before using obsfs to manage your objects on OBS, you need to mount an OBS parallel file system to your local file system. Once the parallel file system is mounted, it works like a local directory. For example, you can upload an object to OBS simply by saving it to the mount point.
Traffic consumed by parallel file systems after they are mounted to ECSs through obsfs is measured as OBS traffic.
Constraints
- obsfs only supports the mounting of OBS parallel file systems but not buckets.
- The local directory to which the parallel file system is mounted needs not to be empty. But its original files will be unavailable after the parallel file system is mounted. They are recovered when the parallel file system is unmounted. Therefore, it is recommended that you use an empty directory as the target directory for mounting a parallel file system.
- Files or folders in the mounted directory do not support hard link commands.
- The number of directory levels cannot exceed 45.
- If a parallel file system is manually mounted by running a command, it needs to be mounted again every time the Linux is restarted.
- The actual size and used space of a parallel file system vary with your actual usage.
You can configure auto mounting of a parallel file system upon startup. For details, see Mounting a Parallel File System Automatically upon Startup.
Prerequisites
- obsfs has been obtained. For details, see Method 1: Download and Install obsfs or Method 2: Generating obsfs by Compilation.
- obsfs has been initialized. For details, see Initializing obsfs.
- The mount point already exists in the local file system.
You can run the mkdir command to create a directory for mounting a parallel file system. For example, to create a directory named mountpoint, the command is:
mkdir mountpoint
Mounting a Parallel File System Manually
- Open the CLI.
- Run the cd command to go to the directory where obsfs is located.
- Run the mount command in the following format:
./obsfs Parallel file system name Local mount point -o url=Region endpoint address -o passwd_file=Key file path -o use_ino Other mount parameters
- Parallel file system name: name of the parallel file system to be mounted
- Mount point: the absolute or relative path of the directory on which a parallel file system is to be mounted
- Region endpoint address: Obtain the region information and endpoint address according to the region where the mounted parallel file system resides. For details, see Regions and Endpoints.
- Mount parameters:
Mount parameters, excepting passwd_file and use_ino, are optional. Select proper parameters according to your actual needs. The format is as follows: -o Parameter=Value. If you do not need to specify a parameter value, use only -o Parameter. Table 1 lists OBS mount parameters and their descriptions.
For details about obsfs mount parameter configurations, run the ./obsfs --help command to learn more.
Table 1 obsfs mount parameters Parameter
Value
Description
passwd_file
Type: String
Value: Set this parameter to the path of the access key file configured in Initializing obsfs.
The access key file contains the AK and SK information required for access obsfs.
use_ino
Required
If this parameter is specified, obsfs allocates the inode number.
big_writes
Not required
After the configuration, the maximum size of the cache can be modified.
max_write
Type: Integer
Recommended value: 128 KB
This parameter is valid only when big_writes is configured. The default write size is 4 KB. The recommended value is 128 KB.
nonempty
Not required
This parameter allows the mount point to be a non-empty directory.
allow_other
Not required
This parameter allows other users to access the parallel file system.
max_background
Type: Integer
Recommended value: 100
You can use this parameter to set the maximum number of waiting requests in the background.
use_path_request_style
Not required
Indicates the path-based access (legacy API). If this parameter is configured, you need to use the specified endpoint address to access OBS.
NOTE:If the value of the URL in the command is an IP address, this parameter must be carried in the mount command. Otherwise, a domain name resolution error is reported.
umask
Not required
This parameter masks the file permissions. The umask command is executed upon each access to the file system, and automatically configures the mask for new permissions.
obsfslog
Not required
This parameter enables the loading of log configuration parameters from the configuration file, including the log mode and level. You can change the log level without restarting the process when this parameter is enabled.
NOTE:The path of the configuration file is: /etc/obsfsconfig. If you want to use this parameter, you need to manually create the configuration file path on the local host and write the content by referring to the following example and comments.
An example of the configuration file content:
//Log mode. The value 0 indicates that the log mode is displayed on the client. If the value is 1, the log file is generated in the following path: /var/log/obsfs, which is named after the process ID. If the value is 2, the log is written into the system log. dbglogmode=1 //Log level. dbg, info, warn, err, crit. dbglevel=info
- Run the following command to view the result:
df -h
If the information similar to the following is displayed, the parallel file system is successfully mounted:
Filesystem Size Used Avail Use% Mounted on obsfs 256T 0 256T 0% /path/to/mountpoint
The actual size and used space of a parallel file system vary with your actual usage.
If the preceding information is not displayed, the parallel file system fails to be mounted. In this case, you can add the following parameters to the command, so that the mount process and detailed debug logs are displayed in the command output:
-d -d -f -o f2 -o curldbg
Then you can locate the fault based on the error information. For details about troubleshooting of common faults, see Failure in Mounting a Parallel File System.
Command Example
In this example, the filesystem001 parallel file system and the access key file path /etc/passwd-obsfs in CN North-Beijing1 region are used as the prerequisites for mounting an OBS parallel file system.
- Mount the parallel file system filesystem001 to the mount point /mnt/mount_path/ and allow the directory to be non-empty.
./obsfs filesystem001 /mnt/mount_path/ -o url=obs.cn-north-1.myhuaweicloud.com -o passwd_file=/etc/passwd-obsfs -o max_write=131072 -o nonempty -o use_ino
- Mount the parallel file system filesystem001 to the /mnt/mount_path/ directory and set the write cache size.
./obsfs filesystem001 /mnt/mount_path/ -o url=obs.cn-north-1.myhuaweicloud.com -o passwd_file=/etc/passwd-obsfs -o big_writes -o max_write=131072 -o max_background=100 -o use_ino
- Mount the filesystem001 parallel file system to the mount point /mnt/mount_path/ and allow other users to access the directory.
./obsfs filesystem001 /mnt/mount_path/ -o url=obs.cn-north-1.myhuaweicloud.com -o passwd_file=/etc/passwd-obsfs -o max_write=131072 -o allow_other -o use_ino
If the value of this parameter is an IP address, add the -o use_path_request_style parameter to the mount command. Otherwise, a domain name resolution error is reported.
Mounting a Parallel File System Automatically upon Startup
The following uses CentOS 7 as an example to describe how to configure automatic mounting upon system startup.
- Log in to the Linux OS as user root.
- Run the following command to create a /home/startobsfs.sh script:
vi /home/startobsfs.sh
- Press i to enter the editing mode, and write the following comments and mount commands to the /home/startobsfs.sh script.
#!/bin/bash cd obsfsabsolute path ./obsfs Parallel file system name Local mount point -o url=Region endpoint address -o passwd_file=Key file path -o use_ino Mount parameters
For details about the mount command parameters, see 3 in section "Mounting a Parallel File System Manually."
- Press Esc and enter :wq to save and exit the script.
- Run the following command to grant the root user the permission to execute the script:
chmod +x /home/startobsfs.sh
- Run the following command to grant the root user the permission to execute the rc.local file:
chmod +x /etc/rc.d/rc.local
The location of the rc.local file varies depending on the OS. In CentOS 7, the file is stored in /etc/rc.d/rc.local.
- Add the following command to the end of the /etc/rc.d/rc.local file, save the file, and exit:
bash /home/startobsfs.sh
If the /etc/rc.d/rc.local file contains an exit command, for example, exit 0, add the command prior to the exit command.
- Restart and verify.
After the Linux OS is restarted, run the following command to check whether the parallel file system is successfully mounted:
df -h
If you want to cancel the automatic mounting of the parallel file system upon startup, delete the script of the obsfs mounting command in the rc.local file.
Follow-up Procedure
Before adding, modifying, or deleting a parameter setting for a mounted parallel file system, you need to unmount the parallel file system and then mount it again. For details about how to unmount a parallel file system, see Unmounting a Parallel File System.
Last Article: Operation Guide
Next Article: Unmounting a Parallel File System
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.