@@ -41,6 +41,8 @@ cleanup_joiner()
41
41
kill -9 $RSYNC_REAL_PID > /dev/null 2>&1 || \
42
42
:
43
43
rm -rf " $RSYNC_CONF "
44
+ rm -f " $STUNNEL_CONF "
45
+ rm -f " $STUNNEL_PID "
44
46
rm -rf " $MAGIC_FILE "
45
47
rm -rf " $RSYNC_PID "
46
48
wsrep_log_info " Joiner cleanup done."
@@ -68,7 +70,7 @@ check_pid_and_port()
68
70
local port_info=" $( sockstat -46lp ${rsync_port} 2> /dev/null | \
69
71
grep " :${rsync_port} " ) "
70
72
local is_rsync=" $( echo $port_info | \
71
- grep ' [[:space:]]\+ rsync[[:space:]]\ +' " $rsync_pid " 2> /dev/null) "
73
+ grep -E ' [[:space:]]+( rsync|stunnel) [[:space:]]+' " $rsync_pid " 2> /dev/null) "
72
74
;;
73
75
* )
74
76
if ! which lsof > /dev/null; then
@@ -79,7 +81,7 @@ check_pid_and_port()
79
81
local port_info=" $( lsof -i :$rsync_port -Pn 2> /dev/null | \
80
82
grep " (LISTEN)" ) "
81
83
local is_rsync=" $( echo $port_info | \
82
- grep -w ' ^rsync[[:space:]]\ +' " $rsync_pid " 2> /dev/null) "
84
+ grep -E ' ^( rsync|stunnel) [[:space:]]+' " $rsync_pid " 2> /dev/null) "
83
85
;;
84
86
esac
85
87
@@ -119,6 +121,12 @@ is_local_ip()
119
121
$get_addr_bin | grep " $address " > /dev/null
120
122
}
121
123
124
+ STUNNEL_CONF=" $WSREP_SST_OPT_DATA /stunnel.conf"
125
+ rm -f " $STUNNEL_CONF "
126
+
127
+ STUNNEL_PID=" $WSREP_SST_OPT_DATA /stunnel.pid"
128
+ rm -f " $STUNNEL_PID "
129
+
122
130
MAGIC_FILE=" $WSREP_SST_OPT_DATA /rsync_sst_complete"
123
131
rm -rf " $MAGIC_FILE "
124
132
156
164
FILTER=" -f '- /lost+found' -f '- /.fseventsd' -f '- /.Trashes'
157
165
-f '+ /wsrep_sst_binlog.tar' -f '+ /ib_lru_dump' -f '+ /ibdata*' -f '+ /*/' -f '- /*'"
158
166
167
+ SSTKEY=$( parse_cnf sst tkey " " )
168
+ SSTCERT=$( parse_cnf sst tcert " " )
169
+ STUNNEL=" "
170
+ if [ -f " $SSTKEY " ] && [ -f " $SSTCERT " ] && wsrep_check_programs stunnel
171
+ then
172
+ STUNNEL=" stunnel ${STUNNEL_CONF} "
173
+ fi
174
+
159
175
if [ " $WSREP_SST_OPT_ROLE " = " donor" ]
160
176
then
161
177
178
+ cat << EOF > "$STUNNEL_CONF "
179
+ CApath = ${SSTCERT%/* }
180
+ foreground = yes
181
+ pid = $STUNNEL_PID
182
+ debug = warning
183
+ client = yes
184
+ connect = ${WSREP_SST_OPT_ADDR%/* }
185
+ TIMEOUTclose = 0
186
+ verifyPeer = yes
187
+ EOF
188
+
162
189
if [ $WSREP_SST_OPT_BYPASS -eq 0 ]
163
190
then
164
191
220
247
221
248
# first, the normal directories, so that we can detect incompatible protocol
222
249
RC=0
223
- eval rsync --owner --group --perms --links --specials \
250
+ eval rsync ${STUNNEL: +--rsh=" $STUNNEL " } \
251
+ --owner --group --perms --links --specials \
224
252
--ignore-times --inplace --dirs --delete --quiet \
225
253
$WHOLE_FILE_OPT ${FILTER} " $WSREP_SST_OPT_DATA /" \
226
254
rsync://$WSREP_SST_OPT_ADDR >&2 || RC=$?
243
271
fi
244
272
245
273
# second, we transfer InnoDB log files
246
- rsync --owner --group --perms --links --specials \
274
+ rsync ${STUNNEL: +--rsh=" $STUNNEL " } \
275
+ --owner --group --perms --links --specials \
247
276
--ignore-times --inplace --dirs --delete --quiet \
248
277
$WHOLE_FILE_OPT -f ' + /ib_logfile[0-9]*' -f ' - **' " $WSREP_LOG_DIR /" \
249
278
rsync://$WSREP_SST_OPT_ADDR -log_dir >&2 || RC=$?
263
292
264
293
find . -maxdepth 1 -mindepth 1 -type d -not -name " lost+found" \
265
294
-print0 | xargs -I{} -0 -P $count \
266
- rsync --owner --group --perms --links --specials \
295
+ rsync ${STUNNEL: +--rsh=" $STUNNEL " } \
296
+ --owner --group --perms --links --specials \
267
297
--ignore-times --inplace --recursive --delete --quiet \
268
298
$WHOLE_FILE_OPT --exclude ' */ib_logfile*' " $WSREP_SST_OPT_DATA " /{}/ \
269
299
rsync://$WSREP_SST_OPT_ADDR /{} >&2 || RC=$?
286
316
echo " continue" # now server can resume updating data
287
317
288
318
echo " $STATE " > " $MAGIC_FILE "
289
- rsync --archive --quiet --checksum " $MAGIC_FILE " rsync://$WSREP_SST_OPT_ADDR
319
+ rsync ${STUNNEL: +--rsh=" $STUNNEL " } \
320
+ --archive --quiet --checksum " $MAGIC_FILE " rsync://$WSREP_SST_OPT_ADDR
290
321
291
322
echo " done $STATE "
292
323
@@ -347,14 +378,37 @@ EOF
347
378
# If the IP is local listen only in it
348
379
if is_local_ip " $RSYNC_ADDR "
349
380
then
350
- rsync --daemon --no-detach --address " $RSYNC_ADDR " --port " $RSYNC_PORT " --config " $RSYNC_CONF " &
381
+ RSYNC_EXTRA_ARGS=" --address $RSYNC_ADDR "
382
+ STUNNEL_ACCEPT=" $RSYNC_ADDR :$RSYNC_PORT "
351
383
else
352
- # Not local, possibly a NAT, listen in all interface
353
- rsync --daemon --no-detach --port " $RSYNC_PORT " --config " $RSYNC_CONF " &
384
+ # Not local, possibly a NAT, listen on all interfaces
385
+ RSYNC_EXTRA_ARGS=" "
386
+ STUNNEL_ACCEPT=" $RSYNC_PORT "
354
387
# Overwrite address with all
355
388
RSYNC_ADDR=" *"
356
389
fi
357
- RSYNC_REAL_PID=$!
390
+
391
+ if [ -z " $STUNNEL " ]
392
+ then
393
+ rsync --daemon --no-detach --port " $RSYNC_PORT " --config " $RSYNC_CONF " ${RSYNC_EXTRA_ARGS} &
394
+ RSYNC_REAL_PID=$!
395
+ else
396
+ cat << EOF > "$STUNNEL_CONF "
397
+ key = $SSTKEY
398
+ cert = $SSTCERT
399
+ foreground = yes
400
+ pid = $STUNNEL_PID
401
+ debug = warning
402
+ client = no
403
+ [rsync]
404
+ accept = $STUNNEL_ACCEPT
405
+ exec = $( which rsync)
406
+ execargs = rsync --server --daemon --config=$RSYNC_CONF .
407
+ EOF
408
+ stunnel " $STUNNEL_CONF " &
409
+ RSYNC_REAL_PID=$!
410
+ RSYNC_PID=$STUNNEL_PID
411
+ fi
358
412
359
413
until check_pid_and_port " $RSYNC_PID " " $RSYNC_REAL_PID " " $RSYNC_ADDR " " $RSYNC_PORT "
360
414
do
0 commit comments