JavaScript is required to for searching.
跳过导航链接
退出打印视图
Oracle® ZFS Storage Appliance 管理指南,发行版 2013.1.3.0
Oracle 技术网
文档库
PDF
打印视图
反馈
search filter icon
search icon

文档信息

关于 Oracle ZFS Storage Appliance

Oracle ZFS Storage Appliance 主要功能

支持的协议

Oracle ZFS Storage Appliance 数据服务

数据可用性

Oracle ZFS Storage Appliance 配置

浏览器用户界面 (Browser User Interface, BUI)

网络图标

显示板图标

Analytics(分析)工具栏图标

身份映射图标

受支持的浏览器

命令行界面 (Command Line Interface, CLI)

CLI 上下文

CLI 属性

使用 CLI 脚本编写工具

使用批处理命令

了解 CLI 脚本命令

访问 CLI 脚本环境

了解内置 CLI 功能

使用 Run 函数

使用 Get 函数

使用 List 函数

使用 Children 函数

使用 Choices 函数

使用用于生成输出的函数

了解 CLI 脚本错误

配置 Oracle ZFS Storage Appliance

使用服务

维护 Oracle ZFS Storage Appliance

使用共享资源

将设备与 Oracle ZFS Storage Appliance 集成

CLI 上下文

CLI 中的一个核心原则就是执行命令时所在的上下文。上下文指定可管理系统的哪些元素,以及可使用哪些命令。上下文采用树结构,在该结构中,上下文本身可能包含嵌套的上下文,并且该结构通常是 BUI 中视图结构的镜像。

登录时的初始上下文是根上下文,充当所有上下文的父代或祖先。要导航到某个上下文,请将该上下文的名称作为命令执行。例如,在浏览器 "Configuration"(配置)视图中提供的功能在 CLI 的 configuration 上下文中可用。从根上下文中,可以通过直接键入某个上下文来访问该上下文:

dory:> configuration
dory:configuration> 

请注意,提示符将发生更改,在提示符中的冒号和大于号之间提供上下文,以反映上下文。

show 命令显示子上下文。例如,从 configuration 上下文中:

dory:configuration> show
Children:
                             net => Configure networking
                        services => Configure services
                         version => Display system version
                           users => Configure administrative users
                           roles => Configure administrative roles
                     preferences => Configure user preferences
                          alerts => Configure alerts
                         storage => Configure Storage

这些子上下文对应于在浏览器中的 "Configuration"(配置)视图下提供的视图,包括 "Network"(网络)、"Services"(服务)、"Users"(用户)和 "Preferences"(首选项)等等。要选择这些子上下文之一,请键入其名称:

dory:configuration> preferences 
dory:configuration preferences> 

可通过指定使用空格分隔的中间上下文直接从祖先导航到某个后代上下文。例如,要直接从根上下文导航到 configuration preferences,直接键入该命令即可:

dory:> configuration preferences
dory:configuration preferences>

有些子上下文是动态的,因为它们不是对应于浏览器中的固定视图,而是对应于用户或系统创建的动态实体。要导航到这些上下文,请使用 select 命令,后跟动态上下文的名称。给定上下文中包含的动态上下文的名称可以使用 list 命令进行显示。例如,users 上下文是一个静态上下文,但是每个用户都是独立的动态上下文。

dory:> configuration users
dory:configuration users> list 
NAME                     USERNAME                 UID        TYPE
John Doe                 bmc                      12345      Dir
Super-User               root                     0          Loc

要选择名为 bmc 的用户,请发出 select bmc 命令:

dory:configuration users> select bmc 
dory:configuration users bmc> 

另外,在某些上下文中,可以使用 selectdestroy 根据实体的属性选择实体。例如,可以通过发出以下命令在 maintenance logs system 上下文中选择 reboot 模块发布的日志条目:

dory:maintenance logs system> select module=reboot 
dory:maintenance logs system entry-034> show
Properties:                                   
  timestamp = 2010-8-14 06:24:41
     module = reboot
   priority = crit
       text = initiated by root on /dev/console syslogd: going down on signal 15

和其他命令一样,select 可以附加到更改上下文的命令中。例如,要从根上下文中选择名为 bmc 的用户:

dory:> configuration users select bmc 
dory:configuration users bmc>

使用 last 命令导航到上一个选定或创建的上下文。以下示例创建了一个复制操作,然后使用 last 和 get id 命令检索复制操作 ID。然后,选择不同的操作,并使用 last 和 get id 命令检索最后访问的复制操作的 ID。

使用 last 命令可以返回到最后访问的节点:

dory:configuration net interfaces> select igb4
dory:configuration net interfaces igb4> done
dory:configuration net interfaces> last
net:configuration net interfaces igb4>

last 命令也可用于检索设备在创建动态节点过程中自动设备的值。例如,在创建每个复制操作时,设备会为其分配一个 ID。last 命令和 get id 命令一起使用时,可以在不使用复制操作名称的情况下检索 ID:

dory:shares p1/share replication> create
dory:shares p1/share action (uncommitted)> set target=dory
                               target = dory (uncommitted)
dory:shares p1/share action (uncommitted)> set pool=p0
                               pool = p0 (uncommitted)
dory:shares p1/share action (uncommitted)> commit
dory:shares p1/share replication> last get id
                               id = 7034367a-d4d8-e26f-fa93-c3b454e3b595
dory:shares p1/share replication>

请注意,如果 last 与其他命令(本例中为 get id)组合,则该命令在上次访问的节点的上下文中运行,但当前节点保持不变。

由于 last 允许在不指定节点全称的情况下检索上次访问的节点及其值,因此本命令在编写脚本时特别方便:

script
              project = 'myproj';
              target = 'mytarget';
              target_pool = 'notmypool';
     
              run('cd /');
              run('shares select ' + project);
              run('replication');
              run('create');
              set('target', target);
              set('pool', target_pool);
              run('commit');
              run('last');
              id = get('id');
              printf("Sending update for replication action id %s ...", id);
              run('sendupdate');
              while (get('state') != 'idle') {
                     printf(".");
                     run('sleep 1');
              }
              printf("done\n");
 .

要返回到之前的上下文,请使用 done 命令:

dory:configuration> done
dory:> 

该命令会导致返回到之前的上下文,该上下文不一定是父上下文,如下所示:

dory:> configuration users select bmc 
dory:configuration users bmc> done
dory:> 

可以使用 done 命令多次,以返回到更早的上下文:

dory:> configuration
dory:configuration> users 
dory:configuration users> select bmc 
dory:configuration users bmc> done
dory:configuration users> done
dory:configuration> done
dory:>

要导航到父上下文,请使用 cd 命令。受经典 UNIX 命令的启发,cd 使用 ".." 参数表示移动到父上下文:

dory:> configuration users select bmc
dory:configuration users bmc> cd ..
dory:configuration users> 

和 UNIX 命令一样,"cd /" 用于移到根上下文:

dory:> configuration
dory:configuration> users 
dory:configuration users> select bmc 
dory:configuration users bmc> cd /
dory:>

和其 UNIX 对应项一样,"cd ../.." 可用于导航到祖父上下文:

dory:> configuration
dory:configuration> users 
dory:configuration users> select bmc 
dory:configuration users bmc> cd ../..
dory:configuration>

上下文名称可以使用 Tab 补齐功能,上下文可以是静态上下文(通过常规命令补齐功能),也可以是动态上下文(通过 select 命令的命令补齐功能)。在下面的示例中,只敲击键盘 15 次即从根上下文中选择了名为 bmc 的用户,如果不使用 Tab 补齐功能,则需要敲击键盘 31 次:

dory:> configtab 
dory:> configuration utab 
dory:> configuration users setab 
dory:> configuration users select tab 
bmc   root  
dory:> configuration users select btab 
dory:> configuration users select bmcenter 
dory:configuration users bmc>

进入某个上下文后,可执行特定于上下文的命令。例如,要获取当前用户的首选项,请从 configuration preferences 上下文中执行 get 命令:

dory:configuration preferences> get
                       locale = C
                 login_screen = status/dashboard
              session_timeout = 15
           session_annotation = 
           advanced_analytics = false

如果更改上下文的命令后还有其他输入内容,系统虽然会在目标上下文中执行该命令,但是会将控制权返回给调用上下文。例如,要在不更改上下文的情况下从根上下文中获取首选项,请将 get 命令附加到上下文导航命令:

dory:> configuration preferences get 
                       locale = C
                 login_screen = status/dashboard
              session_timeout = 15
           session_annotation = 
           advanced_analytics = false

当在系统中创建新的实体时,与新实体关联的上下文通常在未提交状态下创建。例如,通过从 configuration alerts threshold 上下文执行 create 命令来创建阈值警报:

dory:> configuration alerts thresholds create 
dory:configuration alerts threshold (uncommitted)>

提示符中的 (uncommitted) 表示这是一个未提交的上下文。未提交的实体通过 commit 命令提交;从未提交的上下文导航到其他位置的任何尝试都将提示进行确认:

dory:configuration alerts threshold (uncommitted)> cd /
Leaving will abort creation of "threshold". Are you sure? (Y/N)

当提交未提交的实体时,将验证与新实体关联的属性,如果无法创建实体,则会生成错误。例如,创建新阈值警报需要指定统计信息名称;不设置该名称会导致错误的发生:

dory:configuration alerts threshold (uncommitted)> commit
error: missing value for property "statname"

要解决此问题,请修正错误,然后重新尝试提交:

dory:configuration alerts threshold (uncommitted)> set statname=cpu.utilization  
                     statname = cpu.utilization (uncommitted)
dory:configuration alerts threshold (uncommitted)> commit
error: missing value for property "limit"
dory:configuration alerts threshold (uncommitted)> set limit=90
                        limit = 90 (uncommitted)
dory:configuration alerts threshold (uncommitted)> commit
dory:configuration alerts thresholds> list
THRESHOLD          LIMIT       TYPE STATNAME
threshold-000         90     normal cpu.utilization

另请参见: