GreatSQL-8.0.25-16-Linux-glibc2.28-x86_64-minimal安装躺坑

GreatSQL开源数据库是适用于金融级应用的国内自主MySQL版本。采用GPLv2协议

官方安装文档

运行环境配置

#关闭selinux
$ setenforce=0
$ sed -i '/^SELINUX=/c'SELINUX=disabled /etc/selinux/config

#关闭防火墙
$ systemctl disable firewalld
$ systemctl stop firewalld
$ systemctl disable iptables
$ systemctl stop iptables
安装依赖包
$ yum install -y pkg-config perl libaio-devel numactl-devel numactl-libs net-tools openssl openssl-devel jemalloc jemalloc-devel

安装包准备

$ cd /usr/local
$ wget https://product.greatdb.com/GreatSQL-8.0.25-16/GreatSQL-8.0.25-16-Linux-glibc2.28-x86_64-minimal.tar.xz
#或者用curl
$ curl -o GreatSQL-8.0.25-16-Linux-glibc2.28-x86_64-minimal.tar.xz https://product.greatdb.com/GreatSQL-8.0.25-16/GreatSQL-8.0.25-16-Linux-glibc2.28-x86_64-minimal.tar.xz

#解压缩
$ tar xf GreatSQL-8.0.25-16-Linux-glibc2.28-x86_64-minimal.tar.xz

添加系统服务配置

$ vim /lib/systemd/system/greatsql.service

文件内容:
[Unit]
Description=GreatSQL Server
Documentation=man:mysqld(8)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
[Service]

# some limits
# file size
LimitFSIZE=infinity
# cpu time
LimitCPU=infinity
# virtual memory size
LimitAS=infinity
# open files
LimitNOFILE=65535
# processes/threads
LimitNPROC=65535
# locked memory
LimitMEMLOCK=infinity
# total threads (user+kernel)
TasksMax=infinity
TasksAccounting=false

User=mysql
Group=mysql
Type=notify
TimeoutSec=0
PermissionsStartOnly=true
ExecStartPre=/usr/local/GreatSQL-8.0.25-16-Linux-glibc2.28-x86_64-minimal/bin/mysqld_pre_systemd
ExecStart=/usr/local/GreatSQL-8.0.25-16-Linux-glibc2.28-x86_64-minimal/bin/mysqld $MYSQLD_OPTS
EnvironmentFile=-/etc/sysconfig/mysql
LimitNOFILE = 10000
Restart=on-failure
RestartPreventExitStatus=1
Environment=MYSQLD_PARENT_PID=1
PrivateTmp=false

重载systemd,加入 greatsql 服务

$ systemctl daemon-reload

编辑mysqld_pre_systemd脚本内容

$ /usr/local/GreatSQL-8.0.25-16-Linux-glibc2.28-x86_64-minimal/bin/mysqld_pre_systemd
文件内容:
#! /bin/bash

# Copyright (c) 2015, 2021, Oracle and/or its affiliates.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2.0,
# as published by the Free Software Foundation.
#
# This program is also distributed with certain software (including
# but not limited to OpenSSL) that is licensed under separate terms,
# as designated in a particular file or component or in included license
# documentation.  The authors of MySQL hereby grant you an additional
# permission to link the program and your derivative works with the
# separately licensed software that they have included with MySQL.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License, version 2.0, for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA

MYSQL_BASEDIR=/usr/local/GreatSQL-8.0.25-16-Linux-glibc2.28-x86_64-minimal

# Script used by systemd mysqld.service to run before executing mysqld
get_option () {
    local section=$1
    local option=$2
    local default=$3m
    local instance=$4
    ret=$(${MYSQL_BASEDIR}/bin/my_print_defaults  ${instance:+--defaults-group-suffix=@$instance} $section | \
	      grep '^--'${option}'=' | cut -d= -f2- | tail -n 1)
    [ -z "$ret" ] && ret=$default
    echo $ret
}

install_validate_password_sql_file () {
    local initfile
    initfile="$(mktemp /var/lib/mysql-files/install-validate-password-plugin.XXXXXX.sql)"
    chmod a+r "$initfile"
    echo "SET @@SESSION.SQL_LOG_BIN=0;" > "$initfile"
    echo "INSERT INTO mysql.component (component_id, component_group_id, component_urn) VALUES (1, 1, 'file://component_validate_password');" >> $initfile
    echo $initfile
}

fix_mysql_upgrade_info () {
    datadir=$(get_option mysqld datadir "/var/lib/mysql${instance:+-$instance}" $instance)
    if [ -d  "$datadir" ]  && [ -O "$datadir/mysql_upgrade_info" ]; then
	chown --reference="$datadir" "$datadir/mysql_upgrade_info"
	if [ -x /usr/bin/chcon ]; then
            /usr/bin/chcon --reference="$datadir" "$datadir/mysql_upgrade_info" > /dev/null 2>&1
	fi
    fi
}

install_db () {
    # Note: something different than datadir=/var/lib/mysql requires SELinux policy changes (in enforcing mode)

    # mysql_upgrade_info file should be owned by mysql user since MySQL 8.0.16
    fix_mysql_upgrade_info

    # No automatic init wanted
    [ -e /etc/sysconfig/mysql ] && . /etc/sysconfig/mysql
    [ -n "$NO_INIT" ] && exit 0

    local instance=$1
    datadir=$(get_option mysqld datadir "/var/lib/mysql${instance:+-$instance}" $instance)
    log=$(get_option mysqld 'log[_-]error' "/var/log/mysql${instance:+-$instance}.log" $instance)

    # Restore log, dir, perms and SELinux contexts

    if [ ! -d "$datadir" -a ! -h "$datadir" -a "x$(dirname "$datadir")" = "x/var/lib" ]; then
	install -d -m 0751 -omysql -gmysql "$datadir" || exit 1
    fi

    if [ ! -e "$log" -a ! -h "$log" -a x$(dirname "$log") = "x/var/log" ]; then
	case $(basename "$log") in
	    mysql*.log) install /dev/null -m0640 -omysql -gmysql "$log" ;;
	    *) ;;
	esac
    fi

    if [ -x /usr/sbin/restorecon ]; then
        /usr/sbin/restorecon "$datadir"
        [ -e "$log" ] && /usr/sbin/restorecon "$log"
	for dir in /var/lib/mysql-files /var/lib/mysql-keyring ; do
            if [ -x /usr/sbin/semanage -a -d /var/lib/mysql -a -d $dir ] ; then
                /usr/sbin/semanage fcontext -a -e /var/lib/mysql $dir >/dev/null 2>&1
                /sbin/restorecon -r $dir
            fi
	done
    fi

    # If special mysql dir is in place, skip db install
    [ -d "$datadir/mysql" ] && exit 0

    # Create initial db and install validate_password plugin
    #initfile="$(install_validate_password_sql_file)"
    ${MYSQL_BASEDIR}/bin/mysqld ${instance:+--defaults-group-suffix=@$instance} --initialize-insecure \
		     --datadir="$datadir" --user=mysql
    #rm -f "$initfile"

    # Generate certs if needed
    if [ -x ${MYSQL_BASEDIR}/bin/mysql_ssl_rsa_setup -a ! -e "${datadir}/server-key.pem" ] ; then
        ${MYSQL_BASEDIR}/bin/mysql_ssl_rsa_setup --datadir="$datadir" --uid=mysql >/dev/null 2>&1
    fi
    exit 0
}

install_db $1

exit 0

添加文件可执行权限

$ chmod ug+x /usr/local/GreatSQL-8.0.25-16-Linux-glibc2.28-x86_64-minimal/bin/mysqld_pre_systemd

编辑GreatSQL全局配置文件

$ vim /etc/my.cnf
内容:
[mysqld]
user=mysql
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

创建mysql系统用户

$ /sbin/groupadd mysql
$ /sbin/useradd -g mysql mysql -d /dev/null -s /sbin/nologin

启动GreatSQL

$ systemctl start greatsql
$ systemctl status greatsql
$ systemctl status greatsql
$ ss -lntp | grep mysqld
# 查看数据库文件
$ ls /var/lib/mysql

进入数据库

mysql -uroot -h 127.0.0.1 -p #默认root无密码进入
修改密码
alter user user() identified by 'GreatSQL@2022';
创建用户,创建的用户需要root账号分配数据库权限才有对应的数据库信息
create user 'zp'@'localhost' identified by 'zp';
grant all on 数据库名.* to zp@'localhost';

连接驱动

使用mysql的驱动进行连接

设置服务开机自启动

cp /usr/local/GreatSQL-8.0.25-16-Linux-glibc2.28-x86_64-minimal/support-files/mysql.server  /etc/rc.d/init.d/mysql

chmod +x mysql
chkconfig --add mysql
chkconfig --list
当2 3 4 5 为on时设置成功

问题汇总

A、启动数据库服务时出现version `CXXABI_1.3.8‘ not found

解决办法:

find / -name "libstdc++.so*"
strings /usr/lib64/libstdc++.so.6|grep CXXABI
下载一个so_.6.0.26.zip的包放到对应目录下解压
unzip libstdc.so_.6.0.26.zip
mv libstdc++.so.6 libstdc++.so.6.bak
ln -s libstdc++.so.6.0.26 libstdc++.so.6
strings /usr/lib64/libstdc++.so.6|grep CXXABI

B、启动数据库服务时出现version `GLIBC_2.28‘ not found

解决办法:

wget  https://mirror.bjtu.edu.cn/gnu/libc/glibc-2.28.tar.xz
tar -xf glibc-2.28.tar.xz -C /usr/local/
cd /usr/local/glibc-2.28/
mkdir build
cd build/
../configure --prefix=/usr/local/glibc-2.28 可能出现make错误,操作下面的解决办法

yum install -y bison
sudo ../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin
make  //make 运行时间较长,可能会有半小时
###如make没有运行成功,解决error后需要先运行make clean,清除之前make的内容,才能再次执行make
make clean
make
make install

C、These critical programs are missing or too old: make compiler

解决办发:

升级make
wget http://ftp.gnu.org/gnu/make/make-4.2.tar.gz
tar -xzvf make-4.2.tar.gz
cd make-4.2
sudo ./configure
sudo make
sudo make install
sudo rm -rf /usr/bin/make
sudo cp ./make /usr/bin/
make -v

D、Check the INSTALL file for required versions.

解决办发:

升级gcc
yum -y install centos-release-scl
yum -y install devtoolset-8-gcc devtoolset-8-gcc-c++ devtoolset-8-binutils
scl enable devtoolset-8 bash
###yum安装完,原来的gcc不覆盖,需要执行enable脚本更新环境变量 
source /opt/rh/devtoolset-8/enable
###想保持覆盖,可将其写入~/.bashrc或/etc/profile
echo "source /opt/rh/devtoolset-8/enable" >>/etc/profile
###查看gcc版本
gcc -v

E、/usr/lib/systemd/system/greatsql.service; enabled;

systemctl enable greatsql.service

F、/bin/sh: error while loading shared libraries: libc.so.6:

ldconfig

G、[Server] Can’t start server: can’t check PID filepath: No such file or directory

 查看、etc/my.conf中配置的路径是否存在不存在则创建对应路径且对其进行权限分配
mkdir -p /var/run/mysqld
chown mysql.mysql /var/run/mysqld
touch /var/run/mysqld/mysqld.pid
chown mysql.mysql /var/run/mysqld/mysqld.pid

H、mysql: error while loading shared libraries: libncurses.so.6: cannot open shared object file: No such file or directory

缺少对应的依赖包,

yum install libncurses.so.6

I、连接Mysql服务器提示:1130-Host XXX is not allowed to connect to this MySQL server

update user set Host='%' where user ='root';
Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐