RPM安装


本文档主要介绍如何用RPM包方式安装GreatSQL数据库,假定本次安装是在CentOS 8.x x86_64环境中安装,并且是以root用户身份执行安装操作。

下载安装包

点击此处RPM安装 - 图1 (opens new window)下载最新的安装包,至少下载以下几个RPM包文件:

  • greatsql-client-8.0.32-24.1.el8.x86_64.rpm
  • greatsql-devel-8.0.32-24.1.el8.x86_64.rpm
  • greatsql-icu-data-files-8.0.32-24.1.el8.x86_64.rpm
  • greatsql-shared-8.0.32-24.1.el8.x86_64.rpm
  • greatsql-server-8.0.32-24.1.el8.x86_64.rpm

提示:建议直接下载RPM集中打包文件,例如 greatsql-8.0.32-24.1.el8.x86_64.rpm-bundle.tar.xz,就无需每个文件单独下载了。

运行环境配置

关闭selinux和防火墙

  1. #关闭selinux
  2. $ setenforce=0
  3. $ sed -i '/^SELINUX=/c'SELINUX=disabled /etc/selinux/config
  4. #关闭防火墙
  5. $ systemctl disable firewalld
  6. $ systemctl stop firewalld
  7. $ systemctl disable iptables
  8. $ systemctl stop iptables

另外,要先确认YUM源可用,因为安装GreatSQL时还要先安装其他依赖包,通过YUM安装最省事。

如果需要配置YUM源,可以参考这篇文档RPM安装 - 图2 (opens new window)

安装依赖包

安装GreatSQL RPM包时,要先安装这些相关依赖包。

  1. $ yum install -y pkg-config perl libaio-devel numactl-devel numactl-libs net-tools openssl openssl-devel jemalloc jemalloc-devel perl-Data-Dumper perl-Digest-MD5

更详细的请参考:安装准备

安装RPM包

执行下面的命令安装PRM包,如果一切顺利的话,相应的过程如下所示:

  1. $ rpm -ivh --nodeps greatsql*rpm
  2. Verifying... ################################# [100%]
  3. Preparing... ################################# [100%]
  4. Updating / installing...
  5. 1:greatsql-shared-8.0.32-24.1.el8 ################################# [ 20%]
  6. 2:greatsql-client-8.0.32-24.1.el8 ################################# [ 40%]
  7. 3:greatsql-icu-data-files-8.0.32-24################################# [ 60%]
  8. 4:greatsql-server-8.0.32-24.1.el8 ################################# [ 80%]
  9. 5:greatsql-devel-8.0.32-24.1.el8 ################################# [100%]

这就安装成功了。

提示

  1. 安装GreatSQL RPM包需要先安装其他依赖包,可执行下面命令完成: yum install -y pkg-config perl libaio-devel numactl-devel numactl-libs net-tools openssl openssl-devel jemalloc jemalloc-devel perl-Data-Dumper perl-Digest-MD5 更详细的请参考:安装准备

其他部分依赖包,如果通过YUM还是无法安装,则加上 --nodeps --force 强制忽略即可,例如:

  1. $ rpm -ivh greatsql*rpm
  2. error: Failed dependencies:
  3. perl(Lmo) is needed by greatsql-server-8.0.32-24.1.el8.x86_64
  4. perl(Lmo::Meta) is needed by greatsql-server-8.0.32-24.1.el8.x86_64
  5. perl(Lmo::Object) is needed by greatsql-server-8.0.32-24.1.el8.x86_64
  6. perl(Lmo::Types) is needed by greatsql-server-8.0.32-24.1.el8.x86_64
  7. perl(Lmo::Utils) is needed by greatsql-server-8.0.32-24.1.el8.x86_64
  8. perl(Percona::Toolkit) is needed by greatsql-server-8.0.32-24.1.el8.x86_64
  9. perl(Quoter) is needed by greatsql-server-8.0.32-24.1.el8.x86_64
  10. perl(Transformers) is needed by greatsql-server-8.0.32-24.1.el8.x86_64
  11. #上述这些依赖包可以先忽略,不影响GreatSQL正常使用
  12. $ rpm -ivh --nodeps --force greatsql*rpm
  13. Preparing... ################################# [100%]
  14. Updating / installing...
  15. 1:greatsql-shared-8.0.32-24.1.el7 ################################# [ 20%]
  16. 2:greatsql-client-8.0.32-24.1.el7 ################################# [ 40%]
  17. 3:greatsql-icu-data-files-8.0.32-24################################# [ 60%]
  18. 4:greatsql-server-8.0.32-24.1.el7 ################################# [ 80%]
  19. 5:greatsql-devel-8.0.32-24.1.el7 ################################# [100%]
  1. 正式安装GreatSQL RPM包时,可能还需要依赖Perl等其他软件包,此处为快速演示,因此加上 --nodeps 参数,忽略相应的依赖关系检查。安装完毕后,如果因为依赖关系无法启动,请再行安装相应软件依赖包。

启动GreatSQL

启动GreatSQL服务前,先修改systemd文件,调高一些limit上限,避免出现文件数、线程数不够用的告警。

  1. # 在[Server]区间增加下面几行内容
  2. $ vim /lib/systemd/system/mysqld.service
  3. ...
  4. [Service]
  5. # some limits
  6. # file size
  7. LimitFSIZE=infinity
  8. # cpu time
  9. LimitCPU=infinity
  10. # virtual memory size
  11. LimitAS=infinity
  12. # open files
  13. LimitNOFILE=65535
  14. # processes/threads
  15. LimitNPROC=65535
  16. # locked memory
  17. LimitMEMLOCK=infinity
  18. # total threads (user+kernel)
  19. TasksMax=infinity
  20. TasksAccounting=false
  21. ...

保存退出,然后再执行命令重载systemd,如果没问题就不会报错:

  1. $ systemctl daemon-reload

执行下面的命令启动GreatSQL服务

  1. $ systemctl start mysqld

检查服务是否已启动,以及进程状态:

  1. $ systemctl status mysqld
  2. mysqld.service - MySQL Server
  3. Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
  4. Active: active (running) since Wed 2022-07-06 10:35:57 CST; 42s ago
  5. Docs: man:mysqld(8)
  6. http://dev.mysql.com/doc/refman/en/using-systemd.html
  7. Process: 43570 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
  8. Main PID: 43653 (mysqld)
  9. Status: "Server is operational"
  10. Tasks: 39 (limit: 149064)
  11. Memory: 446.4M
  12. CGroup: /system.slice/mysqld.service
  13. └─43653 /usr/sbin/mysqld
  14. ...
  15. $ ps -ef | grep mysqld
  16. mysql 43653 1 3 10:35 ? 00:00:02 /usr/sbin/mysqld
  17. $ ss -lntp | grep mysqld
  18. LISTEN 0 70 *:33060 *:* users:(("mysqld",pid=43653,fd=23))
  19. LISTEN 0 128 *:3306 *:* users:(("mysqld",pid=43653,fd=26))
  20. # 查看数据库文件
  21. $ ls /var/lib/mysql
  22. auto.cnf ca.pem '#ib_16384_1.dblwr' ib_logfile1 mysql.ibd mysqlx.sock.lock server-cert.pem undo_002
  23. binlog.000001 client-cert.pem ib_buffer_pool ibtmp1 mysql.sock performance_schema server-key.pem
  24. binlog.index client-key.pem ibdata1 '#innodb_temp' mysql.sock.lock private_key.pem sys
  25. ca-key.pem '#ib_16384_0.dblwr' ib_logfile0 mysql mysqlx.sock public_key.pem undo_001

可以看到,GreatSQL服务已经正常启动了。

连接登入GreatSQL

RPM方式安装GreatSQL后,会随机生成管理员root的密码,通过搜索日志文件获取:

  1. $ grep -i root /var/log/mysqld.log
  2. 2022-07-06T02:35:54.691879Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: K<f9Iapd#wwp

可以看到,root账户的密码是:”K<f9Iapd#wwp” (不包含双引号),复制到粘贴板里。

首次登入GreatSQL后,要立即修改root密码,否则无法执行其他操作,并且新密码要符合一定安全规则:

  1. $ mysql -uroot -p
  2. Enter password: #<--这个地方粘贴上面复制的随机密码
  3. Welcome to the MySQL monitor. Commands end with ; or \g.
  4. Your MySQL connection id is 8
  5. Server version: 8.0.32-24 GreatSQL, Release 24, Revision 3714067bc8c
  6. Copyright (c) 2021-2023 GreatDB Software Co., Ltd
  7. Copyright (c) 2009-2021 Percona LLC and/or its affiliates
  8. Copyright (c) 2000, 2021, Oracle and/or its affiliates.
  9. ...
  10. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  11. greatsql> \s #<--想执行一个命令,提示要先修改密码
  12. ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
  13. greatsql> alter user user() identified by 'GreatSQL@202X'; #<--修改密码
  14. Query OK, 0 rows affected (0.02 sec)
  15. greatsql> \s #<--就可以正常执行其他命令了
  16. --------------
  17. mysql Ver 8.0.32-24 for Linux on x86_64 (GreatSQL, Release 24, Revision 3714067bc8c)
  18. Connection id: 11
  19. Current database:
  20. Current user: root@localhost
  21. SSL: Not in use
  22. Current pager: stdout
  23. Using outfile: ''
  24. Using delimiter: ;
  25. Server version: 8.0.32-24 GreatSQL, Release 24, Revision 3714067bc8c
  26. Protocol version: 10
  27. Connection: Localhost via UNIX socket
  28. Server characterset: utf8mb4
  29. Db characterset: utf8mb4
  30. Client characterset: utf8mb4
  31. Conn. characterset: utf8mb4
  32. UNIX socket: /var/lib/mysql/mysql.sock
  33. Binary data as: Hexadecimal
  34. Uptime: 10 min 14 sec
  35. Threads: 2 Questions: 7 Slow queries: 0 Opens: 130 Flush tables: 3 Open tables: 46 Queries per second avg: 0.005
  36. --------------
  37. greatsql> show databases; #<--查看数据库列表
  38. +--------------------+
  39. | Database |
  40. +--------------------+
  41. | information_schema |
  42. | mysql |
  43. | performance_schema |
  44. | sys |
  45. +--------------------+
  46. 4 rows in set (0.01 sec)
  47. greatsql>

关闭/重启GreatSQL

执行下面的命令关闭GreatSQL数据库。

  1. $ systemctl stop mysqld

执行下面的命令重启GreatSQL数据库。

  1. $ systemctl restart mysqld

至此,RPM包方式安装GreatSQL数据库完成。

问题反馈

联系我们

扫码关注微信公众号

greatsql-wx