revision-id: 2c13e8046abc4a896a7df3eafb1aeb05011415ff () parent(s): author: Sergei Petrunia committer: Sergei Petrunia timestamp: 2020-03-07 15:49:22 +0300 message: Initial commit --- 01-setup-trees.sh | 6 ++ prepare-server.sh | 94 +++++++++++++++++++++++++++ setup-server/setup-mariadb-current.sh | 117 ++++++++++++++++++++++++++++++++++ setup-server/setup-os-ubuntu.sh | 24 +++++++ 4 files changed, 241 insertions(+) diff --git a/01-setup-trees.sh b/01-setup-trees.sh new file mode 100644 index 0000000..b0ecb5a --- /dev/null +++ b/01-setup-trees.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +./setup-server/setup-mariadb-current.sh 10.5-mdev6915-ext +./setup-server/setup-mariadb-current.sh 10.5 0c35e80dc9ff24bcb8e710cb8cb16428c8c9986f + + diff --git a/prepare-server.sh b/prepare-server.sh new file mode 100755 index 0000000..03c0100 --- /dev/null +++ b/prepare-server.sh @@ -0,0 +1,94 @@ +#!/bin/bash + +# +# +# +usage () { +echo "Usage: $0 [-m] server_name" +echo " -m - Put datadir on /dev/shm" +} + +### +### Parse options +### + +while getopts ":pmcd" opt; do + case ${opt} in + m ) USE_RAMDISK=1 + ;; + \? ) + usage; + exit 1 + ;; + esac +done +shift $((OPTIND -1)) + +SERVERNAME=$1 + +if [ "x${SERVERNAME}y" = "xy" ] ; then + usage; + exit 1 +fi + +if [ ! -d $SERVERNAME ]; then + echo "Can't find tree $SERVERNAME." + exit 1 +fi + +if [[ $USE_RAMDISK ]] ; then + echo " Using /dev/shm for data dir" +fi + +############################################################################# +### Start the server +killall -9 mysqld +sleep 5 + +DATA_DIR=$SERVERNAME-data +rm -rf $DATA_DIR + +if [[ $USE_RAMDISK ]] ; then + rm -rf /dev/shm/$DATA_DIR + cp -r ${DATA_DIR}.clean /dev/shm/$DATA_DIR + ln -s /dev/shm/$DATA_DIR $DATA_DIR +else + cp -r ${DATA_DIR}.clean $DATA_DIR +fi + +#exit 0; +./$SERVERNAME/sql/mysqld --defaults-file=./my-${SERVERNAME}.cnf & + + +server_attempts=0 + +while true ; do + client_attempts=0 + while true ; do + ./$SERVERNAME/client/mysql --defaults-file=./my-${SERVERNAME}.cnf -uroot -e "create database sbtest" + + if [ $? -eq 0 ]; then + break + fi + sleep 1 + + client_attempts=$((client_attempts + 1)) + if [ $client_attempts -ge 10 ]; then + break; + fi + done + + MYSQLD_PID=`ps -C mysqld --no-header | awk '{print $1}'` + if [[ "a${MYSQLD_PID}b" != "ab" ]] ; then + break + fi + + server_attempts=$((server_attempts + 1)) + if [ $server_attempts -ge 4 ]; then + echo "Failed to launch mysqld" + exit 1 + fi +done + +# Done. + diff --git a/setup-server/setup-mariadb-current.sh b/setup-server/setup-mariadb-current.sh new file mode 100755 index 0000000..12b8b55 --- /dev/null +++ b/setup-server/setup-mariadb-current.sh @@ -0,0 +1,117 @@ +#!/bin/bash + +set -e + + +if [ "x${1}y" == "xy" ] ; then + echo "Usage: $0 BRANCH_NAME [revision]" + exit 1 +fi + +BRANCH="${1}" +REVISION="${2}" +HOMEDIR=`pwd` +DATADIR="$HOMEDIR/mariadb-$BRANCH-data" + +if [ -d $DATADIR ] ; then + echo "Data directory $DATADIR exists, will not overwrite it " + du -hs $DATADIR + exit 1; +fi + +# --single-branch +git clone --branch $BRANCH https://github.com/MariaDB/server.git mariadb-$BRANCH + + +( +cd mariadb-$BRANCH + +if [ "x${REVISION}y" != "xy" ] ; then + git reset --hard $REVISION +fi + +git submodule init +git submodule update +cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DWITHOUT_MROONGA:bool=1 -DWITHOUT_TOKUDB:bool=1 +make -j8 +cd .. +) + +( + cd mariadb-$BRANCH/mysql-test + ./mtr alias + cp -r var/install.db $DATADIR + cp -r var/install.db $DATADIR.clean +) + +# Guess a reasonable socket name +source_dir=`pwd` +socket_name="`basename $source_dir`.sock" +SOCKETNAME="/tmp/$socket_name" + + +# plugin-load=ha_rocksdb.so +# default-storage-engine=rocksdb +# skip-innodb +# default-tmp-storage-engine=MyISAM +# skip-slave-start +# plugin-dir=$HOMEDIR/mariadb-$BRANCH/storage/rocksdb +# log-bin=pslp +# binlog-format=row + +cat > $HOMEDIR/my-mariadb-$BRANCH.cnf << EOF +[mysqld] + +bind-address=0.0.0.0 +datadir=$DATADIR +plugin-dir=$HOMEDIR/mariadb-$BRANCH/mysql-test/var/plugins + +log-error +lc_messages_dir=$HOMEDIR/mariadb-$BRANCH/sql/share + +tmpdir=/tmp +port=3341 +socket=$SOCKETNAME +gdb +server-id=12 + +innodb_buffer_pool_size=8G + +EOF + +cat > mysql-vars.sh <<EOF +MYSQL="./mariadb-$BRANCH/client/mysql" +MYSQL_SOCKET="--socket=$SOCKETNAME" +MYSQL_USER="-uroot" +MYSQL_ARGS="\$MYSQL_USER \$MYSQL_SOCKET" +EOF + +source mysql-vars.sh +cp mysql-vars.sh mariadb-$BRANCH-vars.sh + +( +cd $HOMEDIR/mariadb-$BRANCH/sql +../sql/mysqld --defaults-file=$HOMEDIR/my-mariadb-$BRANCH.cnf & +) + + +client_attempts=0 +while true ; do + echo $MYSQL $MYSQL_ARGS -e "select version()"; + $MYSQL $MYSQL_ARGS -e "select version()"; + + if [ $? -eq 0 ]; then + break + fi + sleep 1 + + client_attempts=$((client_attempts + 1)) + if [ $client_attempts -ge 30 ]; then + echo "Failed to start server." + exit 1 + fi +done + +echo "Done setting up MariaDB" + diff --git a/setup-server/setup-os-ubuntu.sh b/setup-server/setup-os-ubuntu.sh new file mode 100755 index 0000000..5206107 --- /dev/null +++ b/setup-server/setup-os-ubuntu.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +if [ -e /etc/debian_version ] ; then + sudo apt-get update + sudo apt-get -y install g++ cmake libbz2-dev libaio-dev bison zlib1g-dev libsnappy-dev libboost-all-dev + sudo apt-get -y install libgflags-dev libreadline6-dev libncurses5-dev liblz4-dev gdb git libzstd-dev + + sudo apt-get -y install libzstd0 + sudo apt-get -y install libssl-dev + + sudo apt-get -y install libgnutls28-dev + +# percona server: + sudo apt-get -y install libcurl4-gnutls-dev + + sudo apt-get -y install sysstat + + sudo ln -s /usr/lib/x86_64-linux-gnu/libz.so /usr/lib/libz.so + sudo sh -c "echo 0 > /proc/sys/kernel/yama/ptrace_scope" + +# Need unzip to unpack TPC-DS generator + sudo apt-get -y install unzip +fi +