当前位置:   article > 正文

DataKit迁移MySQL到openGauss_error: can not install gauss with root

error: can not install gauss with root

前言

本文将分享DataKit迁移MySQL到openGauss的项目实战,供广大openGauss爱好者参考。

1. 下载操作系统

https://www.openeuler.org/zh/download

图片

https://support.huawei.com/enterprise/zh/doc/EDOC1100332931/1a643956

https://support.huawei.com/enterprise/zh/doc/EDOC1100332931/fddc1451

1.1. 关闭selinux

[root@olnode01 tmp]# cat /etc/selinux/config 
  1. # This file controls the state of SELinux on the system.
  2. # SELINUX= can take one of these three values:
  3. # enforcing - SELinux security policy is enforced.
  4. # permissive - SELinux prints warnings instead of enforcing.
  5. # disabled - No SELinux policy is loaded.
  6. SELINUX=disabled
  7. # SELINUXTYPE= can take one of these three values:
  8. # targeted - Targeted processes are protected,
  9. # minimum - Modification of targeted policy. Only selected processes are protected.
  10. # mls - Multi Level Security protection.
  11. SELINUXTYPE=targeted

 

1.2. 关闭防火墙

  1. [root@olnode01 tmp]# systemctl status firewalld
  2. ● firewalld.service - firewalld - dynamic firewall daemon
  3. Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
  4. Active: active (running) since Thu 2023-12-07 20:57:23 CST; 40min ago
  5. Docs: man:firewalld(1)
  6. Main PID: 1013 (firewalld)
  7. Tasks: 2
  8. Memory: 33.2M
  9. CGroup: /system.slice/firewalld.service
  10. └─1013 /usr/bin/python3 /usr/sbin/firewalld --nofork --nopid
  1. Dec 07 20:57:23 olnode01.bluemoon.ltd systemd[1]: Starting firewalld - dynamic firewall daemon...
  2. Dec 07 20:57:23 olnode01.bluemoon.ltd systemd[1]: Started firewalld - dynamic firewall daemon.
  3. [root@olnode01 tmp]# systemctl disable firewalld
  4. Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
  5. Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
  6. [root@olnode01 tmp]# systemctl stop firewalld
  7. [root@olnode01 tmp]# systemctl status firewalld
  8. ● firewalld.service - firewalld - dynamic firewall daemon
  9. Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
  10. Active: inactive (dead)
  11. Docs: man:firewalld(1)

 

  1. Dec 07 20:57:23 olnode01.bluemoon.ltd systemd[1]: Starting firewalld - dynamic firewall daemon...
  2. Dec 07 20:57:23 olnode01.bluemoon.ltd systemd[1]: Started firewalld - dynamic firewall daemon.
  3. Dec 07 21:37:57 olnode01.bluemoon.ltd systemd[1]: Stopping firewalld - dynamic firewall daemon...
  4. Dec 07 21:37:58 olnode01.bluemoon.ltd systemd[1]: firewalld.service: Succeeded.
  5. Dec 07 21:37:58 olnode01.bluemoon.ltd systemd[1]: Stopped firewalld - dynamic firewall daemon.
 

1.3. 修改字符集

    echo export LANG=en_US.UTF-8 >> /etc/profile

1.4. 关闭RemoveIPC

默认RemoveIPC=yes,表示当用户退出时,会删除该用户的共享内存段和信号量。

1.5. 刷新服务

  1. systemctl daemon-reload
  2. systemctl restart systemd-logind
  3. loginctl show-session | grep RemoveIPC
  4. systemctl show systemd-logind | grep RemoveIPC

1.6. 关闭透明大页

  1. echo never >> /sys/kernel/mm/transparent_hugepage/defrag
  2. echo never >> /sys/kernel/mm/transparent_hugepage/enabled
  3. echo 'echo never >> /sys/kernel/mm/transparent_hugepage/defrag' >> /etc/rc.d/rc.local
  4. echo 'echo never >> /sys/kernel/mm/transparent_hugepage/enabled' >> /etc/rc.d/rc.local
  5. sh /etc/rc.d/rc.local
 

1.7. 安装软件依赖和工具

  1. yum install libaio-devel flex bison ncurses-devel glibc-devel patch readline-devel libnsl -y
  2. yum install tar vim java sysstat -y
  3. # yum remove java-1.8* yum remove java-1.7*
  4. yum install -y java-11-openjdk.x86_64  ava-11-openjdk-devel.x86_64  java-11-openjdk-headless.x86_64  java-11-openjdk-devel.x86_64
 

1.8. 修改资源使用限制

  1. omm soft nproc 16384
  2. omm hard nproc 16384
  3. omm soft nofile 65536
  4. omm hard nofile 65536
  5. omm soft memlock 4000000
  6. omm hard memlock 4000000

sysctl -p

1.9. 软链接readline

  1. [omm@olnode01 simpleInstall]$ rpm -qa|grep readline
  2. readline-8.0-4.oe1.x86_64
  3. readline-devel-8.0-4.oe1.x86_64
  4. [omm@olnode01 simpleInstall]$ ldconfig -p|grep readline
  5. libreadline.so.8 (libc6,x86-64) => /lib64/libreadline.so.8
  6. libreadline.so (libc6,x86-64) => /lib64/libreadline.so
  7. libguilereadline-v-18.so.18 (libc6,x86-64) => /lib64/libguilereadline-v-18.so.18
  8.         libguilereadline-v-18.so (libc6,x86-64=> /lib64/libguilereadline-v-18.so
  1. cd /lib64
  2. ln -s libreadline.so.8 libreadline.so.7

 

2. 下载openGauss安装包

https://opengauss.obs.cn-south-1.myhuaweicloud.com/5.0.0/x86_openEuler/openGauss-5.0.0-openEuler-64bit-all.tar.gz

图片

下面这个要注意了,一定要下载5.1版本的,5.0版本的运维插件要自己安装

图片

3.创建用户并安装openGauss

 

3.1. 创建用户组dbgroup。

groupadd dbgroup

3.2. 创建用户组dbgroup下的普通用户omm,并设置普通用户omm的密码,密码建议设置为omm@123。

  1. useradd -g dbgroup omm
  2. passwd omm
 

3.3. 使用omm用户登录到openGauss包安装的主机,解压openGauss压缩包到安装目录(假定安装目录为/opt/software/openGauss,请用实际值替换)。

  1. # tar -jxf openGauss-x.x.x-操作系统-64bit.tar.bz2 -C /opt/software/openGauss
  2. gzip -d openGauss-5.0.0-openEuler-64bit-all.tar.gz
  3. tar -xvf openGauss-5.0.0-openEuler-64bit-all.tar -C /opt/software/openGauss/
  4. tar -jxvf openGauss-5.0.0-openEuler-64bit.tar.bz2

 

3.4. 假定解压包的路径为/opt/software/openGauss,进入解压后目录下的simpleInstall。

cd /opt/software/openGauss/simpleInstall

3.5. 执行install.sh脚本安装openGauss。

  1. # 修改目录权限后,切换到普通用户,否则会提示:Error: can not install openGauss with root
  2. sh install.sh  -w omm@1234
 

上述命令中,-w是指初始化数据库密码(gs_initdb指定),安全需要必须设置。

centos7.8报sem不足:

sysctl -w kernel.sem="250 85000 250 330" 

3.6. 安装后会自动配置环境变量

vi /home/omm/.bashrc

  1. # User specific aliases and functions
  2. export GAUSSHOME=/opt/software/openGauss
  3. export PATH=$GAUSSHOME/bin:$PATH
  4. export LD_LIBRARY_PATH=$GAUSSHOME/lib:$LD_LIBRARY_PATH
  5. export GS_CLUSTER_NAME=dbCluster
  6. ulimit -n 1000000

 

3.7. 安装执行完成后,使用ps和gs_ctl查看进程是否正常。

  1. ps ux | grep gaussdb
  2. gs_ctl query -D /opt/software/openGauss/data/single_node
 

3.8. 执行ps命令,显示类似如下信息:

  1. omm 24209 11.9 1.0 1852000 355816 pts/0 Sl 01:54 0:33 /opt/software/openGauss/bin/gaussdb -D /opt/software/openGauss/single_node
  2. omm      20377  0.0  0.0 119880  1216 pts/0    S+   15:37   0:00 grep --color=auto gaussdb

 

3.9. 执行gs_ctl命令,显示类似如下信息:

  1. gs_ctl query ,datadir is /opt/software/openGauss/data/single_node
  2. HA state:
  3. local_role : Normal
  4. static_connections : 0
  5. db_state : Normal
  6. detail_information : Normal
  1. Senders info:
  2. No information

 

  1. Receiver info:
  2. No information 
 

3.10. 执行安装脚本

 

  1. [omm@olnode01 simpleInstall]$ sh install.sh -w omm@1234
  2. [step 1]: check parameter
  3. [step 2]: check install env and os setting
  4. install.sh: line 91: netstat: command not found
  5. [step 3]: change_gausshome_owner
  6. [step 4]: set environment variables
  7. /etc/profile.d/system-info.sh: line 26: bc: command not found
  8. /etc/profile.d/system-info.sh: line 35: bc: command not found
  9. /home/omm/.bashrc: line 11: ulimit: open files: cannot modify limit: Operation not permitted
  10. [step 6]: init datanode
  11. The files belonging to this database system will be owned by user "omm".
  12. This user must also own the server process.
  13. The database cluster will be initialized with locale "en_US.UTF-8".
  14. The default database encoding has accordingly been set to "UTF8".
  15. The default text search configuration will be set to "english".
  16. creating directory /opt/software/openGauss/data/single_node ... ok
  17. creating subdirectories ... in ordinary occasionok
  18. creating configuration files ... ok
  19. selecting default max_connections ... 100
  20. selecting default shared_buffers ... 1024MB
  21. Begin init undo subsystem meta.
  22. [INIT UNDO] Init undo subsystem meta successfully.
  23. creating template1 database in /opt/software/openGauss/data/single_node/base/1 ... The core dump path is an invalid directory
  24. 2023-12-07 22:12:02.098 [unknown] [unknown] localhost 139730482409408 0[0:0#0] [BACKEND] WARNING: macAddr is 12/699528221, sysidentifier is 797105/4095585850, randomNum is 4069764666
  25. ok
  26. initializing pg_authid ... ok
  27. setting password ... ok
  28. initializing dependencies ... ok
  29. loading PL/pgSQL server-side language ... ok
  30. creating system views ... ok
  31. creating performance views ... ok
  32. loading system objects' descriptions ... ok
  33. creating collations ... ok
  34. creating conversions ... ok
  35. creating dictionaries ... ok
  36. setting privileges on built-in objects ... ok
  37. initialize global configure for bucketmap length ... ok
  38. creating information schema ... ok
  39. loading foreign-data wrapper for distfs access ... ok
  40. loading foreign-data wrapper for log access ... ok
  41. loading hstore extension ... ok
  42. loading foreign-data wrapper for MOT access ... ok
  43. loading security plugin ... ok
  44. update system tables ... ok
  45. creating snapshots catalog ... ok
  46. vacuuming database template1 ... ok
  47. copying template1 to template0 ... ok
  48. copying template1 to postgres ... ok
  49. freezing database template0 ... ok
  50. freezing database template1 ... ok
  51. freezing database postgres ... ok
  52. WARNING: enabling "trust" authentication for local connections
  53. You can change this by editing pg_hba.conf or using the option -A, or
  54. --auth-local and --auth-host, the next time you run gs_initdb.
  55. Success. You can now start the database server of single node using:
  56. gaussdb -D /opt/software/openGauss/data/single_node --single_node
  57. or
  58. gs_ctl start -D /opt/software/openGauss/data/single_node -Z single_node -l logfile
  59. [step 7]: start datanode
  60. .....ECUTOR] ACTION: Please refer to backend log for more details.
  61. [2023-12-07 22:12:16.581][18900][][gs_ctl]: done
  62. [2023-12-07 22:12:16.581][18900][][gs_ctl]: server started (/opt/software/openGauss/data/single_node)
  63. import sql file
  64. Would you like to create a demo database (yes/no)? yes
  65. Load demoDB [school,finance] success.
  66. [complete successfully]: You can start or stop the database server using:
  67. gs_ctl start|stop|restart -D $GAUSSHOME/data/single_node -Z single_node

3.11. 设置opengauss开机启动

3.11.1. 写配置
vi /usr/lib/systemd/system/opengauss.service 
[Unit]Description=openGauss    #当前服务的简单描述Documentation=openGauss Server    #服务配置文件的位置After=syslog.target    #在某服务之后启动After=network.target  [Service]Type=forking    #ExecStart字段将以fork()方式启动,后台运行 #服务运行的用户User=omm#服务运行的用户组Group=omm  Environment=PGDATA=/opt/software/openGauss/dataEnvironment=GAUSSHOME=/opt/software/openGaussEnvironment=LD_LIBRARY_PATH=/opt/software/openGauss/lib #启动服务的命令,可以是可执行程序、系统命令或shell脚本,必须是绝对路径。ExecStart=/opt/software/openGauss/bin/gs_ctl start -D /opt/software/openGauss/data/single_node  #重启服务的命令,可以是可执行程序、系统命令或shell脚本,必须是绝对路径。ExecReload=/opt/software/openGauss/bin/gs_ctl restart -D /opt/software/openGauss/data/single_node #停止服务的命令,可以是可执行程序、系统命令或shell脚本,必须是绝对路径。ExecStop=/opt/software/openGauss/bin/gs_ctl stop -D /opt/software/openGauss/data/single_node #Systemd停止sshd服务方式 mixed:主进程将收到SIGTERM信号,子进程收到SIGKILL信号KillMode=mixed KillSignal=SIGINTTimeoutSec=0 [Install]WantedBy=multi-user.target
  1. [Unit]
  2. Description=openGauss
  3. Documentation=openGauss Server
  4. After=syslog.target
  5. After=network.target
  6. [Service]
  7. Type=forking
  8. User=omm
  9. Group=dbgroup
  10. Environment=PGDATA=/opt/software/openGauss/data
  11. Environment=GAUSSHOME=/opt/software/openGauss
  12. Environment=LD_LIBRARY_PATH=/opt/software/openGauss/lib
  13. ExecStart=/opt/software/openGauss/bin/gs_ctl start -D /opt/software/openGauss/data/single_node
  14. ExecReload=/opt/software/openGauss/bin/gs_ctl restart -D /opt/software/openGauss/data/single_node
  15. ExecStop=/opt/software/openGauss/bin/gs_ctl stop -D /opt/software/openGauss/data/single_node
  16. KillMode=mixed
  17. KillSignal=SIGINT
  18. TimeoutSec=0
  19. [Install]
  20. WantedBy=multi-user.target
3.11.2. 配启动
#重新加载配置文件systemctl daemon-reload  #启用opengauss服务systemctl enable opengauss #执行opengauss服务systemctl start opengauss #查看opengauss服务的状态systemctl status opengauss #停止openGauss服务systemctl stop opengauss

3.12. 配置PG监听和连接权限

3.12.1. pg_hba.conf
3.12.1.1. 写配置
gs_guc set -D /opt/software/openGauss/data/single_node -h "host all all 0.0.0.0/0 sha256"gs_guc set -D /opt/software/openGauss/data/single_node -h "host replication all 0.0.0.0/0 sha256"
3.12.1.2. 确认配置是否写入
[omm@hp400 single_node]$ cat pg_hba.conf|egrep -v "^#|^$"local   all             all                                     trusthost    all             all             127.0.0.1/32            trusthost all all 0.0.0.0/0 sha256host    all             all             ::1/128                 trusthost replication all 0.0.0.0/0 sha256
3.12.2. postgresql.conf
3.12.2.1. 写配置
gs_guc set -D /opt/software/openGauss/data/single_node -c "listen_addresses = '*'"gs_guc set -D /opt/software/openGauss/data/single_node -c "wal_level = logical"
3.12.2.2. 确认配置是否写入
[omm@hp400 single_node]$ egrep "listen_address|wal_level" postgresql.conflisten_addresses = '*'    # what IP address(es) to listen on;wal_level = logical      # minimal, archive, hot_standby or logical

3.13. 启动数据库

systemctl start opengauss

4. 连接数据库并创建datakit用户

4.1. 连接数据库​​​​​​​

gsql -d postgres -p 5432 -ropenGauss=# \l                           List of databasesName    | Owner | Encoding |   Collate   |    Ctype    | Access privileges -----------+-------+----------+-------------+-------------+------------------- finance   | omm   | UTF8     | en_US.UTF-8 | en_US.UTF-8 |  postgres  | omm   | UTF8     | en_US.UTF-8 | en_US.UTF-8 |  school    | omm   | UTF8     | en_US.UTF-8 | en_US.UTF-8 |  template0 | omm   | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/omm           +        |       |          |             |             | omm=CTc/omm template1 | omm   | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/omm           +        |       |          |             |             | omm=CTc/omm(5 rows)

4.2. 创建数据库

4.2.1. datakit使用的数据库​​​​​​​
create user datakit identified by 'datakit@1234';grant all privilege to datakit;-- alter user datakit sysadmincreate database datakit;
4.2.2. 待写入数据的数据库(mysql 2 pg)
create database world with dbcompatibility='b';
4.2.3. 连接目标数据库world
gsql -d world -p 5432 -r

5. 安装datakit

 

5.1. 创建目录

mkdir -p /opt/datakit/datakit5.1/{logs,config,ssl,files}

5.2. 解压文件到目录

tar -zxvf Datakit-5.1.0.tar.gz -C /opt/datakit/datakit5.1

5.3. 将配置文件application-temp.yml传至config下。

修改文件目录以及连接信息

  1. url: jdbc:opengauss://ip:port/database?currentSchema=public
  2. username: dbuser
  3. password: dbpassword
  4. 修改为:
  5. jdbc:opengauss://127.0.0.1:5432/datakitdb?currentSchema=public
  6. username: datakit
  7. password: datakit@1234
  1. system:
  2. # File storage path
  3. defaultStoragePath: /opt/datakit/datakit5.1/files
  4. # Whitelist control switch
  5. whitelist:
  6. enabled: false
  7. server:
  8. port: 9494
  9. ssl:
  10. key-store: /opt/datakit/datakit5.1/ssl/keystore.p12
  11. key-store-password: 123456
  12. key-store-type: PKCS12
  13. enabled: true
  14. servlet:
  15. context-path: /
  16. logging:
  17. file:
  18. path: /opt/datakit/datakit5.1/logs/
  19. spring:
  20. datasource:
  21. type: com.alibaba.druid.pool.DruidDataSource
  22. driver-class-name: org.opengauss.Driver
  23. url: jdbc:opengauss://127.0.0.1:5432/datakit?currentSchema=public&batchMode=off
  24. username: datakit
  25. password: datakit@1234
  26. druid:
  27. test-while-idle: true
  28. test-on-borrow: true
  29. validation-query: "select 1"
  30. validation-query-timeout: 10000
  31. connection-error-retry-attempts: 0
  32. break-after-acquire-failure: true
  33. max-wait: 6000
  34. keep-alive: true
  35. max-active: 30
  36. min-evictable-idle-time-millis: 600000
  37. management:
  38. server:
  39. port: 9494

5.4. 生成证书

5.4.1. 生成ssl的java必须跟运行DataKit是一个java版本

密码要和上面的配置文件一致

  1. keytool -genkey -noprompt \
  2. -dname "CN=opengauss, OU=opengauss, O=opengauss, L=Beijing, S=Beijing, C=CN"\
  3. -alias opengauss\
  4. -storetype PKCS12 \
  5. -keyalg RSA \
  6. -keysize 2048 \
  7. -keystore /opt/datakit/datakit5.1/ssl/keystore.p12 \
  8. -validity 3650 \
  9. -storepass 123456

 5.5. 创建datakit运行用户并修改权限

  1. useradd ops
  2. chown -R ops:ops /opt/datakit

5.6. 切换到ops用户启动

  1. cd /opt/datakit/datakit5.1 && nohup java -Xms2048m -Xmx4096m -jar /opt/datakit/datakit5.1/openGauss-datakit-5.1.0.jar --spring.profiles.active=temp > /opt/datakit/datakit5.1/logs/datakit.out 2>&1 &

6. 准备mysql数据库

6.1. yum安装mysql

  1. wget http://repo.mysql.com/mysql57-community-release-el7-10.noarch.rpm
  2. rpm -Uvh mysql57-community-release-el7-10.noarch.rpm
  3. yum install -y mysql-community-server --nogpgcheck

 

6.2. 启动mysql

  1. systemctl start mysqld.service

6.3. 检查是否启动成功

systemctl status mysqld.service

 

6.4. 导入实例数据

6.4.1. 创建用户
  1. [root@mysqldb log]# cat mysqld.log |grep pass
  2. 2023-12-24T13:10:12.643017Z 1 [Note] A temporary password is generated for root@localhost: j8T(quBRT.K2
  3. [root@mysqldb mysqld]# mysql -uroot -p
  4. mysql> set global validate_password_policy=0;
  5. Query OK, 0 rows affected (0.00 sec)
  6. mysql> set global validate_password_length=1;
  7. Query OK, 0 rows affected (0.00 sec)
  8. mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'datakit@1234';
  9. Query OK, 0 rows affected (0.00 sec)

6.4.2. 下载样例数据库

wget https://downloads.mysql.com/docs/world-db.tar.gz
6.4.3. 导入
source /tmp/world-db/world.sql

6.5. 创建远程登录用户

grant all on *.* to root@'%' identified by 'datakit@1234';

6.6. 配置binlog日志

  1. tid_mode = ON
  2. enforce_gtid_consistency = ON
  3. character_set_server = UTF8MB4
  4. server-id = 170
  5. log-bin=on
  6. log_bin_basename=/var/lib/mysql/mysql-bin
  7. log_bin_index=/var/lib/mysql/mysql-bin.index

6.7. 安装java

yum install -y java-11-openjdk.x86_64  ava-11-openjdk-devel.x86_64  java-11-openjdk-headless.x86_64  java-11-openjdk-devel.x86_64

 7. datakit修改密码

 默认登陆账号密码:admin/admin123

 

 

https://cloud.tencent.com/developer/article/2368209

 

8. 创建主机和实例

8.1. 创建主机

 8.2. 给主机创建一个普通用户(操作PG数据库)

 8.3. 创建mysql实例

 8.4. 创建openGauss实例

 8.5. 创建后如下

 9. 离线迁移

 

 

 

 

 9.1. 迁移插件安装

 中断安装,比如 kill 掉java进程(安装失败也要等待300s)

update tb_migration_host_portal_install set install_status=10;

 

下载安装包准备上传

 

 

缺少mysqlclient lib包
  • mysql如果是二进制安装的话,我这个版本是没有18这个lib包的
  1. [root@mysqldb lib]# ls -ltrh /usr/local/mysql/lib
  2. total 1001M
  3. -rw-r--r-- 1 mysql mysql 392M Jun 21 2023 libmysqld-debug.a
  4. -rw-r--r-- 1 mysql mysql 43K Jun 21 2023 libmysqlservices.a
  5. -rwxr-xr-x 1 mysql mysql 11M Jun 21 2023 libmysqlclient.so.20.3.30
  6. -rw-r--r-- 1 mysql mysql 26M Jun 21 2023 libmysqlclient.a
  7. -rw-r--r-- 1 mysql mysql 574M Jun 21 2023 libmysqld.a
  8. lrwxrwxrwx 1 mysql mysql 25 Jun 21 2023 libmysqlclient.so.20 -> libmysqlclient.so.20.3.30
  9. lrwxrwxrwx 1 mysql mysql 20 Jun 21 2023 libmysqlclient.so -> libmysqlclient.so.20
  10. drwxr-xr-x 2 mysql mysql 28 Jan 10 13:36 pkgconfig
  11. drwxr-xr-x 4 mysql mysql 28 Jan 10 13:36 mecab
  12. drwxr-xr-x 3 mysql mysql 4.0K Jan 10 13:36 plugin
  13. lrwxrwxrwx 1 root root 25 Jan 10 14:41 libmysqlclient.so.18 -> libmysqlclient.so.20.3.30
  • 在porta安装日志下面,会有如下报错

  1. [root@mysqldb logs]# cat /ops/portal/error.log
  2. /ops/portal/tools/chameleon/chameleon-5.1.0
  3. install.sh: /ops/portal/tools/chameleon/chameleon-5.1.0/venv/bin/chameleon: /venv/bin/python3.6: bad interpreter: No such file or directory
  4. Traceback (most recent call last):
  5. File "/ops/portal/tools/chameleon/chameleon-5.1.0/venv/lib/python3.6/site-packages/MySQLdb/__init__.py", line 18, in <module>
  6. from . import _mysql
  7. ImportError: libmysqlclient.so.18: cannot open shared object file: No such file or directory
  8. During handling of the above exception, another exception occurred:
  • 查看到符合当前mysql的版本,通过yum安装即可

  1. Installed:
  2. mysql-community-libs-compat.x86_64 0:5.7.44-1.el7
  3. Complete!
  4. [root@datakit bin]# rpm -ql mysql-community-libs-compat-5.7.44-1.el7.x86_64
  5. /etc/ld.so.conf.d/mysql-x86_64.conf
  6. /usr/lib64/mysql
  7. /usr/lib64/mysql/libmysqlclient.so.18
  8. /usr/lib64/mysql/libmysqlclient.so.18.1.0
  9. /usr/lib64/mysql/libmysqlclient_r.so.18
  10. /usr/lib64/mysql/libmysqlclient_r.so.18.1.0
  11. /usr/share/doc/mysql-community-libs-compat-5.7.44
  12. /usr/share/doc/mysql-community-libs-compat-5.7.44/LICENSE
  13. /usr/share/doc/mysql-community-libs-compat-5.7.44/README
  • 其他有用命令

  1. # 重新加载lib库
  2. /sbin/ldconfig -v
  3. # 查看位置
  4. locate libmysql
  5. # 手动配置lib库
  6. vi /etc/ld.so.conf.d/mysql.conf
  7. # 查看是否有对应的lib库
  8. ldconfig -p|grep mysql
  • ldconfig,此时安装迁移插件应该没有问题

  1. [root@mysqldb lib]# ldconfig -p|grep mysql
  2. libmysqlclient.so.20 (libc6,x86-64) => /usr/local/mysql/lib/libmysqlclient.so.20
  3. libmysqlclient.so.20 (libc6,x86-64) => /usr/lib64/mysql/libmysqlclient.so.20
  4. libmysqlclient.so.18 (libc6,x86-64) => /usr/lib64/mysql/libmysqlclient.so.18
  5. libmysqlclient.so (libc6,x86-64) => /usr/local/mysql/lib/libmysqlclient.so
  • 如果是在线安装,会遇到403错误,现在要登陆了才能下载

  1. download portal package failed:
  2. --2024-01-09 12:11:24-- https://opengauss.obs.cn-south-1.myhuaweicloud.com/latest/tools/PortalControl-5.1.0.tar.gz
  3. Resolving opengauss.obs.cn-south-1.myhuaweicloud.com (opengauss.obs.cn-south-1.myhuaweicloud.com)... 122.9.127.163, 122.9.127.162
  4. Connecting to opengauss.obs.cn-south-1.myhuaweicloud.com (opengauss.obs.cn-south-1.myhuaweicloud.com)|122.9.127.163|:443... connected.
  5. HTTP request sent, awaiting response... 403 Forbidden
  6. 2024-01-09 12:11:25 ERROR 403: Forbidden.
  • 出现如下提示最终还是能成功安装的:

  1. /ops/portal/tools/chameleon/chameleon-5.1.0
  2. install.sh: /ops/portal/tools/chameleon/chameleon-5.1.0
  3. /venv/bin/chameleon: /venv/bin/python3.6: bad interpreter: No such file or directory

 安装成功后的截图

 主机上有对应的进程

  1. [root@mysqldb alternatives]# jps
  2. 19073 QuorumPeerMain
  3. 19122 SupportedKafka
  4. 4874 Jps
  5. 19487 SchemaRegistryMai

10. 全量迁移

10.1. 选中主机,启动迁移

图片

10.2. 迁移中

图片

10.3. 迁移结束

图片

图片

10.4. 日志所在目录

 

  1. [root@mysqldb datacheck]# pwd
  2. /ops/portal/workspace/2/logs/datacheck
  3. [root@mysqldb datacheck]# ls -ltrh
  4. total 36K
  5. -rw-rw-r-- 1 appadm appadm 2.2K Jan 10 15:31 business-source.log
  6. -rw-rw-r-- 1 appadm appadm 2.1K Jan 10 15:31 business-sink.log
  7. -rw-rw-r-- 1 appadm appadm 282 Jan 10 15:31 business-check.log
  8. -rw-rw-r-- 1 appadm appadm 3.1K Jan 10 15:31 source.log
  9. -rw-rw-r-- 1 appadm appadm 3.3K Jan 10 15:31 sink.log
  10. -rw-rw-r-- 1 appadm appadm 422 Jan 10 15:31 kafka-sink.log
  11. -rw-rw-r-- 1 appadm appadm 422 Jan 10 15:31 kafka-source.log
  12. -rw-rw-r-- 1 appadm appadm 3.3K Jan 10 15:31 check.log
  13. -rw-rw-r-- 1 appadm appadm 2.1K Jan 10 15:31 kafka-check.log
  14. [root@mysqldb datacheck]# ls -l /ops/portal/workspace/2/logs/
  15. total 24
  16. drwxrwxr-x 2 appadm appadm 204 Jan 10 15:30 datacheck
  17. drwxrwxr-x 2 appadm appadm 51 Jan 10 15:30 debezium
  18. -rw-rw-r-- 1 appadm appadm 162 Jan 10 15:31 error.log
  19. -rw-rw-r-- 1 appadm appadm 17400 Jan 10 15:31 full_migration.log
  20. [root@mysqldb datacheck]# find /ops -name schema-registry.log
  21. /ops/portal/workspace/2/logs/debezium/schema-registry.log
  22. /ops/portal/tools/debezium/confluent-5.5.1/logs/schema-registry.log

11. 增量迁移

11.1. PG里面创建第二个库

create database world2 with dbcompatibility='b';

11.2. 创建在线迁移任务

图片

11.3. 启动

 

  • 全量迁移完成并校验成功后进入增量迁移

图片

11.4. 在mysql端进行DDL和DML

mysql 端进行了5个事务

  1. root@localhost 16:08:00 [world]> create table t1(id int primary key,name varchar(32));
  2. Query OK, 0 rows affected (0.01 sec)
  3. root@localhost 16:08:31 [world]> insert into t1 values(1,'zhangsan');
  4. Query OK, 1 row affected (0.01 sec)
  5. root@localhost 16:08:45 [world]> insert into t1 values(2,'22'),(3,'33');
  6. Query OK, 2 rows affected (0.01 sec)
  7. Records: 2 Duplicates: 0 Warnings: 0
  8. root@localhost 16:09:00 [world]> create table city_copy like city;
  9. Query OK, 0 rows affected (0.03 sec)
  10. root@localhost 16:09:22 [world]> insert into city_copy select * from city;
  11. Query OK, 4079 rows affected (0.06 sec)
  12. Records: 4079 Duplicates: 0 Warnings: 0

 

 上面一直卡住,再起一个的时候报错(内存不足):

OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000680000000,

中间还有一次翻车了

  1. py_opengauss.exceptions.ClientCannotConnectError: could not establish connection to server
  2. CODE: 08001
  3. LOCATION: CLIENT
  4. CONNECTION: [failed]
  5. failures[0]:
  6. socket('192.168.2.3', 5432)
  7. py_opengauss.exceptions.InsufficientPrivilegeError: Please use the original role to connect B-compatibility database first, to load extension dolphin
  8. CODE: 42501
  9. LOCATION: SERVER
  10. CONNECTOR: [IP4] pq://datakit:***@192.168.2.3:5432/world4?[sslmode]=disable
  11. category: None
  12. DRIVER: py_opengauss.driver.pq3.Driver

第6次增量 

在mysql端进行增删改和DDL

  1. root@localhost 16:48:04 [world]> delete from t1 where id=3;
  2. Query OK, 1 row affected (0.01 sec)
  3. root@localhost 16:48:12 [world]> insert into t1 values(4,44);
  4. Query OK, 1 row affected (0.01 sec)
  5. root@localhost 16:48:24 [world]> update t1 set name=222 where id=2;
  6. Query OK, 1 row affected (0.00 sec)
  7. Rows matched: 1 Changed: 1 Warnings: 0
  8. root@localhost 16:48:36 [world]> update t1 set name=2223 where id=2;
  9. Query OK, 1 row affected (0.00 sec)
  10. Rows matched: 1 Changed: 1 Warnings: 0
  11. root@localhost 16:49:03 [world]> create table t2 (id int primary key, name char(20));
  12. Query OK, 0 rows affected (0.01 sec)
  13. root@localhost 16:49:41 [world]> insert into t2 select * from t1;
  14. Query OK, 3 rows affected (0.01 sec)
  15. Records: 3 Duplicates: 0 Warnings: 0

 

 

停止增量

图片

12. 反向迁移

图片

12.1. 在PG端进行增删改

  1. world4=# \c world4
  2. Non-SSL connection (SSL connection is recommended when requiring high-security)
  3. You are now connected to database "world4" as user "omm".
  4. world4=# set search_path=world;
  5. SET
  6. world4=# select * from t2;
  7. id | name
  8. ----+----------------------
  9. 1 | zhangsan
  10. 2 | 2223
  11. 4 | 44
  12. (3 rows)
  13. world4=# insert into t2 values(5,55);
  14. INSERT 0 1
  15. world4=# update t2 set name=5555 where id=5;
  16. UPDATE 1
  17. world4=# delete from t2 where id=1;
  18. DELETE 1

 

12.2. PG端DDL

 

PG建表无法同步到mysql,但是继续在PG继续进行DML,原有表的数据依然能同步到mysql。

 

  1. orld4=# create table pg_table( id bigint primary key);
  2. NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "pg_table_pkey" for table "pg_table"
  3. CREATE TABLE
  4. world4=# create table t3(id bigint primary key);
  5. NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "t3_pkey" for table "t3"
  6. CREATE TABLE
  7. world4=# show tables;
  8. Tables_in_world
  9. -----------------
  10. city
  11. city_copy
  12. country
  13. countrylanguage
  14. pg_table
  15. t1
  16. t2
  17. t3
  18. (8 rows)
  19. world4=# update t2 set name=55555555 where id=5;
  20. UPDATE 1
  21. world4=# create table t4(id bigint);
  22. CREATE TABLE
  23. world4=# insert into t4 values(1),(2);
  24. INSERT 0 2
  25. world4=# select * from t4;
  26. id
  27. ----
  28. 1
  29. 2
  30. (2 rows)

 

  1. root@localhost 17:01:41 [world]> show tables;
  2. +-----------------+
  3. | Tables_in_world |
  4. +-----------------+
  5. | city |
  6. | city_copy |
  7. | country |
  8. | countrylanguage |
  9. | t1 |
  10. | t2 |
  11. +-----------------+
  12. 6 rows in set (0.00 sec)
  13. root@localhost 17:03:08 [world]> select * from t2;
  14. +----+----------+
  15. | id | name |
  16. +----+----------+
  17. | 2 | 2223 |
  18. | 4 | 44 |
  19. | 5 | 55555555 |
  20. +----+----------+
  21. 3 rows in set (0.00 sec)

至此,迁移部分实践分享结束,欢迎大家一起交流学习。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/111609
推荐阅读
相关标签
  

闽ICP备14008679号