~akopytov/percona-xtrabackup/bug1166888-2.1

« back to all changes in this revision

Viewing changes to utils/build.sh

  • Committer: Alexey Kopytov
  • Date: 2012-02-10 20:05:56 UTC
  • mto: (391.1.5 staging)
  • mto: This revision was merged to the branch mainline in revision 390.
  • Revision ID: akopytov@gmail.com-20120210200556-6kx41z8wwrqfucro
Rebase of the parallel compression patch on new trunk + post-review
fixes.

Implementation of parallel compression and streaming for XtraBackup.

This revision implements the following changes:

* InnoDB files are now streamed by the xtrabackup binary rather than
innobackupex. As a result, integrity is now verified by xtrabackup and
thus tar4ibd is no longer needed, so it was removed.

* xtrabackup binary now accepts the new '--stream' option which has
exactly the same semantics as the '--stream' option in
innobackupex: it tells xtrabackup to stream all files to the standard
output in the specified format rather than storing them locally.

* The xtrabackup binary can now do parallel compression using the
quicklz library. Two new options were added to xtrabackup to support
this feature:

- '--compress' tells xtrabackup to compress all output data, including
the transaction log file and meta data files, using the specified
compression algorithm. The only currently supported algorithm is
'quicklz'. The resulting files have the qpress archive format,
i.e. every *.qp file produced by xtrabackup is essentially a one-file
qpress archive and can be extracted and uncompressed by the qpress
file archiver (http://www.quicklz.com/).

- '--compress-threads' specifies the number of worker threads used by
xtrabackup for parallel data compression. This option defaults to 1.

Parallel compression ('--compress-threads') can be used together with
parallel file copying ('--parallel'). For example, '--parallel=4
--compress --compress-threads=2' will create 4 IO threads that will
read the data and pipe it to 2 compression threads.

* To support simultaneous compression and streaming, a new custom
streaming format called 'xbstream' was introduced to XtraBackup in
addition to the 'tar' format. That was required to overcome some
limitations of traditional archive formats such as 'tar', 'cpio' and
others that do not allow streaming dynamically generated files, for
example dynamically compressed files.  Other advantages of xbstream over
traditional streaming/archive formats include ability to stream multiple
files concurrently (so it is possible to use streaming in the xbstream
format together with the --parallel option) and more compact data
storage.

* To allow streaming and extracting files to/from the xbstream format
produced by xtrabackup, a new utility aptly called 'xbstream' was
added to the XtraBackup distribution. This utility has a tar-like
interface:

- with the '-x' option it extracts files from the stream read from its
standard input to the current directory unless specified otherwise
with the '-C' option.

- with the '-c' option it streams files specified on the command line
to its standard output.

The utility also tries to minimize its impact on the OS page cache by
using the appropriate posix_fadvise() calls when available.

Show diffs side-by-side

added added

removed removed

Lines of Context:
109
109
    cd $top_dir
110
110
}
111
111
 
 
112
function build_libarchive()
 
113
{
 
114
        echo "Building libarchive"
 
115
        cd $top_dir/src/libarchive
 
116
        
 
117
        cmake  . \
 
118
            -DENABLE_CPIO=OFF \
 
119
            -DENABLE_OPENSSL=OFF \
 
120
            -DENABLE_TAR=OFF \
 
121
            -DENABLE_TEST=OFF
 
122
        $MAKE_CMD || exit -1
 
123
}
 
124
 
112
125
function build_xtrabackup()
113
126
{
 
127
    build_libarchive
114
128
    echo "Building XtraBackup"
115
 
    mkdir $build_dir
116
 
    cp $top_dir/Makefile $top_dir/xtrabackup.c $top_dir/xb_regex.h $build_dir
117
129
 
118
130
    # Read XTRABACKUP_VERSION from the VERSION file
119
131
    . $top_dir/VERSION
120
132
 
121
 
    cd $build_dir
122
 
    $MAKE_CMD $xtrabackup_target XTRABACKUP_VERSION=$XTRABACKUP_VERSION
 
133
    cd $top_dir/src
 
134
    if [ "`uname -s`" = "Linux" ]
 
135
    then
 
136
        export LIBS="$LIBS -lrt"
 
137
    fi
 
138
    $MAKE_CMD MYSQL_ROOT_DIR=$server_dir clean
 
139
    $MAKE_CMD MYSQL_ROOT_DIR=$server_dir XTRABACKUP_VERSION=$XTRABACKUP_VERSION $xtrabackup_target
123
140
    cd $top_dir
124
141
}
125
142
 
126
 
function build_tar4ibd()
127
 
{
128
 
    echo "Building tar4ibd"
129
 
    unpack_and_patch libtar-1.2.11.tar.gz tar4ibd_libtar-1.2.11.patch
130
 
    cd libtar-1.2.11
131
 
    ./configure
132
 
    $MAKE_CMD
133
 
    cd $top_dir
134
 
}
135
143
 
136
144
################################################################################
137
 
# Do all steps to build the server, xtrabackup and tar4ibd
 
145
# Do all steps to build the server, xtrabackup and xbstream
138
146
# Expects the following variables to be set before calling:
139
147
#   mysql_version       version string (e.g. "5.1.53")
140
148
#   server_patch        name of the patch to apply to server source before
150
158
    server_dir=$top_dir/mysql-$mysql_version_short
151
159
    server_tarball=mysql-$mysql_version.tar.gz
152
160
    innodb_dir=$server_dir/storage/$innodb_name
153
 
    build_dir=$innodb_dir/xtrabackup
154
161
 
155
162
    echo "Downloading sources"
156
 
    auto_download $server_tarball libtar-1.2.11.tar.gz
 
163
    auto_download $server_tarball
157
164
 
158
165
    test -d $server_dir && rm -r $server_dir
159
166
 
164
171
    build_server
165
172
 
166
173
    build_xtrabackup
167
 
 
168
 
    build_tar4ibd
169
174
}
170
175
 
171
 
if ! test -f xtrabackup.c
 
176
if ! test -f src/xtrabackup.c
172
177
then
173
178
        echo "`basename $0` must be run from the directory with XtraBackup sources"
174
179
        usage
177
182
type=$1
178
183
top_dir=`pwd`
179
184
 
 
185
 
180
186
case "$type" in
181
187
"innodb51_builtin" | "5.1")
182
188
        mysql_version=$MYSQL_51_VERSION
228
234
        server_dir=$top_dir/Percona-Server
229
235
        branch_dir=percona-server-5.1-xtrabackup
230
236
        innodb_dir=$server_dir/storage/innodb_plugin
231
 
        build_dir=$innodb_dir/xtrabackup
232
237
        xtrabackup_target=xtradb
233
238
        configure_cmd="./configure --enable-local-infile \
234
239
            --enable-thread-safe-client \
244
249
 
245
250
        echo "Downloading sources"
246
251
        
247
 
        auto_download libtar-1.2.11.tar.gz
248
 
 
249
252
        # Get Percona Server
250
253
        if [ -d $branch_dir ]
251
254
        then
277
280
 
278
281
        build_xtrabackup
279
282
 
280
 
        build_tar4ibd
281
283
        ;;
282
284
"xtradb55"|"galera55")
283
285
        server_dir=$top_dir/Percona-Server-5.5
284
286
        branch_dir=percona-server-5.5-xtrabackup
285
287
        innodb_dir=$server_dir/storage/innobase
286
 
        build_dir=$innodb_dir/xtrabackup
287
288
        xtrabackup_target=xtradb55
288
289
        # We need to build with partitioning due to MySQL bug #58632
289
290
        configure_cmd="cmake . \
301
302
 
302
303
        echo "Downloading sources"
303
304
        
304
 
        auto_download libtar-1.2.11.tar.gz
305
 
 
306
305
        # Get Percona Server
307
306
        if [ -d $branch_dir ]
308
307
        then
335
334
 
336
335
        build_xtrabackup
337
336
 
338
 
        build_tar4ibd
339
337
        ;;
340
338
*)
341
339
        usage