Chinaunix首页 | 论坛 | 博客
  • 博客访问: 141928
  • 博文数量: 27
  • 博客积分: 2613
  • 博客等级: 少校
  • 技术积分: 270
  • 用 户 组: 普通用户
  • 注册时间: 2004-12-17 13:12
个人简介

No pain, no gain.

文章分类

全部博文(27)

文章存档

2011年(4)

2010年(2)

2009年(2)

2008年(3)

2007年(2)

2006年(4)

2005年(4)

2004年(6)

我的朋友

分类: Sybase

2008-11-15 11:32:59

稳定队列的命令行安装

稳定队列是一对数据库表,它们保存事务,直到复制系统不再需要这些事务为止。参与 SQL Remote 安装的每个 Adaptive Server Enterprise 数据库都需要一个稳定队列。

有关稳定队列的详细信息,请参见稳定队列。

稳定队列可与参与 SQL Remote 的数据库位于同一数据库中,也可存在于一个单独的数据库中。如果将稳定队列单独保存在另一数据库中,将会使备份和恢复计划变得复杂;但通过将稳定队列负载单独放在独立的设备和/ 或独立的 Adaptive Server Enterprise 服务器上,可以提高性能。

安装稳定队列:

1 在您的 SQL Remote 安装目录中找到稳定队列的初始化脚本stableq.sql

2 制作 stableq.sql 脚本文件的备份副本。然后将以下两行添加到stableq.sql 的起始位置:

use database_name

go

其中 database_name 是将要保存稳定队列的数据库的名称。这两行将当前数据库设置为 database_name,以便在database_name 数据库中创建稳定队列。该稳定队列表由数据库所有者拥有。

3 Adaptive Server Enterprise 服务器运行脚本。切换到保存稳定队列脚本的目录,并输入下面的命令行(应在一行中输入该命令的所有内容)以运行该脚本:

isql -S server-name -U login_id -P password -Istableq.sql -o logfile

其中 server-name Adaptive Server Enterprise 的名称,login_id password 对应于拥有服务器上系统管理员权限且拥有此数据库的用户,而 logfile 是保存来自脚本的日志信息的日志文件名。login_id 必须符合消息代理所使用的名称。有关详细信息,请参见消息代理和复制安全性。

4 检查日志文件以确认表和过程创建成功,并且没有错误。

5 Starting Open Server

Ssqueue -c “eng=HQSERVER;dbn=HQDB;uid=sa;pwd=’’” -cq “eng=QUEUE_DB_SRV;dbn=QUEUE_DB;uid=sa;pwd=’’” -dl -os 2M -v -o “C:\output.log”  SSQUEUE

6 Change procxmode

       sp_procxmode ‘procedure name’ ,’chained’

从数据库卸载稳定队列:

1 以拥有 dbo 权限的用户身份连接到包含稳定队列的数据库上。

2 运行 sp_queue_drop 存储过程来删除除该过程本身之外的所有

稳定队列对象。sp_queue_drop 过程是与其它稳定队列对象一起安装的。

exec sp_queue_drop

go

3 删除 sp_queue_drop 过程本身以完成卸载过程。

drop procedure sp_queue_drop

go

 

稳定队列恢复问题

将稳定队列放在单独的数据库中会使备份和恢复变得复杂,因为必须恢复两个数据库的一致版本。

常规的恢复会自动将两个数据库恢复到一致的状态,但从介质故障中进行恢复时则需要小心一些。在恢复数据库转储和事务转储时,务必将稳定队列恢复到一个一致点。

为了帮助从介质故障中进行恢复,稳定存储数据库中提供了两个过程:

1 sp_queue_dump_database 每次从事务日志中扫描到转储数据库时,都将调用该过程。

2 sp_queue_dump_transaction 每次从事务日志中扫描转储事务时,都将调用该过程。

您可以修改这些存储过程,以便在稳定存储数据库中发布 dump database dump transaction 命令。

 

设置 SQL Remote Open Server

本节描述如何使用 SQL Remote Open Server 设置 SQL Remote 系统。具体过程取决于 SQL Remote 稳定队列是保留在与所复制表不同的Adaptive Server Enterprise 数据库中,还是保留在同一 Adaptive Server Enterprise 数据库中。

有关稳定队列位置的详细信息,请参见稳定队列。

数据的初始副本设置过程假定您使用抽取实用程序生成每一远程数据库中数据的初始副本。您必须确保不使用 Replication Server 初始化同步功能来用于此目的。

设置 SQL Remote Open Server 的过程分为两个阶段:

? 准备 SQL Remote 设置 此阶段取决于您当前是否已安装 SQLRemote

? SQL Remote Open Server 添加到设置中不论是否具有以前的安装,此阶段都是相同的。

? 准备 SQL Remote 设置(如果您当前已安装 SQL Remote):

1 在安静的主数据库上,使用消息代理将所有余下的事务扫描到稳定队列中。

安静数据库是这样的数据库:在该数据库中,消息代理和 SQL Remote Open Server 都未运行,并且没有复制任何事务。

2 请遵守升级用于 Adaptive Server Enterprise SQL Remote 一节中介绍的步骤,在统一的站点升级您的 SQL Remote 软件。

3 使用以下命令使消息代理截断点在统一数据库无效:

dbcc settrunc( 'ltm', 'ignore' )

4 在稳定队列数据库中,执行存储过程

sp_queue_log_transfer_reset

 

  1. If the SQL Remote stable queue is in a separate database:
    • Set up the stable queue database as a replicate database in a Replication Server setup. This will create the tables and procedures needed by Replication Server, such as rs_lastcommit.
    • Drop the Replication Server connection to the stable queue database.
  2. Add an entry to your interfaces file for the SQL Remote Open Server. The default name used on the SQL Remote Open Server command line is SSQueue.
  3. Start the SQL Remote Open Server.
  4. Create a Replication Server connection to the SQL Remote Open Server. The user ID and password for this connection must match the user ID and password specified on the SQL Remote Open Server command line for the stable queue connection (that is, the -cq switch, or -c if -cq is not specified).

Configure Replication Server now    
You should configure Replication Server for this connection at this point. For a description, see .

  1. Connect to SSQueue.Queue

create connection to SSQueue.QUEUE

    set error class rs_sqlserver_error_class

    set function string class rs_sqlserver_function_class

    set username sa

    set password ‘’

  1. Define, activate, and validate Replication Server replication definitions and subscriptions for the SQL Remote tables sr_marker, sr_remoteuser, sr_subscription, and sr_passthrough. The script ssremote.rs is a sample script to perform this task. You will need to edit the server and database names in the script to match your names.

If the SQL Remote system tables have any data in them, create the replication definitions so that no materialization happens.

For information on creating replication definitions with no materialization, see the Replication Server Administration Guide. The section in Chapter 7, Managing Subscriptions entitled Bulk Materialization describes how to set up Replication Server for the case where data exists at a remote database.

  1. Define, activate, and validate replication definitions and subscriptions for the tables in your database that need to be replicated by SQL Remote. These must be created without materialization.

配置 Replication Server

本节描述如何配置 Replication Server 来用于 SQL Remote Open Server SQL Remote Open Server Replication Server 连接必须设定几个配置参数。

设置 dsi_xact_group_size 参数

缺省情况下, Replication Server 将多个事务组合成较大的事务。

dsi_xact_group_size 参数控制组合事务的最大大小。

dsi_xact_group_size 参数必须设置为 -1,以禁用事务分组。在 SQL Remote 设置中,源于不同远程数据库的事务不得组合在一起。

如何设置参数您可以使用以下语句设置参数:

CONFIGURE CONNECTION TO "ssqueue_server"

SET dsi_xact_group_size TO '-1'

 

ALTER CONNECTION TO  SSQueue.QUEUE

     SET dsi_xact_group_size TO '-1'

 

ALTER CONNECTION TO  SSQueue.QUEUE

     SET dsi_fadeout_time TO '-1'

 

 

设置 dsi_num_threads 参数

SQL Remote Open Server 不支持多个 DSI 线程。Replication Server 不应配置为在 SQL Remote 连接上使用多个 DSI 线程。

SQL Remote 数据创建复制定义

用于 SQL Remote 所复制的表的复制定义必须具有某些特性。本节将描述这些特性。

在某些情况下, SQL Remote UPDATE 操作复制为 INSERT DELETE (请参见更新的复制)。这在 Replication Server 文档中称作预

订迁移。为了将 UPDATE 复制为 INSERT SQL Remote 要求该行的完整前像。这意味着,在对可能需要被复制为 INSERT 的表的任何UPDATE (更新)的 WHERE 子句中, Replication Server 必须指定每一列的值。

配置 Replication Server

达到此目的的最简单方法是在复制定义的 PRIMARY KEY 中列出所有列。这促使 Replication Server 在每一更新的 WHERE 子句中包括每一列。REPLICATE MINIMAL COLUMNS 可用于这些复制定义,以免在更新的 SET 子句中设置所有列。

文本和图像列Replication Server 在复制定义的主键中不接受 TEXT IMAGE 列。您应该在复制定义的 PRIMARY KEY 列表中包括除 TEXT IMAGE 列之外的所有列,并且在 ALWAYS_REPLICATE 子句中指定所有 TEXT IMAGE 列。您应该在复制定义中使用 REPLICATE ALL COLUMNS,而不要使用 REPLICATE MINIMAL COLUMNS。这促使 Replication Server TEXT IMAGE 列的前像发送到 SQL Remote Open Server,无论是否发生更新。

使用dsi_sql_data_style 数据样式

Replication Server 11.5 具有用于 SQL Remote 的新的dsi_sql_data_style。此数据样式自动在每一 UPDATE WHERE 子句中包括所有列。不必在复制定义的 PRIMARY KEY 中列出所有列。使用 REPLICATE MINIMAL COLUMNS 的复制定义防止 Replication Server 保留被更新的行的完整前映像,这样, SQL Remote dsi_sql_data_style 将不处理 REPLICATE MINIMAL COLUMNS

挂起和重新开始连接在配置与 SQL Remote Open Server Replication Server 连接后,您应该挂起并恢复该连接,以便参数设置可以生效。以下命令可完成此任务:

suspend connection to ssqueue_server

go

resume connection to ssqueue_server

go

 

13 SQL Remote Replication Server 一起使用

 

其它问题

本节列出了与将 SQL Remote Replication Server 一起使用有关的其它问题。

运行消息代理 应通过命令行选项来运行消息代理,以进行接收和发送(-r -s)。这可以防止消息代理尝试扫描事务日志。如果在复制代理正运行时消息代理尝试扫描事务日志,则在尝试保留 [日志传送上下文] 时会显示一条错误消息。

SQL Remote Open Server 中的过程调用 SQL Remote Open Server 将其从 Replication Server 接收的所有过程调用都传送到稳定队列数据库中。

例如,在稳定队列数据库中执行 rs_get_lastcommit rs_update_lastcommit

协调转储 Replication Server 提供在主数据库和稳定队列数据库之间协调数据库转储和事务日志转储的机制。rs_dumpdb s_dumptran 函数字符串可用于执行稳定队列数据库的协调转储。有关详细信息,请参见 Replication Server 文档。

模式更改 如果您对 SQL Remote 系统进行任何模式更改,则必须在安静系统上执行这一更改。这包括关闭 SQL Remote Open Server

阅读(1339) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~