首页 > 代码库 > Tachyon基本使用06-----Tachyon 命令行接口

Tachyon基本使用06-----Tachyon 命令行接口

一、tachyon命令介绍

# tachyon
Usage: tachyon COMMAND 
where COMMAND is one of:
  format [-s]         格式化Format Tachyon (如果指定 -s 参数,表示在 underfs 不存在时进行)
  bootstrap-conf      生成一个配置文件,如果不存在
  tfs           命令行客户端
  loadufs         加载三、Tachyon命令行操作现有的底层文件系统到Tachyon
  runTest        运行一个终端到终端的测试中的Tachyon集群
  runTests       运行所有的终端到终端的测试中的Tachyon集群上
  killAll <WORD>     杀死包WORD进程
  copyDir <PATH>   复制PATH到所有节点
  clearCache      清除操作系统缓存
  thriftGen         生成所有 thrift 代码
  version         打印Tachyon版本
Commands print help wheninvoked without parameters.
#

二、Tachyon命令行客户端

1.查看Tachyon命令行客户端帮助

# tachyon tfs
Usage: java TFsShell
       [cat <path>]
       [count <path>]
       [ls <path>]
       [lsr <path>]
       [mkdir <path>]
       [rm <path>]
       [tail <path>]
       [touch <path>]
       [mv <src> <dst>]
       [copyFromLocal <src><remoteDst>]
       [copyToLocal <src><localDst>]
       [fileinfo <path>]
       [location <path>]
       [report <path>]
       [request <tachyonaddress><dependencyId>]
       [pin <path>]
       [unpin <path>]
#

2.参数介绍

PATH变量格式
tachyon://<masternode address>:<master node port>/<path>
或者,如果没有提供标头,默认主机名和端口(在env文件中)将被使用。
/<path>

3.命令行其它操作选项

OperationSyntaxDescription
catcat "path"Print the content of the file to the console.
count
count "path"Display the number of folders and files matching the specified prefix in "path".
ls
ls "path"List all the files and directories directly under the given path with information such as size.
lsrlsr "path"Recursively list all the files and directories directly under the given path with information such as size.
mkdirmkdir "path"Create a directory under the given path, along with any necessary parent directories. Will fail if the path already exists.
rmrm "path"Remove a file or directory and all folders and files under that directory.
tailtail "path"Print the last 1KB of the specified file to the console.
touchtouch "path"Create a 0 byte file at the specified location.
mvmv "source" "destination"Move a file or directory specified by "source" to a new path "destination". Will fail if "destination" already exists.
copyFromLocalcopyFromLocal "source path" "remote path"Copy the specified file to the path specified by "remote path". Will fail if "remote path" already exists.
copyToLocalcopyToLocal "remote path" "local path"Copy the specified file from the path specified by "remote source" to a local destination.
fileinfofileinfo "path"Print the information of the blocks of a specified file.
pinpin "path"Pins the given file, such that Tachyon will never evict it from memory. If called on a folder, it recursively pins all contained files and any new files created within this folder.
unpinunpin "path"Unpins the given file to allow Tachyon to start evicting it again. If called on a folder, it recursively unpins all contained files and any new files created within this folder.

三、Tachyon命令行操作

1.创建文件夹

# tachyon tfs mkdir /test
Successfully created directory /test
# tachyon tfs mkdir /test/one
Successfully created directory /test/one
# tachyon tfs mkdir /test/two
Successfully created directory /test/two
#

2.创建文件

# tachyon tfs touch /test/one/one.txt
/test/one/one.txt has been created
# tachyon tfs touch /test/two/two.txt
/test/two/two.txt has been created
#

3.上传本地文件

# tachyon tfs copyFromLocal /etc/passwd /test/passwd
Copied /etc/passwd to /test/passwd
#

4.查看文件

# tachyon tfs ls /test
0.00 B    09-30-2014 14:42:18:525                 /test/one
0.00 B    09-30-2014 14:42:21:952                 /test/two
1671.00 B 09-30-201414:52:18:574  In Memory      /test/passwd
# tachyon tfs lsr /test
0.00 B    09-30-2014 14:42:18:525                 /test/one
0.00 B    09-30-2014 14:44:00:167  In Memory     /test/one/one.txt
0.00 B    09-30-2014 14:42:21:952                 /test/two
0.00 B    09-30-2014 14:44:14:956  In Memory     /test/two/two.txt
1671.00 B 09-30-201414:52:18:574  In Memory      /test/passwd
#

5.查看文件信息

# tachyon tfs fileinfo /test/passwd
/test/passwd with file id 82 have following blocks: 
ClientBlockInfo(blockId:88046829568,offset:0, length:1671, locations:[NetAddress(mHost:hadoop01, mPort:29998)])
#

6.查看文件内容

# tachyon tfs cat /test/passwd |head -n 2
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
# tachyon tfs tail /test/passwd |head -n 2
n/nologin
usbmuxd:x:113:113:usbmuxd
user:/:/sbin/nologin
#

7.查看目录下文件个数

# tachyon tfs count/test
File Count               Folder Count             Total Bytes    
3                        3                        1671           
#

8.在内存注册和取消注册文件和文件夹

# tachyon tfs pin /test
File ‘/test‘ was successfully pinned.
# tachyon tfs unpin /test
File ‘/test‘ was successfully unpinned.
#

9.移动文件

# tachyon tfs mv/test/one/one.txt /test/one.txt
Renamed/test/one/one.txt to /test/one.txt
# tachyon tfs lsr /test
0.00 B    09-30-2014 14:42:18:525                 /test/one
0.00 B    09-30-2014 14:42:21:952                 /test/two
0.00 B    09-30-2014 14:44:14:956  In Memory     /test/two/two.txt
0.00 B    09-30-2014 14:44:00:167  In Memory     /test/one.txt
1671.00 B 09-30-201414:52:18:574  In Memory      /test/passwd
#

10.下载文件

# tachyon tfs copyToLocal /test/passwd /tmp/tachyon.txt
Copied /test/passwd to /tmp/tachyon.txt
# head -n 2 /tmp/tachyon.txt 
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
#

11.删除文件

# tachyon tfs rm /test/two
/test/two has beenremoved
# tachyon tfs lsr /test
0.00 B    09-30-2014 14:42:18:525                 /test/one
0.00 B    09-30-2014 14:44:00:167  In Memory     /test/one.txt
1671.00 B 09-30-201414:52:18:574  In Memory      /test/passwd
#


本文出自 “tachyon” 博客,请务必保留此出处http://ucloud.blog.51cto.com/3869454/1564173

Tachyon基本使用06-----Tachyon 命令行接口