Compile and install GreatSQL in Ubuntu

This article describes how to build an Ubuntu environment with Docker and compile the source code of GreatSQL into binary files.

1. Preparation

Docker workdir = /data/docker-ubuntu

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

1.1. Configure apt source configuration files in Ubuntu

Before compiling, it is recommended to configure apt sources so that the deployment environment can download software packages more quickly.

Take Ali and Tencent cloud hosts as examples, you can configure them as follows (choose one of the two APT sources) :

# tencent cloud/root @ greatsql ~ # cat/data/docker - ubuntu ubuntu - 20.4 - sources. The 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 multiverseCopy the code

If it’s AliYun, replace it with the following

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
Copy the code

This file is ready for later use in the Dockerfile.

In addition, according to my own test, in the process of building docker image, the source of Ali Cloud is more prone to error, please test and select by yourself.

Install Docker, boost, GreatSQL, boost, boost, GreatSQL, etc.

I have also prepared a shell script to automate the compilation of GreatSQL, which I can take for myself:

[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 | the 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 installCopy the code

1.2. Build docker image

Build an Ubuntu image with this Dockerfile:

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 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 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/*Copy the code

Start building docker image, save it to local 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.tarCopy the code

Create a docker container and copy the GreatSQL source package into it:

[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-automakeCopy the code

Dockerfiles on different OS and architecture platforms can be referenced by the following link:

  • Dockerfile-centos7-x86
  • Dockerfile-centos8-x86
  • Dockerfile-centos7-arm
  • Dockerfile-centos8-arm

In addition, I also put the Docker image file package on the network disk to share, interested can also directly download:

  • [Baidu cloud disk] Link: pan.baidu.com/s/188iZ_vT4… Extraction code: 8C22

2. Compile GreatSQL

Once in the container, extract 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/Copy the code

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

[root@greatsql /]# CD /opt/ greatSQL-8.0.25 [root@greatsql /]# /bin/bash /opt/ greatSQL-automake.sh...Copy the code

After compiling, install binaries to /usr/local/greatSQL-8.0.25 and run the following command to check the 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)Copy the code

That completes the compilation.

read

  • Play with MySQL 8.0 source code compilation
  • Add GreatSQL to the system Systemd service
  • Deploy the MGR cluster using GreatSQL
  • InnoDB Cluster+GreatSQL Deploy MGR Cluster
  • Deploy GreatSQL in Docker and build MGR cluster
  • Ansible one-click install GreatSQL and build MGR cluster
  • Deploy GreatSQL in Docker and build MGR cluster

The full text.

Enjoy GreatSQL 🙂

This article is published by OpenWrite!