在ORCAL中实现的复制

来源:互联网 发布:caj转换word软件 编辑:程序博客网 时间:2024/06/14 03:15
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
在Internet上运作数据库经常会有这样的需求:把遍布全国各城市相似的数据库应用统一起来,一个节点的数据改变不仅体现在本地,还反映到远端。复制技术给用户提供了一种快速访问共享数据的办法。
  一、实现数据库复制的前提条件
  1、数据库支持高级复制功能
  您可以用system身份登录数据库,查看v$option视图,如果其中Advancedreplication为TRUE,则支持高级复制功能;否则不支持。
  2、数据库初始化参数要求
  ①、db_domain=test.com.cn
  指明数据库的域名(默认的是WORLD),这里可以用您公司的域名。
  ②、global_names=true
  它要求数据库链接(databaselink)和被连接的数据库名称一致。
  现在全局数据库名:db_name+”.”+db_domain
  ③、有跟数据库job执行有关的参数
  job_queue_processes=1
  job_queue_interval=60
  distributed_transactions=10
  open_links=4
  第一行定义SNP进程的启动个数为n。系统缺省值为0,正常定义范围为0~36,根据任务的多少,可以配置不同的数值。
  第二行定义系统每隔N秒唤醒该进程一次。系统缺省值为60秒,正常范围为1~3600秒。事实上,该进程执行完当前任务后,就进入睡眠状态,睡眠一段时间后,由系统的总控负责将其唤醒。
  如果修改了以上这几个参数,需要重新启动数据库以使参数生效。
  二、实现数据库同步复制的步骤
  假设在Internet上我们有两个数据库:一个叫深圳(shenzhen),一个叫北京(beijing)。
  具体配置见下表:
 数据库名 shenzhen Beijing 数据库域名 test.com.cn test.com.cn 数据库sid号 shenzhen beijing Listener端口号 1521 1521 服务器ip地址 10.1.1.200 10.1.1.200  
1、确认两台数据库之间可以互相访问,在tnsnames.ora里设置数据库连接字符串。
  ①、例如:深圳这边的数据库连接字符串是以下的格式
  beijing=
  (DESCRIPTION=
  (ADDRESS_LIST=
  (ADDRESS=(PROTOCOL=TCP)(HOST=10.1.1.200)(PORT=1521))
  )
  (CONNECT_DATA=
  (SERVICE_NAME=beijing)
  )
  )
  运行$tnspingbeijing
  出现以下提示符:
  Attemptingtocontact(ADDRESS=(PROTOCOL=TCP)(HOST=10.1.1.200)(PORT=1521))
  OK(n毫秒)
  表明深圳数据库可以访问北京数据库。
  ②、在北京那边也同样配置,确认$tnspingshenzhen是通的。
  2、改数据库全局名称,建公共的数据库链接。
  ①、用system身份登录shenzhen数据库
  SQL>alterdatabaserenameglobal_nametoshenzhen.test.com.cn;
  用system身份登录beijing数据库:
  SQL>alterdatabaserenameglobal_nametobeijing.test.com.cn;
  ②、用system身份登录shenzhen数据库
  SQL>createpublicdatabaselinkbeijing.test.com.cnusing'beijing';
  测试数据库全局名称和公共的数据库链接
  SQL>select*fromglobal_name@beijing.test.com.cn;
  返回  结果为beijing.test.com.cn就对了。
  用system身份登录beijing数据库:
  SQL>createpublicdatabaselinkshenzhen.test.com.cnusing'shenzhen';
  测试数据库全局名称和公共的数据库链接
  SQL>select*fromglobal_name@shenzhen.test.com.cn;
  返回结果为shenzhen.test.com.cn就对了。
  3、建立管理数据库复制的用户repadmin,并赋权。
  ①、用system身份登录shenzhen数据库
  SQL>createuserrepadminidentifiedbyrepadmindefaulttablespaceusers
  temporarytablespacetemp;
  SQL>executedbms_defer_sys.register_propagator('repadmin');
  SQL>grantexecuteanyproceduretorepadmin;
  SQL>executedbms_repcat_admin.grant_admin_any_repgroup('repadmin');
  SQL>grantcommentanytabletorepadmin;1<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
原创粉丝点击