hello~~大家好,我又来了,哈哈~~今天发两贴shareplex的基础的东西。shareplex是以前quest公司的一款数据同步软件,貌似现在被dell公司收购了。
利用shareplex,可以实现在oracle数据库之间实现不停机数据迁移。这一帖简单描述以下shareplex的部署。
整个部署是基于redhat平台的,oracle数据库版本为11g,部署流程如下:
源端主机名:shareplex01
目标端主机名:shareplex02
1.配置两个主机的/etc/hosts
[root@shareplex01 ~]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
192.168.56.101 shareplex01
192.168.56.103 shareplex02
[root@shareplex01 ~]#
[root@shareplex02 ~]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
192.168.56.101 shareplex01
192.168.56.103 shareplex02
[root@shareplex02 ~]#
2.检查源端和目标端/etc/oratab文件:
都必须要有$ORACLE_SID和$ORACLE_HOME
orcl:/oracle/app/oracle/product/11.2.0.3/db_1:N
3.检查系统参数:
[root@shareplex01 ~]# ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 16383
max locked memory (kbytes, -l) 32
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 16383
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
[root@shareplex01 ~]#
[root@shareplex02 ~]# ulimit -c 1500000
4.检查oracle参数:
SQL> show parameter recovery_parallelism
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
recovery_parallelism integer 0
SQL>
上面参数必须修改为0.
5.源端每个节点打开补充日志 (需在业务少的时候进行、确认没有长时间事物v$transaction),查看节点的补充日志是否打开:
SQL> select supplemental_log_data_ui,supplemental_log_data_pk from v$database;
SUP SUP
--- ---
NO NO
SQL>
日志补充没有打开,打开日志补充:
SQL> alter database add supplemental log data (primary key,unique index) columns;
Database altered.
SQL>
SQL> select supplemental_log_data_ui,supplemental_log_data_pk from v$database;
SUP SUP
--- ---
YES YES
SQL>
注意:如果是rac要在各个节点都执行。
6.安装shareplex:
上传shareplex软件包:
[root@shareplex01 softwares]# ls -ltr
total 2509244
-rw-r--r-- 1 root root 66283520 Oct 27 16:07 SharePlex-8.0.1-b22-oracle110-rh-40-amd64-m64.tar
[root@shareplex01 softwares]#
root用户解压:
[root@shareplex01 softwares]# tar -xvf SharePlex-8.0.1-b22-oracle110-rh-40-amd64-m64.tar
SharePlex-8.0.1-b22-oracle110-rh-40-amd64-m64.tpm
更改权限:
[root@shareplex01 softwares]# chown -R oracle:oinstall SharePlex-8.0.1-b22-oracle110-rh-40-amd64-m64.tpm
[root@shareplex01 softwares]# ls -ltr
total 2574036
-rwxr-xr-x 1 oracle oinstall 66273882 Apr 27 2013 SharePlex-8.0.1-b22-oracle110-rh-40-amd64-m64.tpm
-rw-r--r-- 1 oracle oinstall 66283520 Oct 27 16:57 SharePlex-8.0.1-b22-oracle110-rh-40-amd64-m64.tar
[root@shareplex01 softwares]#
源端oracle用户直接运行解压后的包安装:
[oracle@shareplex01 softwares]$ ls
database p10404530_112030_Linux-x86-64_2of7.zip SharePlex-8.0.1-b22-oracle110-rh-40-amd64-m64.tpm
p10404530_112030_Linux-x86-64_1of7.zip SharePlex-8.0.1-b22-oracle110-rh-40-amd64-m64.tar
[oracle@shareplex01 softwares]$ ./SharePlex-8.0.1-b22-oracle110-rh-40-amd64-m64.tpm
Unpacking ..................................................................
..........................................................................
..........................................................................
..........................................................................
..........................................................................
..........................................................................
..........................................................................
..........................................................................
..........................................................................
..........................................................................
..........................................................................
..........................................................................
..........................................................................
..........................................................................
..........................................................................
..........................................................................
..........................................................................
..........................................................................
..........................................................................
..........................................................................
.....................................................................
SharePlex for Oracle installation program:
SharePlex Version: 8.0.1
Supported Oracle Version: 11gR1, 11gR2
Build platform: rh-40-amd64
Target platform: rh-40-amd64
Please enter the product directory location? /oracle/quest/splex/product
Please enter the variable data directory location? /oracle/quest/splex/datadir
...Installation failed...
Installation log saved to: /home/oracle/.shareplex/INSTALL-SharePlex-8.0.1-1410271705.log
ERROR: tpm: spo-check-locations: Permission denied - /oracle/quest
[oracle@shareplex01 softwares]$ ls -ld /oracle/
drwxr-xr-x 5 root root 4096 Oct 15 17:15 /oracle/
[oracle@shareplex01 softwares]$ exit
logout
[root@shareplex01 softwares]# chown -R oracle:oinstall /oracle
[root@shareplex01 softwares]# su - oracle
[oracle@shareplex01 ~]$ cd /oracle/softwares/
[oracle@shareplex01 softwares]$ ls
database p10404530_112030_Linux-x86-64_2of7.zip SharePlex-8.0.1-b22-oracle110-rh-40-amd64-m64.tpm
p10404530_112030_Linux-x86-64_1of7.zip SharePlex-8.0.1-b22-oracle110-rh-40-amd64-m64.tar
[oracle@shareplex01 softwares]$ ./SharePlex-8.0.1-b22-oracle110-rh-40-amd64-m64.tpm
Unpacking ..................................................................
..........................................................................
..........................................................................
..........................................................................
..........................................................................
..........................................................................
..........................................................................
..........................................................................
..........................................................................
..........................................................................
..........................................................................
..........................................................................
..........................................................................
..........................................................................
..........................................................................
..........................................................................
..........................................................................
..........................................................................
..........................................................................
..........................................................................
.....................................................................
SharePlex for Oracle installation program:
SharePlex Version: 8.0.1
Supported Oracle Version: 11gR1, 11gR2
Build platform: rh-40-amd64
Target platform: rh-40-amd64
Please enter the product directory location? /oracle/quest/splex/product
Please enter the variable data directory location? /oracle/quest/splex/datadir
Please specify the SharePlex Admin group (select a number):
1. [oinstall]
2. dba
?
Please wait while the installer obtains Oracle information ..
Please enter the ORACLE_SID that corresponds to this installation? [orcl]
Please enter the ORACLE_HOME directory that corresponds to this ORACLE_SID? [/oracle/app/oracle/product/11.2.0.3/db_1]
Please enter the TCP/IP port number for SharePlex communications? [2100]
Preparing to install SharePlex for Oracle v. 8.0.1:
User: oracle
Admin Group: oinstall
Product Directory: /oracle/quest/splex/product
Variable Data Directory: /oracle/quest/splex/datadir
ORACLE_SID: orcl
ORACLE_HOME: /oracle/app/oracle/product/11.2.0.3/db_1
Proceed with installation? [yes]
Installing ................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
..............
Setting file ownerships ...................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
...........................
Setting file permissions ..................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
............................
Do you have a valid SharePlex for Oracle v. 8.0.1 license? [yes]
Please enter the License key? BJ7FY8NZ504JB1UG7RBFW22LCEV0ZV1E11
Please enter the customer name associated with this license key? Trial Version
SharePlex for Oracle v. 8.0.1 license validation successful:
Customer Name: Trial Version
License Key: BJ7FY8NZ504JB1UG7RBFW22LCEV0ZV1E11
Product Name: SharePlex for Oracle - RAC
License Key Type: "Trial Key"
Expires: at Midnight of Nov 14, 2014
NOTE: You can upgrade this license key or add license keys for additional machines
by executing utility /oracle/quest/splex/product/install/splex_add_key.
Installation log saved to: /home/oracle/.shareplex/INSTALL-SharePlex-8.0.1-1410271709.log
SharePlex for Oracle v. 8.0.1 installation successful.
[oracle@shareplex01 softwares]$
以上安装过程会提示输入:
product目录,data目录,管理用户和管理组(一般选oracle用户和组)核对ORACLE_SID,核对ORACLE_HOME,选择端口号,输入license key和
license name。
如果源端和目标端端口不一致,到数据目录修改:
[oracle@shareplex01 datadir]$ pwd
/oracle/quest/splex/datadir
[oracle@shareplex01 datadir]$ ls
config data db dump log rim save state temp
[oracle@shareplex01 datadir]$
[oracle@shareplex01 data]$ pwd
/oracle/quest/splex/datadir/data
[oracle@shareplex01 data]$ vi paramdb
...
SP_COP_TPORT 2100
SP_COP_UPORT 2100
SP_SYS_LIC_40134 "BJ7FY8NZ504JB1UG7RBFW22LCEV0ZV1E11:Trial Version"
将上面两个端口改成和目标端一致就可以了。
7.源端和目标端的环境变量配置:
在path中加入/oracle/quest/splex/product/bin
PATH=.:$PATH:$HOME/bin:/oracle/quest/splex/product/bin:$ORACLE_HOME/bin
. ./.bash_profile
测试环境变量是否生效:
[oracle@shareplex01 ~]$ sp_ctrl
*******************************************************
* SharePlex for Oracle Command Utility
* Copyright 2012 Quest Software, Inc.
* ALL RIGHTS RESERVED.
* Protected by U.S. Patents: 7,461,103 and 7,065,538
*******************************************************
Your tcp port is not set properly or 'sp_cop' is not running
Attempted to connect to sp_cop on port 2100
sp_ctrl >
8.创建用户:
sp_ctrl > help
List of command groups:
config - Control configurations.
connect - Control sp_cop connections.
info - Display status and statistics.
maint - Control displays and files.
misc - Miscellaneous commands.
param - Control parameters.
properties - Display properties of the system, SharePlex and user.
queues - Control queues.
run - Control processes.
sync - Control synchronization.
target - Define target configuration.
Type 'help' and a group name for a list of commands in the group
Type 'help' and a command name for a full description and syntax
sp_ctrl >
9.配置shareplex,需要一个具有dba权限的oracle用户,这里使用system用户:
[oracle@shareplex01 ~]$ ora_setup
Welcome to the Oracle SharePlex setup process.
This process creates tables and user accounts needed to run
Oracle SharePlex replication.
Please note the following:
** In response to prompts, a carriage return will choose the default
given in brackets. If there is no default, a reply must be entered.
** To exit the program while the program is waiting for input, use the
CTRL-C key sequence.
This sequences can be entered by holding down the CONTROL key and
pressing the C key.
Enter the Oracle SID for which SharePlex should be installed [orcl] :
In order to create the SharePlex tables and user account, we must
connect to the database as a DBA user
Enter a DBA user name : system
Enter password for the DBA account, which will not echo :
connecting--This may take a few seconds.
validating user name and password. . . This may take a few seconds.
SharePlex objects will need to be created under a special
account. You can pick an existing user or create a new one.
Would you like to create a new SharePlex user ? [y] :
Enter username for new user [SPLEX/SPLEX] : shareplex
Enter password for new user :
Re-enter password for new user :
Warning: This user is now being granted unlimited tablespace.
This privilege will remain in effect until it is explicitly changed.
Do you want to enable replication of tables with TDE? [y] :
Checking Oracle's kernel for TDE support...
Checking the TDE Support procedures...Not Loaded
Loading TDE procedures from /oracle/app/oracle/product/11.2.0.3/db_1/rdbms/admin/prvtclkm.plb...OK.
Granting execute privilege on SYS.DBMS_INTERNAL_CLKM to user shareplex ...OK.
The Shareplex TDE Shared Secret has not been specified yet.
Enter the shared secret :
Please set the Shareplex TDE Shared Secret to enable TDE support.
Setup will now install SharePlex objects.
These are the existing tablespaces.
SYSTEM SYSAUX UNDOTBS1 TEMP USERS EXAMPLE
Enter the default tablespace for use by SharePlex [USERS] : users
Enter the temporary tablespace for use by SharePlex [TEMP] : temp
Enter the index tablespace for use by SharePlex [ ] : users
Creating SharePlex objects [Installation type: Fresh]. . .
Creating SharePlex Oracle-timezone-region map . . . Done.
Creating Conflict Resolution Package . . . Done.
Setup of SharePlex objects successful . . .
Creating SharePlex Dataequator Read Anydata Function . . . Done.
Creating SharePlex Dataequator Write Anydata Function . . . Done.
Changing SharePlex parameter database . . .
Setup completed successfully
[oracle@shareplex01 ~]$
10.在后台启动shareplex:
命令:sp_cop &
[oracle@shareplex01 ~]$ sp_cop &
[1] 10755
[oracle@shareplex01 ~]$
*******************************************************
* SharePlex for Oracle Startup
* Copyright 2012 Quest Software, Inc.
* ALL RIGHTS RESERVED.
* Protected by U.S. Patents: 7,461,103 and 7,065,538
* Version: 8.0.1.22-m64-oracle110
* VarDir : /oracle/quest/splex/datadir
* Port : 2100
*******************************************************
[oracle@shareplex01 ~]$ ps -ef |grep sp_
oracle 10755 6943 0 17:49 pts/2 00:00:00 /oracle/quest/splex/product/.app-modules/sp_cop
oracle 10783 6943 0 17:53 pts/2 00:00:00 grep sp_
[oracle@shareplex01 ~]$
11.配置目标端:
检查环境修改配置参数,先安装软件,再ora_setup配置。和源端一模一样。
配置完也sp_cop启动目标端。
12.编辑测试表:
现在源端创建个测试用户testsp,并创建一张表,在目标端创建相同的用户并授相同的权限,在目标端也建相同的表。
SQL> create user testsp identified by testsp;
User created.
SQL> grant dba to testsp;
Grant succeeded.
SQL> conn testsp/testsp
Connected.
SQL> create table testspx as select * from dba_objects where 1=2;
Table created.
SQL>
sp_ctrl (shareplex01:2100)> list config
File Name State Datasource
-------------------------------------------------- ---------- ---------------
ORA_config Inactive o.SOURCE_SID
Last Modified At: 27-Oct-14 17:10 Size: 151
sp_ctrl (shareplex01:2100)> copy config ORA_config to ora_con
sp_ctrl (shareplex01:2100)> list config
File Name State Datasource
-------------------------------------------------- ---------- ---------------
ora_con Inactive o.SOURCE_SID
Last Modified At: 27-Oct-14 18:38 Size: 151
ORA_config Inactive o.SOURCE_SID
Last Modified At: 27-Oct-14 17:10 Size: 151
sp_ctrl (shareplex01:2100)> edit config ora_con
编辑成下面形式:
sp_ctrl (shareplex01:2100)> view config ora_con
datasource:o.orcl
#source tables target tables routing map
testsp.testspx testsp.testspy shareplex02@o.orcl
sp_ctrl (shareplex01:2100)>
sp_ctrl (shareplex01:2100)> activate config ora_con
sp_ctrl (shareplex01:2100)> show
Process Source Target State PID
---------- ------------------------------------ ------------ -------------------- ------
Capture o.orcl Running 11385
Read o.orcl Running 11390
Export shareplex01 shareplex02 Running 11405
sp_ctrl (shareplex01:2100)>
如果目标端没有创建表,同步的是由会报错post进程自动停止:
Info 2014-10-27 18:58:47.412080 13858 1804461616 Poster launched, pid = 13858 (posting from orcl, queue shareplex01, to orcl)
Warning 2014-10-27 19:03:51.328598 13858 1101293888 s:2 Poster: 15022 - Error posting ODR_INSERTN to table "TESTSP"."TESTSPY". (posting from orcl, queue shareplex01, to orcl) [module opo]
Notice 2014-10-27 19:03:51.328909 13858 1101293888 s:2 Poster: Oracle error: ORA-00942: table or view does not exist. rowid:AAASu7AAEAAAASHAAA (posting from orcl, queue shareplex01, to orcl) [module opo]
Error 2014-10-27 19:03:51.328984 13858 1101293888 s:2 Poster stopped: Internal error encountered; cannot continue (posting from orcl, queue shareplex01, to orcl)
Info 2014-10-27 19:03:51.334335 13605 1804461616 Poster exited with code=1, pid = 13858 (posting from orcl, queue shareplex01, to orcl)
[root@shareplex02 log]#
sp_ctrl (shareplex02:2100)> show
Process Source Target State PID
---------- ------------------------------------ ------------ -------------------- ------
Import shareplex01 shareplex02 Running 13857
Post o.orcl-shareplex01 o.orcl Stopped - due to error
sp_ctrl (shareplex02:2100)>
启动post进程:
sp_ctrl (shareplex02:2100)> show
Process Source Target State PID
---------- ------------------------------------ ------------ -------------------- ------
Import shareplex01 shareplex02 Running 14203
Post o.orcl-shareplex01 o.orcl Stopped - due to error
sp_ctrl (shareplex02:2100)> start post
sp_ctrl (shareplex02:2100)> show
Process Source Target State PID
---------- ------------------------------------ ------------ -------------------- ------
Import shareplex01 shareplex02 Running 14203
Post o.orcl-shareplex01 o.orcl Running 14303
sp_ctrl (shareplex02:2100)>
启动后在源端改变数据,目标端随着改变。
源端查看队列状态:
sp_ctrl (shareplex01:2100)> qstatus
Queues Statistics for shareplex01
Name: o.orcl (Capture queue)
Number of messages: 2 (Age 0 min; Size 2 mb)
Backlog (messages): 2 (Age 0 min)
Name: shareplex01 (Export queue)
Number of messages: 0 (Age 0 min; Size 1 mb)
Backlog (messages): 0 (Age 0 min)
sp_ctrl (shareplex01:2100)>
目标端查看队列状态:
sp_ctrl (shareplex02:2100)> qstatus
Queues Statistics for shareplex02
Name: shareplex01 (o.orcl-o.orcl) (Post queue)
Number of messages: 0 (Age 0 min; Size 1 mb)
Backlog (messages): 0 (Age 0 min)
sp_ctrl (shareplex02:2100)>
完毕!