V8R3迁移V8R6
<h1>迁移工具(V8R6)</h1>
<ol>
<li>先在R6创建好与R3对应的用户、数据库、模式
<pre><code class="language-shell">创建用户
create user 用户名 password '密码';
授权
alter user 用户名 CREATEDB;
alter user 用户名 CREATEROLE;
alter user 用户名 LOGIN;
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA pg_catalog to 用户名; # 此SQL是针对迁移时报错“对pg_xxx表权限不够”,一般不需要执行。如果出现类似“对pg_xxx表权限不够”执行此SQL为用户授权重新迁移即可。
创数据库并关联用户
create database 库名 with owner=&quot;用户名&quot; encoding UTF8 template=template0 LC_CTYPE='zh_CN.UTF8' LC_COLLATE='zh_CN.UTF8';
创建模式
CREATE SCHEMA 模式名 AUTHORIZATION &quot;库名&quot;;</code></pre>
<p><img src="http://60.191.64.5:16100/server/index.php?s=/api/attachment/visitFile/sign/4839b3b4a69b4201006949bd9d780e75" alt="" /></p></li>
<li>打开迁移工具,分别填写R3和R6需要迁移的库的相关信息
<img src="http://60.191.64.5:16100/server/index.php?s=/api/attachment/visitFile/sign/c226e627515a0a068ee7f0eec3f60ced" alt="" />
<img src="http://60.191.64.5:16100/server/index.php?s=/api/attachment/visitFile/sign/0d0c06e9365832ee3861a790abb118c7" alt="" />
3.新建迁移任务
<img src="http://60.191.64.5:16100/server/index.php?s=/api/attachment/visitFile/sign/83f62a44dd2be49432c4e9a2d044f42e" alt="" />
<img src="http://60.191.64.5:16100/server/index.php?s=/api/attachment/visitFile/sign/4f638b1fce9d84f72595239aca2eba27" alt="" />
<img src="http://60.191.64.5:16100/server/index.php?s=/api/attachment/visitFile/sign/87037f28bc251362310be9559d5f92d4" alt="" />
<img src="http://60.191.64.5:16100/server/index.php?s=/api/attachment/visitFile/sign/dc36f2cee73f5321d676af2fb257b372" alt="" />
<img src="http://60.191.64.5:16100/server/index.php?s=/api/attachment/visitFile/sign/6067abb877797824c894d4b96d7ba47c" alt="" />
<img src="http://60.191.64.5:16100/server/index.php?s=/api/attachment/visitFile/sign/72e4a621d46e5926b04ea1dabd19ed0c" alt="" />
<img src="http://60.191.64.5:16100/server/index.php?s=/api/attachment/visitFile/sign/af7fe4e3a73dd507e85d666865f7b13d" alt="" />
4.迁移结束,检查是否有报错信息
<img src="http://60.191.64.5:16100/server/index.php?s=/api/attachment/visitFile/sign/d5b8ad9ec287268d3d4e40ed90482b69" alt="" />
<img src="http://60.191.64.5:16100/server/index.php?s=/api/attachment/visitFile/sign/1312bcc3ad8224d642a0cd2e0528e654" alt="" />
<h1>命令行</h1>
<p>R3_R6迁移首选迁移工具,但无法用迁移工具直连数据库时只能用命令行迁移。</p>
<ul>
<li>先将R3库数据用命令导出,在本地用管理工具还原
<pre><code class="language-shell">./sys_dump -p 端口 -U 用户名 -f 数据文件保存路径.dmp -Fc -n 库名</code></pre>
<p><img src="http://60.191.64.5:16100/server/index.php?s=/api/attachment/visitFile/sign/7664f896207d03046e1fe97d7c32eb16" alt="" />
<img src="http://60.191.64.5:16100/server/index.php?s=/api/attachment/visitFile/sign/2b2bbfe6aec27d87fe66acbead77bf4c" alt="" /></p></li>
<li>再在本地将R3数据利用迁移工具将数据导成R6,再将本地R6数据导出上传到服务器用命令还原(同样需要提前创建好用户、库、模式)。本地迁成R6后检查注意检查表数、乱码、序列等,没问题就工具或命令行导出。
<pre><code class="language-shell">./sys_restore -p 端口 -U 用户名 -d 库名 --no-tablespaces -c --if-exists -O -x -j 4 /home/kingbase/数据文件存放路径.dmp</code></pre>
<p><img src="http://60.191.64.5:16100/server/index.php?s=/api/attachment/visitFile/sign/339e512db1222b629897284965513e08" alt="" />
<img src="http://60.191.64.5:16100/server/index.php?s=/api/attachment/visitFile/sign/4108c10d18d90604af4b61474298a668" alt="" /></p></li>
</ul></li>
</ol>