dbswitch: 异构数据库迁移同步(搬家)工具
(base) root@node13:~# cat /etc/issue
Ubuntu 20.04.5 LTS \n \l
(base) root@node13:~# curl -k -sSL https://gitee.com/dromara/dbswitch/attach_files/1878800/download > /tmp/dbswitch_install.sh && bash /tmp/dbswitch_install.sh
Docker version 24.0.7, build afdd53b
docker-compose version 1.25.0, build unknown
Error response from daemon: No such container: dbswitch_webui
1.9.8: Pulling from inrgihc/dbswitch
e7c96db7181b: Pull complete
f910a506b6cb: Pull complete
b6abafe80f63: Pull complete
7236bacef262: Pull complete
bd5cabd0b908: Pull complete
e5a4a63c5a3d: Pull complete
Digest: sha256:b03c6132dd670666b9835310759c9c911b5f294a2e36fc97bea5bd6519eecde1
Status: Downloaded newer image for registry.cn-hangzhou.aliyuncs.com/inrgihc/dbswitch:1.9.8
registry.cn-hangzhou.aliyuncs.com/inrgihc/dbswitch:1.9.8
Creating network "dbswtich_default" with the default driver
Pulling mysqldb (mysql:5.7)...
5.7: Pulling from library/mysql
20e4dcae4c69: Pull complete
1c56c3d4ce74: Pull complete
e9f03a1c24ce: Pull complete
68c3898c2015: Pull complete
6b95a940e7b6: Pull complete
90986bb8de6e: Pull complete
ae71319cb779: Pull complete
ffc89e9dfd88: Pull complete
43d05e938198: Pull complete
064b2d298fba: Pull complete
df9a4d85569b: Pull complete
Digest: sha256:4bc6bc963e6d8443453676cae56536f4b8156d78bae03c0145cbe47c2aad73bb
Status: Downloaded newer image for mysql:5.7
Creating dbswitch_mysqldb ... done
Creating dbswitch_webui ... done
*********************************************************************************************************************************************************************************************
!!! 恭 喜 您 DBSWITCH 已 经 安 装 ( 或 升 级 ) 【成 功】 !!!
DBSWITCH访问信息如下:
地址:htttp://127.0.0.1:9088
账号:admin
密码:123456
*********************************************************************************************************************************************************************************************
(base) root@node13:~# netstat -tunlp|grep 9088
tcp 0 0 0.0.0.0:9088 0.0.0.0:* LISTEN 846951/docker-proxy
tcp6 0 0 :::9088 :::* LISTEN 846958/docker-proxy
(base) root@node13:~#
http://192.168.207.13:9088
admin/123456
测试从mysql到oracle,可以导入成功,不过表名多了双引号:
同样oracle到postgresql表名也多了双引号:
不能删除数据源,否则由于外键依赖的问题,导致列表报错:
删掉一个数据源后任务列表报错 · Issue #IANBO8 · dromara/dbswitch - Gitee.com
临时处理办法:
进入容器:
(base) root@node13:~# docker exec -it 490cc6414c54 /bin/bash
bash-4.2# mysql -utangyibo -n dbswitch -p123456
bash-4.2# exit
exit
删除相关任务重来,或者恢复之前删除的信息:
启停容器操作:
(base) root@node13:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
45bb0453fadd registry.cn-hangzhou.aliyuncs.com/inrgihc/dbswitch:1.9.8 "/dbswitch-release/b…" 39 minutes ago Up 39 minutes 0.0.0.0:9088->9088/tcp, :::9088->9088/tcp dbswitch_webui
490cc6414c54 mysql:5.7 "docker-entrypoint.s…" 39 minutes ago Up 39 minutes 3306/tcp, 33060/tcp dbswitch_mysqldb
(base) root@node13:~# docker stop 45bb0453fadd
45bb0453fadd
(base) root@node13:~# docker stop 490c
490c
(base) root@node13:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
(base) root@node13:~# docker start 490cc6414c54
490cc6414c54
(base) root@node13:~# docker start 45bb0453fadd
45bb0453fadd
(base) root@node13:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
45bb0453fadd registry.cn-hangzhou.aliyuncs.com/inrgihc/dbswitch:1.9.8 "/dbswitch-release/b…" 40 minutes ago Up 4 seconds 0.0.0.0:9088->9088/tcp, :::9088->9088/tcp dbswitch_webui
490cc6414c54 mysql:5.7 "docker-entrypoint.s…" 40 minutes ago Up 14 seconds 3306/tcp, 33060/tcp dbswitch_mysqldb
(base) root@node13:~#
dbswitch_install.sh脚本内容:
#!/bin/bash
set -e
shellwidth=$(stty size | awk '{print $2}')
DOWNLOAD_URL_DOCKER="https://get.docker.com"
TMP_DBSWITCH_DIR="/tmp/dbswtich"
command_exists() {
command -v "$@" > /dev/null 2>&1
}
# install docker
install_docker_service() {
if command_exists docker && [ -e /var/run/docker.sock ]; then
docker --version
else
mkdir -p /etc/docker/
cat > /etc/docker/daemon.json <<EOF
{
"registry-mirrors":[
"https://docker.mirrors.ustc.edu.cn",
"http://hub-mirror.c.163.com",
"https://dhyjbe13.mirror.aliyuncs.com"
],
"insecure-registries": ["127.0.0.1/8"],
"max-concurrent-downloads":10,
"log-driver":"json-file",
"log-level":"warn",
"log-opts":{
"max-size":"10m",
"max-file":"3"
},
"data-root":"/var/lib/docker"
}
EOF
curl -sSL ${DOWNLOAD_URL_DOCKER} -o /tmp/docker.sh
sh /tmp/docker.sh --mirror Aliyun
docker --version
rm -f /tmp/docker.sh
service docker restart
fi
}
# install docker-compose
install_docker_compose() {
if command_exists docker-compose ; then
docker-compose --version
else
echo "download docker-compose now ..."
curl -SL https://gitee.com/dromara/dbswitch/attach_files/1601064/download > /usr/local/bin/docker-compose && chmod +x /usr/local/bin/docker-compose
docker-compose --version
fi
}
# install dbswitch
install_dbswitch_service() {
docker rm -f dbswitch_webui || true >>/dev/null
docker pull registry.cn-hangzhou.aliyuncs.com/inrgihc/dbswitch:1.9.8
rm -rf ${TMP_DBSWITCH_DIR} && mkdir -p ${TMP_DBSWITCH_DIR}
cat > ${TMP_DBSWITCH_DIR}/docker-compose.yml <<EOF
version: '3.3'
services:
mysqldb:
container_name: dbswitch_mysqldb
image: mysql:5.7
volumes:
- "/data/mysql:/var/lib/mysql"
environment:
TZ: Asia/Shanghai
MYSQL_DATABASE: dbswitch
MYSQL_USER: tangyibo
MYSQL_PASSWORD: 123456
MYSQL_ROOT_PASSWORD: 123456
MYSQL_ROOT_HOST: '%'
dbswitch:
container_name: dbswitch_webui
image: registry.cn-hangzhou.aliyuncs.com/inrgihc/dbswitch:1.9.8
environment:
MYSQLDB_HOST: dbswitch_mysqldb
MYSQLDB_PORT: 3306
MYSQLDB_USERNAME: tangyibo
MYSQLDB_PASSWORD: 123456
MYSQLDB_NAME: dbswitch
ports:
- 9088:9088
depends_on:
- mysqldb
EOF
cd ${TMP_DBSWITCH_DIR} && docker-compose up -d
rm -rf ${TMP_DBSWITCH_DIR}
}
# pring line on screen
function print_line() {
for ((i = 1; i <= $shellwidth; i++)); do
echo -n '*'
done
}
# print success
print_success(){
echo ''
print_line
echo ''
echo " !!! 恭 喜 您 DBSWITCH 已 经 安 装 ( 或 升 级 ) 【成 功】 !!!"
echo ''
echo ''
echo " DBSWITCH访问信息如下:"
echo ""
echo " 地址:htttp://127.0.0.1:9088 "
echo " 账号:admin "
echo " 密码:123456 "
echo ''
print_line
echo ''
}
install_docker_service
install_docker_compose
install_dbswitch_service
print_success