{"id":32830,"date":"2023-09-15T09:30:22","date_gmt":"2023-09-15T01:30:22","guid":{"rendered":"https:\/\/www.deepin.org\/?p=32830"},"modified":"2023-09-15T14:38:10","modified_gmt":"2023-09-15T06:38:10","slug":"2023-09-15","status":"publish","type":"post","link":"https:\/\/www.deepin.org\/en\/2023-09-15\/","title":{"rendered":"An article on SBD (a storage-based extended protection service)"},"content":{"rendered":"<img loading=\"lazy\" src=\"https:\/\/storage.deepin.org\/thread\/202309151433003421_\u84dd\u8272\u6241\u5e73\u7b80\u7ea6\u65b0\u95fb\u8bdd\u9898__2023-09-14+18_36_38.png\" alt=\"\" width=\"900\" height=\"383\" \/><\/p>\n<h2 class=\"ql-direction-ltr ql-long-10365\" data-header=\"2\" data-foldable=\"true\" data-default-linespacing=\"100\"><span class=\"ql-author-10365\">OVERVIEW<\/span><\/h2>\n<p class=\"ql-direction-ltr ql-long-10365\"><span class=\"ql-author-10365\">SBD is a storage-based extended protection service that stands for STONITH Block Device.<\/span><span class=\"ql-author-10365\">\u00a0<\/span><\/p>\n<p class=\"ql-direction-ltr ql-long-10365\"><span class=\"ql-author-10365\">The highest priority for highly available clusters is to protect data integrity. This protection is achieved by preventing uncoordinated parallel access to data stores. Clusters use several control mechanisms to achieve this goal.<\/span><\/p>\n<p class=\"ql-direction-ltr ql-long-10365\"><span class=\"ql-author-10365\">However, electing several DCs in a cluster can result in network partitions or software failures. If this so-called \"node splitting\" is allowed to occur, data corruption may occur.<\/span><span class=\"ql-author-10365\">\u00a0<\/span><\/p>\n<p class=\"ql-direction-ltr ql-long-10365\"><span class=\"ql-author-10365\">The main mechanism that can be used to avoid this situation is node shielding through STONITH. If SBD is used as a node shielding mechanism the node can be shut down in the event of a node split without the need for an external shutdown device.<\/span><\/p>\n<h2 class=\"ql-direction-ltr ql-long-10365\" data-header=\"2\" data-foldable=\"true\" data-default-linespacing=\"100\"><span class=\"ql-author-10365\">SBD Components and Mechanisms<\/span><\/h2>\n<p class=\"ql-direction-ltr ql-long-10365\"><strong class=\"ql-author-10365\">SBD Partition<\/strong><\/p>\n<p class=\"ql-direction-ltr ql-long-10365\"><span class=\"ql-author-10365\">In an environment where all nodes have access to shared storage, a small partition of the device is formatted for use with SBD. the size of this partition depends on the block size of the used disks (for example, for a standard SCSI disk with a block size of 512 bytes, the size of this partition would be 1 MB; a DASD disk with a block size of 4 KB would require a partition with a 4 MB size). The initialization process creates a message layout on the device, configuring message slots for up to 255 nodes.<\/span><\/p>\n<p class=\"ql-direction-ltr ql-long-10365\"><strong class=\"ql-author-10365\">SBD Daemon<\/strong><\/p>\n<p class=\"ql-direction-ltr ql-long-10365\"><span class=\"ql-author-10365\">After configuring the appropriate SBD daemon, bring it online on each node and start the cluster. It terminates after all other cluster components have shut down, ensuring that cluster resources are never activated without SBD supervision.<\/span><\/p>\n<p class=\"ql-direction-ltr ql-long-10365\"><strong class=\"ql-author-10365\">Messages<\/strong><\/p>\n<p class=\"ql-direction-ltr ql-long-10365\"><span class=\"ql-author-10365\">This daemon automatically assigns one of the message slots on the partition to itself and continuously monitors it for messages sent to itself. Upon receiving a message, the daemon will immediately execute a request, such as initiating a power-down or reboot cycle for masking.<\/span><\/p>\n<p class=\"ql-direction-ltr ql-long-10365\"><span class=\"ql-author-10365\">In addition, this daemon continuously monitors connectivity to the storage device and terminates itself when it is unable to connect to the partition. This ensures that it does not disconnect from the mask message. If clustered data resides in the same logical unit in different partitions, the workload will terminate as soon as connectivity to storage is lost, so no additional points of failure are added.<\/span><\/p>\n<p class=\"ql-direction-ltr ql-long-10365\"><strong class=\"ql-author-10365\">softdog<\/strong><\/p>\n<p class=\"ql-direction-ltr ql-long-10365\"><span class=\"ql-author-10365\">Whenever you use SBD, you must ensure that the checkpoints are working properly. Newer systems support hardware checkpoints, which need to be \"energized\" or \"fed\" by a software component. The software component (in this case the SBD daemon) \"feeds\" the checkpoints by periodically writing service pulses to the checkpoints. If the daemon stops feeding checkpoints, the hardware forces the system to reboot. This prevents the SBD process itself from failing, such as losing response or getting stuck due to I\/O errors.<\/span><\/p>\n<p class=\"ql-direction-ltr ql-long-10365\"><span class=\"ql-author-10365\">If a Pacemaker cluster is active, SBD will not block itself when the majority of the device's nodes are lost. For example, suppose your cluster contains three nodes: A, B, and C. Due to network separation, A can only see itself, while B and C can still communicate with each other. In this case, there are two cluster partitions, one with a quorum due to the majority of nodes (B and C) and the other without (A). If this happens when the majority of the blocking devices are inaccessible, node A will immediately shut itself down, while nodes B and C will continue to operate.<\/span><\/p>\n<h2 class=\"ql-direction-ltr ql-long-10365\" data-header=\"2\" data-foldable=\"true\" data-default-linespacing=\"100\"><span class=\"ql-author-10365\">SBD Usage Requirements<\/span><\/h2>\n<ul>\n<li class=\"\"><span class=\"ql-author-10365\">Up to three SBD devices can be used for storage-based shielding. When using one to three devices, the shared storage must be accessible from all nodes.<\/span><\/li>\n<li class=\"\"><span class=\"ql-author-10365\">The path to the shared storage device must be permanent and consistent across all nodes in the cluster. Use stable device names, such as \/dev\/disk\/by-id\/dm-uuid-part1-mpath-abcedf12345.<\/span><\/li>\n<li class=\"\"><span class=\"ql-author-10365\">Shared storage can be connected via Fibre Channel (FC), Fibre Channel over Ethernet (FCoE), or even iSCSI, and zone-based RAID and multipathing are recommended for reliability.<\/span><\/li>\n<li class=\"\"><span class=\"ql-author-10365\">An SBD device can be shared between different clusters as long as the number of nodes sharing the device does not exceed 255.<\/span><\/li>\n<\/ul>\n<h2 class=\"ql-direction-ltr ql-long-10365\" data-header=\"2\" data-foldable=\"true\" data-default-linespacing=\"100\"><span class=\"ql-author-10365\">Setting up the SBD device<\/span><\/h2>\n<p class=\"ql-direction-ltr ql-long-10365\"><strong class=\"ql-author-10365\">SBD Device Initialization<\/strong><\/p>\n<p class=\"ql-direction-ltr ql-long-10365\"><span class=\"ql-author-10365\">To use SBD with shared storage, you must first create message layouts on one or three block devices. sbd create command writes metadata headers to one or more of the specified devices. It will also initialize message slots for up to 255 nodes. If the command is executed without any other options, the default timeout settings are used.<\/span><\/p>\n<p class=\"ql-direction-ltr ql-long-10365\"><span class=\"ql-author-10365\">Note: Ensure that the device or devices to be used for SBD do not hold any important data. Execution of the sbd create command directly rewrites approximately the first MB of the specified block device(s) without further requests or backups.<\/span><\/p>\n<ol>\n<li class=\"\"><span class=\"ql-author-10365\">Decide which block device or block devices to use for SBD.<\/span><\/li>\n<li><span class=\"ql-author-10365\">Use the following command to initialize the SBD device:<\/span><\/li>\n<\/ol>\n<p>root # sbd -d \/dev\/SBD create<\/p>\n<ul>\n<li class=\"\"><span class=\"ql-author-10365\">Please replace \/dev\/SBD with the actual path name, for example:<\/span><\/li>\n<\/ul>\n<p>\/dev\/disk\/by-id\/scsi-ST2000DM001-0123456_Wabcdefg\u3002<\/p>\n<ol>\n<li class=\"\"><span class=\"ql-author-10365 ql-font-microsoftyahei\"><span class=\"ql-author-10365 ql-font-microsoftyahei\">C<\/span><\/span><span class=\"ql-author-10365\">heck what has been written to the device:<\/span><\/li>\n<\/ol>\n<p>root # sbd -d \/dev\/SBD dump<br \/>\nHeader version : 2.1<br \/>\nUUID : 619127f4-0e06-434c-84a0-ea82036e144c<br \/>\nNumber of slots : 255<br \/>\nSector size : 512<br \/>\nTimeout (watchdog) : 5<br \/>\nTimeout (allocate) : 2<br \/>\nTimeout (loop) : 1<br \/>\nTimeout (msgwait) : 10<br \/>\n==Header on disk \/dev\/SBD is dumped<\/p>\n<p class=\"ql-direction-ltr ql-long-10365\"><strong class=\"ql-author-10365\">To edit the SBD configuration file<\/strong><\/p>\n<ul>\n<li><span class=\"ql-author-10365\">Open the file<\/span><\/li>\n<\/ul>\n<p>\/etc\/sysconfig\/sbd<\/p>\n<ol>\n<li class=\"ql-direction-ltr\"><span class=\"ql-author-10365\">Search for the following parameter: <\/span><\/li>\n<\/ol>\n<p>SBD_DEVICE<\/p>\n<p class=\"ql-direction-ltr\"><span class=\"ql-author-10365\">This parameter specifies the device to be monitored and used to exchange SBD messages. <\/span><\/p>\n<p class=\"ql-direction-ltr ql-text-indent-1\"><span class=\"ql-author-10365\">Edit this line and replace SBD with your SBD device:<\/span><\/p>\n<p class=\"ql-direction-ltr ql-text-indent-1\">SBD_DEVICE=\"\/dev\/SBD\"<\/p>\n<p class=\"ql-direction-ltr ql-text-indent-1\"><span class=\"ql-author-10365\">If you need to specify more than one device, use a semicolon to separate the devices (the order of the devices is irrelevant):<\/span><\/p>\n<p class=\"ql-direction-ltr ql-text-indent-1\">SBD_DEVICE=\"\/dev\/SBD\uff1b \/dev\/SBD1\uff1b\/dev\/SBD2\"<\/p>\n<p class=\"ql-direction-ltr ql-text-indent-1\"><span class=\"ql-author-10365\">If you are not able to access the SBD device, the daemon will not be able to start the cluster and will be disabled. <\/span><\/p>\n<ol>\n<li>\n<p class=\"ql-direction-ltr\"><span class=\"ql-author-10365\">Search for the following parameter:<\/span><\/p>\n<\/li>\n<\/ol>\n<p class=\"ql-direction-ltr\"><span class=\"ql-author-10365\">SBD_DELAY_START<\/span><\/p>\n<p class=\"ql-direction-ltr\"><span class=\"ql-author-10365\">Enables or disables delays. Set SBD_DELAY_START to yes (if msgwait is relatively long and cluster nodes boot quickly). Setting this parameter to yes delays SBD startup at boot time. This delay is sometimes required for virtual machines.<\/span><\/p>\n<p class=\"ql-direction-ltr\"><span class=\"ql-author-10365\">Enable the SBD daemon after adding the SBD device to the SBD profile The SBD daemon is a critical part of the cluster. This daemon needs to be run when the cluster is running. Therefore, whenever you start the pacemaker service, as a dependency, you must also start the sbd service.<\/span><\/p>\n<div>\n<div>\n<p class=\"ql-direction-ltr\"><strong class=\"ql-author-10365\">Enabling and Starting the SBD Service<\/strong><\/p>\n<\/div>\n<\/div>\n<div>\n<p class=\"ql-direction-ltr\"><span class=\"ql-author-10365\">On each node, enable the SBD service:<\/span><\/p>\n<p class=\"ql-direction-ltr\">root # systemctl enable sbd<\/p>\n<\/div>\n<div>\n<div>\n<p class=\"ql-direction-ltr\"><span class=\"ql-author-10365\">Whenever the Pacemaker service is started, the SBD service will be started along with the Corosync service.<\/span><\/p>\n<\/div>\n<\/div>\n<div>\n<p class=\"ql-direction-ltr\"><span class=\"ql-author-10365\">On each node, restart the cluster:<\/span><\/p>\n<p>root # pcs stonith sbd enable device=\"\/dev\/SBD\"<\/p>\n<p>root # pcs cluster restart<\/p>\n<\/div>\n<div>\n<div>\n<p class=\"ql-direction-ltr\"><span class=\"ql-author-10365\">This action automatically triggers the start of the SBD daemon.<\/span><\/p>\n<\/div>\n<div>\n<div>\n<p class=\"ql-direction-ltr\"><strong class=\"ql-author-10365\">Testing the SBD Device<\/strong><span class=\"ql-author-10365\">\u00a0<\/span><\/p>\n<p class=\"ql-direction-ltr\"><span class=\"ql-author-10365\">The following command dumps the node slots and their current messages from the SBD device:<\/span><\/p>\n<p class=\"ql-direction-ltr\">root # sbd -d \/dev\/SBD list<\/p>\n<\/div>\n<div>\n<p class=\"ql-direction-ltr\"><span class=\"ql-author-10365\">You should now see all the cluster nodes that have booted with SBD listed here. For example, if you have a two-node cluster, the message slot should show clear for both nodes:<\/span><\/p>\n<p>0 alice clear<\/p>\n<p>1 bob clear<\/p>\n<\/div>\n<div>\n<p class=\"ql-direction-ltr\"><span class=\"ql-author-10365\">Try sending the test message to one of the nodes:<\/span><\/p>\n<p>root # sbd -d \/dev\/SBD message alice test<\/p>\n<\/div>\n<div>\n<p class=\"ql-direction-ltr\"><span class=\"ql-author-10365\">This node will acknowledge receipt of the message in the syslog file:<\/span><\/p>\n<p>May 03 16:08:31 alice sbd[66139]: \/dev\/SBD: notice: servant: Received command test from bob on disk \/dev\/SBD<\/p>\n<\/div>\n<div>\n<p class=\"ql-direction-ltr\"><span class=\"ql-author-10365\">This confirms that SBD is indeed running properly on the node and is ready to receive messages.<\/span><\/p>\n<\/div>\n<\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>OVERVIEW SBD is a storage-based extended protection service that stands for STONITH Block Device.\u00a0 The highest priority for highly available clusters is to protect data integrity. This protection is achieved by preventing uncoordinated parallel access to data stores. Clusters use several control mechanisms to achieve this goal. However, electing several DCs in a cluster can result in network partitions or software failures. If this so-called \"node splitting\" is allowed to occur, data corruption may occur.\u00a0 The main mechanism that can be used to avoid this situation is node shielding through STONITH. If SBD is used as a node shielding mechanism ...<a href=https:\/\/www.deepin.org\/en\/2023-09-15\/>Read more<\/a><\/p>\n","protected":false},"author":11164,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[155,93],"tags":[],"_links":{"self":[{"href":"https:\/\/www.deepin.org\/en\/wp-json\/wp\/v2\/posts\/32830"}],"collection":[{"href":"https:\/\/www.deepin.org\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.deepin.org\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.deepin.org\/en\/wp-json\/wp\/v2\/users\/11164"}],"replies":[{"embeddable":true,"href":"https:\/\/www.deepin.org\/en\/wp-json\/wp\/v2\/comments?post=32830"}],"version-history":[{"count":5,"href":"https:\/\/www.deepin.org\/en\/wp-json\/wp\/v2\/posts\/32830\/revisions"}],"predecessor-version":[{"id":32837,"href":"https:\/\/www.deepin.org\/en\/wp-json\/wp\/v2\/posts\/32830\/revisions\/32837"}],"wp:attachment":[{"href":"https:\/\/www.deepin.org\/en\/wp-json\/wp\/v2\/media?parent=32830"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.deepin.org\/en\/wp-json\/wp\/v2\/categories?post=32830"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.deepin.org\/en\/wp-json\/wp\/v2\/tags?post=32830"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}