腾讯云轻量应用服务器下使用RPM包方式安装GreatSQL单主环境

腾讯云轻量应用服务器下使用RPM方式安装GreatSQL数据库

今天主要介绍使用RPM包方式在腾讯云轻量应用服务器上安装部署GreatSQL数据库,服务器系统为CentOS 7.6并以root身份进行操作,虚拟机环境中安装步骤也大体相同

运行环境配置

首先需要关闭selinux和防火墙

#关闭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

下载GreatSQL提供的RPM包

切换至/usr/local目录下,使用wget下载以下四个包:

  • greatsql-client-8.0.25-16.1.el7.x86_64.rpm
  • greatsql-devel-8.0.25-16.1.el7.x86_64.rpm
  • greatsql-shared-8.0.25-16.1.el7.x86_64.rpm
  • greatsql-server-8.0.25-16.1.el7.x86_64.rpm
cd /usr/local
wget https://product.greatdb.com/GreatSQL-8.0.25-16/greatsql-client-8.0.25-16.1.el7.x86_64.rpm
wget https://product.greatdb.com/GreatSQL-8.0.25-16/greatsql-devel-8.0.25-16.1.el7.x86_64.rpm
wget https://product.greatdb.com/GreatSQL-8.0.25-16/greatsql-shared-8.0.25-16.1.el7.x86_64.rpm
wget https://product.greatdb.com/GreatSQL-8.0.25-16/greatsql-server-8.0.25-16.1.el7.x86_64.rpm

腾讯云轻量应用服务器下使用RPM包方式安装GreatSQL单主环境_第1张图片

安装RPM包

安装之前需要先检查系统自带的MariaDB是否卸载,如未卸载会导致安装错误

在这里插入图片描述

#查询是否安装有MariaDB
rpm -qa | grep maria
#卸载MariaDB
yum remove -y mariadb-libs.x86_64

接下来使用以下命令安装GreatSQL

rpm -ivh greatsql*rpm

腾讯云轻量应用服务器下使用RPM包方式安装GreatSQL单主环境_第2张图片

这样即是安装成功

修改配置信息

vim /lib/systemd/system/mysqld.service

在[Service]区间内增加以下内容,并修改LimitNOFILE=65535

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

保存退出后,执行重载命令

systemctl daemon-reload

执行命令启动GreatSQL服务

systemctl start mysqld

执行命令检查GreatSQL服务是否正常启动,以及进程状态

[root@VM-4-4-centos local]# systemctl status mysqld
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Sat 2022-09-03 14:09:17 CST; 5s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 5750 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 5856 (mysqld)
   Status: "Server is operational"
   CGroup: /system.slice/mysqld.service
           └─5856 /usr/sbin/mysqld

Sep 03 14:09:08 VM-4-4-centos systemd[1]: Starting MySQL Server...
Sep 03 14:09:17 VM-4-4-centos systemd[1]: Started MySQL Server.

[root@VM-4-4-centos local]# ps -ef | grep mysqld
mysql     5856     1  2 14:09 ?        00:00:02 /usr/sbin/mysqld

[root@VM-4-4-centos local]# ss -lntp | grep mysqld
LISTEN     0      70        [::]:33060                 [::]:*                   users:(("mysqld",pid=5856,fd=22))
LISTEN     0      128       [::]:3306                  [::]:*                   users:(("mysqld",pid=5856,fd=25))

#查看数据库文件
[root@VM-4-4-centos local]# cd /var/lib/mysql
[root@VM-4-4-centos mysql]# ls
auto.cnf       client-cert.pem    ibdata1       mysql            mysqlx.sock.lock    server-key.pem
binlog.000001  client-key.pem     ib_logfile0   mysql.ibd        performance_schema  sys
binlog.index   #ib_16384_0.dblwr  ib_logfile1   mysql.sock       private_key.pem     undo_001
ca-key.pem     #ib_16384_1.dblwr  ibtmp1        mysql.sock.lock  public_key.pem      undo_002
ca.pem         ib_buffer_pool     #innodb_temp  mysqlx.sock      server-cert.pem

登录GreatSQL数据库

在使用RPM方式安装GreatSQL数据库并成功启动后,会自动帮我们生成一个root密码,需要我们手动搜索日志来获取

[root@VM-4-4-centos mysql]# grep -i root /var/log/mysqld.log
2022-09-03T06:09:12.005684Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: jov6e1a,7_lG

现在我们就可以使用随机生成的密码进行登录

mysql -uroot -pjov6e1a,7_lG

腾讯云轻量应用服务器下使用RPM包方式安装GreatSQL单主环境_第3张图片

登录后会发现,使用命令会报错!?这是怎么回事

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

原来在首次登录GreatSQL后,要立即修改root密码,否则无法执行其他操作,并且新密码要符合一定安全规则,那么我们可以使用以下命令修改root密码:

mysql> alter user user() identified by 'GreatSQL@2022';
Query OK, 0 rows affected (0.01 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

至此,GreatSQL部署完成,可以愉快的使用了

你可能感兴趣的:(腾讯云,服务器,linux)