sg_persist用法

1,262 阅读3分钟

linux平台:

【读钥匙】子命令:(完整是这样:sg_persist --in --read-keys --device=/dev/sdb )
sg_persist /dev/sdb

【读当前的预定】,用'--read-reservation'选项,或者使用其简化形式'-r':
sg_persist -r /dev/sdb

【登记一个新预定钥匙】0x123abc: 
sg_persist --out --register --param-sark=123abc /dev/sdb

【预定设备】,类型为'write exclusive':
sg_persist --out --reserve --param-rk=123abc --prout-type=1 /dev/sdb

【释放预定】 (注意 --param-rk和--prout-type参数必须和预定匹配): 
sg_persist --out --release --param-rk=123abc --prout-type=1 /dev/sdb

【取消登记钥匙】(and not effect other registrations which is what '--clear' would do): 
sg_persist --out --register --param-rk=123abc /dev/sdb 

centos:

sg_persist --in --no-inquiry --read-reservation --device=/dev/sdb 
###sg_persist --in --no-inquiry --read-reservation --device=/dev/disk/by-id/scsi-360014050fae2af3d5f540d9befd2e61d
sg_persist --out --no-inquiry --register --param-sark=123abc --device=/dev/sdb
sg_persist --out --no-inquiry --clear --param-rk=123abc --device=/dev/sdb

HA Monitor Cluster Software Guide


7.4.12 Canceling SCSI reservation for shared disk

This subsection explains how to cancel SCSI reservation for shared disk. Do not perform this procedure if not instructed to do so in the error handling procedures.

Only the superuser can cancel reservations. You can perform this procedure on any host. The procedure is the same whether the configuration is single-path or multi-path.

To cancel SCSI reservation for shared disk:

  1. Verify that the shared disk has been reserved.
    The following shows how to do this:

    ```

    /usr/bin/sg_persist --in --no-inquiry --read-reservation --device=device-name

    
    Legend:
    
    *device-name*: This is the value indicated in the KAMN725-W message. In a single-path configuration, it is a symbolic link, and in a multi-path configuration, it is the local device of DMMP. If the device name displayed in the KAMN725-W message is followed by a path name, this is the path name.
    
    The following example specifies /dev/disk/by-id/scsi-360060e8010462fe004f2b6ae00000065 as the device name.
    
    Example
    
    |                                                                                                                                                     |
    | --------------------------------------------------------------------------------------------------------------------------------------------------- |
    | ```
    # /usr/bin/sg_persist -in --no-inquiry --read-reservation --device=/dev/disk/by-id/scsi-360060e8010462fe004f2b6ae00000065
    ```![](<> "点击并拖拽以移动") |
    
    Result:
    
    If the message shown below is displayed, check that 0x1 matches the key displayed in the KAMN725-W message.
    
    |                                                                                                                                          |
    | ---------------------------------------------------------------------------------------------------------------------------------------- |
    | ```
    PR generation=0xnn, Reservation follows:   Key=0x1   scope: LU_SCOPE,  type: Write Exclusive, registrants only
    ```![](<> "点击并拖拽以移动") |
    
    If the key does not match the key displayed in the KAMN725-W message or the following message is displayed, check and, if necessary, revise the specified device name, and then re-execute the command.
    
    |                                                                            |
    | -------------------------------------------------------------------------- |
    | ```
    PR generation=0xnn, there is NO reservation held
    ```![](<> "点击并拖拽以移动") |
    
    
  2. Prepare to cancel reservations.
    The following shows how to prepare:

    ```

    /usr/bin/sg_persist --out --no-inquiry --register --param-sark=key --device=device-name

    
    Legend:
    
    *key*, *device-name*: This is the value indicated in the KAMN725-W message. In a single-path configuration, it is a symbolic link, and in a multi-path configuration, it is the local device of DMMP. If the device name displayed in the KAMN725-W message is followed by a path name, this is the path name.
    
    The following example specifies /dev/disk/by-id/scsi-360060e8010462fe004f2b6ae00000065 as the device name.
    
    Example
    
    |                                                                                                                                                                |
    | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
    | ```
    # /usr/bin/sg_persist --out --no-inquiry --register --param-sark=0x1 --device=/dev/disk/by-id/scsi-360060e8010462fe004f2b6ae00000065
    ```![](<> "点击并拖拽以移动") |
    
    If nothing is displayed after execution, the preparation has been completed.
    
    Note that the message shown below might be displayed. In this case also, the preparation has been completed. Continue with cancellation of reservation.
    
    |                                                                                                            |
    | ---------------------------------------------------------------------------------------------------------- |
    | ```
    persistent reserve out: scsi status: Reservation Conflict PR out: command failed
    ```![](<> "点击并拖拽以移动") |
    
    
  3. Cancel the reservation.
    The following shows how to cancel the reservation:

    ```

    /usr/bin/sg_persist --out --no-inquiry --clear --param-rk=key --device=device-name

    
    Legend:
    
    *key*, *device-name*: This is the value indicated in the KAMN725-W message. In a single-path configuration, it is a symbolic link, and in a multi-path configuration, it is the local device of DMMP. If the device name displayed in the KAMN725-W message is followed by a path name, this is the path name.
    
    The following example specifies /dev/disk/by-id/scsi-360060e8010462fe004f2b6ae00000065 as the device name.
    
    Example
    
    |                                                                                                                                                           |
    | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
    | ```
    # /usr/bin/sg_persist --out --no-inquiry --clear --param-rk=0x1 --device=/dev/disk/by-id/scsi-360060e8010462fe004f2b6ae00000065
    ```![](<> "点击并拖拽以移动") |
    
    If nothing is displayed after execution, the reservation has been cancelled successfully.
    
    
  4. Verify that the reservation has been cancelled.
    The following shows how to verify reservation cancellation:

    ```

    /usr/bin/sg_persist --in --no-inquiry --read-reservation --device=device-name # /usr/bin/sg_persist --in --no-inquiry --read-key --device=device-name

    
    Legend:
    
    *device-name*: This is the value displayed in the KAMN725-W message. In a single-path configuration, it is a symbolic link, and in a multi-path configuration, it is the local device of DMMP.
    
    The following example specifies /dev/disk/by-id/scsi-360060e8010462fe004f2b6ae00000065 as the device name.
    
    Example
    
    |                                                                                                                                                                                                                                                                         |
    | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
    | ```
    # /usr/bin/sg_persist --in --no-inquiry --read-reservation --device=/dev/disk/by-id/scsi-360060e8010462fe004f2b6ae00000065 # /usr/bin/sg_persist --in --no-inquiry --read-key --device=/dev/disk/by-id/scsi-360060e8010462fe004f2b6ae00000065
    ```![](<> "点击并拖拽以移动") |
    
    Result:
    
    |                                                                                                                             |
    | --------------------------------------------------------------------------------------------------------------------------- |
    | ```
    PR generation=0xnn, there is NO reservation held PR generation=0xnn, there is NO reservation held
    ```![](<> "点击并拖拽以移动") |
    
    If the above messages are displayed, the reservation has been cancelled. If these messages are not displayed, check the steps beginning with step 1 and then re-execute them.
    

[Contents][Back][Next]


[Trademarks]

All Rights Reserved. Copyright (C) 2012, Hitachi, Ltd.