Lists the Hadoop commands to set, retrieve, and remove extended attributes on files, directories and FUSE mounted paths.
You can set, retrieve, and remove extended attributes on files, directories, and FUSE mounted
file path using the hadoop
fs command. When setting an extended attribute:
| text | The given string must be enclosed in double quotes to be treated as text. |
| hex | The given string must begin with 0x or 0X to be treated as hexadecimal number. |
| base64 | The given string must begin with 0s or 0S to be treated as base64 encoding. |
To set an extended attribute name and value for a file or directory, run the following command:
hadoop fs -setfattr -n name [-v value] <path>
For example:
hadoop fs -setfattr -n system.name -v system-hadoopfs /volforsnap/smallfile.txt
hadoop fs -setfattr -n user.name -v user-hadoopfs /volforsnap/smallfile.txt
hadoop fs -setfattr -n security.name -v security-hadoopfs /volforsnap/smallfile.txt
hadoop fs -setfattr -n trusted.name -v trusted-hadoopfs /volforsnap/smallfile.txtTo retrieve the extended attributes associated with a file or directory, run the following command:
hadoop fs -getfattr [-R] -n name | -d [-e en] <path>
For example:
hadoop fs -getfattr -d /volforsnap/smallfile.txt
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/mapr/hadoop/hadoop-2.7.0/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/mapr/lib/slf4j-log4j12-1.7.12.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
# file: /volforsnap/smallfile.txt
system.name="system-hadoopfs"
trusted.name="trusted-hadoopfs"
security.name="security-hadoopfs"
user.name="user-hadoopfs"To remove an extended attribute by name, run the following command:
hadoop fs -setfattr -x name <path>
For example:
hadoop fs -setfattr -x user.key1 /xattrs/m7user1/dir1