参考地址
https://docs.opengauss.org/zh/docs/latest/docs/InstallationGuide/%E5%AE%B9%E5%99%A8%E9%95%9C%E5%83%8F%E5%AE%89%E8%A3%85.html
https://gitcode.com/opengauss/openGauss-workbench
前置条件
1.docker
2.最好有centos物理机,可用docker容器替代
3.navicat,可用pg方式连接gauss,方便查询数据,很多功能不兼容
1.docker运行gauss
$ docker run --name opengauss --privileged=true -d -e GS_PASSWORD=Enmo@123 -p 8888:5432 opengauss/opengauss-server:latest
错误 密码不符合规则
Error: The supplied GS_PASSWORD is not meet requirements.
Please Check if the password contains uppercase, lowercase, numbers, special characters, and password length(8).
At least one uppercase, lowercase, numeric, special character.
Example: Enmo@123
进入docker容器
$ docker exec -it <CONTAINER ID> bash
登录初始用户
gsql -d postgres -p 5432;
$ gsql -d postgres -U gaussdb -W Enmo@123 -h 127.0.0.1 -p 5432;
创建新用户 添加权限
CREATE USER test WITH PASSWORD 'Enmo@123';
grant all privileges to test; //所有权限,datakit初始化需要
create database db_datakit; //用于启动datakit
2.可视化工具 datakit
下载地址
https://gitcode.com/opengauss/openGauss-workbench
参考文档
https://bbs.huaweicloud.com/forum/thread-02127157948194171003-1-1.html
https://developer.huawei.com/home/forum/hwc/thread-02127157962320479007-1-1.html
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 /Users/zzh/project/Datakit-6.0.0/ssl/keystore.p12 -validity 3650 -storepass 123456
报错:
Error querying database. Cause: org.opengauss.util.PSQLException: [127.0.0.1:53696/127.0.0.1:8888] ERROR: relation "sys_user" does not exist on gaussdb
没有配置datakit数据库
docker容器内数据节点位置
/var/lib/opengauss/data
开放用户远程连接
gs_guc set -D /var/lib/opengauss/data -h "host all all 0.0.0.0/0 sha256"
gs_guc set -D /var/lib/opengauss/data -c "listen_addresses = '*'"
gs_ctl restart -D /var/lib/opengauss/data //重启docker容器
启动
sh ./run.sh start
停止
sh ./run.sh stop
状态查看
sh ./run.sh status
报错
1.datakit mysql数据源连通性不可用
需要添加连接参数,添加useSSL=true等参数
2.连上数据库,无法读取数据表
查看日志发现
querySource soruce database error, The connection property 'useSSL' acceptable values are: 'TRUE', 'FALSE', 'YES' or 'NO'. The value 'false/information_schema' is not acceptable.
期望:jdbc:mysql://172.26.147.120:31001/information_schema?useUnicode=true&useSSL=false
实际:jdbc:mysql://172.26.147.120:31001?useUnicode=true&useSSL=false/information_schema
解决办法:
先将mysql数据迁移到本地mysql(不需要连接配置)
docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=123456 -d -p 13306:3306 mysql
DataKit安装Portal
需要centos7的物理机,用docker启动了一个
docker run -d -p 3322:22 --name sshd-container centos-with-ssh:7 /usr/sbin/sshd -D
3.前置校查失败
参考地址https://bbs.huaweicloud.com/blogs/432259
1.mysql,opengauss不可连接
datakit中的数据源要用执行机能访问到的内网ip,不能用127.0.0.1(datakit和执行机都要能连通)
2.大小写参数: 不一致,分别为:MySQL参数lower_case_table_names=0,openGauss参数lower_case_table_names=show dolphin.lower_case_table_names; execute failed;ERROR: unrecognized configuration parameter "dolphin.lower_case_table_names"
openGauss没有dolphin.lower_case_table_names参数
CREATE EXTENSION dolphin;//加载dolphin插件
SELECT datname, datcompatibility FROM pg_database;//查询dolphin插件是否启用
CREATE DATABASE mysql_db WITH DBCOMPATIBILITY 'B'; //加载dolphin插件需要创建B类型(mysql)数据库
SHOW dolphin.lower_case_table_names;//查询大小写配置
SHOW data_directory;//查询配置文件postgresql.conf路径
postgresql.conf添加 dolphin.lower_case_table_names = 1并重启
3.迁移失败
Process chameleon init_replica --config default_4 exit abnormally occurred in checking chameleon replica order. Error message: pymysql.err.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'MASTER STATUS' at line 1") Run chameleon order init_replica failed,or you can try read /datakit/portal/workspace/4/logs/full_migration.log or error.log to get detailed information to solve the exception.
mysql最新9.3不支持 SHOW MASTER STATUS语句,重装5.7版本
执行 docker run -d --name mysql57 -e MYSQL_ROOT_PASSWORD=123456 -p 13307:3306 mysql:5.7
4.迁移结果
迁移完成,100张表(基本没数据)耗时3分钟,迁移数据在用户同名的模式下
5.导出sql和导入
导出
gs_dump -U test -W Enmo@123 -n test -a -f /data/all_metadata.sql mysql_db
mysql_db是数据库名,如果不能用-d参数就加在命令末尾
-n 限定模式,这里只导出test模式
-a 只导出数据,不导出模式创建语句,不建议添加,导入时报错
导入
导入到mysql_db1的test模式
gsql -U test -W Enmo@123 -d mysql_db1 -f /data/all_metadata.sql