Foreword:
Sometimes there is a need to migrate Oracle database data to postgresql. In fact, there are many tools to choose from, but from the perspective of migration efficiency and accuracy, it is undoubtedly the open source free tool ora2pg on GitHub. suitable.
The advantages of ora2pg are free, fast migration speed, accurate migration data, simple and fast deployment
The following will introduce how to deploy and install ora2pg under centos7 of server A, install and deploy an Oracle through docker on another server B, and simply write some data
Environment introduction:
The IP of server A is 192.168.123.11, the operating system is centos, and the postgresql database is installed.
The IP of server B is 192.168.123.12, the operating system is centos, and the Oracle database started by docker is installed.
one,
Overview of postgresql
The IP address of the server where the pg database is located is 192.168.123.11
Plan to install ora2pg on this server
two,
ora2pg installation and deployment
The relevant documents are on Baidu Netdisk at the following address:
Link: https://pan.baidu.com/s/1ixb6Vi7aCvNXfzWOqM13rw?pwd=ora2
Extraction code: ora2
-- Sharing from Baidu Netdisk Super Member V5
Version Notes:
The version of ora2pg is relatively high, considering that the pg database version is 12 and the Oracle database version is 11g, which is relatively new, and the ora2pg version is higher and has slightly more functions.
Architecture description:
The working principle of ora2pg is to use the Oracle client to connect to the Oracle database through the dbd plug-in and dbi plug-in, read the preset custom rules (the custom rules are defined in the ora2pg configuration file), and scan the Oracle database according to the set rules. The target table is used to reversely generate SQL storage statements that can be used directly by the postgresql database.
1,
dbi installation
yum install -y perl-DBI
This plug-in basically does not need to consider too many version issues, just install it directly from the local warehouse yum.
2,
dbd installation
cd DBD-Oracle-1.83/
perl Makefile.PL -l
make
make install
There is basically nothing to say, as long as you have the basic compilation environment.
3,
oracle client installation
unzip instantclient-basic-linux.x64-19.20.0.0.0dbru.zip
unzip instantclient-sdk-linux.x64-19.20.0.0.0dbru.zip
unzip instantclient-sqlplus-linux.x64-19.20.0.0.0dbru.zip
mkdir -p /opt/user/lib
mv instantclient_19_20 /opt/user/lib
cd /opt/user/lib
chmod 755 /opt/user/lib/instantclient_19_20/
chmod 755 -Rf /opt/user/lib/instantclient_19_20/
echo "export PATH=/opt/user/lib/instantclient_19_20/:$PATH">>/etc/profile
echo "export LD_LIBRARY_PATH=/opt/user/lib/instantclient_19_20/:$LD_LIBRARY_PATH">>/etc/profile
source /etc/profile
4,
ora2pg installation
The installation is similar to DBD installation, there is nothing much to say.
cd ora2pg-23.1/
perl Makefile.PL -l
echo $?
make
echo $?
make install
echo $?
three,
Oracle database deployment
Oracle database deployment is very simple because it is for testing purposes. Therefore, just use docker combined with docker-compose to pull up the Oracle database.
[root@oula2 ~]# cat oracle.yaml
version: '3'
services:
oracle:
restart: always
image: hub.c.163.com/springwen/oracle12c
container_name: oracle
volumes:
- /usr/local/oracle/data:/u01/app/oracle
- /usr/local/oracle/source:/docker-entrypoint-initdb.d
environment:
- "TZ=Asia/Shanghai"
- "DBCA_TOTAL_MEMORY=16192"
- "IMPORT_FROM_VOLUME=true"
ports:
- 53432:1521
- 36888:8080
logging:
driver: "json-file"
options:
max-size: "1g"
Use sqldeveloper to connect to the database:
The password of the sys user is oracle
Create emp test table:
CREATE TABLE emp (
emp_id NUMBER(10) PRIMARY KEY,
emp_name VARCHAR2(50),
emp_age NUMBER(3),
emp_sal NUMBER(10, 2)
);
Create test user:
CREATE USER gzmpc
IDENTIFIED BY PASSWORD
DEFAULT TABLESPACE gzmoc_wk
TEMPORARY TABLESPACE gzmoc_wk_tablespace_temp;
grant create session to gzmpc;
grant create table to gzmpc;
grant unlimited tablespace to gzmpc;
ALTER USER gzmpc IDENTIFIED BY gzmpc;
To be continued! ! ! !