summaryrefslogtreecommitdiff
path: root/scripts/wsrep_sst_rsync.sh
diff options
context:
space:
mode:
authorSeppo Jaakola <seppo.jaakola@codership.com>2013-08-07 00:17:16 +0300
committerSeppo Jaakola <seppo.jaakola@codership.com>2013-08-07 00:17:16 +0300
commit551ad1cf6f80ad1fab35746eee304d733baa9adf (patch)
tree120046ba39eaa403a7b9c0d3de0a03b5de0c1bbb /scripts/wsrep_sst_rsync.sh
parent7cf10ddf8ca7044278b4aa1cf5a5525675cd101d (diff)
downloadmariadb-git-551ad1cf6f80ad1fab35746eee304d733baa9adf.tar.gz
Merged FreeBSD compatibility changes (up to revision 3893 in lp:~codership/codership-mysql/5.5-23)
Diffstat (limited to 'scripts/wsrep_sst_rsync.sh')
-rwxr-xr-x[-rw-r--r--]scripts/wsrep_sst_rsync.sh64
1 files changed, 42 insertions, 22 deletions
diff --git a/scripts/wsrep_sst_rsync.sh b/scripts/wsrep_sst_rsync.sh
index af2d41f2659..7cd232e0887 100644..100755
--- a/scripts/wsrep_sst_rsync.sh
+++ b/scripts/wsrep_sst_rsync.sh
@@ -20,6 +20,8 @@
RSYNC_PID=
RSYNC_CONF=
+OS=$(uname)
+[ "$OS" == "Darwin" ] && export -n LD_LIBRARY_PATH
. $(dirname $0)/wsrep_sst_common
@@ -50,14 +52,32 @@ check_pid_and_port()
local rsync_pid=$(cat $pid_file)
local rsync_port=$2
- check_pid $pid_file && \
- netstat -anpt 2>/dev/null | \
- grep LISTEN | grep \:$rsync_port | grep $rsync_pid/rsync >/dev/null
+ if [ "$OS" == "Darwin" -o "$OS" == "FreeBSD" ]; then
+ # no netstat --program(-p) option in Darwin and FreeBSD
+ check_pid $pid_file && \
+ lsof -i -Pn 2>/dev/null | \
+ grep "(LISTEN)" | grep ":$rsync_port" | grep -w '^rsync[[:space:]]\+'"$rsync_pid" >/dev/null
+ else
+ check_pid $pid_file && \
+ netstat -lnpt 2>/dev/null | \
+ grep LISTEN | grep \:$rsync_port | grep $rsync_pid/rsync >/dev/null
+ fi
}
MAGIC_FILE="$WSREP_SST_OPT_DATA/rsync_sst_complete"
rm -rf "$MAGIC_FILE"
+# Old filter - include everything except selected
+# FILTER=(--exclude '*.err' --exclude '*.pid' --exclude '*.sock' \
+# --exclude '*.conf' --exclude core --exclude 'galera.*' \
+# --exclude grastate.txt --exclude '*.pem' \
+# --exclude '*.[0-9][0-9][0-9][0-9][0-9][0-9]' --exclude '*.index')
+
+# New filter - exclude everything except dirs (schemas) and innodb files
+FILTER=(-f '- lost+found' -f '+ /ib_lru_dump' -f '+ /ibdata*' -f '+ /ib_logfile*' -f '+ */' -f '-! */*')
+# Old versions of rsync have a bug transferring filter rules to daemon, so specify filter rules directly to daemon
+FILTER_DAEMON="- lost+found + /ib_lru_dump + /ibdata* + ib_logfile* + */ -! */*"
+
if [ "$WSREP_SST_OPT_ROLE" = "donor" ]
then
@@ -85,21 +105,12 @@ then
sync
- # Old filter - include everything except selected
- # FILTER=(--exclude '*.err' --exclude '*.pid' --exclude '*.sock' \
- # --exclude '*.conf' --exclude core --exclude 'galera.*' \
- # --exclude grastate.txt --exclude '*.pem' \
- # --exclude '*.[0-9][0-9][0-9][0-9][0-9][0-9]' --exclude '*.index')
-
- # New filter - exclude everything except dirs (schemas) and innodb files
- FILTER=(-f '- lost+found' -f '+ /ib_lru_dump' -f '+ /ibdata*' -f '+ /ib_logfile*' -f '+ */' -f '-! */*')
-
# first, the normal directories, so that we can detect incompatible protocol
RC=0
rsync --archive --no-times --ignore-times --inplace --delete --quiet \
--no-recursive --dirs \
$WHOLE_FILE_OPT "${FILTER[@]}" "$WSREP_SST_OPT_DATA/" \
- rsync://$WSREP_SST_OPT_ADDR || RC=$?
+ rsync://$WSREP_SST_OPT_ADDR-with_filter || RC=$?
[ $RC -ne 0 ] && wsrep_log_error "rsync returned code $RC:"
@@ -122,9 +133,11 @@ then
# then, we parallelize the transfer of database directories, use . so that pathconcatenation works
pushd "$WSREP_SST_OPT_DATA" 1>/dev/null
- count=$(grep -c processor /proc/cpuinfo)
+ count=1
+ [ "$OS" == "Linux" ] && count=$(grep -c processor /proc/cpuinfo)
+ [ "$OS" == "Darwin" -o "$OS" == "FreeBSD" ] && count=$(sysctl -n hw.ncpu)
- find . -maxdepth 1 -mindepth 1 -type d -print0 | xargs -i -0 -P $count \
+ find . -maxdepth 1 -mindepth 1 -type d -print0 | xargs -I{} -0 -P $count \
rsync --archive --no-times --ignore-times --inplace --delete --quiet \
$WHOLE_FILE_OPT "$WSREP_SST_OPT_DATA"/{}/ \
rsync://$WSREP_SST_OPT_ADDR/{} || RC=$?
@@ -151,7 +164,7 @@ then
echo "continue" # now server can resume updating data
echo "$STATE" > "$MAGIC_FILE"
- rsync -aqc "$MAGIC_FILE" rsync://$WSREP_SST_OPT_ADDR
+ rsync --archive --quiet --checksum "$MAGIC_FILE" rsync://$WSREP_SST_OPT_ADDR
echo "done $STATE"
@@ -180,7 +193,7 @@ then
fi
trap "exit 32" HUP PIPE
- trap "exit 3" INT TERM
+ trap "exit 3" INT TERM ABRT
trap cleanup_joiner EXIT
MYUID=$(id -u)
@@ -190,12 +203,19 @@ then
cat << EOF > "$RSYNC_CONF"
pid file = $RSYNC_PID
use chroot = no
+[$MODULE-with_filter]
+ path = $WSREP_SST_OPT_DATA
+ read only = no
+ timeout = 300
+ uid = $MYUID
+ gid = $MYGID
+ filter = $FILTER_DAEMON
[$MODULE]
- path = $WSREP_SST_OPT_DATA
- read only = no
- timeout = 300
- uid = $MYUID
- gid = $MYGID
+ path = $WSREP_SST_OPT_DATA
+ read only = no
+ timeout = 300
+ uid = $MYUID
+ gid = $MYGID
EOF
# rm -rf "$DATA"/ib_logfile* # we don't want old logs around