二进制包安装


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

下载安装包

点击此处二进制包安装 - 图1 (opens new window)下载最新的安装包,下载以下文件:

  • GreatSQL-8.0.32-25-Linux-glibc2.28-x86_64-minimal.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源,可以参考这篇文档二进制包安装 - 图2 (opens new window)

安装依赖包

安装GreatSQL需要先安装其他依赖包,可执行下面命令完成:

  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 python2 perl-JSON perl-Test-Simple

如果报告个别依赖包安装失败或者找不到就删掉,然后重试。更详细的请参考:安装准备

下载二进制包并安装

将下载的二进制包放在安装目录 /usr/local/ 下,并解压缩:

  1. # 下载
  2. $ cd /usr/local
  3. $ wget https://product.greatdb.com/GreatSQL-8.0.32-25/GreatSQL-8.0.32-25-Linux-glibc2.28-x86_64-minimal.tar.xz
  4. #或者用curl
  5. $ curl -o GreatSQL-8.0.32-25-Linux-glibc2.28-x86_64-minimal.tar.xz https://product.greatdb.com/GreatSQL-8.0.32-25/GreatSQL-8.0.32-25-Linux-glibc2.28-x86_64-minimal.tar.xz
  6. #解压缩
  7. $ tar xf GreatSQL-8.0.32-25-Linux-glibc2.28-x86_64-minimal.tar.xz

编辑systemd系统服务文件,增加GreatSQL服务文件:

  1. $ vim /lib/systemd/system/greatsql.service
  2. [Unit]
  3. Description=GreatSQL Server
  4. Documentation=man:mysqld(8)
  5. Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
  6. After=network.target
  7. After=syslog.target
  8. [Install]
  9. WantedBy=multi-user.target
  10. [Service]
  11. # some limits
  12. # file size
  13. LimitFSIZE=infinity
  14. # cpu time
  15. LimitCPU=infinity
  16. # virtual memory size
  17. LimitAS=infinity
  18. # open files
  19. LimitNOFILE=65535
  20. # processes/threads
  21. LimitNPROC=65535
  22. # locked memory
  23. LimitMEMLOCK=infinity
  24. # total threads (user+kernel)
  25. TasksMax=infinity
  26. TasksAccounting=false
  27. User=mysql
  28. Group=mysql
  29. #如果是GreatSQL 5.7版本,此处需要改成simple模式,否则可能服务启用异常
  30. #如果是GreatSQL 8.0版本则可以使用notify模式
  31. #Type=simple
  32. Type=notify
  33. TimeoutSec=0
  34. PermissionsStartOnly=true
  35. ExecStartPre=/usr/local/GreatSQL-8.0.32-25-Linux-glibc2.28-x86_64-minimal/bin/mysqld_pre_systemd
  36. ExecStart=/usr/local/GreatSQL-8.0.32-25-Linux-glibc2.28-x86_64-minimal/bin/mysqld $MYSQLD_OPTS
  37. EnvironmentFile=-/etc/sysconfig/mysql
  38. LimitNOFILE = 10000
  39. Restart=on-failure
  40. RestartPreventExitStatus=1
  41. Environment=MYSQLD_PARENT_PID=1
  42. PrivateTmp=false

务必确认文件中目录及文件名是否正确。

执行命令重载systemd,加入 greatsql 服务,如果没问题就不会报错:

  1. $ systemctl daemon-reload

这就安装成功并将GreatSQL添加到系统服务中,后面可以用 systemctl 来管理GreatSQL服务。

编辑GreatSQL全局配置文件 /etc/my.cnf,加入下面内容:

  1. $ vim /etc/my.cnf
  2. [mysql]
  3. socket=/var/lib/mysql/mysql.sock
  4. [mysqld]
  5. user=mysql
  6. datadir=/var/lib/mysql
  7. socket=/var/lib/mysql/mysql.sock
  8. log-error=/var/log/mysqld.log
  9. pid-file=/var/run/mysqld/mysqld.pid

保存退出。

创建mysql系统用户:

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

创建相关文件夹,并修改用户组:

  1. mkdir /var/run/mysqld/ /var/lib/mysql-files/ /var/lib/mysql/
  2. chown mysql:mysql /var/run/mysqld/ /var/lib/mysql-files/ /var/lib/mysql/ /usr/local/GreatSQL-8.0.32-25-Linux-glibc2.28-x86_64-minimal/

编辑mysqld_pre_systemd脚本文件,修改程序目录:

将文件中的 /usr/local/GreatSQL-8.0.32-25-Linux-glibc2.28-x86_64/改为实际安装目录。

启动GreatSQL

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

  1. $ systemctl start greatsql

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

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

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

连接登入GreatSQL

采用minimal二进制包安装GreatSQL后,通过log-error日志查看初始化密码,即可登入。

  1. $ cat /var/log/mysqld.log|grep password
  2. [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: NrkNcJya<9f6

若使用了GreatSQL推荐的my.cnf则错误日志路径发生改变,请使用以下命令查看初始化密码

  1. $ $ grep -i root /data/GreatSQL/error.log
  2. ... A temporary password is generated for root@localhost: ji!pjndiw5sJ

复制密码即可登入GreatSQL

  1. $ /usr/local/GreatSQL-8.0.32-25-Linux-glibc2.28-x86_64-minimal/bin/mysql -uroot
  2. Welcome to the MySQL monitor. Commands end with ; or \g.
  3. Your MySQL connection id is 8
  4. Server version: 8.0.32-25 GreatSQL, Release 25, Revision db07cc5cb73
  5. Copyright (c) 2021-2023 GreatDB Software Co., Ltd
  6. Copyright (c) 2009-2021 Percona LLC and/or its affiliates
  7. Copyright (c) 2000, 2021, Oracle and/or its affiliates.
  8. ...
  9. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  10. greatsql> \s
  11. --------------
  12. mysql Ver 8.0.32-25 for Linux on x86_64 (GreatSQL, Release 25, Revision db07cc5cb73)
  13. Connection id: 8
  14. Current database:
  15. Current user: root@localhost
  16. SSL: Not in use
  17. Current pager: stdout
  18. Using outfile: ''
  19. Using delimiter: ;
  20. Server version: 8.0.32-25 GreatSQL, Release 25, Revision db07cc5cb73
  21. Protocol version: 10
  22. Connection: Localhost via UNIX socket
  23. Server characterset: utf8mb4
  24. Db characterset: utf8mb4
  25. Client characterset: utf8mb4
  26. Conn. characterset: utf8mb4
  27. UNIX socket: /var/lib/mysql/mysql.sock
  28. Binary data as: Hexadecimal
  29. Uptime: 17 min 23 sec
  30. Threads: 2 Questions: 12 Slow queries: 0 Opens: 120 Flush tables: 3 Open tables: 36 Queries per second avg: 0.011
  31. --------------
  32. greatsql> SHOW DATABASES; #<--查看数据库列表
  33. +--------------------+
  34. | Database |
  35. +--------------------+
  36. | information_schema |
  37. | mysql |
  38. | performance_schema |
  39. | sys |
  40. +--------------------+
  41. 4 rows in set (0.01 sec)

登录后及时修改密码

  1. ALTER USER 'root'@'localhost' IDENTIFIED BY 'PASSWORD'

关闭/重启GreatSQL

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

  1. $ systemctl stop greatsql

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

  1. $ systemctl restart greatsql

至此,二进制包方式安装GreatSQL数据库完成。

问题反馈

联系我们

扫码关注微信公众号

greatsql-wx