aerospike工具集——ascli

aerospike cli(aerospike命令行界面)
用法
ascli的基本用法:
ascli OPTIONS COMMAND


Options

--list 查看所有的COMMAND
[root@mobiead-06 server]# ascli --list
  eval
  exists
  get
  put
  remove
  udf-get
  udf-list
  udf-put
  udf-remove
  udf-record-apply
  scan-list
  scan-kill
  query-list
  query-kill


--help 查看帮助信息
[root@mobiead-06 server]# ascli --help

Usage: ascli [options] <command> [args]

Command Line Utility for Aerospike Database

Options:
  -h <host>
     The server hostname or IP address. Default: 127.0.0.1
  -p <port>
     The server port number. Default: 3000
  -U <user name>
     User name used to authenticate with cluster.
  -P[<password>]
     Password used to authenticate with cluster.
     User will be prompted on command line if -P specified and no password is given.
  -t <timeout>
     Transaction timeout in milliseconds.
  --list
     List the commands.

--path=<path> 指定ascli命令的查找路径

Commands
Command Description
exists 检查记录是否存在
get 获取一条记录
put 增加一条记录
remove 删除一条记录
query-list 列出当前正在运行的查询工作
query-kill 结束一个查询任务
scan-list 当前正在运行的扫描作业列表
scan-kill 结束一个扫描作业
udf-get 下载一个自定义模块函数
udf-put 上传一个自定义模块函数
udf-list 自定义模块函数列表
udf-remove 删除一个自定义模块函数
udf-record-apply 给记录应用自定义函数

put
ascli put test myset mykey '{"name":"mobilead","org":"social-touch"}' 
在test命名空间的myset集合中插入mykey的键,内容分别是name和org,以json的格式插入
$ ascli put test test test '{"a": "A", "b": 1, "c": [1,2,3], "d": {"x": 4}}'
$ if [ $? == 0 ]; thenecho"success"; elseecho"failure"; fi;
success


get
ascli get test myset mykey

exists
ascli exists test myset mykey
$ ascli exists test test test
Key: test exists.
$ if [ $? == 0 ]; thenecho “exists”; elseecho “doesn't exist”; fi; exists

remove
ascli remove test myset mykey
$ ascli remove test test test
$ if [ $? == 0 ]; thenecho “success”; elseecho “failure”; fi;
success
$ ascli exists test test test
$ if [ $? == 0 ]; thenecho “exists”; elseecho “doesn't exist”; fi; doesn't exist

query-list
ascli query-list [-v]
加上-v可以打印更加详细的信息
$ ascli query-list
TRANSACTION ID          STATUS
472341955492950239      RUNNING

$ ascli query-list -v
NODE               TRANSACTION ID          STATUS     PROGRESS      EXEC TIME(ms)
BB92A20F7290C00    13912474952720922700    RUNNING    [n=191079]    24672587

query-kill
ascli query-kill <id>
$ ascli query-kill 14542284165954543608
TRANSACTION ID          STATUS
14542284165954543608    Ok

scan-list
$ ascli scan-list
SCAN ID                 STATUS     PROGRESS    PRIORITY    EXEC TIME(ms)  NS/SET
2137924950893220379     IN PROG    0%[n=63]    medium      1526           test/null

scan-kill
$ ascli scan-kill 2137924950893220379
SCAN ID            STATUS
2137924950893220379     Ok


ascli – Scripting
ascli eval

Commands
Command Description
:print Display statistics from last command.
:reset Reset accumulated statistics.
:repeat <n> Repeat all commands on the stack n times.
:clear Clear the stack.
:quit Quit eval.
在eval中输入的每一个命令等会被推送到堆栈,栈处理最多1000个命令,每个命令最多可以有1000个字符。
一旦你有一个或多个命令在堆栈上,你可以重复使用的命令:repeat;
如果你想清除堆栈,使用:clear;
:print命令将打印统计以来的程序或上次:reset的命令发出的开始;
:reset命令将重置统计;

Examlpe
$ ascli eval
put test users user1 '{"name":"John"}'
:print
>>
  time:    0.42700 ms
  success: 1
  failure: 0
:reset
:print
>>
  time:    0.00000 ms
  success: 0
  failure: 0
get test users user1
{"name": "John"}
:reset
:repeat 10
{"name": "John"}
{"name": "John"}
{"name": "John"}
{"name": "John"}
{"name": "John"}
{"name": "John"}
{"name": "John"}
{"name": "John"}
{"name": "John"}
{"name": "John"}
:print
>>
  time:    3.08900 ms
  success: 20
  failure: 0
:quit

用户自定义函数管理
udf-put
[ root@mobiead-06 server]# touch example1.lua
[ root@mobiead-06 server]# vim example1.lua

function hello()
  return"Hello World!"
end
[ root@mobiead-06 server]# ascli udf-put example1.lua

udf-list
[ root@mobiead-06 server]# ascli udf-list
ad_udf.lua
example1.lua

udf-get
[ root@mobiead-06 server]# ascli udf-get example1.lua 
function hello()
      return "Hello World!"
end

udf-remove
[ root@mobiead-06 server]# ascli udf-remove example1.lua

udf-record-apply
ascli udf-record-apply <ns> <set> <key> <module> <function> ARGS
<ns>命名空间
<set>setname
<key> key
<module>lua脚本文件名,不带后缀
<function>函数名
ARGS 参数列表

Example:

$ ascli udf-record-apply test test 1 example1 hello
"Hello World!"








你可能感兴趣的:(aerospike工具集——ascli)