unix:freebsd:system_builds:carp
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | unix:freebsd:system_builds:carp [2019/07/10 20:46] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Setting up CARP ====== | ||
+ | |||
+ | You need carp set up to tell the nodes which is primary and which is secondary. | ||
+ | |||
+ | I'm using vlan50 for my data, so we need to be able to switch between machines. The two machines will have 192.168.209.0/ | ||
+ | * iscsi-0: 192.168.209.67 | ||
+ | * iscsi-1: 192.168.209.68 | ||
+ | * CARP: 192.168.209.64 | ||
+ | |||
+ | ===== Enable carp and set shared IP ===== | ||
+ | |||
+ | Add the directives to load the carp module and make the alias for vlan50. the carp.preempt sets it so so when the parent interface goes down or comes up, the carp interface will do the same | ||
+ | <code bash> | ||
+ | echo ' | ||
+ | echo ' | ||
+ | echo ' | ||
+ | </ | ||
+ | |||
+ | if you want to test this, you can run the following: | ||
+ | |||
+ | <code bash> | ||
+ | kldload carp | ||
+ | sysctl net.inet.carp.preempt=1 | ||
+ | ifconfig vlan50 alias vhid 1 pass iscsilan 10.19.209.64/ | ||
+ | </ | ||
+ | |||
+ | ===== Set devd ===== | ||
+ | |||
+ | Add the following to the bottom of / | ||
+ | <code bash> | ||
+ | notify 30 { | ||
+ | match " | ||
+ | match " | ||
+ | match " | ||
+ | action "/ | ||
+ | }; | ||
+ | |||
+ | notify 30 { | ||
+ | match " | ||
+ | match " | ||
+ | match " | ||
+ | action "/ | ||
+ | }; | ||
+ | |||
+ | </ | ||
+ | |||
+ | ===== Create the failover script ===== | ||
+ | |||
+ | This is taken mainly from the hast article at [https:// | ||
+ | |||
+ | The following script is designed to bring up/shutdown the hast volumes and will eventually be used to handle the iSCSI service and NFS. It already handles the zpool itself. | ||
+ | |||
+ | Change resource list and pool name before implementing. | ||
+ | |||
+ | <code bash failover> | ||
+ | #!/bin/sh | ||
+ | |||
+ | # https:// | ||
+ | # Original script by Freddie Cash < | ||
+ | # Modified by Michael W. Lucas < | ||
+ | # and Viktor Petersson < | ||
+ | # Modified by George Kontostanos < | ||
+ | |||
+ | # The names of the HAST resources, as listed in / | ||
+ | resources=" | ||
+ | |||
+ | # delay in mounting HAST resource after becoming master | ||
+ | # make your best guess | ||
+ | delay=3 | ||
+ | |||
+ | # logging | ||
+ | log=" | ||
+ | name=" | ||
+ | pool=" | ||
+ | |||
+ | # end of user configurable stuff | ||
+ | |||
+ | case " | ||
+ | | ||
+ | logger -p $log -t $name " | ||
+ | sleep ${delay} | ||
+ | |||
+ | # Wait for any "hastd secondary" | ||
+ | for disk in ${resources}; | ||
+ | while $( pgrep -lf " | ||
+ | sleep 1 | ||
+ | done | ||
+ | |||
+ | # Switch role for each disk | ||
+ | | ||
+ | if [ $? -ne 0 ]; then | ||
+ | logger -p $log -t $name " | ||
+ | exit 1 | ||
+ | fi | ||
+ | done | ||
+ | |||
+ | # Wait for the /dev/hast/* devices to appear | ||
+ | for disk in ${resources}; | ||
+ | for I in $( jot 60 ); do | ||
+ | [ -c "/ | ||
+ | sleep 0.5 | ||
+ | done | ||
+ | |||
+ | if [ ! -c "/ | ||
+ | logger -p $log -t $name "GEOM provider / | ||
+ | exit 1 | ||
+ | fi | ||
+ | done | ||
+ | |||
+ | logger -p $log -t $name "Role for HAST resources ${resources} switched to primary." | ||
+ | |||
+ | |||
+ | logger -p $log -t $name " | ||
+ | # Import ZFS pool. Do it forcibly as it remembers hostid of | ||
+ | # the other cluster node. | ||
+ | out=`zpool import -f " | ||
+ | if [ $? -ne 0 ]; then | ||
+ | logger -p local0.error -t hast "ZFS pool import for resource ${resource} failed: ${out}." | ||
+ | exit 1 | ||
+ | fi | ||
+ | logger -p local0.debug -t hast "ZFS pool for resource ${resource} imported." | ||
+ | |||
+ | ;; | ||
+ | |||
+ | | ||
+ | logger -p $log -t $name " | ||
+ | |||
+ | # Switch roles for the HAST resources | ||
+ | zpool list | egrep -q " | ||
+ | if [ $? -eq 0 ]; then | ||
+ | # Forcibly export file pool. | ||
+ | | ||
+ | if [ $? -ne 0 ]; then | ||
+ | | ||
+ | exit 1 | ||
+ | fi | ||
+ | | ||
+ | fi | ||
+ | for disk in ${resources}; | ||
+ | sleep $delay | ||
+ | | ||
+ | if [ $? -ne 0 ]; then | ||
+ | logger -p $log -t $name " | ||
+ | exit 1 | ||
+ | fi | ||
+ | | ||
+ | done | ||
+ | ;; | ||
+ | esac | ||
+ | </ | ||
+ | ===== References ===== | ||
+ | * https:// | ||
+ | * https:// | ||
+ | * https:// | ||
unix/freebsd/system_builds/carp.txt · Last modified: 2019/07/10 20:46 by 127.0.0.1