- The original content of GreatSQL community cannot be used without authorization. Please contact Xiaobian and indicate the source for reprint.
In the near future, we plan to create a docker image of GreatSQL to facilitate community users to use GreatSQL.
The environment for making docker images is based on CentOS 7.9:
[root@greatsql]# cat /etc/redhat-release CentOS Linux release 7.9.2009 (Core) [root@greatsql]# uname -a Linux GreatSQL 3.10.0-1160.11.1.el7.x86_64 #1 SMP Fri Dec 18 16:34:56 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
1. Preparatory work
To create a docker image, you need to install docker and start the service.
[root@greatsql]# yum install -y docker [root@greatsql]# systemctl start docker
Prepare a CentOS basic image and select CentOS 7 as the basic image.
[root@greatsql]# docker pull centos:7 [root@greatsql]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE docker.io/centos 7 8652b9f0cb4c 7 months ago 204 MB
The repository of this image is docker IO / CentOS. The tag is 7 (indicates CentOS 7 version), the tag ID is 8652b9f0cb4c, the last update time was 7 months ago, and the image size is 204MB.
Here, it is also possible to select the image of CentOS 8, but some system commands are slightly different. The specific choice depends on your personal preference.
2. Start making docker image
First create the working directory / data / docker greatsql:
[root@greatsql]# mkdir -p /data/docker-greatsql && cd /data/docker-greatsql
2.1 preparation of installation package and supporting equipment
jemalloc is required to run GreatSQL. It is usually not available in the default yum source, so download it locally first:
[root@greatsql]# wget https://mirrors.cloud.tencent.com/percona/tools/yum/release/7Server/RPMS/x86_64/jemalloc-3.6.0-3.el7.x86_64.rpm
Prepare the GreatSQL binary package, put it in the / data / docker GreatSQL directory, and send the GreatSQL. SQL in advance service, my. CNF, sysconfig / MySQL and other files are also placed in:
[root@greatsql]# ls GreatSQL-8.0.23-14-Linux-glibc2.17-x86_64 bin cmake docs include lib LICENSE LICENSE-test man README README-test run share support-files var [root@greatsql]# ls -aR GreatSQL-8.0.23-14-Linux-glibc2.17-x86_64/support-files/ GreatSQL-8.0.23-14-Linux-glibc2.17-x86_64/support-files/: . .. greatsql.service my.cnf mysqld_multi.server mysql-log-rotate mysql.server sysconfig GreatSQL-8.0.23-14-Linux-glibc2.17-x86_64/support-files/sysconfig: . .. mysql
Reminder: the great SQL binary file used in the docker image has been subjected to a strip operation to delete the symbol information and debugging information in the binary program file. Its advantage is that the file is very small, but its disadvantage is that it cannot be used for gdb tracking and debugging in the later stage.
Next, edit the Dockfile document.
2.2 editing Dockerfile
The Dockerfile document is as follows:
FROM centos:7 MAINTAINER greatsql@greatdb.com RUN localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 ENV LANG en_US.utf8 ENV MYSQL_DATA_DIR=/data/GreatSQL ENV MYSQL_USER=mysql ENV MYSQL_UID_GID=3306 ENV MYSQL_EXTRACT_DIR=/usr/local ENV TMP_DIR=/tmp ENV MYSQL_PORT=3306 ENV GREATSQL="GreatSQL-8.0.23-14-Linux-glibc2.17-x86_64" ENV MYSQL_BASEDIR=${MYSQL_EXTRACT_DIR}/${GREATSQL} ENV JEMALLOC_RPM="jemalloc-3.6.0-1.el7.x86_64.rpm" ENV DEP_LIBS="numactl-libs libaio readline-devel ncurses-devel" ENV GREATSQL_INIT="greatsql-init.sh" #Creating user mysql RUN groupadd -g ${MYSQL_UID_GID} ${MYSQL_USER}; \ useradd -u ${MYSQL_UID_GID} -r -g ${MYSQL_UID_GID} -s /sbin/nologin \ -c "MySQL User" ${MYSQL_USER} #Copying files COPY ${GREATSQL} ${MYSQL_EXTRACT_DIR}/${GREATSQL} COPY ${JEMALLOC_RPM} ${TMP_DIR} #Installing jemalloc & depend libs RUN yum install -y ${TMP_DIR}/${JEMALLOC_RPM} ; yum install -y ${DEP_LIBS} RUN cd ${MYSQL_BASEDIR}/support-files && \ cp -f my.cnf /etc/my.cnf ; \ echo "LD_PRELOAD=/usr/lib64/libjemalloc.so.1" >> /etc/sysconfig/mysql ; \ echo "THP_SETTING=never" >> /etc/sysconfig/mysql ; \ echo "export PATH=\$PATH:${MYSQL_BASEDIR}/bin" >> /etc/profile.d/mysql.sh ; \ source /etc/profile.d/mysql.sh RUN PATH="\$PATH:${MYSQL_BASEDIR}/bin" RUN export PATH #Creating datadir RUN mkdir -p ${MYSQL_DATA_DIR} && chown -R ${MYSQL_USER}:${MYSQL_USER} ${MYSQL_BASEDIR} ; \ chmod -R ug+rwX ${MYSQL_BASEDIR} ; \ chmod -R ug+rwX /etc/my.cnf RUN rm -f ${TMP_DIR}/${JEMALLOC_RPM} COPY ${GREATSQL_INIT} /docker-entrypoint.sh ENTRYPOINT ["/docker-entrypoint.sh"] EXPOSE ${MYSQL_PORT} ${MYSQL_PORT}0 ${MYSQL_PORT}1 CMD ["mysqld"]
The content is easy to understand, so I won't explain it in detail.
2.3 making images
Run docker build to create a new image:
[root@greatsql]# cd /data/docker-greatsql #Usage: docker build -t [image name]: [image tag] [path of dockerfile file] [root@greatsql]# docker build -t greatsql:8.0.23 ./
Parameter - t greatsql:8.0.23 is used to set tag, that is, the image name.
The whole construction process is as follows (some output contents are omitted):
Sending build context to Docker daemon 1.041 GB Step 1/26 : FROM centos:7 ---> 8652b9f0cb4c Step 2/26 : MAINTAINER greatsql@greatdb.com ---> Running in 2241e5964885 ---> b88695fed8ba ... Removing intermediate container 25d994ce8e90 Successfully built d1963ef0c403
Seeing the final success indicates that the packaging is successful. If there is an error, you need to solve it one by one according to the error information.
2.4 save image to local
Save the image file locally to facilitate copying to other servers without external network. Run docker save:
#Usage docker save -o [export file. tar] [image name]: [image label] [root@greatsql]# docker save -o Docker-GreatSQL-8.0.23-centos7.tar greatsql:8.0.23
After saving successfully, you can see the local image package name docker-greatsql-8.0.23-centos7 tar.
Run the command docker load to load the local image:
#Usage: docker load -i [local tar package file] [root@greatsql]# docker load -i Docker-GreatSQL-8.0.23-centos7.tar Loaded image: greatsql:8.0.23 [root@greatsql]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE greatsql latest 6540b4fa4887 3 days ago 502 MB greatsql 8.0.23-centos7 d1963ef0c403 3 days ago 582 MB greatsql 8.0.23 d1963ef0c403 3 days ago 582 MB
2.5 publish docker image
To release to the official warehouse https://hub.docker.com For example.
You need to register your account first, and then log in with this account:
[root@greatsql]# docker login -u greatsql Password: *********
Before publishing for the first time, label the local image, for example:
#Usage: docker tag local image name [: label] warehouse name / publish image name [: label] #Add a centos7 tag first [root@greatsql]# docker tag greatsql:8.0.23 greatsql/greatsql:8.0.23-centos7 #Add a default latest tag [root@greatsql]# docker tag greatsql:8.0.23 greatsql/greatsql:latest
After labeling, you can publish the image:
#Usage: docker push warehouse name / publish image name [: label] [root@greatsql]# docker push greatsql/greatsql:8.0.23-centos7 The push refers to a repository [docker.io/greatsql/greatsql] 953e779e02c1: Pushed ... 8ce193c7940e: Pushed 174f56854903: Layer already exists 8.0.23-centos7: digest: sha256:d28b16236cc097cc6bab10d94afe47562b518ffe201c7fb86688cf4cb4916975 size: 3050 #Release the image of the latest tag once [root@greatsql]# docker push greatsql/greatsql:latest
To view a list of mirrors:
[root@greatsql]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE greatsql/greatsql latest 6540b4fa4887 3 days ago 582 MB <-- Mirror image in official warehouse greatsql/greatsql 8.0.23-centos7 d1963ef0c403 3 days ago 582 MB <-- Mirror image in official warehouse greatsql 8.0.23 d1963ef0c403 3 days ago 582 MB <-- Local Mirror
You can search the mirror image and feel the joy of seeing the fruits of your labor.
[root@greatsql]# docker search greatsql INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED docker.io docker.io/greatsql/greatsql 0
Now you can download the image:
[root@greatsql]# docker pull greatsql/greatsql
If no tag name is added, the latest one will be automatically selected, which is equivalent to:
[root@greatsql]# docker pull greatsql/greatsql:latest
You can modify the tag name and download it yourself.
This time, I'll stop here. Next, I'll introduce how to use the GreatSQL Docker image to build an MGR cluster.
The level is limited. Please help readers to see what can be optimized. Thank you.
Enjoy GreatSQL & Docker :)
Download the domestic CentOS 7 yum source file. Take Alibaba and Tencent as examples. You can configure it this way (choose one of the two yum sources):
#Alibaba cloud [root@greatsql]# wget -O CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo #Tencent cloud [root@greatsql]# wget -O CentOS-Base.repo http://mirrors.cloud.tencent.com/repo/centos7_base.repo
Enjoy GreatSQL :)
Article recommendation:
GreatSQL MGR FAQ
https://mp.weixin.qq.com/s/J6...
Wan Da #12, how can the MGR cluster automatically select the master without manual intervention
https://mp.weixin.qq.com/s/07...
"2021 data technology Carnival · ON LINE": evolution and practice of MySQL high availability architecture
https://mp.weixin.qq.com/s/u7...
Packet capture analysis of where an sql statement is slow
https://mp.weixin.qq.com/s/AY...
Wan Da #15, what are the conditions that may cause the MGR service to fail to start
https://mp.weixin.qq.com/s/in...
Technology sharing | why MGR consistency mode does not recommend AFTER
https://mp.weixin.qq.com/s/rN...
About GreatSQL
GreatSQL is a MySQL branch maintained by Wanli database. It focuses on improving the reliability and performance of MGR and supports the parallel query feature of InnoDB. It is a branch version of MySQL suitable for financial applications.
Gitee:
https://gitee.com/GreatSQL/Gr...
GitHub:
https://github.com/GreatSQL/G...
Bilibili:
https://space.bilibili.com/13...
Wechat & QQ group:
You can search and add GreatSQL community assistant wechat friends, send verification information "add group" to join GreatSQL/MGR communication wechat group
QQ group: 533341697
Wechat assistant: wanlidbc
This article is composed of blog one article multi posting platform OpenWrite release!