社群生態 | openEuler、龍蜥Anolis、統信UOS三大主流作業系統下編譯GreatSQL二進位制包

萬里資料庫發表於2023-04-21

為了更好地支援更多作業系統及相關生態, GreatSQL社群決定釋出 openEuler、龍蜥Anolis、統信UOS三個作業系統下的GreatSQL二進位制包。 相應的二進位制包可以訪問gitee.com上的 GreatSQL專案  下載。

本文簡要記錄在這三個作業系統下編譯GreatSQL二進位制包的過程。
  • 1.  編譯環境

  • 2.  編譯前準備工作

  • 3.  編譯GreatSQL

  • 4.  初始化並啟動GreatSQL資料庫

  • 5.  執行sysbench測試

  • 附錄: 編譯sysbench



1. 編譯環境

本次編譯都是採用鯤鵬916這個型號的CPU(泰山2280伺服器系列):
    $ lscpu
    Architecture:          aarch64
    Byte Order:            Little Endian
    CPU(s):                64
    On-line CPU(s) list:   0-63
    Thread(s) per core:    1
    Core(s) per socket:    32
    Socket(s):             2
    NUMA node(s):          4
    Model:                 2
    BogoMIPS:              100.00
    L1d cache:             32K
    L1i cache:             48K
    L2 cache:              1024K
    L3 cache:              16384K
    NUMA node0 CPU(s):     0-15
    NUMA node1 CPU(s):     16-31
    NUMA node2 CPU(s):     32-47
    NUMA node3 CPU(s):     48-63
    Flags:                 fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid
上述  lscpu  是在物理機上執行的,實際編譯環境則是在這個物理機上執行的虛機中,分配了8個CPU、16G記憶體。
檢視作業系統發行版本
openEuler
    $ cat /etc/os-release

    NAME= "openEuler"
    VERSION= "22.03 LTS"
    ID= "openEuler"
    VERSION_ID= "22.03"
    PRETTY_NAME= "openEuler 22.03 LTS"
    ANSI_COLOR= "0;31"
龍蜥Anolis
    $ cat /etc/os-release
    NAME= "Anolis OS"
    VERSION= "8.6"
    ID= "anolis"
    ID_LIKE= "rhel fedora centos"
    VERSION_ID= "8.6"
    PLATFORM_ID= "platform:an8"
    PRETTY_NAME= "Anolis OS 8.6"
    ANSI_COLOR= "0;31"
    HOME_URL= "
統信UOS
    $ cat /etc/os-release
    PRETTY_NAME= "UnionTech OS Server 20"
    NAME= "UnionTech OS Server 20"
    VERSION_ID= "20"
    VERSION= "20"
    ID= "uos"
    HOME_URL= "
    BUG_REPORT_URL= "
    VERSION_CODENAME= "kongzi"
    PLATFORM_ID= "platform:uelc20"
    [root@yejr-uos-aarch64 ~] #
    [root@yejr-uos-aarch64 ~] #
    $ cat /etc/uos-release
    UnionTech OS Server release 20 (kongzi)
並且都採用OS中預設的預設YUM源
    $ cat openEuler.repo
     #generic-repos is licensed under the Mulan PSL v2.
     #You can use this software according to the terms and conditions of the Mulan PSL v2.
     #You may obtain a copy of Mulan PSL v2 at:
     #    
     #THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
     #IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
     #PURPOSE.
     #See the Mulan PSL v2 for more details.

    [OS]
    name=OS
    baseurl= $basearch/
    enabled=1
    gpgcheck=1
    gpgkey= $basearch/RPM-GPG-KEY-openEuler

    [everything]
    name=everything
    baseurl= $basearch/
    enabled=1
    gpgcheck=1
    gpgkey= $basearch/RPM-GPG-KEY-openEuler
    ...
龍蜥Anolis
    $ cat AnolisOS-AppStream.repo
    [AppStream]
    name=AnolisOS- $releasever - AppStream
    baseurl= $releasever/AppStream/ $basearch/os
    enabled=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ANOLIS
    gpgcheck=1
統信UOS
    $ cat UniontechOS.repo
    [UniontechOS- $releasever-AppStream]
    name = UniontechOS  $releasever AppStream
    baseurl =  $basearch
    enabled = 1
    username= $auth_u
    password= $auth_p
    gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-uos-release
    gpgcheck = 0
    skip_if_unavailable = 1

    [UniontechOS- $releasever-BaseOS]
    name = UniontechOS  $releasever BaseOS
    baseurl =  $basearch
    enabled = 1
    username= $auth_u
    password= $auth_p
    gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-uos-release
    gpgcheck = 0
    skip_if_unavailable = 1
    ...

2. 編譯前準備工作

參考檔案  麒麟OS+龍芯環境編譯GreatSQL ,提前安裝必要的一些基礎包
    $ dnf makecache
    $ dnf install --skip-broken -y automake bison bison-devel boost-devel bzip2 bzip2-devel clang \
    cmake cmake3 diffutils expat-devel file flex gcc gcc-c++ git jemalloc jemalloc-devel \
    graphviz libaio-devel libarchive libcurl-devel libevent libevent-devel libverto-libevent libevent-doc libffi-devel libicu-devel libssh \
    libtirpc libtirpc-devel libtool libxml2-devel libzstd libzstd-devel lz4-devel \
    lz4-static make ncurses-devel ncurses-libs net-tools numactl numactl-devel numactl-libs openldap-clients \
    openldap-devel openssl openssl-devel pam pam-devel perl perl-Env perl-JSON perl-Memoize \
    perl-Time-HiRes pkg-config psmisc re2-devel readline-devel \
    snappy-devel tar time unzip vim wget zlib-devel
openEuler下就可以根據安裝檔案 麒麟OS+龍芯環境編譯GreatSQL 中列出的所有包,包括 jemalloc 包。
下載安裝jemalloc rpm包(rpm包依賴glibc版本,可能無法直接使用,可以自行下載原始碼包編譯)
  • https://fedora.pkgs.org/36/fedora-aarch64/jemalloc-devel-5.2.1-7.fc36.aarch64.rpm.html

  • 原始碼包 

當然了,jemalloc並庫不是必須的,用它的好處是可以最佳化記憶體管理效能等。有條件的話儘量啟用,實在搞不定就放棄。
如果需要手動編譯安裝jemalloc,參考下面的方法即可:
    $ tar zxf jemalloc-5.2.1.tar.gz
    $ mv jemalloc-jemalloc-886e40b/
    $ ./autogen.sh
    $ ./configure --prefix=/usr && make && make install
分別下載幾個編譯過程中需要的依賴包:
  • boost, 

  • patchelf,  , 下載後重新命名為 patchelf-0.14.tar.gz

  • rpcsvc-proto, 

下載GreatSQL原始碼包:
將所有的原始碼包都放在 /opt 目錄下。
編譯安裝patchelf:
    $  cd /opt && tar zxvf patchelf-0.14.tar.gz &&  cd patchelf-0.14 && ./bootstrap.sh && ./configure && make && make install
編譯安裝rpcsvc-proto:
    $  cd /opt && tar zxvf rpcsvc-proto-1.4.tar.gz &&  cd rpcsvc-proto-1.4/ && ./configure && make && make install
編譯安裝rpcsvc-proto:
    [root@ky10 ~] # cd /opt && tar zxvf rpcsvc-proto-1.4.tar.gz && cd rpcsvc-proto-1.4/ && ./configure && make && make install
確認glibc版本:
    $ ldd --version

    ldd (GNU libc) 2.28
    Copyright (C) 2018 Free Software Foundation, Inc.
    This is free software; see the  source  for copying conditions.  There is NO
    warranty; not even  for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    Written by Roland McGrath and Ulrich Drepper.
在本次編譯過程中,openEuler 2203的glibc版本是2.34。

3. 編譯GreatSQL

接下來編譯GreatSQL二進位制包
    $ cat /opt/greatsql-build-tarball.sh

     #!/bin/bash
    MAJOR_VERSION=8
    MINOR_VERSION=0
    PATCH_VERSION=25
    RELEASE=17
    REVISION= "4733775f703"
    GLIBC=`ldd --version | grep ldd | tail -n 1 | awk  '{print $NF}'`
    ARCH=aarch64
    OS=openEuler
    PKG_NAME=GreatSQL- ${MAJOR_VERSION}. ${MINOR_VERSION}. ${PATCH_VERSION}- ${RELEASE}- ${OS}-glibc ${GLIBC}- ${ARCH}BASE_DIR=/usr/ local/ ${PKG_NAME}
    SRC_DIR=/opt
    BOOST_SOURCE_DIR=boost_1_73_0
    GREATSQL_SOURCE_DIR=greatsql-8.0.25-17
    JOBS=`nproc`

    # 如果你的OS環境下已安裝jemalloc,建議也啟用jemalloc編譯選項
    # 如果沒有安裝jemalloc,則將本行引數註釋掉

    CMAKE_EXE_LINKER_FLAGS= " -ljemalloc "

     cd  ${SRC_DIR}/ ${GREATSQL_SOURCE_DIR} && \
    rm -fr bld && \
    mkdir bld && \
     cd bld && \
    cmake .. -DBOOST_INCLUDE_DIR= ${SRC_DIR}/ ${BOOST_SOURCE_DIR} \
    -DLOCAL_BOOST_DIR= ${SRC_DIR}/ ${BOOST_SOURCE_DIR} \
    -DCMAKE_INSTALL_PREFIX= ${BASE_DIR} -DWITH_ZLIB=bundled \
    -DWITH_NUMA=ON -DCMAKE_EXE_LINKER_FLAGS= " ${CMAKE_EXE_LINKER_FLAGS}" \
    -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_CONFIG=mysql_release \
    -DWITH_TOKUDB=OFF -DWITH_ROCKSDB=OFF \
    -DCOMPILATION_COMMENT= "GreatSQL (GPL), Release  ${RELEASE}, Revision  ${REVISION}" \
    -DMAJOR_VERSION= ${MAJOR_VERSION} -DMINOR_VERSION= ${MINOR_VERSION} -DPATCH_VERSION= ${PATCH_VERSION} \
    -DWITH_UNIT_TESTS=OFF -DWITH_NDBCLUSTER=OFF -DWITH_SSL=system -DWITH_SYSTEMD=ON \
    -DWITH_LIBEVENT=system \
    && make -j ${JOBS} && make -j ${JOBS} install
不出意外的話,就可以編譯生成二進位制檔案了。

4. 初始化並啟動GreatSQL資料庫

GreatSQL初始化,my.cnf可以參考這份模板:
    $ groupadd mysql && useradd -g mysql mysql -s /sbin/nologin -d /dev/null

    $  echo  '/usr/local/GreatSQL-8.0.25-17-openEuler-glibc2.34-aarch64/lib/' > /etc/ld.so.conf.d/greatsql.conf

    $ ldconfig -p | grep -i percona
     libperconaserverclient.so.21 (libc6,AArch64) => /usr/ local/GreatSQL-8.0.25-17-openEuler-glibc2.34-aarch64/lib/libperconaserverclient.so.21
     libperconaserverclient.so (libc6,AArch64) => /usr/ local/GreatSQL-8.0.25-17-openEuler-glibc2.34-aarch64/lib/libperconaserverclient.so
     
     
      # 確保沒有找不到的動態庫
    $ ldd /usr/ local/GreatSQL-8.0.25-17-openEuler-glibc2.34-aarch64/bin/mysqld | grep -i not

    $ ./bin/mysqld --defaults-file=/etc/my.cnf --initialize-insecure

    $ ./bin/mysqld --defaults-file=/etc/my.cnf &

    $ lsof -p `pidof mysqld` | grep -i jemalloc
    mysqld  85204 mysql  mem       REG                8,3     471696   3329101 /usr/lib64/libjemalloc.so.2

5. 執行sysbench測試

準備跑一輪sysbench測試
      #先設定PATH
    $  export PATH= $PATH:/usr/ local/GreatSQL-8.0.25-17-openEuler-glibc2.34-aarch64/bin

    $ mysqladmin create sbtest

    $  cd /usr/ local/share/sysbench/
    $ sysbench /usr/ local/share/sysbench/oltp_read_write.lua --mysql-host=localhost --mysql-user=root --mysql-password= "" --mysql-socket=/usr/ local/GreatSQL-8.0.25-17-openEuler-glibc2.34-aarch64/data/mysql.sock --mysql-db=sbtest --db-driver=mysql --tables=10 --table_size=10000 prepare

    $  for i  in $(seq 1 3); do sysbench /usr/ local/share/sysbench/oltp_read_write.lua --mysql-host=localhost --mysql-user=root --mysql-password= "" --mysql-socket=/usr/ local/GreatSQL-8.0.25-17-openEuler-glibc2.34-aarch64/data/mysql.sock --mysql-db=sbtest --db-driver=mysql --tables=10 --table_size=10000 --report-interval=1 --threads=8 --rand-type=uniform --db-ps-mode= disable  --time=900 run > greatsql-802517- $i. log; sleep 300;  done

附錄:編譯sysbench

     #先做個動態庫軟連結
    $  cd /usr/ local/GreatSQL-8.0.25-17-openEuler-glibc2.34-aarch64/lib/
    $ ln -s libperconaserverclient.so libmysqlclient.so
    $  cd /tmp/sysbench/
    $ ./autogen.sh
    $ ./configure --with-mysql-includes=/usr/ local/GreatSQL-8.0.25-17-openEuler-glibc2.34-aarch64/include/ --with-mysql-libs=/usr/ local/GreatSQL-8.0.25-17-openEuler-glibc2.34-aarch64/lib/ && make && make install


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/69997641/viewspace-2947421/,如需轉載,請註明出處,否則將追究法律責任。

相關文章