Showing posts with label Red Hat Cluster Suite. Show all posts
Showing posts with label Red Hat Cluster Suite. Show all posts

Tuesday, 28 April 2015

LVM2. change a clustered LVM volume group to non-clustered

APPLIES TO:


Operating Systems:
  • RHEL5
  • RHEL6
  • RHEL7

SYMPTOMS


Need to activate cluster volume group

SOLUTION


Check, is this volume group is clustered:
# vgdisplay vgtest01 --config 'global {locking_type = 0}' | grep Clustered
  WARNING: Locking disabled. Be careful! This could corrupt your metadata.
  Clustered             yes

Now you have two ways.
- If this volume is on cluster node, and clvmd is running
# vgchange -cn vgtest01
   Volume group "vgtest01" successfully changed

- If the cluster cannot achieve quorum, or clvmd is unable to function for whatever reason or you need to temporarily activate the volume group.

# vgchange -cn vgtest01 --config 'global {locking_type = 0}'
  WARNING: Locking disabled. Be careful! This could corrupt your metadata.
  Volume group "vgtest01" successfully changed

# vgchange -ay vgtest01



Before activating clustered volume group in non cluster environment, ensure that this volume group not in use in other cluster members.

      Sunday, 26 April 2015

      How can I view, create, and remove SCSI persistent reservations and keys. from redhat

      APPLIES TO:


      Redhat Enterprise Linux 5, 6, 7
      Oracle Enterprise Linux 5, 6, 7
      SUSE Linux Enterprise Server 9,10, 11, 12

      SYMPTOMS


      Can't read/write to lun.
      Can't join cluster.

      Also you can see something like that in your dmesg:
      [6902380.608058] sd 11:0:0:1: [sdc] tag#16 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_OK
      [6902380.608060] sd 11:0:0:1: [sdc] tag#16 CDB: Read(10) 28 00 00 1f ff 80 00 00 08 00
      [6902380.608061] blk_update_request: critical nexus error, dev sdc, sector 2097024
      [6902380.608064] Buffer I/O error on dev sdc1, logical block 261872, async page read
      [6902380.609007] sd 11:0:0:1: reservation conflict
      [6902380.609011] sd 11:0:0:1: [sdc] tag#14 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_OK
      [6902380.609013] sd 11:0:0:1: [sdc] tag#14 CDB: Read(10) 28 00 00 00 08 00 00 00 01 00
      [6902380.609015] blk_update_request: critical nexus error, dev sdc, sector 2048
      [6902380.609523] sd 11:0:0:1: reservation conflict
      [6902380.609526] blk_update_request: critical nexus error, dev sdc, sector 0


      Scsi persistent reservation, usualy used in cluster environment, it's allow scsi initiator to reserve LUN to exclusive access.

      SOLUTION


      Install sg3_utils package. (in case of SLES, use zypper)
      # yum install sg3_utils


      To view the keys registered on a LUN use the following command:
      # sg_persist --in -k -d /dev/sdd
      

      To view the reservations currently out on a device use the following command:
      # sg_persist --in -r -d /dev/sdd
      

      Keys are 6 or 8 digit HEX numbers. Key numbers can be arbitrary. For example 0xDEADBEEF or 0x123ABC To register a key on a LUN use the following command:
      # sg_persist --out --register --param-sark=0xDEADBEEF /dev/sdd
      

      You can take out a reservation on behalf of a key with the following command:
      # sg_persist --out --reserve --param-rk=0xDEADBEEF --prout-type=1 /dev/sdd
      The reservation types are defined in the SCSI Primary Commands spec. Here are the reservation types from the sg_persist manpage

      1-> write exclusive
      3-> exclusive access
      5-> write exclusive - registrants only
      6-> exclusive access - registrants only
      7-> write exclusive - all registrants
      8-> exclusive access - all registrants.



      to  release a registration:

      # sg_persist --out --release --param-rk=0xDEADBEEF  --prout-type=5 /dev/sdd

      to unregister a key:

      # sg_persist --out --register --param-rk=0xDEADBEEF  /dev/sdd

      clear the reservation and all registered keys:

      # sg_persist --out --clear --param-rk=0xDEADBEEF   /dev/sdd





      Saturday, 9 August 2014

      Using SCSI Persistent Reservation Fencing (fence_scsi) in RHEL 6 (RHEL KB)

      Using SCSI Persistent Reservation Fencing (fence_scsi) in RHEL 6

      Originally is article 40112 at access.redhat.com

      1 Introduction

      When cluster nodes share storage devices, it is necessary to control access to the storage devices. In the event of a node failure, the failed not should not have access to the underlying storage devices. SCSI persistent reservations provide the capability to control the access of each node to shared storage devices. Red Hat Cluster Suite employs SCSI persistent reservations as a fencing methods through the use of the fence_scsi agent. The fence_scsi agent provides a method to revoke access to shared storage devices, provided that the storage support SCSI persistent reservations.
      Using SCSI reservations as a fencing method is quite different from traditional power fencing methods. It is important to understand the software, hardware, and configuration requirements prior to using SCSI persistent reservations as a fencing method.
      This document describes the use of SCSI persistent reservations for Red Hat Cluster Suite version 6.0 and greater. Information about using SCSI persistent reservations with older version of Red Hat Cluster Suite can be found here: Using SCSI Persistent Reservations with Red Hat Enterprise Linux 4 or 5

      2 Overview

      In order to understand how Red Hat Cluster Suite is able to use SCSI persistent reservations as a fencing method, it is helpful to have some basic knowledge of SCSI persistent reservations.
      There are two important concepts within SCSI persistent reservations that should be made clear: registrations and reservations.

      2.1 Registrations

      A registration occurs when a node registers a unique key with a device. A device can have many registrations. For our purposes, each node will create a registration on each device.

      2.2 Reservations

      A reservation dictates how a device can be accessed. In contrast to registrations, there can be only one reservation on a device at any time. The node that holds the reservation is known as the "reservation holder". The reservation defines how other nodes may access the device. For example, Red Hat Cluster Suite uses a "Write Exclusive, Registrants Only" reservation. This type of reservation indicates that only nodes that have registered with that device may write to the device.

      2.3 Fencing

      Red Hat Cluster Suite is able to perform fencing via SCSI persistent reservations by simply removing a node's registration key from all devices. When a node failure occurs, the fence_scsi agent will remove the failed node's key from all devices, thus preventing it from being able to write to those devices.

      3 Requirements

      3.1 Software Requirements

      In order use SCSI persistent reservations as a fencing method, the following software requirements must be met:

      3.2 Storage Requirements

      In order to use SCSI persistent reservations as a fencing method, all shared storage must be SPC-3 compliant. In addition, all devices must support the "preempt and abort" service action. SCSI-2 devices are not supported.

      4 Limitations

      • Multipath devices can be used with fence_scsi, but only use cases with device-mapper-multipath are supported by Red Hat. No other types of multipath devices are currently tested or directly supported by Red Hat.
      • All nodes in the cluster must have a consistent view of storage. In other words, all nodes in the cluster must register with the same devices. This limitation exists for the simple reason that each node must be able to remove another node's registration key from all the devices that it registered with. In order to do this, the node performing the fencing operation must be aware of all devices that other nodes are registered with.
      • If fence_scsi is used in conjunction with qdisk, the qdisk device must not be controlled by fence_scsi. If fence_scsi is configured to do automatic device detection, then the qdisk device must not be under clvmd control. If fence_scsi uses manually defined devices, the qdisk device must not be listed. See section 5.4 of this document for information about automatic and manual device configuration.
      • Devices used for the cluster volumes should be a complete LUN, not partitions. SCSI persistent reservations work on an entire LUN, meaning that access is controlled to each LUN, not individual partitions.

      5 Configuration

      5.1 Unfencing

      In addition to the standard fence section, fence_scsi requires an additional unfence section in each clusternode entry. This unfence section is used at cluster startup to created registrations on all devices. This unfence section must contains a device entry which should be identical to the device entry in the fence section except that the unfence section must have "action=on" in its device entry.
      Below is an example of the fence and unfence sections.
          <clusternode name="node-01" votes="1" nodeid="1">
              <fence>
                  <method name="scsi">
                  <device name="scsi_dev" key="1"/>
                  </method>
              </fence>
              <unfence>
                  <device name="scsi_dev" key="1" action="on"/>
              </unfence>
          </clusternode>
      
      In this example the node's key value is manually defined. If keys are manually defined, they must be defined in both the fence and unfence elements and the key values must be equivalent. For more information about manually defined key values, see section 5.2.

      5.2 Keys

      SCSI persistent reservations use unique key values for registrations and reservations. These key values can be manually defined in the cluster.conf file or they can be generated automatically.
      To manually define key values, use the "key" parameter within the device sections for each clusternode entry. This key value must be given in both the fence and unfence sections of the configuration file and the value must be the same within each clusternode.
      Below is an example where keys are defined manually for a node.
          <clusternode name="node-01" votes="1" nodeid="1">
              <fence>
                  <method name="scsi">
                  <device name="scsi_dev" key="1"/>
                  </method>
              </fence>
              <unfence>
                  <device name="scsi_dev" key="1" action="on"/>
              </unfence>
          </clusternode>
      
      In this example, the node will use a key value of "1". Note that the key value is given in the fence and unfence sections. All other node configurations should use the same format, except that they must use different key values. The key value can be any hexadecimal value, up to 64 bits.
      To have the cluster automatically define key values, simply do not use the "key" parameter. When the "key" parameter is not defined, key values will be generated by combining the cluster_id and the nodeid. This value is guaranteed to be unique and consistent for all nodes in the cluster.

      5.3 Devices

      The devices to be used with fence_scsi can be manually configured or discovered automatically.
      To manually define the devices to be used with fence_scsi, use the "devices" parameter within the fencedevice section. The devices parameter should be a comma-separated list of block devices. The devices listed here will receive SCSI persistent reservations commands (registrations and reservations), so each device listed must be a SPC-3 compliant.
      Below is an example where devices are defined manually.
          <fencedevices>
              <fencedevice agent="fence_scsi" name="scsi_dev"
                  devices="/dev/sda, /dev/sdb, /dev/sdc"/>
          </fencedevices>
      
      In this example, there are three devices defined to be used with fence_scsi (/dev/sda, /dev/sdb, /dev/sdc).
      It is important to note that specifying devices by device name (eg. /dev/sda) can be problematic and should generally be avoided. The reason for this is that a specific device may be named differently on other node. For example, the device named "/dev/sdb" on one node may be named "/dev/sdc" on another node. To avoid this problem, it is recommended that devices be listed by SCSI ID. This can be accomplished by specifying a device by way of its "/dev/disk/by-id/..." path. If the device is a dm-multipath device it is necessary for proper registration to all slave devices to use the disk/by-id device referring to the dm-multipath device and not to the scsi device.(e.g. /dev/mapper/mpathX or /dev/disk/by-id/dm-uuid-mpath-...).
      To have the cluster automatically discover the devices to be used with fence_scsi, simply do not use the "devices" parameter. In the absence of this parameter, the fence_scsi agent will attempt to automatically discover cluster storage devices by querying clvmd for a list of devices that belong to cluster volumes. All devices that within cluster volumes will be used, and each must be SPC-3 compliant.

      5.4 APTPL

      The fence_scsi agent can be configured to optionally use the APTPL flag (Activate Persist Through Power Loss) option. This feature requires that the storage supports APTPL. To enable this feature, simply set the "aptpl" parameter in the fencedevice section of the cluster.conf file.
      Below is an example where the APTPL option is enabled.
          <fencedevices>
              <fencedevice agent="fence_scsi" name="scsi_dev" aptpl="1"/>
          </fencedevices>
      

      5.5 Logging

      The fence_scsi agent can be configured to optionally write detailed logging information to a specific file. To enable logging to file, simply set the "logfile" parameter in the fencedevice section of the cluster.conf file.
      Below is an example where logging to a file is enabled.
          <fencedevices>
              <fencedevice agent="fence_scsi" name="scsi_dev" logfile="/tmp/fence_scsi.log"/>
          </fencedevices>
      

      5.6 Example

      Below is a sample configuration (cluster.conf) for a cluster that uses SCSI persistent reservations as its fence method.
          <?xml version="1.0"?>
          <cluster config_version="1" name="my_cluster">
          <cman expected_votes="1" cluster_id="1"/>
          <fence_daemon post_fail_delay="0" post_join_delay="30"/>
          <clusternodes>
              <clusternode name="node-01" votes="1" nodeid="1">
                  <fence>
                      <method name="scsi">
                      <device name="scsi_dev" key="1"/>
                  </method>
              </fence>
              <unfence>
                  <device name="scsi_dev" key="1" action="on"/>
              </unfence>
              </clusternode>
              <clusternode name="node-02" votes="1" nodeid="2">
                  <fence>
                      <method name="scsi">
                      <device name="scsi_dev" key="2"/>
                      </method>
                  </fence>
                  <unfence>
                      <device name="scsi_dev" key="2" action="on"/>
                  </unfence>
              </clusternode>
              <clusternode name="node-03" votes="1" nodeid="3">
                  <fence>
                      <method name="scsi">
                      <device name="scsi_dev" key="3"/>
                      </method>
                  </fence>
                  <unfence>
                      <device name="scsi_dev" key="3" action="on"/>
                  </unfence>
                  </clusternode>
              </clusternodes>
          <fencedevices>
              <fencedevice agent="fence_scsi" name="scsi_dev" aptpl="1"
                  devices="/dev/sda, /dev/sdb, /dev/sdc"
                  logfile="/tmp/fence_scsi.log"/>
          </fencedevices>
          </cluster>

      change a clustered LVM volume group to non-clustered.

      GOAL


      How to change clustered volume group to non-clustered and vise versa.

      ERROR example:
      # vgimport /dev/mapper/mpath-c0t5000CCA027C3225Cd0
        connect() failed on local socket: Connection refused 
        WARNING: Falling back to local file-based locking. 
        Volume Groups with the clustered attribute will be inaccessible. 
        Skipping clustered volume group vgclu1


      SOLUTION


      Check that volume group has clusterd attribute
         # vgs --config 'global {locking_type = 0}'
        WARNING: Locking disabled. Be careful! This could corrupt your metadata.
        VG     #PV #LV #SN Attr   VSize  VFree 
        vgclu1  1   1   0 wz--nc 96.00M 76.00M       <----- Attr includes the 'c' flag meaning clustered.
      
       
      Make sure that this volume group not using cluster software, for e.x. Redhat Cluster Suite.



      Force take over clusger volume group
       # vgchange -cn vgclu1 --config 'global {locking_type = 0}'
        WARNING: Locking disabled. Be careful! This could corrupt your metadata.
        Volume group "vgname" successfully changed
      # vgchange -ay vgclu1 
        WARNING: After making this change, you must not activate the volume group on more than one server at a time or LVM metadata corruption can occur (even if no changes are made).
      
       

      To temporarily activate the volume group, but leave it clustered, use the following command:
       # vgchange -ay vgclu1 --config 'global { locking_type = 0 }'
        WARNING: Locking disabled. Be careful! This could corrupt your metadata.
        1 logical volume(s) in volume group "vgclu1" now active
      WARNING You must not execute this command on more than one server at a time or LVM metadata corruption can occur (even if no changes are made).

      WARNING The vgchange using --config 'global {locking_type = 0}' will not work on a mirrored Logical Volume. The user must restore the VG from a valid LVM backup file using vgcfgrestore. Optionally the user can run lvconvert -m0 on the mirrored LV and run the commands outlined in steps 1-3 above then remirror using lvconvert. Please note that the re-mirroring process can take a while depending on the size of the LV being re-mirrored.