Skip to content

Commit 57b8c23

Browse files
author
Anthony Yeh
committed
[WIP] Support Percona Server
1 parent 1159a12 commit 57b8c23

17 files changed

Lines changed: 1705 additions & 22 deletions

Dockerfile.percona

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM vitess/bootstrap:percona
2+
3+
# Clear out old tree from bootstrap image.
4+
USER root
5+
RUN rm -rf /vt/src/github.com/youtube/vitess
6+
7+
# Re-copy sources from working tree
8+
COPY . /vt/src/github.com/youtube/vitess
9+
10+
# Fix permissions
11+
RUN chown -R vitess:vitess /vt
12+
USER vitess
13+
14+
# Build Vitess
15+
RUN make build

Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,30 @@ docker_bootstrap:
105105
docker/bootstrap/build.sh common
106106
docker/bootstrap/build.sh mariadb
107107
docker/bootstrap/build.sh mysql56
108+
docker/bootstrap/build.sh percona
108109

109110
docker_base:
110111
# Fix permissions before copying files, to avoid AUFS bug.
111112
chmod -R o=g *
112113
docker build -t vitess/base .
113114

115+
docker_base_percona:
116+
chmod -R o=g *
117+
docker build -f Dockerfile.percona -t vitess/base:percona .
118+
119+
docker_base_mariadb:
120+
chmod -R o=g *
121+
docker build -f Dockerfile.mariadb -t vitess/base:mariadb .
122+
114123
docker_lite:
115124
cd docker/lite && ./build.sh
116125

126+
docker_lite_mariadb:
127+
cd docker/lite && ./build.sh mariadb
128+
129+
docker_lite_percona:
130+
cd docker/lite && ./build.sh percona
131+
117132
docker_guestbook:
118133
cd examples/kubernetes/guestbook && ./build.sh
119134

bootstrap.sh

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -140,44 +140,41 @@ ln -snf $VTTOP/go/zk/zkctl/zksrv.sh $VTROOT/bin/zksrv.sh
140140
ln -snf $VTTOP/test/vthook-test.sh $VTROOT/vthook/test.sh
141141

142142
# install mysql
143-
if [ -z "$MYSQL_FLAVOR" ]; then
144-
export MYSQL_FLAVOR=MariaDB
145-
fi
146-
case "$MYSQL_FLAVOR" in
147-
"MySQL56")
148-
myversion=`$VT_MYSQL_ROOT/bin/mysql --version | grep 'Distrib 5\.6'`
149-
[ "$myversion" != "" ] || fail "Couldn't find MySQL 5.6 in $VT_MYSQL_ROOT. Set VT_MYSQL_ROOT to override search location."
150-
echo "Found MySQL 5.6 installation in $VT_MYSQL_ROOT."
143+
case "${MYSQL_FLAVOR}" in
144+
"MySQL56" | "Percona")
145+
myversion=`${VT_MYSQL_ROOT}/bin/mysql --version | grep 'Distrib 5\.6'`
146+
[ "$myversion" != "" ] || fail "Couldn't find MySQL 5.6 in ${VT_MYSQL_ROOT}. Set VT_MYSQL_ROOT to override search location."
147+
echo "Found MySQL 5.6 installation in ${VT_MYSQL_ROOT}."
151148
;;
152149

153150
"MariaDB")
154-
myversion=`$VT_MYSQL_ROOT/bin/mysql --version | grep MariaDB`
155-
[ "$myversion" != "" ] || fail "Couldn't find MariaDB in $VT_MYSQL_ROOT. Set VT_MYSQL_ROOT to override search location."
156-
echo "Found MariaDB installation in $VT_MYSQL_ROOT."
151+
myversion=`${VT_MYSQL_ROOT}/bin/mysql --version | grep MariaDB`
152+
[ "$myversion" != "" ] || fail "Couldn't find MariaDB in ${VT_MYSQL_ROOT}. Set VT_MYSQL_ROOT to override search location."
153+
echo "Found MariaDB installation in ${VT_MYSQL_ROOT}."
157154
;;
158155

159156
*)
160-
fail "Unsupported MYSQL_FLAVOR $MYSQL_FLAVOR"
157+
fail "Unsupported MYSQL_FLAVOR ${MYSQL_FLAVOR}"
161158
;;
162159

163160
esac
164161

165162
# save the flavor that was used in bootstrap, so it can be restored
166163
# every time dev.env is sourced.
167-
echo "$MYSQL_FLAVOR" > $VTROOT/dist/MYSQL_FLAVOR
164+
echo "${MYSQL_FLAVOR}" > $VTROOT/dist/MYSQL_FLAVOR
168165

169166
# generate pkg-config, so go can use mysql C client
170-
[ -x $VT_MYSQL_ROOT/bin/mysql_config ] || fail "Cannot execute $VT_MYSQL_ROOT/bin/mysql_config. Did you install a client dev package?"
167+
[ -x ${VT_MYSQL_ROOT}/bin/mysql_config ] || fail "Cannot execute ${VT_MYSQL_ROOT}/bin/mysql_config. Did you install a client dev package?"
171168

172169
cp $VTTOP/config/gomysql.pc.tmpl $VTROOT/lib/gomysql.pc
173-
echo "Version:" "$($VT_MYSQL_ROOT/bin/mysql_config --version)" >> $VTROOT/lib/gomysql.pc
174-
echo "Cflags:" "$($VT_MYSQL_ROOT/bin/mysql_config --cflags) -ggdb -fPIC" >> $VTROOT/lib/gomysql.pc
175-
if [ "$MYSQL_FLAVOR" == "MariaDB" ]; then
170+
echo "Version:" "$(${VT_MYSQL_ROOT}/bin/mysql_config --version)" >> $VTROOT/lib/gomysql.pc
171+
echo "Cflags:" "$(${VT_MYSQL_ROOT}/bin/mysql_config --cflags) -ggdb -fPIC" >> $VTROOT/lib/gomysql.pc
172+
if [ "${MYSQL_FLAVOR}" == "MariaDB" ] || [ "${MYSQL_FLAVOR}" == "Percona" ]; then
176173
# Use static linking because the shared library doesn't export
177174
# some internal functions we use, like cli_safe_read.
178-
echo "Libs:" "$($VT_MYSQL_ROOT/bin/mysql_config --libs_r | sed -r 's,-lmysqlclient(_r)?,-l:libmysqlclient.a -lstdc++,')" >> $VTROOT/lib/gomysql.pc
175+
echo "Libs:" "$(${VT_MYSQL_ROOT}/bin/mysql_config --libs_r | sed -r 's,-lmysqlclient(_r)?,-l:libmysqlclient.a -lstdc++,')" >> $VTROOT/lib/gomysql.pc
179176
else
180-
echo "Libs:" "$($VT_MYSQL_ROOT/bin/mysql_config --libs_r)" >> $VTROOT/lib/gomysql.pc
177+
echo "Libs:" "$(${VT_MYSQL_ROOT}/bin/mysql_config --libs_r)" >> $VTROOT/lib/gomysql.pc
181178
fi
182179

183180
# install bson

config/mycnf/master_percona.cnf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Options for enabling GTID
2+
# https://dev.mysql.com/doc/refman/5.6/en/replication-gtids-howto.html
3+
gtid_mode = ON
4+
log_bin
5+
log_slave_updates
6+
enforce_gtid_consistency

dev.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ fi
8484
case "$MYSQL_FLAVOR" in
8585
"MySQL56")
8686
;;
87+
"Percona")
88+
;;
8789
"MariaDB")
8890
export LD_LIBRARY_PATH=$(prepend_path $LD_LIBRARY_PATH $VT_MYSQL_ROOT/lib)
8991
export CGO_CFLAGS="$CGO_CFLAGS -I$VT_MYSQL_ROOT/include"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM vitess/bootstrap:common
2+
3+
# Install Percona 5.6
4+
RUN apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys 430BDF5C56E7C94E848EE60C1C4CBDCDCD2EFD2A \
5+
&& add-apt-repository 'deb http://repo.percona.com/apt jessie main' \
6+
&& { \
7+
echo debconf debconf/frontend select Noninteractive; \
8+
echo percona-server-server-5.6 percona-server-server/root_password password 'unused'; \
9+
echo percona-server-server-5.6 percona-server-server/root_password_again password 'unused'; \
10+
} | debconf-set-selections \
11+
&& apt-get update \
12+
&& apt-get install -y percona-server-server-5.6 libperconaserverclient18.1-dev --no-install-recommends \
13+
&& rm -rf /var/lib/apt/lists/*
14+
15+
# Bootstrap Vitess
16+
WORKDIR /vt/src/github.com/youtube/vitess
17+
USER vitess
18+
ENV MYSQL_FLAVOR Percona
19+
RUN ./bootstrap.sh --skip_root_installs

docker/bootstrap/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ fi
1515
# To avoid AUFS permission issues, files must allow access by "other"
1616
chmod -R o=g *
1717

18-
docker build --no-cache -f docker/bootstrap/Dockerfile.$flavor -t vitess/bootstrap:$flavor .
18+
docker build -f docker/bootstrap/Dockerfile.$flavor -t vitess/bootstrap:$flavor .

docker/lite/Dockerfile.percona

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# This image is only meant to be built from within the build.sh script.
2+
FROM debian:jessie
3+
4+
# Install dependencies
5+
UN apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys 430BDF5C56E7C94E848EE60C1C4CBDCDCD2EFD2A \
6+
&& add-apt-repository 'deb http://repo.percona.com/apt jessie main' \
7+
&& { \
8+
echo debconf debconf/frontend select Noninteractive; \
9+
echo percona-server-server-5.6 percona-server-server/root_password password 'unused'; \
10+
echo percona-server-server-5.6 percona-server-server/root_password_again password 'unused'; \
11+
} | debconf-set-selections \
12+
&& apt-get update \
13+
&& apt-get install -y percona-server-server-5.6 memcached bzip2 --no-install-recommends \
14+
&& rm -rf /var/lib/apt/lists/*
15+
16+
17+
# Set up Vitess environment (just enough to run pre-built Go binaries)
18+
ENV VTTOP /vt/src/github.com/youtube/vitess
19+
ENV VTROOT /vt
20+
ENV GOTOP $VTTOP/go
21+
ENV VTDATAROOT $VTROOT/vtdataroot
22+
ENV GOBIN $VTROOT/bin
23+
ENV GOPATH $VTROOT
24+
ENV PATH $VTROOT/bin:$PATH
25+
ENV VT_MYSQL_ROOT /usr
26+
ENV PKG_CONFIG_PATH $VTROOT/lib
27+
ENV LD_LIBRARY_PATH $VTROOT/dist/vt-zookeeper-3.4.6/lib
28+
29+
# Copy binaries (placed by build.sh)
30+
COPY lite/vt /vt
31+
32+
# Create vitess user
33+
RUN groupadd -r vitess && useradd -r -g vitess vitess && \
34+
mkdir -p /vt/vtdataroot && chown -R vitess:vitess /vt
35+
36+
# Create mount point for actual data (e.g. MySQL data dir)
37+
VOLUME /vt/vtdataroot

docker/lite/build.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
# This is the script to build the vitess/lite Docker image by extracting
44
# the pre-built binaries from a vitess/base image.
55

6+
flavor=$1
7+
8+
if [[ -z "$flavor" ]]; then
9+
echo "Flavor not specified as first argument building default image"
10+
fi
11+
612
# Extract files from vitess/base image
713
mkdir base
814
sudo docker run -ti --rm -v $PWD/base:/base -u root vitess/base bash -c 'cp -R /vt /base/'
@@ -31,7 +37,12 @@ sudo rm -rf base
3137
chmod -R o=g lite
3238

3339
# Build vitess/lite image
34-
sudo docker build -t vitess/lite .
40+
41+
if [[ -n "$flavor" ]]; then
42+
sudo docker build -f docker/bootstrap/Dockerfile.$flavor -t vitess/lite:$flavor .
43+
else
44+
sudo docker build -t vitess/lite .
45+
fi
3546

3647
# Clean up temporary files
3748
rm -rf lite

examples/local/vttablet-up.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ case "$MYSQL_FLAVOR" in
4444
"MariaDB")
4545
export EXTRA_MY_CNF=$VTROOT/config/mycnf/master_mariadb.cnf
4646
;;
47+
"Percona")
48+
export EXTRA_MY_CNF=$VTROOT/config/mycnf/master_percona.cnf
49+
;;
4750
*)
4851
echo "Please set MYSQL_FLAVOR to MySQL56 or MariaDB."
4952
exit 1

0 commit comments

Comments
 (0)