# 在讲openGauss和datakit之前,我先说下pgloader这个工具也支持将数据从mysql同步到openGauss或者postgresql,但是
注意了,官网明确说明了不支持视图和触发器的迁移,如果你只是迁移表结构和数据,那么这个既简单又快下面我简述下安装部署流程和可能会遇到的问题
安装一种是docker(github地址最下面就有)一种是编译安装
1、docker
docker pull ghcr.io/dimitri/pgloader:latest
docker run --rm -it ghcr.io/dimitri/pgloader:latest pgloader --version启动docker
docker run -tid --name pgloader_test dimitri/pgloader创建迁移脚本
vim openGauss.loader
LOAD DATABASE
FROM mysql://root:12345@192.168.1.202:3306/test
INTO postgresql://root:12345@192.168.1.202:5432/postgres
WITH include drop, create tables, create indexes, reset no sequences,workers = 8, concurrency = 1,multiple readers per thread, rows per range = 50000
CAST
type varchar when(= 1 precision) to "boolean" drop typemod keep default keep not null;将配置文件拷贝到docker内执行
docker cp ./openGauss.loader pgloader_test:/进行docker容器
docker exec -it pgloader_test /bin/bash执行迁移任务(一种是执行自定义的迁移脚本,另外一种是直接执行迁移任务)
1、pgloader openGauss.loader
2、pgloader mysql://root:12345@192.168.1.202:3306/test postgresql://jroot:12345@192.168.1.202:5432/postgres2、编译安装
cd /usr/local
tar -zxvf pgloader-3.6.9.tar.gz
cd pgloader-3.6.9/
chmod 755 bootstrap-centos.sh#需要下载很多关联插件
./bootstrap-centos.sh#先package打包,后还要下载一些资源包
#此版本打包时,需要用到 openSSL11 版本的 so 库,
#如果有提示到 ("libcrypto.so.1.1" "libcrypto.so.1.0.0" "libcrypto.so.3" "libcrypto.so") 相关信息,
#需要先执行一下 yum -y install openssl openssl-devel ,再重新 make 。
make pgloader#复制执行文件到用户本地执行目录
cp build/bin/pgloader /usr/local/bin/#查看版本
pgloader --version执行迁移任务
pgloader mysql://root:12345@192.168.1.202:3306/test postgresql://jroot:12345@192.168.1.202:5432/postgres可能遇到的问题:
1、Condition QMYND:MYSQL-UNSUPPORTED-AUTHENTICATION was signalled
解决:
pgloader不支持caching_sha2_password
在/etc/my.cnf 中增加 default-authentication-plugin=mysql_native_password
重启mysql
2、KABOOM!
INFO: Control stack guard page unprotected
Control stack guard page temporarily disabled: proceed with cautionWhat I am doing here?Control stack exhausted (no more space for function call frames).
This is probably due to heavily nested or infinitely recursive function
calls, or a tail call that SBCL cannot or has not optimized away.PROCEED WITH CAUTION.
解决:
出现这个问题我是docker安装的,后来改用编译安装的方式了参考:
https://blog.csdn.net/2401_83143557/article/details/137864590(docker安装参考)
https://www.cnblogs.com/java365/articles/17789520.html(编译安装参考)
https://pgloader.readthedocs.io/en/latest/ref/mysql.html#mysql-schema-transformations(pgloader的doc)
https://github.com/dimitri/pgloader(pgloader的github)
#1 关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
systemctl status firewalld#2 当前JDK版本
wget https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_linux-x64_bin.tar.gzvim /etc/profile
export JAVA_HOME=/usr/local/jdk-11.0.2
export PATH=$PATH:$JAVA_HOME/bin
source /etc/profilejava -version# 一定要创建软连接
ln -s /usr/local/jdk-11.0.2/bin/java /usr/bin/java#3 安装python环境
wget https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tgz
tar -zxvf Python-3.6.8.tgz
cd Python-3.6.8
./configure --prefix=/root/python3.6.8
make && make installvi ~/.bashrc
alias python='/root/python3.6.8/bin/python3.6'
alias pip='/root/python3.6.8/bin/pip3'
source ~/.bashrcpython -V
pip --version# 4 修改国内镜像源
vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://rsk59qvc.mirror.aliyuncs.com"]
}
service docker restart#5 安装mysql
docker run --name mysql8 --restart=always -v /mysql_8.0.26/conf.d:/etc/mysql/conf.d -v /mysql_8.0.26/data:/var/lib/mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=jysa -d mysql:8.0.26 docker-entrypoint.sh --character-set-server=utf8mb4 --collation-server=utf8mb4_0900_ai_ci --lower-case-table-names=1[mysqld]
binlog_format = ROW
log_bin = mysql-bin
server_id = 1
binlog_row_image = FULL
enforce_gtid_consistency = ON
gtid_mode = ONdocker restart 容器id一定要修改mysql的密码校验插件
将caching_sha2_password修改为mysql_native_password
一定记得改完插件类型后,修改密码,不然可能导致登录不上(如图一)# 6 设置
vi /etc/sysctl.conf
kernel.sem = 250 32000 100 999
sysctl -p# 7 安装opengauss:5.1.0
wget https://opengauss.obs.cn-south-1.myhuaweicloud.com/5.1.0/x86/openGauss-5.1.0-CentOS-64bit.tar.bz2useradd openGauss
passwd openGauss
usermod -aG openGauss openGauss
cat /etc/sudoers | grep openGauss
openGauss ALL=(ALL) ALLsu openGauss
sudo mkdir /ops/openGauss5.1.0
sudo yum -y install bzip2
sudo tar -jxf openGauss-5.1.0-CentOS-64bit.tar.bz2/ops/openGauss5.1.0/simpleInstall
sh install.sh -w "Jyzx2024" && source ~/.bashrc# 修改配置文件
编辑 postgresql.conf
listen_addresses = '*'
local_bind_address = '*'
max_connections = 1000
password_encryption_type = 1cd /ops/openGauss5.1.0/bin
gsql -d postgres
create user jyzx with createdb password 'Jyzx2024';
grant all privileges to jyzx;# 这里使用的是openGuass用户
gs_ctl restart -D $GAUSSHOME/data/single_node -Z single_node# 注意上面openGauss是通过部署包安装,也可以通过docker镜像安装
镜像包我放到这儿了,启动命令也在这儿:https://download.csdn.net/download/AinUser/89600056
启动容器之后,需要通过命令su - omm命令切换用户,然后执行相关的创建用户并授权的SQL,这个SQL上面有# 8 安装openGauss datakit
wget https://opengauss.obs.cn-south-1.myhuaweicloud.com/5.1.0/tools/Datakit/Datakit-5.1.0.tar.gzmkdir /ops/datakit5.1.0
tar -zxvf Datakit-5.1.0.tar.gzmkdir -p logs config ssl files
cp ./application-temp.yml ./config/
vim ./config/application-temp.yml
spring:datasource:type: com.alibaba.druid.pool.DruidDataSourcedriver-class-name: org.opengauss.Driverurl: jdbc:opengauss://192.168.1.202:5432/postgres?currentSchema=public&batchMode=offusername: jyzxpassword: Jyzx@2024.druid:test-while-idle: falsetest-on-borrow: truevalidation-query: "select 1"validation-query-timeout: 10000connection-error-retry-attempts: 0break-after-acquire-failure: truemax-wait: 6000keep-alive: truemax-active: 30min-evictable-idle-time-millis: 600000# 生成ssl
keytool -genkey -noprompt \
-dname "CN=opengauss, OU=opengauss, O=opengauss, L=Beijing, S=Beijing, C=CN" \
-alias opengauss \
-storetype PKCS12 \
-keyalg RSA \
-keysize 2048 \
-keystore /ops/datakit5.1.0/ssl/keystore.p12 \
-validity 3650 \
-storepass 123456/ops/datakit5.1
java -Xms4096m -Xmx8092m -jar openGauss-datakit-5.1.0.jar --spring.profiles.active=temp# 注意
1、java软连接一定要建立,不然使用新创建的用户可能会找不到java命令
2、datakit平台,服务器管理一定要记住密码,迁移任务中心才会显示设备
3、启动datakit的内存一定要大,不然可能导致zookeeper和kafka进程被杀
4、进入容器后切用户一定要记得使用su - omm参考:
https://jeames.blog.csdn.net/article/details/134016239(安装openGuass数据库)
https://blog.csdn.net/weixin_41645135/article/details/135891534(安装datakit)
https://opengauss.org/zh/download/archive/(官网下载包)
https://docs-opengauss.osinfra.cn/zh/docs/5.0.0/docs/DataMigrationGuide/%E5%85%A8%E9%87%8F%E8%BF%81%E7%A7%BB.html(官网全量迁移文档)
https://app.yinxiang.com/fx/a780e65f-2852-4e83-b91f-8cfbc16d7996(同事的笔记)备注:
手动启动kafka和zookeeper,如果是启动,第一次会先启动zookeeper,再一次执行启动命令,才会启动kafka-- 可以先执行停止kafka的命令,确保Kafka进程已停止,避免启动时出错,停止kafka的命令如下
java -Dpath=/data/dgq/portal/portal/ -Dorder=stop_kafka -Dskip=true -jar /data/dgq/portal/portal/portalControl-6.0.0rc1-exec.jar
-- 启动kafka进程的命令
java -Dpath=/data/dgq/portal/portal/ -Dorder=start_kafka -Dskip=true -jar /data/dgq/portal/portal/portalControl-6.0.0rc1-exec.jar