GreatSQL单机环境安装

Posted bisal(Chen Liu)

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了GreatSQL单机环境安装相关的知识,希望对你有一定的参考价值。

国产数据库之-GreatSQL》介绍了万里的GreatSQL数据库,在这篇文章中,我们尝试搭建一个单机版的环境。

GreatSQL是源于Percona Server的分支版本,因此从整体安装的流程上,和mysql基本一致。

1. 下载安装文件

可以从这个链接,下载对应平台的安装文件,如果是CentOS,可以选择GreatSQL-8.0.25-15-Linux-glibc2.17-x86_64.tar.xz,

https://gitee.com/GreatSQL/GreatSQL/releases

2. 创建用户和相关的文件夹,并授予权限

groupadd mysql
useradd -g mysql mysql
mkdir -p /opt/mysql/data/data,logs,tmp
chown -R mysql:mysql /opt/mysql/

3. 配置文件

配置my.cnf,

# /etc/my.cnf
[client]
port=3306
socket=/opt/mysql/data/tmp/mysql.3306.sock


[mysql]
prompt="\\u@mysqldb \\R:\\m:\\s [\\d]> "
no-auto-rehash
loose-skip-binary-as-hex


[mysqld]
user=mysql
port=3306
basedir=/opt/mysql/GreatSQL
datadir=/opt/mysql/data/data
socket=/opt/mysql/data/tmp/mysql.3306.sock
pid-file=/opt/mysql/data/tmp/mysql.3306.pid
character-set-server=utf8mb4
lower_case_table_names=1
innodb_temp_data_file_path=ibtmp1:12M:autoextend:max:5G
default_authentication_plugin=mysql_native_password


slow_query_log=1
log_timestamps=SYSTEM
slow_query_log_file=/opt/mysql/data/logs/slow.log
log-error=/opt/mysql/data/logs/mysql.error.log
long_query_time=1
log_queries_not_using_indexes =1
log_throttle_queries_not_using_indexes=60
min_examined_row_limit = 100
log_slow_admin_statements = 1
server-id=15910
log-bin=/opt/mysql/data/logs/mysql-binlog


[mysqld_safe]
log-error=/opt/mysql/data/logs/mysql.error.log
pid-file=/opt/mysql/data/tmp/mysql.3306.pid


[mysqldump]
quick
max_allowed_packet = 64M

4. 安装依赖包

GreatSQL依赖jemalloc库,因此需要安装,

yum -y install jemalloc jemalloc-devel

确认安装状态,

[root@bisal software]# ldconfig -p | grep libjemalloc
        libjemalloc.so.1 (libc6,x86-64) => /lib64/libjemalloc.so.1
        libjemalloc.so (libc6,x86-64) => /lib64/libjemalloc.so

5. 初始化数据库

如果非生产环境,还可以使用--initialize-insecure,无密码初始化,

./mysqld --defaults-file=/opt/mysql/GreatSQL/my.cnf --basedir=/opt/mysql/GreatSQL --datadir=/opt/mysql/data/data --initialize
2022-04-03T09:46:56.502250+08:00 0 [System] [MY-013169] [Server] /opt/mysql/GreatSQL/bin/mysqld (mysqld 8.0.25-15) initializing of server in progress as process 22877
2022-04-03T09:46:56.535114+08:00 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-04-03T09:46:58.300456+08:00 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.

如果指定--initialize-insecure,会提示,

root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.

6. 启动数据库

可以使用mysql.server start,启动数据库,

mysql.server start

7. 登录数据库

使用默认密码,登录数据库,

[mysql@bisal bin]$ mysql -uroot -p'FAucEoQJ0-;9'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \\g.
Your MySQL connection id is 9
Server version: 8.0.25-15


Copyright (c) 2021-2021 GreatDB Software Co., Ltd
Copyright (c) 2009-2021 Percona LLC and/or its affiliates
Copyright (c) 2000, 2021, Oracle and/or its affiliates.


Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.


Type 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.

和MySQL一样,初次登录,需要改账号密码,

mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

set或者alter user两种形式,

mysql> set password='root';
Query OK, 0 rows affected (0.03 sec)
mysql> alter user current_user() identified by 'root';
Query OK, 0 rows affected (0.01 sec)

除此之外,和MySQL一样,GreatSQL还可以通过源码安装,具体可参考,

https://gitee.com/GreatSQL/GreatSQL-Doc/blob/master/docs/build-greatsql-with-source.md

MySQL安装相关的历史文章,

小白学习MySQL - 数据库软件和初始化安装

初探MySQL-小白的Linux安装笔记

MySQL 5.6搭建主从复制

MySQL 5.6 rpm安装方法和碰见的问题

MySQL的rpm和源码两种安装操作》

近期更新的文章:

推荐一款小游戏

还得唠叨两句中国男足

国产数据库之-GreatSQL

无外网的情况下,DBeaver下载数据库驱动的方案

SQL Server中怎么知道哪些表被访问过?

文章分类和索引:

公众号900篇文章分类和索引

以上是关于GreatSQL单机环境安装的主要内容,如果未能解决你的问题,请参考以下文章

麒麟OS和龙芯环境编译安装GreatSQL

麒麟OS和龙芯环境编译安装GreatSQL

GreatSQL配置到系统systemd服务

分布式编译系统的搭建

麒麟OS+龙芯环境编译GreatSQL

技术分享 | 利用systemd管理MySQL单机多实例