Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
551ad1cf
Commit
551ad1cf
authored
Aug 07, 2013
by
Seppo Jaakola
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merged FreeBSD compatibility changes (up to revision 3893 in lp:~codership/codership-mysql/5.5-23)
parent
7cf10ddf
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
222 additions
and
58 deletions
+222
-58
.bzrignore
.bzrignore
+3
-0
cmake/install_macros.cmake
cmake/install_macros.cmake
+24
-0
cmake/os/FreeBSD.cmake
cmake/os/FreeBSD.cmake
+3
-0
scripts/mysqld_safe.sh
scripts/mysqld_safe.sh
+3
-2
scripts/wsrep_sst_rsync.sh
scripts/wsrep_sst_rsync.sh
+42
-22
scripts/wsrep_sst_xtrabackup.sh
scripts/wsrep_sst_xtrabackup.sh
+145
-34
sql/wsrep_utils.cc
sql/wsrep_utils.cc
+2
-0
No files found.
.bzrignore
View file @
551ad1cf
...
@@ -72,6 +72,9 @@ RelWithDebInfo
...
@@ -72,6 +72,9 @@ RelWithDebInfo
.vimrc
.vimrc
ac_available_languages_fragment
ac_available_languages_fragment
BitKeeper/
BitKeeper/
build_debug
build_install
build_release
client/*.ds?
client/*.ds?
client/completion_hash.cpp
client/completion_hash.cpp
client/decimal.c
client/decimal.c
...
...
cmake/install_macros.cmake
View file @
551ad1cf
...
@@ -13,8 +13,30 @@
...
@@ -13,8 +13,30 @@
# along with this program; if not, write to the Free Software
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
if
(
APPLE
)
LIST
(
APPEND CMAKE_CXX_LINK_EXECUTABLE
"dsymutil <TARGET>"
)
LIST
(
APPEND CMAKE_C_LINK_EXECUTABLE
"dsymutil <TARGET>"
)
LIST
(
APPEND CMAKE_CXX_CREATE_SHARED_LIBRARY
"dsymutil <TARGET>"
)
LIST
(
APPEND CMAKE_C_CREATE_SHARED_LIBRARY
"dsymutil <TARGET>"
)
LIST
(
APPEND CMAKE_CXX_CREATE_SHARED_MODULE
"dsymutil <TARGET>"
)
LIST
(
APPEND CMAKE_C_CREATE_SHARED_MODULE
"dsymutil <TARGET>"
)
ENDIF
()
GET_FILENAME_COMPONENT
(
MYSQL_CMAKE_SCRIPT_DIR
${
CMAKE_CURRENT_LIST_FILE
}
PATH
)
GET_FILENAME_COMPONENT
(
MYSQL_CMAKE_SCRIPT_DIR
${
CMAKE_CURRENT_LIST_FILE
}
PATH
)
INCLUDE
(
${
MYSQL_CMAKE_SCRIPT_DIR
}
/cmake_parse_arguments.cmake
)
INCLUDE
(
${
MYSQL_CMAKE_SCRIPT_DIR
}
/cmake_parse_arguments.cmake
)
MACRO
(
INSTALL_DSYM_DIRECTORIES targets
)
IF
(
APPLE
)
FOREACH
(
target
${
targets
}
)
GET_TARGET_PROPERTY
(
location
${
target
}
LOCATION
)
GET_TARGET_PROPERTY
(
type
${
target
}
TYPE
)
# It's a dirty hack, but cmake too stupid and mysql cmake files too buggy */
STRING
(
REPLACE
"liblibmysql.dylib"
"libmysqlclient.
${
SHARED_LIB_MAJOR_VERSION
}
.dylib"
location
${
location
}
)
IF
(
type MATCHES
"EXECUTABLE"
OR type MATCHES
"MODULE"
OR type MATCHES
"SHARED_LIBRARY"
)
INSTALL
(
DIRECTORY
"
${
location
}
.dSYM"
DESTINATION
${
INSTALL_LOCATION
}
COMPONENT Debuginfo
)
ENDIF
()
ENDFOREACH
()
ENDIF
()
ENDMACRO
()
FUNCTION
(
INSTALL_DEBUG_SYMBOLS
)
FUNCTION
(
INSTALL_DEBUG_SYMBOLS
)
IF
(
MSVC
)
IF
(
MSVC
)
...
@@ -31,6 +53,7 @@ FUNCTION (INSTALL_DEBUG_SYMBOLS)
...
@@ -31,6 +53,7 @@ FUNCTION (INSTALL_DEBUG_SYMBOLS)
MESSAGE
(
FATAL_ERROR
"No INSTALL_LOCATION passed to INSTALL_DEBUG_SYMBOLS"
)
MESSAGE
(
FATAL_ERROR
"No INSTALL_LOCATION passed to INSTALL_DEBUG_SYMBOLS"
)
ENDIF
()
ENDIF
()
SET
(
targets
${
ARG_DEFAULT_ARGS
}
)
SET
(
targets
${
ARG_DEFAULT_ARGS
}
)
FOREACH
(
target
${
targets
}
)
FOREACH
(
target
${
targets
}
)
GET_TARGET_PROPERTY
(
type
${
target
}
TYPE
)
GET_TARGET_PROPERTY
(
type
${
target
}
TYPE
)
GET_TARGET_PROPERTY
(
location
${
target
}
LOCATION
)
GET_TARGET_PROPERTY
(
location
${
target
}
LOCATION
)
...
@@ -252,6 +275,7 @@ FUNCTION(MYSQL_INSTALL_TARGETS)
...
@@ -252,6 +275,7 @@ FUNCTION(MYSQL_INSTALL_TARGETS)
INSTALL
(
TARGETS
${
TARGETS
}
DESTINATION
${
ARG_DESTINATION
}
${
COMP
}
)
INSTALL
(
TARGETS
${
TARGETS
}
DESTINATION
${
ARG_DESTINATION
}
${
COMP
}
)
INSTALL_DEBUG_SYMBOLS
(
${
TARGETS
}
${
COMP
}
INSTALL_LOCATION
${
ARG_DESTINATION
}
)
INSTALL_DEBUG_SYMBOLS
(
${
TARGETS
}
${
COMP
}
INSTALL_LOCATION
${
ARG_DESTINATION
}
)
INSTALL_DSYM_DIRECTORIES
(
"
${
TARGETS
}
"
)
ENDFUNCTION
()
ENDFUNCTION
()
...
...
cmake/os/FreeBSD.cmake
View file @
551ad1cf
...
@@ -38,3 +38,6 @@ IF(CMAKE_SIZEOF_VOID_P EQUAL 4 AND CMAKE_SYSTEM_PROCESSOR STREQUAL "i386")
...
@@ -38,3 +38,6 @@ IF(CMAKE_SIZEOF_VOID_P EQUAL 4 AND CMAKE_SYSTEM_PROCESSOR STREQUAL "i386")
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-march=i686"
)
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-march=i686"
)
SET
(
CMAKE_REQUIRED_FLAGS
"
${
CMAKE_REQUIRED_FLAGS
}
-march=i686"
)
SET
(
CMAKE_REQUIRED_FLAGS
"
${
CMAKE_REQUIRED_FLAGS
}
-march=i686"
)
ENDIF
()
ENDIF
()
SET
(
HAVE_SYS_TIMEB_H CACHE INTERNAL
""
)
scripts/mysqld_safe.sh
View file @
551ad1cf
...
@@ -241,7 +241,8 @@ wsrep_recover_position() {
...
@@ -241,7 +241,8 @@ wsrep_recover_position() {
if
[
-z
"
$rp
"
]
;
then
if
[
-z
"
$rp
"
]
;
then
local
skipped
=
"
$(
grep
WSREP
$wr_logfile
|
grep
'skipping position recovery'
)
"
local
skipped
=
"
$(
grep
WSREP
$wr_logfile
|
grep
'skipping position recovery'
)
"
if
[
-z
"
$skipped
"
]
;
then
if
[
-z
"
$skipped
"
]
;
then
log_error
"WSREP: Failed to recover position: "
`
cat
$wr_logfile
`
;
log_error
"WSREP: Failed to recover position:
'
`
cat
$wr_logfile
`
'"
ret
=
1
ret
=
1
else
else
log_notice
"WSREP: Position recovery skipped"
log_notice
"WSREP: Position recovery skipped"
...
@@ -253,7 +254,7 @@ wsrep_recover_position() {
...
@@ -253,7 +254,7 @@ wsrep_recover_position() {
wsrep_start_position_opt
=
"--wsrep_start_position=
$start_pos
"
wsrep_start_position_opt
=
"--wsrep_start_position=
$start_pos
"
fi
fi
rm
$wr_logfile
[
$ret
-eq
0
]
&&
rm
$wr_logfile
return
$ret
return
$ret
}
}
...
...
scripts/wsrep_sst_rsync.sh
100644 → 100755
View file @
551ad1cf
...
@@ -20,6 +20,8 @@
...
@@ -20,6 +20,8 @@
RSYNC_PID
=
RSYNC_PID
=
RSYNC_CONF
=
RSYNC_CONF
=
OS
=
$(
uname
)
[
"
$OS
"
==
"Darwin"
]
&&
export
-n
LD_LIBRARY_PATH
.
$(
dirname
$0
)
/wsrep_sst_common
.
$(
dirname
$0
)
/wsrep_sst_common
...
@@ -50,14 +52,32 @@ check_pid_and_port()
...
@@ -50,14 +52,32 @@ check_pid_and_port()
local
rsync_pid
=
$(
cat
$pid_file
)
local
rsync_pid
=
$(
cat
$pid_file
)
local
rsync_port
=
$2
local
rsync_port
=
$2
check_pid
$pid_file
&&
\
if
[
"
$OS
"
==
"Darwin"
-o
"
$OS
"
==
"FreeBSD"
]
;
then
netstat
-anpt
2>/dev/null |
\
# no netstat --program(-p) option in Darwin and FreeBSD
grep
LISTEN |
grep
\:
$rsync_port
|
grep
$rsync_pid
/rsync
>
/dev/null
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"
MAGIC_FILE
=
"
$WSREP_SST_OPT_DATA
/rsync_sst_complete"
rm
-rf
"
$MAGIC_FILE
"
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"
]
if
[
"
$WSREP_SST_OPT_ROLE
"
=
"donor"
]
then
then
...
@@ -85,21 +105,12 @@ then
...
@@ -85,21 +105,12 @@ then
sync
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
# first, the normal directories, so that we can detect incompatible protocol
RC
=
0
RC
=
0
rsync
--archive
--no-times
--ignore-times
--inplace
--delete
--quiet
\
rsync
--archive
--no-times
--ignore-times
--inplace
--delete
--quiet
\
--no-recursive
--dirs
\
--no-recursive
--dirs
\
$WHOLE_FILE_OPT
"
${
FILTER
[@]
}
"
"
$WSREP_SST_OPT_DATA
/"
\
$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
:"
[
$RC
-ne
0
]
&&
wsrep_log_error
"rsync returned code
$RC
:"
...
@@ -122,9 +133,11 @@ then
...
@@ -122,9 +133,11 @@ then
# then, we parallelize the transfer of database directories, use . so that pathconcatenation works
# then, we parallelize the transfer of database directories, use . so that pathconcatenation works
pushd
"
$WSREP_SST_OPT_DATA
"
1>/dev/null
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
\
rsync
--archive
--no-times
--ignore-times
--inplace
--delete
--quiet
\
$WHOLE_FILE_OPT
"
$WSREP_SST_OPT_DATA
"
/
{}
/
\
$WHOLE_FILE_OPT
"
$WSREP_SST_OPT_DATA
"
/
{}
/
\
rsync://
$WSREP_SST_OPT_ADDR
/
{}
||
RC
=
$?
rsync://
$WSREP_SST_OPT_ADDR
/
{}
||
RC
=
$?
...
@@ -151,7 +164,7 @@ then
...
@@ -151,7 +164,7 @@ then
echo
"continue"
# now server can resume updating data
echo
"continue"
# now server can resume updating data
echo
"
$STATE
"
>
"
$MAGIC_FILE
"
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
"
echo
"done
$STATE
"
...
@@ -180,7 +193,7 @@ then
...
@@ -180,7 +193,7 @@ then
fi
fi
trap
"exit 32"
HUP PIPE
trap
"exit 32"
HUP PIPE
trap
"exit 3"
INT TERM
trap
"exit 3"
INT TERM
ABRT
trap
cleanup_joiner EXIT
trap
cleanup_joiner EXIT
MYUID
=
$(
id
-u
)
MYUID
=
$(
id
-u
)
...
@@ -190,12 +203,19 @@ then
...
@@ -190,12 +203,19 @@ then
cat
<<
EOF
> "
$RSYNC_CONF
"
cat
<<
EOF
> "
$RSYNC_CONF
"
pid file =
$RSYNC_PID
pid file =
$RSYNC_PID
use chroot = no
use chroot = no
[
$MODULE
-with_filter]
path =
$WSREP_SST_OPT_DATA
read only = no
timeout = 300
uid =
$MYUID
gid =
$MYGID
filter =
$FILTER_DAEMON
[
$MODULE
]
[
$MODULE
]
path =
$WSREP_SST_OPT_DATA
path =
$WSREP_SST_OPT_DATA
read only = no
read only = no
timeout = 300
timeout = 300
uid =
$MYUID
uid =
$MYUID
gid =
$MYGID
gid =
$MYGID
EOF
EOF
# rm -rf "$DATA"/ib_logfile* # we don't want old logs around
# rm -rf "$DATA"/ib_logfile* # we don't want old logs around
...
...
scripts/wsrep_sst_xtrabackup.sh
View file @
551ad1cf
...
@@ -15,14 +15,25 @@
...
@@ -15,14 +15,25 @@
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston
# MA 02110-1301 USA.
# MA 02110-1301 USA.
# This is a reference script for Percona XtraBackup-based state snapshot tansfer
#############################################################################################################
# Dependencies: (depending on configuration)
# This is a reference script for Percona XtraBackup-based state snapshot transfer #
# xbcrypt for encryption/decryption.
# Dependencies: (depending on configuration) #
# qpress for decompression. Download from http://www.quicklz.com/qpress-11-linux-x64.tar till
# xbcrypt for encryption/decryption. #
# https://blueprints.launchpad.net/percona-xtrabackup/+spec/package-qpress is fixed.
# qpress for decompression. Download from http://www.quicklz.com/qpress-11-linux-x64.tar till #
# my_print_defaults to extract values from my.cnf.
# https://blueprints.launchpad.net/percona-xtrabackup/+spec/package-qpress is fixed. #
# netcat for transfer.
# my_print_defaults to extract values from my.cnf. #
# xbstream for streaming.
# netcat for transfer. #
# xbstream/tar for streaming. (and xtrabackup ofc) #
# #
# Currently only option in cnf is read specifically for SST #
# [sst] #
# streamfmt=tar|xbstream #
# #
# Default is tar till lp:1193240 is fixed #
# You need to use xbstream for encryption, compression etc., however, #
# lp:1193240 requires you to manually cleanup the directory prior to SST #
# #
#############################################################################################################
.
$(
dirname
$0
)
/wsrep_sst_common
.
$(
dirname
$0
)
/wsrep_sst_common
...
@@ -30,6 +41,13 @@ ealgo=""
...
@@ -30,6 +41,13 @@ ealgo=""
ekey
=
""
ekey
=
""
ekeyfile
=
""
ekeyfile
=
""
encrypt
=
0
encrypt
=
0
nproc
=
1
ecode
=
0
XTRABACKUP_PID
=
""
sfmt
=
"tar"
strmcmd
=
""
declare
-a
RC
get_keys
()
get_keys
()
{
{
...
@@ -39,6 +57,11 @@ get_keys()
...
@@ -39,6 +57,11 @@ get_keys()
if
!
my_print_defaults
-c
$WSREP_SST_OPT_CONF
xtrabackup |
grep
-q
encrypt
;
then
if
!
my_print_defaults
-c
$WSREP_SST_OPT_CONF
xtrabackup |
grep
-q
encrypt
;
then
return
return
fi
fi
if
[[
$sfmt
==
'tar'
]]
;
then
wsrep_log_info
"NOTE: Encryption cannot be enabled with tar format"
return
fi
wsrep_log_info
"Encryption enabled in my.cnf - not supported at the moment - Bug in Xtrabackup - lp:1190343"
wsrep_log_info
"Encryption enabled in my.cnf - not supported at the moment - Bug in Xtrabackup - lp:1190343"
ealgo
=
$(
my_print_defaults
-c
$WSREP_SST_OPT_CONF
xtrabackup |
grep
--
'--encrypt='
|
cut
-d
=
-f2
)
ealgo
=
$(
my_print_defaults
-c
$WSREP_SST_OPT_CONF
xtrabackup |
grep
--
'--encrypt='
|
cut
-d
=
-f2
)
ekey
=
$(
my_print_defaults
-c
$WSREP_SST_OPT_CONF
xtrabackup |
grep
--
'--encrypt-key='
|
cut
-d
=
-f2
)
ekey
=
$(
my_print_defaults
-c
$WSREP_SST_OPT_CONF
xtrabackup |
grep
--
'--encrypt-key='
|
cut
-d
=
-f2
)
...
@@ -56,10 +79,58 @@ get_keys()
...
@@ -56,10 +79,58 @@ get_keys()
encrypt
=
1
encrypt
=
1
}
}
read_cnf
()
{
sfmt
=
$(
my_print_defaults
-c
$WSREP_SST_OPT_CONF
sst |
grep
--
'--streamfmt'
|
cut
-d
=
-f2
)
if
[[
$sfmt
==
'xbstream'
]]
;
then
wsrep_log_info
"Streaming with xbstream"
if
[[
"
$WSREP_SST_OPT_ROLE
"
==
"joiner"
]]
;
then
wsrep_log_info
"xbstream requires manual cleanup of data directory before SST - lp:1193240"
strmcmd
=
"xbstream -x -C
${
DATA
}
"
elif
[[
"
$WSREP_SST_OPT_ROLE
"
==
"donor"
]]
;
then
strmcmd
=
"xbstream -c
${
INFO_FILE
}
${
IST_FILE
}
"
else
wsrep_log_error
"Invalid role:
$WSREP_SST_OPT_ROLE
"
exit
22
fi
else
sfmt
=
"tar"
wsrep_log_info
"Streaming with tar"
wsrep_log_info
"Note: Advanced xtrabackup features - encryption,compression etc. not available with tar."
if
[[
"
$WSREP_SST_OPT_ROLE
"
==
"joiner"
]]
;
then
wsrep_log_info
"However, xbstream requires manual cleanup of data directory before SST - lp:1193240."
strmcmd
=
"tar xfi - -C
${
DATA
}
"
elif
[[
"
$WSREP_SST_OPT_ROLE
"
==
"donor"
]]
;
then
strmcmd
=
"tar cf -
${
INFO_FILE
}
${
IST_FILE
}
"
else
wsrep_log_error
"Invalid role:
$WSREP_SST_OPT_ROLE
"
exit
22
fi
fi
}
get_proc
()
{
set
+e
nproc
=
$(
grep
-c
processor /proc/cpuinfo
)
[[
-z
$nproc
||
$nproc
-eq
0
]]
&&
nproc
=
1
set
-e
}
cleanup_joiner
()
cleanup_joiner
()
{
{
# Since this is invoked just after exit NNN
local
estatus
=
$?
if
[[
$estatus
-ne
0
]]
;
then
wsrep_log_error
"Cleanup after exit with status:
$estatus
"
fi
local
PID
=
$(
ps
-aef
|grep nc|
grep
$NC_PORT
|
awk
'{ print $2 }'
)
local
PID
=
$(
ps
-aef
|grep nc|
grep
$NC_PORT
|
awk
'{ print $2 }'
)
wsrep_log_info
"Killing nc pid
$PID
"
if
[[
$estatus
-ne
0
]]
;
then
wsrep_log_error
"Killing nc pid
$PID
"
else
wsrep_log_info
"Killing nc pid
$PID
"
fi
[
-n
"
$PID
"
-a
"0"
!=
"
$PID
"
]
&&
kill
$PID
&&
(
kill
$PID
&&
kill
-9
$PID
)
||
:
[
-n
"
$PID
"
-a
"0"
!=
"
$PID
"
]
&&
kill
$PID
&&
(
kill
$PID
&&
kill
-9
$PID
)
||
:
rm
-f
"
$MAGIC_FILE
"
rm
-f
"
$MAGIC_FILE
"
if
[
"
${
WSREP_SST_OPT_ROLE
}
"
=
"joiner"
]
;
then
if
[
"
${
WSREP_SST_OPT_ROLE
}
"
=
"joiner"
]
;
then
...
@@ -74,6 +145,24 @@ check_pid()
...
@@ -74,6 +145,24 @@ check_pid()
[
-r
"
$pid_file
"
]
&&
ps
-p
$(
cat
"
$pid_file
"
)
>
/dev/null 2>&1
[
-r
"
$pid_file
"
]
&&
ps
-p
$(
cat
"
$pid_file
"
)
>
/dev/null 2>&1
}
}
cleanup_donor
()
{
# Since this is invoked just after exit NNN
local
estatus
=
$?
if
[[
$estatus
-ne
0
]]
;
then
wsrep_log_error
"Cleanup after exit with status:
$estatus
"
fi
local
pid
=
$XTRABACKUP_PID
if
check_pid
"
$pid
"
then
wsrep_log_error
"xtrabackup process is still running. Killing... "
kill_xtrabackup
fi
rm
-f
"
$pid
"
rm
-f
${
DATA
}
/
${
IST_FILE
}
}
kill_xtrabackup
()
kill_xtrabackup
()
{
{
#set -x
#set -x
...
@@ -123,12 +212,11 @@ IST_FILE="xtrabackup_ist"
...
@@ -123,12 +212,11 @@ IST_FILE="xtrabackup_ist"
MAGIC_FILE
=
"
${
DATA
}
/
${
INFO_FILE
}
"
MAGIC_FILE
=
"
${
DATA
}
/
${
INFO_FILE
}
"
rm
-f
"
${
MAGIC_FILE
}
"
rm
-f
"
${
MAGIC_FILE
}
"
read_cnf
if
[
"
$WSREP_SST_OPT_ROLE
"
=
"donor"
]
if
[
"
$WSREP_SST_OPT_ROLE
"
=
"donor"
]
then
then
trap
cleanup_donor EXIT
# UUID=$6
# SEQNO=$7
# BYPASS=$8
NC_PORT
=
$(
echo
$WSREP_SST_OPT_ADDR
|
awk
-F
'[:/]'
'{ print $2 }'
)
NC_PORT
=
$(
echo
$WSREP_SST_OPT_ADDR
|
awk
-F
'[:/]'
'{ print $2 }'
)
REMOTEIP
=
$(
echo
$WSREP_SST_OPT_ADDR
|
awk
-F
':'
'{ print $1 }'
)
REMOTEIP
=
$(
echo
$WSREP_SST_OPT_ADDR
|
awk
-F
':'
'{ print $1 }'
)
...
@@ -137,7 +225,7 @@ then
...
@@ -137,7 +225,7 @@ then
then
then
TMPDIR
=
"/tmp"
TMPDIR
=
"/tmp"
INNOBACKUPEX_ARGS
=
"--galera-info --stream=
xbstream
INNOBACKUPEX_ARGS
=
"--galera-info --stream=
$sfmt
--defaults-file=
${
WSREP_SST_OPT_CONF
}
--defaults-file=
${
WSREP_SST_OPT_CONF
}
--socket=
${
WSREP_SST_OPT_SOCKET
}
"
--socket=
${
WSREP_SST_OPT_SOCKET
}
"
...
@@ -152,7 +240,6 @@ then
...
@@ -152,7 +240,6 @@ then
INNOBACKUPEX_ARGS
=
"
${
INNOBACKUPEX_ARGS
}
--password="
INNOBACKUPEX_ARGS
=
"
${
INNOBACKUPEX_ARGS
}
--password="
fi
fi
get_keys
get_keys
if
[[
$encrypt
-eq
1
]]
;
then
if
[[
$encrypt
-eq
1
]]
;
then
if
[[
-n
$ekey
]]
;
then
if
[[
-n
$ekey
]]
;
then
...
@@ -162,6 +249,8 @@ then
...
@@ -162,6 +249,8 @@ then
fi
fi
fi
fi
wsrep_log_info
"Streaming the backup to joiner at
${
REMOTEIP
}
${
NC_PORT
}
"
set
+e
set
+e
${
INNOBACKUPEX_BIN
}
${
INNOBACKUPEX_ARGS
}
${
TMPDIR
}
\
${
INNOBACKUPEX_BIN
}
${
INNOBACKUPEX_ARGS
}
${
TMPDIR
}
\
2>
${
DATA
}
/innobackup.backup.log |
\
2>
${
DATA
}
/innobackup.backup.log |
\
...
@@ -182,31 +271,37 @@ then
...
@@ -182,31 +271,37 @@ then
# innobackupex implicitly writes PID to fixed location in ${TMPDIR}
# innobackupex implicitly writes PID to fixed location in ${TMPDIR}
XTRABACKUP_PID
=
"
${
TMPDIR
}
/xtrabackup_pid"
XTRABACKUP_PID
=
"
${
TMPDIR
}
/xtrabackup_pid"
if
check_pid
"
${
XTRABACKUP_PID
}
"
then
wsrep_log_error
"xtrabackup process is still running. Killing... "
kill_xtrabackup
exit
22
fi
rm
-f
"
${
XTRABACKUP_PID
}
"
else
# BYPASS
else
# BYPASS
wsrep_log_info
"Bypassing the SST for IST"
STATE
=
"
${
WSREP_SST_OPT_GTID
}
"
STATE
=
"
${
WSREP_SST_OPT_GTID
}
"
echo
"continue"
# now server can resume updating data
echo
"continue"
# now server can resume updating data
echo
"
${
STATE
}
"
>
"
${
MAGIC_FILE
}
"
echo
"
${
STATE
}
"
>
"
${
MAGIC_FILE
}
"
echo
"1"
>
"
${
DATA
}
/
${
IST_FILE
}
"
echo
"1"
>
"
${
DATA
}
/
${
IST_FILE
}
"
get_keys
get_keys
pushd
${
DATA
}
1>/dev/null
set
+e
if
[[
$encrypt
-eq
1
]]
;
then
if
[[
$encrypt
-eq
1
]]
;
then
if
[[
-n
$ekey
]]
;
then
if
[[
-n
$ekey
]]
;
then
(
cd
${
DATA
}
;
xbstream
-c
${
INFO_FILE
}
${
IST_FILE
}
| xbcrypt
--encrypt-algo
=
$ealgo
--encrypt-key
=
$ekey
)
|
${
NC_BIN
}
${
REMOTEIP
}
${
NC_PORT
}
xbstream
-c
${
INFO_FILE
}
${
IST_FILE
}
| xbcrypt
--encrypt-algo
=
$ealgo
--encrypt-key
=
$ekey
|
${
NC_BIN
}
${
REMOTEIP
}
${
NC_PORT
}
else
else
(
cd
${
DATA
}
;
xbstream
-c
${
INFO_FILE
}
${
IST_FILE
}
| xbcrypt
--encrypt-algo
=
$ealgo
--encrypt-key-file
=
$ekeyfile
)
|
${
NC_BIN
}
${
REMOTEIP
}
${
NC_PORT
}
xbstream
-c
${
INFO_FILE
}
${
IST_FILE
}
| xbcrypt
--encrypt-algo
=
$ealgo
--encrypt-key-file
=
$ekeyfile
|
${
NC_BIN
}
${
REMOTEIP
}
${
NC_PORT
}
fi
fi
else
else
(
cd
${
DATA
}
;
xbstream
-c
${
INFO_FILE
}
${
IST_FILE
}
)
|
${
NC_BIN
}
${
REMOTEIP
}
${
NC_PORT
}
$strmcmd
|
${
NC_BIN
}
${
REMOTEIP
}
${
NC_PORT
}
fi
fi
rm
-f
${
DATA
}
/
${
IST_FILE
}
RC
=(
"
${
PIPESTATUS
[@]
}
"
)
set
-e
popd
1>/dev/null
for
ecode
in
"
${
RC
[@]
}
"
;
do
if
[[
$ecode
-ne
0
]]
;
then
wsrep_log_error
"Error while streaming data to joiner node: "
\
"exit codes:
${
RC
[@]
}
"
exit
1
fi
done
#rm -f ${DATA}/${IST_FILE}
fi
fi
echo
"done
${
WSREP_SST_OPT_GTID
}
"
echo
"done
${
WSREP_SST_OPT_GTID
}
"
...
@@ -217,8 +312,7 @@ then
...
@@ -217,8 +312,7 @@ then
touch
$SST_PROGRESS_FILE
touch
$SST_PROGRESS_FILE
sencrypted
=
1
sencrypted
=
1
ecode
=
0
nthreads
=
1
declare
-a
RC
MODULE
=
"xtrabackup_sst"
MODULE
=
"xtrabackup_sst"
...
@@ -247,11 +341,21 @@ then
...
@@ -247,11 +341,21 @@ then
${
NC_BIN
}
-dl
${
NC_PORT
}
| xbcrypt
-d
--encrypt-algo
=
$ealgo
--encrypt-key-file
=
$ekeyfile
| xbstream
-x
-C
${
DATA
}
${
NC_BIN
}
-dl
${
NC_PORT
}
| xbcrypt
-d
--encrypt-algo
=
$ealgo
--encrypt-key-file
=
$ekeyfile
| xbstream
-x
-C
${
DATA
}
fi
fi
else
else
${
NC_BIN
}
-dl
${
NC_PORT
}
|
xbstream
-x
-C
${
DATA
}
${
NC_BIN
}
-dl
${
NC_PORT
}
|
$strmcmd
fi
fi
RC
=(
"
${
PIPESTATUS
[@]
}
"
)
RC
=(
"
${
PIPESTATUS
[@]
}
"
)
set
-e
set
-e
if
[[
$sfmt
==
'xbstream'
]]
;
then
# Special handling till lp:1193240 is fixed"
if
[[
${
RC
[
$((
${#
RC
[@]
}
-
1
))
]
}
-eq
1
]]
;
then
wsrep_log_error
"Xbstream failed"
wsrep_log_error
"Data directory
${
DATA
}
needs to be empty for SST: lp:1193240"
\
"Manual intervention required in that case"
exit
32
fi
fi
wait
%%
# join wait_for_nc thread
wait
%%
# join wait_for_nc thread
for
ecode
in
"
${
RC
[@]
}
"
;
do
for
ecode
in
"
${
RC
[@]
}
"
;
do
...
@@ -279,6 +383,7 @@ then
...
@@ -279,6 +383,7 @@ then
if
[
!
-r
"
${
IST_FILE
}
"
]
if
[
!
-r
"
${
IST_FILE
}
"
]
then
then
wsrep_log_info
"Proceeding with SST"
rebuild
=
""
rebuild
=
""
wsrep_log_info
"Removing existing ib_logfile files"
wsrep_log_info
"Removing existing ib_logfile files"
rm
-f
${
DATA
}
/ib_logfile
*
rm
-f
${
DATA
}
/ib_logfile
*
...
@@ -306,10 +411,15 @@ then
...
@@ -306,10 +411,15 @@ then
fi
fi
fi
fi
get_proc
# Rebuild indexes for compact backups
# Rebuild indexes for compact backups
if
grep
-q
'compact = 1'
${
DATA
}
/xtrabackup_checkpoints
;
then
if
grep
-q
'compact = 1'
${
DATA
}
/xtrabackup_checkpoints
;
then
wsrep_log_info
"Index compaction detected"
wsrep_log_info
"Index compaction detected"
rebuild
=
"--rebuild-indexes"
nthreads
=
$(
my_print_defaults
-c
$WSREP_SST_OPT_CONF
xtrabackup |
grep
--
'--rebuild-threads'
|
cut
-d
=
-f2
)
[[
-z
$nthreads
]]
&&
nthreads
=
$nproc
wsrep_log_info
"Rebuilding with
$nthreads
threads"
rebuild
=
"--rebuild-indexes --rebuild-threads=
$nthreads
"
fi
fi
if
test
-n
"
$(
find
${
DATA
}
-maxdepth
1
-name
'*.qp'
-print
-quit
)
"
;
then
if
test
-n
"
$(
find
${
DATA
}
-maxdepth
1
-name
'*.qp'
-print
-quit
)
"
;
then
...
@@ -327,7 +437,8 @@ then
...
@@ -327,7 +437,8 @@ then
rm
-f
${
DATA
}
/ibdata1
rm
-f
${
DATA
}
/ibdata1
# Decompress the qpress files
# Decompress the qpress files
find
${
DATA
}
-type
f
-name
'*.qp'
-printf
'%p\n%h\n'
| xargs
-P
$(
grep
-c
processor /proc/cpuinfo
)
-n
2 qpress
-d
wsrep_log_info
"Decompression with
$nproc
threads"
find
${
DATA
}
-type
f
-name
'*.qp'
-printf
'%p\n%h\n'
| xargs
-P
$nproc
-n
2 qpress
-d
extcode
=
$?
extcode
=
$?
set
-e
set
-e
...
@@ -354,7 +465,7 @@ then
...
@@ -354,7 +465,7 @@ then
exit
22
exit
22
fi
fi
else
else
wsrep_log_info
"Running IST"
wsrep_log_info
"
${
IST_FILE
}
received from donor:
Running IST"
fi
fi
cat
"
${
MAGIC_FILE
}
"
# output UUID:seqno
cat
"
${
MAGIC_FILE
}
"
# output UUID:seqno
...
...
sql/wsrep_utils.cc
View file @
551ad1cf
...
@@ -358,6 +358,8 @@ size_t guess_ip (char* buf, size_t buf_len)
...
@@ -358,6 +358,8 @@ size_t guess_ip (char* buf, size_t buf_len)
#elif defined(__sun__)
#elif defined(__sun__)
const
char
cmd
[]
=
"/sbin/ifconfig -a | "
const
char
cmd
[]
=
"/sbin/ifconfig -a | "
"/usr/gnu/bin/grep -m1 -1 -E 'net[0-9]:' | tail -n 1 | awk '{ print $2 }'"
;
"/usr/gnu/bin/grep -m1 -1 -E 'net[0-9]:' | tail -n 1 | awk '{ print $2 }'"
;
#elif defined(__APPLE__) || defined(__FreeBSD__)
const
char
cmd
[]
=
"route -nv get 8.8.8.8 | tail -n1 | awk '{print $5}'"
;
#else
#else
char
*
cmd
;
char
*
cmd
;
#error "OS not supported"
#error "OS not supported"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment