Compile and install GreatSQL under Ubuntu

Compile and install GreatSQL under Ubuntu

This article introduces how to use Docker to build Ubuntu environment and compile GreatSQL source code into binary files.

1. Preparatory work

First create the Docker's workdir as / data / Docker Ubuntu:

[root@greatsql ~]# mdkir /data/docker-ubuntu

1.1. Configure apt source configuration file in Ubuntu environment

Before compiling, it is recommended to configure the apt source first, so that the subsequent deployment environment can download the software package faster.

Take Alibaba and Tencent virtual machines as examples, which can be configured in this way (one of the two apt sources can be selected):

#Tencent cloud
[root@greatsql ~]# cat /data/docker-ubuntu/ubuntu-20.4-sources.list

deb http://mirrors.cloud.tencent.com/ubuntu/ focal main restricted
deb http://mirrors.cloud.tencent.com/ubuntu/ focal-updates main restricted
deb http://mirrors.cloud.tencent.com/ubuntu/ focal universe
deb http://mirrors.cloud.tencent.com/ubuntu/ focal-updates universe
deb http://mirrors.cloud.tencent.com/ubuntu/ focal multiverse
deb http://mirrors.cloud.tencent.com/ubuntu/ focal-updates multiverse
deb http://mirrors.cloud.tencent.com/ubuntu/ focal-backports main restricted universe multiverse
deb http://mirrors.cloud.tencent.com/ubuntu/ focal-security main restricted
deb http://mirrors.cloud.tencent.com/ubuntu/ focal-security universe
deb http://mirrors.cloud.tencent.com/ubuntu/ focal-security multiverse

If it is Alibaba cloud, change to the following content

deb http://mirrors.aliyun.com/ubuntu/ focal main restricted
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted
deb http://mirrors.aliyun.com/ubuntu/ focal universe
deb http://mirrors.aliyun.com/ubuntu/ focal-updates universe
deb http://mirrors.aliyun.com/ubuntu/ focal multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted
deb http://mirrors.aliyun.com/ubuntu/ focal-security universe
deb http://mirrors.aliyun.com/ubuntu/ focal-security multiverse

This file is prepared first, and it will be used in Dockerfile later.

In addition, according to my own test, alicloud's source is more prone to errors in the process of building docker images. Please test and select by yourself.

Install Docker, Download boost, GreatSQL source package, etc. I have directly skipped these tasks. You can directly refer to this document: Compile and install GreatSQL under Linux.

I also prepared one Automated compilation of shell scripts for GreatSQL , you can take it yourself:

[root@greatsql ~]# cat /data/docker-ubuntu/greatsql-automake.sh

#!/bin/bash
MAJOR_VERSION=8
MINOR_VERSION=0
PATCH_VERSION=25
RELEASE=15
REVISION=`date +%Y%m%d%H%M`
BASE_DIR=/usr/local/GreatSQL-8.0.25
JOBS=16
#reversion=`echo $RANDOM | sha256sum | cut -c1-11` && echo $reversion;
cmake . -DBOOST_INCLUDE_DIR=../boost_1_73_0 -DCMAKE_INSTALL_PREFIX=${BASE_DIR} -DWITH_ZLIB=bundled \
-DWITH_NUMA=ON -DFORCE_INSOURCE_BUILD=1 -DCMAKE_EXE_LINKER_FLAGS="-ljemalloc" \
-DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_CONFIG=mysql_release \
-DCOMPILATION_COMMENT="GreatSQL (GPL), Release ${RELEASE}, Revision ${REVISION}" \
-DWITH_TOKUDB=OFF -DWITH_ROCKSDB=OFF -DWITH_COREDUMPER=OFF \
-DMAJOR_VERSION=${MAJOR_VERSION} -DMINOR_VERSION=${MINOR_VERSION} -DPATCH_VERSION=${PATCH_VERSION} && \
make -j${JOBS} VERBOSE=1 && make install

1.2. Build docker image

Use the following Dockerfile to build an Ubuntu image:

FROM ubuntu
ENV LANG en_US.utf8
ARG UID=1001
ARG GID=1001
ARG UNAME=mysql
#ENV TZ Asia/Shanghai

ENV PATH="/usr/local/mysql/bin:${PATH}"
ENV LD_LIBRARY_PATH="/usr/loca/mysql/lib:${LD_LIBRARY_PATH}"
ENV TERM=xterm

COPY ubuntu-20.4-sources.list /etc/apt/sources.list

#RUN apt-get update && apt-get install -y --no-install-recommends tzdata && rm -rf /var/lib/apt/lists/*
RUN apt update && apt install -y --no-install-recommends tzdata && rm -rf /var/lib/apt/lists/*
ENV TZ Asia/Shanghai

RUN apt update -y && apt upgrade -y && \
apt install -y --fix-missing gcc-10 cmake automake build-essential diffutils git lbzip2 libaio-dev libbison-dev \
libcurl4-openssl-dev libevent-dev libexpat1-dev libffi-dev libgflags-dev libgtest-dev libjemalloc-dev \
libldap2-dev liblz4-dev libncurses-dev libnuma-dev libreadline-dev libsnappy-dev libssh-dev libtirpc-dev \
libtool libxml2-dev libzstd-dev make net-tools numactl pkg-config psmisc vim wget \
&& groupadd -g $GID -o $UNAME && useradd -m -g $GID -u $UID -o -s /bin/bash $UNAME \
&& /usr/bin/install -m 0775 -o mysql -g root -d /var/lib/mysql /var/run/mysqld /docker-entrypoint-initdb.d \
&& /usr/bin/install -m 0664 -o mysql -g root /dev/null /etc/sysconfig/mysql

COPY patchelf-0.12.tar.gz /tmp/
RUN cd /tmp && tar -xzvf patchelf-0.12.tar.gz && cd patchelf-0.12 && ./bootstrap.sh && ./configure && make && make install

COPY rpcsvc-proto-1.4.tar.gz /tmp/rpcsvc-proto-1.4.tar.gz
RUN tar zxvf /tmp/rpcsvc-proto-1.4.tar.gz -C /tmp && cd /tmp/rpcsvc-proto-1.4/ && ./configure && make && make install

COPY boost_1_73_0.tar.gz /opt/
COPY greatsql-automake.sh /opt/

RUN rm -fr /tmp/*

Start to build the docker image. After success, save it locally and import the local image:

[root@greatsql ~]# docker build -t docker-ubuntu .
... ...
[root@greatsql ~]# docker save -o docker-ubuntu.tar docker-ubuntu
[root@greatsql ~]# docker load -i docker-ubuntu.tar

Create a docker container and copy the GreatSQL source package:

[root@greatsql ~]# docker run -itd --name greatsql --hostname=greatsql docker-ubuntu
[root@greatsql ~]# docker cp /opt/greatsql-8.0.25-15.tar.gz greatsql:/opt/
[root@greatsql ~]# docker exec -it greatsql bash
[root@greatsql /]# ls -l /opt/
-rw------- 1 root root 128699082 Jul 27 06:56 boost_1_73_0.tar.gz
-rw------- 1 1000 1000 526639994 Jul 27 05:59 greatsql-8.0.25-15.tar.gz
-rw-r--r-- 1 root root        751 Nov 12 15:25 greatsql-automake.sh

Dockerfile s under other different OS and architecture platforms can be referenced by the following link:

In addition, I also shared the Docker image file package on the network disk. Those interested can also download it directly:

2. Compiling GreatSQL

After entering the container, unzip the GreatSQL and boost source packages:

[root@greatsql /]# tar zxf /opt/greatsql-8.0.25-15.tar.gz -C /opt
[root@greatsql /]# tar zxf /opt/boost_1_73_0.tar.gz -C /opt/

You can directly call the automatic compilation script to start compilation, or you can compile manually:

[root@greatsql /]# cd /opt/greatsql-8.0.25
[root@greatsql /]# /bin/bash /opt/greatsql-automake.sh
...

After compilation, the binary files will be installed in / usr/local/GreatSQL-8.0.25 directory, and the following command will be executed to check and test:

[root@greatsql /]# /usr/local/GreatSQL-8.0.25/bin/mysqld --verbose --version
/usr/local/GreatSQL-8.0.25/bin/mysqld  Ver 8.0.25-15 for Linux on x86_64 (GreatSQL (GPL), Release 15, Revision 202111121536)

This completes the compilation.

Extended reading

End of the full text.

Enjoy GreatSQL 😃

This article is composed of blog one article multi posting platform OpenWrite release!

Posted on Mon, 22 Nov 2021 00:57:42 -0500 by vapokerpro