- 1. 概述
- 2. 插件包下载、放置
- 3. 安装插件
- 4. 修改参数[重要]
- 5. 创建mysql兼容性数据库
- 6. 创建扩展
- 7. 安装验证
1. 概述
dolphin是MogDB针对MySQL的兼容插件包,其中新增了MySQL数据类型,函数等功能的相关支持。插件安装首先需要下载plugins插件包,此实验根据环境选择了Plugins-3.0.1-CentOS-x86_64.tar.gz介质。此实验环境具体如下:
IP | 操作系统 | 数据库版本 | Plugins |
---|---|---|---|
192.168.60.128 | CentOS 7 x86_64 | MogDB V3.0.1 | v3.0.1 |
2. 插件包下载、放置
- 插件包放置位置
[root@amogdb mysql]# su - omm
Last login: Mon Aug 15 22:00:23 CST 2022 on pts/0
[omm@amogdb ~]$ cd $GPHOME/script/
[omm@amogdb script]$
- 创建static文件夹
[omm@amogdb script]$ mkdir -p static
- 下载插件包,并将其放置到上步新建的文件夹static下
[omm@amogdb static]$ pwd
/data/mogdb/install/om/script/static
[omm@amogdb static]$ exit
logout
[root@amogdb mysql]# mv '/root/桌面/Plugins-3.0.1-CentOS-x86_64.tar.gz' /data/mogdb/install/om/script/static
[omm@amogdb script]$ cd static/
[omm@amogdb static]$ ll
total 72700
-rwxrw-rw-. 1 root root 74443447 Aug 16 20:24 Plugins-3.0.1-CentOS-x86_64.tar.gz
- 设置权限
[omm@amogdb static]$ chmod +x Plugins-3.0.1-CentOS-x86_64.tar.gz
[omm@amogdb static]$ ll
total 72700
-rwxrw-rw-. 1 omm dbgrp 74443447 Aug 16 20:24 Plugins-3.0.1-CentOS-x86_64.tar.gz
注意:如果提示chmod: changing permissions of ‘Plugins-3.0.1-CentOS-x86_64.tar.gz’: Operation not permitted,此时可能需要设置文件的权限:chown -R omm:dbgrp /data/mogdb/install/om/script/static/Plugins-3.0.1-CentOS-x86_64.tar.gz。
3. 安装插件
使用gs_install_plugin工具安装plugin插件
gs_install_plugin -p /data/mogdb/install/om/script/static/Plugins-3.0.1-CentOS-x86_64.tar.gz --plugins dolphin --force
参数说明:
“-p” 插件包的存放地址
“- -plugins” 选择安装的部分插件
“- -force” 指定覆盖旧的插件
回显如下:
[omm@amogdb static]$ gs_install_plugin -p /data/mogdb/install/om/script/static/Plugins-3.0.1-CentOS-x86_64.tar.gz --plugins dolphin --force
SUCCESS: dolphin
4. 修改参数[重要]
- 在CREATE EXTENSION之前,需要设置参数:
gs_guc set -I all -N all -c "enable_wdr_snapshot=off"
由于dolphin插件会和参数WDR冲突,需要关掉相关配置。在推荐参数设置脚本中,此参数设置为on。所以在安装完mogdb并且执行过这个脚本的,在创建dolphin扩展前一定要关掉这项参数。
- 修改shared_preload_libraries参数
1> 先找到dolphin.so文件所在地址
[root@amogdb mysql]# find / -name dolphin.so
/data/mogdb/install/om/script/static/plugins/plugins/dolphin/dolphin.so
/data/mogdb/install/app_1a363ea9/lib/postgresql/dolphin.so
2> 复制上面app的地址,修改postgresql.conf中的shared_preload_libraries参数
[omm@amogdb ~]$ vim /data/mogdb/install/data/dn/postgresql.conf
shared_preload_libraries = '/data/mogdb/install/app_1a363ea9/lib/postgresql/dolphin.so'
# (change requires restart)
保存后需要重启数据库生效修改参数。
[omm@amogdb ~]$ gs_om -t restart
Stopping cluster.
=========================================
Successfully stopped cluster.
=========================================
End stop cluster.
Starting cluster.
=========================================
[SUCCESS] amogdb
2022-08-16 21:55:43.617 [unknown] [unknown] localhost 140643687024896 0[0:0#0] 0 [BACKEND] WARNING: could not create any HA TCP/IP sockets
2022-08-16 21:55:43.617 [unknown] [unknown] localhost 140643687024896 0[0:0#0] 0 [BACKEND] WARNING: could not create any HA TCP/IP sockets
2022-08-16 21:55:43.618 [unknown] [unknown] localhost 140643687024896 0[0:0#0] 0 [BACKEND] WARNING: No explicit IP is configured for listen_addresses GUC.
2022-08-16 21:55:43.619 [unknown] [unknown] localhost 140643687024896 0[0:0#0] 0 [BACKEND] WARNING: Failed to initialize the memory protect for g_instance.attr.attr_storage.cstore_buffers (16 Mbytes) or shared memory (3711 Mbytes) is larger.
=========================================
Successfully started.
[omm@amogdb ~]$ gsql -d my_test -p 26000 -r
gsql ((MogDB 3.0.1 build 1a363ea9) compiled at 2022-08-05 17:31:04 commit 0 last mr )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
my_test=# show shared_preload_libraries ;
shared_preload_libraries
------------------------------------------------------------
/data/mogdb/install/app_1a363ea9/lib/postgresql/dolphin.so
(1 row)
如果不执行上述操作可能会在重启时遇到无法启动的问题或者会提示"Can’t create dolphin extension lib is not in shared_preload_libraries"的字样。
5. 创建mysql兼容性数据库
MogDB=# create database my_test DBCOMPATIBILITY 'B';
CREATE DATABASE
DBCOMPATIBILITY compatibility_type
指定兼容的数据库的类型。compatibility_type取值范围: A、B、C、PG。分别表示兼容Oracle、MySQL、Teradata和PostgreSQL。但是C目前已经放弃支持,因此常用的取值是A、B、PG,默认兼容A。
my_test=# create extension dolphin;
ERROR: Can't create dolphin extension lib is not in shared_preload_libraries
6. 创建扩展
在B-type的数据库下(兼容mysql),执行CREATE EXTENSION命令:
my_test=# create extension dolphin;
CREATE EXTENSION
my_test=# set sql_mode=' ';
SET
7. 安装验证
接下来执行mysql特有函数以验证dolphin插件安装是否成功,以rand()函数为例:
my_test=# select rand();
rand
------------------
0.18004750367254
(1 row)
my_test=# \c postgres
Non-SSL connection (SSL connection is recommended when requiring high-security)
You are now connected to database "postgres" as user "omm".
MogDB=# select rand();
ERROR: function rand() does not exist
LINE 1: select rand();
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
CONTEXT: referenced column: rand
MogDB=#
在安装了dolphin插件的B-Type数据库my_test上可以正确执行rand()函数,但是在未安装插件的数据库上就无法执行,报错为function rand() does not exist。
!!安装dolphin插件成功!!