当前位置:   article > 正文

万里开源数据库GreatSQL-8.0.25-16-Linux-glibc2.28安装及问题记录_万里数据库安装

万里数据库安装

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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

安装包准备

$ 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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

添加系统服务配置

$ 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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43

重载systemd,加入 greatsql 服务

$ systemctl daemon-reload
  • 1

编辑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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116

添加文件可执行权限

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

编辑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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

创建mysql系统用户

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

启动GreatSQL

$ systemctl start greatsql
$ systemctl status greatsql
$ systemctl status greatsql
$ ss -lntp | grep mysqld
# 查看数据库文件
$ ls /var/lib/mysql
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

进入数据库

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';
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

连接驱动

使用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时设置成功
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

问题汇总

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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

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

systemctl enable greatsql.service
  • 1

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

ldconfig
  • 1

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
  • 1
  • 2
  • 3
  • 4
  • 5

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
  • 1

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

update user set Host='%' where user ='root';
  • 1
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小小林熬夜学编程/article/detail/139687
推荐阅读
相关标签
  

闽ICP备14008679号