Академический Документы
Профессиональный Документы
Культура Документы
Index ........................................................................................... 69
A typical high availability disaster recovery (HADR) configuration consists of two or more
servers: one designated as the primary, on which all transaction processing takes place; the
others as standby, which act as warm standbys for the primary server and contain copies of
designated databases from the primary server.
Note: This release supports only a single standby server.
Some high availability solutions (for example, the Adaptive Server® Cluster Edition) share or
use common resources between nodes. However, HADR is a "shared nothing" configuration:
each node has separate resources, including disks.
In an HADR system, servers are separate entities, and data is replicated from the primary
server to the standby server. If the primary server fails, a standby server is promoted to the role
of primary server either manually or automatically. Once the promotion is complete, clients
can reconnect to the new primary server, and see data as on the previous primary server.
Note: This release supports only a manual promotion.
Servers can be separated geographically, which makes an HADR system capable of
withstanding the loss of an entire computing facility. For example, your system may include a
primary server that is located in San Francisco and a standby server in North Dakota, ensuring
that if the primary server is destroyed, the standby server is safe and ready to assume control.
Additionally, an HADR system includes Replication Server, which synchronizes the
databases between the primary and standby servers. Adaptive Server uses the Replication
Agent to communicate with Replication Server, and Replication Server uses Open Client
connectivity to communicate with the standby Adaptive Server.
The Replication Agent detects any data changes that are made on the primary server, and sends
them to the primary Replication Server. In the figure below, the unidirectional arrows indicate
that, although both Replication Servers are configured, only one direction is enabled at a time:
The most fundamental service offered by Adaptive Server HADR is the planned failover from
the primary to the standby server, which allows maintenance activity to occur on the old
primary server, while applications continue on the new primary.
HADR provides protection in the event of a disaster: if the primary server is lost, the standby
server can be used as a replacement. Client applications can be switched to the standby server,
and the standby server is quickly available for users, although there may be a data loss.
You can configure applications running in an HADR system to retrieve and maintain a list of
addresses of the HADR members, and to receive asynchronous updates concerning any
changes to the configuration. Applications distinguish between the primary and the standby
server, and refrain from connecting to the latter unless the primary is unreachable. Connection
attempts to the standby server without the necessary privileges are silently redirected to the
primary via the login redirection mechanism, which is supported by connectivity libraries
SAP® ERP runs on Adaptive Server configured for HADR. Configure and administer HADR
using either isql to administer HADR outside the Business Suite, or the SAP Disaster
Recovery Agent (DR Agent) to configure HADR inside the Business Suite:
• in isql – to administer HADR outside the Business Suite. Use the sp_hadr_admin system
procedure. sp_hadr_admin is created when you run installmaster, but you must
also enable HADR before this system procedure is available for use.
• DR Agent – to administer HADR inside the Business Suite. Client applications connect to
the DR Agent through its TDS interface (ODBC, JDBC, or Open Client). The DR Agent
uses JDBC to communicate with the servers on either host, and to other DR Agents in the
HADR system.
For complete information , see the DR Agent Users Guide.
Note: The commands described in this manual are for reference. SAP recommends that you
use the SAP tools for administering and configuring the HADR sytem. SAP tools are wrappers
around DR Admin tools, which, in turn, are wrappers for the sp_hadr_admin system
procedure
Note: If Adaptive Server is configured for password encryption (that is, net password
encryption reqd is set to a value other than "DEFAULT"), you must also set encryption as a
server option on any remote HADR servers:
sp_serveroption server_HADR_nameDR, 'net password encryption', true
To view the current local member list from the primary or standby server, issue:
sp_hadr_admin listserver
This example output shows the current member list for the Sybase_HADR system:
name network_name
-------------- ----------------------------
server1 server1
server2 server2
The check connects to and queries each configured HADR member. If a remote HADR
member in the group is identified as an existing primary server, the check does not allow the
local server to be promoted to the primary server. Generally, you cannot override this check.
If the check fails to connect to one or more remote HADR member, it assumes that the
unreachable member may be a primary server, and refuses to promote the local server to
primary. In this situation, you can use the force parameter to override the split-brain check:
sp_hadr_admin primary, force
Before using the force parameter, verify that there is no other primary server present in the
group.
This example shows output from monHADRMembers for HADR group MYGRP:
select * from monHADRMembers
GroupName
ServerName
Mode
State
ServerMap
------------------------ ------------------------------------
------------------------ -------------------------------------
------------------------------------------------------------
------------------------------------------------------------
---------------------------------------------------------------
MYGRP LONDONDR
Standby Inactive
tcp asekernel1 17682
MYGRP PARISDR
Primary Active
tcp asekernel1 17672
Use admin sqm_process_time to monitor Replication Server. See the Replication Server
Reference Manual.
See the Performance and Tuning Series: Monitoring Tables for information about configuring
and querying the Adaptive Server monitoring tables.
Note: When you include the force parameter, the HADR system forcibly terminates all the
transactions started by privileged and unprivileged connections. Unprivilged connections
cannot start new transactions when the server is in the deactivating state.
To determine the external mode of the server, view the @@hadr_mode global variable, which
returns:
HADR Mode Value HADR Mode Name Description
-1 Disabled HADR is disabled.
To determine the internal state of the server, view the @@hadr_state global variable, which
returns:
HADR State Value HADR State Name Description
0 Unknown HADR is in an unknown state.
This value is typically returned
when HADR is in disabled
mode.
1 Active Primary server allows transac-
tion processing from user appli-
cations, but may not be actively
replicating data.
2 Inactive Server is inactive, and does not
allow transaction processing
from user applications.
3 Deactivating The server is changing from the
active to the inactive state, and
the log is being drained. Even-
tually, the mode should transi-
tion to the inactive state. If de-
activation times out, the mode
may switch back to the active
state.
Use the primary parameter to move a server from standby to primary mode. The primary
parameter verifies that the system does not already contain an existing primary server by
connecting to each member in the group and querying for its mode. If any server identifies
itself as the primary server, or if the sp_hadr_admin command cannot connect to any member
in the system, the command fails and leaves the mode of the standby server unchanged.
Use the force parameter to promote a server to primary mode if some servers are unreachable.
The new primary server remains in the inactive state until you explicitly activate it to allow
user transaction processing. However, if a server is reachable and identified as the primary
server, promoting the local server to a primary role fails, even if you include the force
parameter.
Use the standby parameter to change a server's mode from primary to standby. The server
must already be in the inactive state.
You can also set the mode of the servers (from primary to standby or vice versa) using the
sp_configure HADR mode configuration parameter. Set HADR mode to 1 on the primary and
0 on a standby server (the value for HADR mode on a non-HADR server is -1). You must restart
the server for the change to HADR mode to take effect.
Note: You cannot use the HADR mode configuration parameter to start a server as the primary
server if any standby servers are unreachable.
You can designate a server as a primary either at start-up, or manually once the server is
running:
• At start-up – if HADR mode is set to 1 (primary), the server checks the member list in
sysservers and the value for @@hadr_mode for each server in the list. If the variable
is set to 1 for any of the servers other than the one you are starting, or if any of those servers
are unreachable, the server that is starting resets HADR mode and @@hadr_state to 0,
writes a message to the error log, and completes the start-up process in standby mode. You
can then manually promote the server you are starting to primary mode. However, if all the
remaining members are running and in standby mode, the server that is starting promotes
itself to primary mode without manual intervention.
• Manually – privileged users can issue sp_hadr_admin primary to promote a standby
server to primary mode. sp_hadr_admin primary verifies the member list in
sysservers and the value for @@hadr_mode for each member in the list. However,
sp_hadr_admin primary does not promote the current server to primary mode if any of the
remaining members are unreachable or already designated as the primary. If this occurs,
use the force parameter to promote a standby server to primary mode.
The manage hadr privilege allows users to manage the HADR configuration using
sp_hadr_admin:
• If you have not enabled granular permissions, users who have the sa_role also
automatically have manage hadr permissions.
• If you have enabled granular permissions, you must specifically grant users manage
hadr permissions.
Truncate any table Truncate any table sa_role, alias to dbo, or replica-
tion_role
Impersonate original user to ex- set session authorization set session authorization
ecute DDL or system procedure
Write to an inactive server that allow HADR login priv- sa_role or allow HADR
is in soft quiesce mode ilege login privilege
The HADR system must halt database processing activity (called a soft quiesce) on the
primary server before it can perform a seamless planned application failover to the standby
server. During this process, the primary server is in the deactivating state, and Adaptive Server
prevents most database transactions from starting.
Only privileged users can perform transactions on servers that are in the inactive state.
Internally, some transactions (for example, housekeeper) still may occur.
During a soft quiesce, the HADR system halts transaction processing in an orderly manner;
allowing ongoing transactions to proceed until the specified timeout, but disallowing new
transactions by unprivileged connections. After the primary server reaches the inactive state,
threads from the primary server's Replication Agent drain the HADR database transaction
logs (unless you issued sp_hadr_admin deactivate with the nodrain parameter). Once the log
is completely drained, the inactive primary is ready for failover.
Before you can promote a standby server to a primary server, you must first demote the
original primary server to standby.
To move a server to the inactive state, issue sp_hadr_admin deactivate. For example:
sp_hadr_admin deactivate, '10', 'label'
(return status = 0)
User connections statistics:: 0 in xact, 0 in chained mode, 1 in
unchained mode, 0 holding server si
de cursors.
Server reached INACTIVE state.
Initiating log drain mechanism.
Command 'deactivate' successful.
(1 row affected)
label should be a meaningful string that is associated with the current deactivation operation,
and should be distinct from previous labels you used (for example,
"scheduled_offline_07092013"). The Replication Server subsystem uses the label when it
replicates data from the primary server to the standby server.
Use the sp_hadr_admin system procedure from the isql command line to manually install,
configure, and administer the HADR system.
Software Version
1. Disable trunc log on chkpt on the master and all other databases participating in the
HADR system. For example, for the D01 database, enter:
sp_dboption D01, 'trunc log on chkpt', false
2. Enable FIPS password storage on the primary and standby servers:
sp_configure 'FIPS login password encryption', 3
3. To require all connections to send encrypted passwords, issue the following command on
both the primary and standby servers:
sp_configure 'net password encryption reqd', 3
A value of 3 for net password encyption reqd configures Adaptive Server for strong
encryption. See net password encyption reqd in Setting Configuration Parameters in the
System Administration Guide: Volume 1.
All subsequent connections to the primary and standby server must include the isql -X
parameter, which initiates the login connection to the server with client-side password
encryption. -X enables extended password-encrypted connections and password-
encrypted connections without plain text password reconnection. isql -X specifies to the
server that you require password encryption. The server returns an encryption key, which
isql uses to encrypt your password. The server uses the same key to authenticate your
password when it arrives.
If isql fails, the system creates a core file that contains your password. If you did not
include the encryption option, the password appears as plain text in the file. If you used the
encryption option, your password is not readable.
4. To allow Adaptive Server to mark large databases for replication, add the -T9149 trace flag
to the primary and standby runserver files (See the Adaptive Server Configuration Guide
for your platform).
5. Restart the primary and standby servers.
1. Create the maintenance user. This example creates a maintenance user named
D01_maint:
use master
create login D01_maint with password Sybase123
sp_role "grant", replication_role, D01_maint
2. Grant the replication_role to the maintenance user, enabling it to replicate the
truncate table command.
3. Use sp_addalias to alias the maintenance user to the database owner on the master and
user databases, allowing this user to update tables that use IDENTITY columns.
4. Grant the sa_role to the maintenance user so it can replicate insert, update, and delete
operations on all tables:
sp_role "grant", sa_role, D01_maint 1
5. Create a new role named sap_maint_user_role:
create role sap_maint_user_role
6. Grant set session authorization permissions to the maintenance user,
allowing it to become another user when applying DDL commands to the replicate
database. The permission must be granted to a user or a role, not a login:
grant set session authorization to sap_maint_user_role
7. Alias D01 _maint to the database owner in the master and user databases:
sp_addalias D01_maint, dbo
8. Automatically activate the maintenance user role upon login:
a. Grant the sap_maint_user_role to the maintenance user:
sp_role "grant", sa_maint_user_role, D01_maint
b. Automatically activate the maintenance user role at login:
Note: You must also set the local server name for all HADR nodes (that is, select
@@servername cannot return NULL).
See also
• Chapter 6, Upgrading Adaptive Server in an HADR System on page 39
• Chapter 8, sp_hadr_admin Syntax on page 61
Prerequisites
You must add the HADR user as a remote login once for each remote HADR server. See
"Adding the HADR User Login."
Task
Note: If the Adaptive Servers are using password encryption (that is, net password
encryption reqd is set to a value other than DEFAULT), all servers in the HADR group must
have encryption set as a server option:
sp_serveroption server_HADR_name 'net password encryption', true
On all servers:
If there are no initialized HADR groups, the HADR system launches, in starting
mode.
2. Create the HADR user login:
create login 'user_name' with password 'password'
3. Initialize the HADR group:
sp_hadr_admin 'init','group_name','local_HADR_server_name'
Note: No additional steps are necessary if you are configuring a standby server.
5. If you are configuring a primary server, promote it to primary mode:
sp_hadr_admin 'primary','force'
You must include the force parameter if any of the HADR nodes added in step 5 are not
online.
6. Activate the primary server:
sp_hadr_admin 'activate'
Materializing a database creates an initial copy of data from one site to the other. Once
completed, the replication software maintains the accuracy of the target site by continuously
applying changes that occur after materialization completes. The tasks required to materialize
a database depends on the type and size of the database.
See your Replication Server Administration Guide for instructions about materializing
databases.
After you have materialized the master database, use bcp to copy these tables to the standby
server:
• syslogins
• sysloginroles
• sysremotelogins
• syssrvroles
• sysusers
• sysroles
• sysalternates
• sysattributes
• sysprotects
• syservers
Before promoting a standby server to primary mode, use sp_hadr_admin propagate to ensure
that the standby server fetches the latest member list from the current primary server when it
starts. Member lists may get outdated if a standby server was unreachable when the primary
published its latest member list.
sp_hadr_admin propagate does not accept any arguments, but increments the generation
number in the member list (even if nothing else has changed) and distributes the member list to
member servers and clients that use the HADR capabilities.
However, if you issue sp_hadr_admin propagate when the generation number is up to date,
the command propagates the current configuration to the specified standby members without
notifying client connections with the hadr_list_cap capability set.
Use nopropagate to prevent the HADR system from propagating member list changes to the
standby servers. Member list changes are updated for user connections when you use
nopropagate.
For an SAP Business Suite for Adaptive Server disaster recovery solution, use the Disaster
Recovery (DR) Agent, which supports automated setup and configuration, monitoring, and
administration capabilities.
See the DR Agent Users Guide for a complete description of starting, stopping, and
administering the HADR system with the DR Agent.
Once you configure the HADR system (that is, after the ERP database materialization),
sysservers should have one entry for an HADR group, and two entries for HADR
servers. These entries should change only when DR Agent issues sap_disable_replication or
sap_teardown.
sap_disable_replication removes the remote HADR server entry for both the primary and
standby servers. sap_teardown removes all HADR entries.
Note: After replication is reenabled, the remote HADR server is not added to the
sysservers table until ERP database materialization completes.
The expected HADR group and HADR server entries in the sysservers table, depending
on the phase of DR setup, are:
DR Setup srvs srvname srvnetname srvcla
Phase ta- ss
tus
Post ERP materi- 8 SID_group SID_local_logi- 17
alization (on pri- cal_ASE_hostDR
mary or standby
servers) 9 SID_primary_logi- primary_physi- 16
cal_ASE_hostDR cal_ASE_host :ASE_port
0 SID_standby_logi- standby_physi- 16
cal_ASE_hostDR cal_ASE_host :ASE_port
Post disable (on 8 SID_group SID_local_logi- 17
primary) cal_ASE_hostDR
9 SID_primary_logi- primary_physi- 16
cal_ASE_hostDR cal_ASE_host :ASE_port
Post disable (on 8 SID_group SID_local_logi- 17
standby) cal_ASE_hostDR
9 SID_standby_logi- standby_physi- 16
cal_ASE_hostDR cal_ASE_host :ASE_port
Post enable (on 8 SID_group SID_local_logi- 17
primary) cal_ASE_hostDR
9 SID_primary_logi- primary_physi- 16
cal_ASE_hostDR cal_ASE_host :ASE_port
Post enable (on 8 SID_group SID_local_logi- 17
standby) cal_ASE_hostDR
9 SID_standby_logi- standby_physi- 16
cal_ASE_hostDR cal_ASE_host :ASE_port
Post ERP Mat (on 8 SID_group SID_local_logi- 17
primary or stand- cal_ASE_hostDR
by)
1. Verify that:
• The DR_admin user and the replication maintenance user have the allow hadr
login privilege.
• Both Adaptive Servers are set to disabled mode (if HADR is enabled, a server could
belong to a different HADR environment).
• The HADR state after processing is set to disabled mode.
2. Issue these commands from either the DR Agent or from isql:
sap_set
sap_set_host
sap_pre_setup_check
sap_setup_replication
Performing Materialization
Once the materialize command processes the ERP database (that is, the primary Business
Suite database), the DR Agent automatically configures the Adaptive Server HADR system.
If the materialize command includes the username and password parameters, the DR Agent
verifies that the user on the standby Adaptive Server has the allow hadr login privilege.
The DR Agent allows the materialize command to continue regardless of the HADR mode or
state on either Adaptive Server, which supports reissuing the materialize command to finish
the process when an error occurs, or after a disable or enable process.
1. The DR Agent configures the HADR system on both Adaptive Servers, and the HADR
setup is performed after the dump and load process. For each Adaptive Server, the DR
Agent:
Performing Failover
Failover switches the HADR primary and standby settings between the Adaptive Servers. If
the primary site is not available, the failover process might need to promote the standby site
without deactivating the primary site.
The DR Agent verifies that the source and target hosts identified in the sap_failover and
sap_host_available commands match the HADR settings. The source host, if available, must
be set to the HADR primary site, and the target host must be set to the HADR standby site.
sap_failover:
1. Deactivates the source Adaptive Server, if the source host (the machine on which Adaptive
Server runs) is available:
sp_hadr_admin ‘deactivate’, 'timeout', 'label'
2. Demotes the source Adaptive Server:
sp_hadr_admin ‘standby’
3. Verifies the label.
4. Promotes the target host:
sp_hadr_admin 'primary'
The DR Agent runs the sap_host_available command when the original primary Adaptive
Server is back online and ready to assume the role of the standby Adaptive Server. The original
primary Adaptive Server is demoted to standby mode when it starts, because the other
Adaptive Server is now configured as the primary.
1. On the HADR primary Adaptive Server, drop the standby Adaptive Server from the
HADR server list:
sp_hadr_admin dropserver
2. If the HADR standby Adaptive Server is available, drop the primary Adaptive Server from
the HADR server list on the standby Adaptive Server:
sp_hadr_admin dropserver
3. Issue select @@hadr_mode and select @@hadr_state to verify that: :
• The source Adaptive Server is set to primary mode and an active state.
• The target Adaptive Server is set to standby mode and an inactive state.
Performing Teardown
Use the teardown process to delete the replication environment, disable the Replication Agent
threads, and disable the HADR system on Adaptive Server.
sap_teardown automatically:
1. Demotes the source Adaptive Server, if the source host (the machine on which Adaptive
Server runs) is available:
sp_hadr_admin 'standby'
2. Drops all servers from the HADR server list on both Adaptive Servers:
sp_hadr_admin dropserver
3. Drops the HADR group from both servers:
sp_hadr_admin dropgroup
4. Disables HADR on both servers:
sp_configure ‘HADR mode’, -1
5. Disables CIS RPC Handling:
sp_configure ‘cis rpc handing’, 0
After issuing the sap_teardown command, verify that the HADR state is inactive on both
Adaptive Servers. If you restart Adaptive Server server at this point, the HADR mode changes
to unknown.
Issue:
• sap_help to display commands and usage information.
• sap_version all to display the versions of all Adaptive Server, Replication Servers, DR
Agents running on the HADR system
• sap_set to display all the settings in the environment including ports, host names, and user
names.
• sap_status path to display the path state, or status of replication along a path.
View the log file to see commands sent to DR Agent and the servers in the replication
environment. The log file is located at $SYBASE/SCC-3_2/plugins/DR/log.
See the DR Agent Users Guide.
Sybase Replication Server documentation can be found here http://infocenter.sybase.com/
help/index.jsp?topic=/com.sybase.infocenter.help.rs.15.7.1.sp100/doc/html/title.html
Installation Issues
Known installation issues are:
• Verify the standby SAP system is stopped before installing the primary servers. Issue this
command to stop the standby system:
stopsap r3
• If the SAP installer encounters an error when configuring the HADR environment:
1. View the SAP installation log for errors, which contains the error as seen from the SAP
installer point of view.
2. If you cannot resolve the error, examine the DR Agent error log on the host running the
primary Replication Server. The log is located in $SYBASE/SCC-3_2/plugins/
DR/log.
3. Examine the Adaptive Server and Replication Server error logs for any errors or
installation information.
4. Once you resolve the error, retry setup by selecting the Retry button in the SAP
Installer (see your SAP installation documentation).
• If the database you materializing is in use:
1. Log into the standby Adaptive Server and issue sp_who to determine which process or
processes are using the database.
2. Each process in the sp_who output has an associated user (see the Adaptive Server
Reference Manual: Procedures).
3. Determine which users are using the database being materialized.
4. Have these users log off the server to remove the process. If necessary, use the kill
command to remove the process. For example, to kill process number 1378, issue:
kill 1378
• Adaptive Server Dump Directory – The DR Agent cannot validate the location or
permissions of the dump directory when Adaptive Server and the Replication Server are
located on separate host computers.
• .sqlanywhere12 Directory – Replication Server uses a SQL Anywhere database to
host the embedded RSSD. When you create the SQL Anywhere database, a directory
named .sqlanywhere12 is created in the user’s home directory. Because the SQL
Anywhere eRSSD functions correctly if this directory is deleted,. you need not backup this
directory. SQL Anywhere write the directory in another location if the home directory
does not exist.
Prerequisites
Check the queue processing time (see admin sqm_process_time in the Replication Server
Reference Manual). If can fail over within the allotted time constraints, change the state of the
primary server to inactive.
Task
1. Deactivate the primary server:
sp_hadr_admin deactivate, 'timeout', 'label'
2. Check that all HADR databases have been drained by the Replication Agent on the
primary server:
sp_hadr_admin status
3. Verify that replication is complete on the standby server by issuing, on the standby server:
sp_hadr_admin status, 'label'
4. Move the current primary server to the standby role. On the primary server, issue:
sp_hadr_admin standby
5. Move the standby server to primary mode. The new primary server remains in an inactive
state and does not allow any transaction activity by unprivileged connections. On the
standby, issue:
sp_hadr_admin primary
6. Reverse the direction for replication (see the Replication Server Reference Manual for
information about commands below).
a) Start replication from the new primary server (which was the old standby server) for
each HADR database:
1. Enable the secondary truncation point in each HADR database in the primary
server:
dbcc settrunc(ltm, 'end')
2. Start the Replication Agent in each HADR database in the primary server:
sp_start_rep_agent database_name
b) Stop replication from the new standby server (which was the old primary server) for
each HADR database:
1. Stop the Replication Agent in each HADR database in the standby server:
sp_stop_rep_agent database_name
2. Disable the secondary truncation point for each HADR database in the standby
server:
See also
• Chapter 6, Upgrading Adaptive Server in an HADR System on page 39
• Chapter 8, sp_hadr_admin Syntax on page 61
admin health makes no report if Replication Agent has drained its log. However, admin
quiesce_check returns a message similar to this if the log is not drained:
admin quiesce_check
Msg 4076, Level 12, State 0:
Server 'ost_replnxb15_02':
RSI is not quiesced. RSI for 16777318:0 sent 3067 unacknowledged
bytes
When the log is drained, move the standby server to primary mode. The new primary remains
in the inactive state and does not allow any transaction activity from unprivileged connections.
On the standby server, issue:
sp_hadr_admin 'primary'
Set the Secondary Truncation Point and Start the Replication Agents
1. Enable the secondary truncation point in each HADR database in the new primary server:
dbcc settrunc(ltm, 'end')
2. Start the Replication Agent in each HADR database in the new primary server:
sp_start_rep_agent database_name
Upgrading an Adaptive Server to a new version in an HADR system requires that you perform
a number of prerequisites, including upgrading the standby Adaptive Server, and finally,
upgrading the primary Adaptive Server.
Before you begin the upgrade steps:
• If you have disabled the sa login and use a different user to perform system administration,
ensure that login has the allow hadr login privilege so it is not redirected to the
primary server when connecting to the standby server.
To verify that the user has the allow hadr login, issue:
select has_privilege("allow hadr login")
or:
sp_helprotect
To grant the allow hadr login privilege to the sapsso role, issue this command, as
sa:
grant allow hadr login to sso_role
• Verify that login redirection is disabled when you connect to Adaptive Server to perform
administration or configuration activities so that, if allow hadr login is not granted,
logins to the standby server fail instead of moving to the primary server. For example, use
isql to set this property:
[isql] CS_PROP_REDIRECT = CS_FALSE in $SYBASE/$SYBASE_OCS/config/
ocs.cfg
• Use select asehostname to verify the host to which you connect.
To verify the host for the sapsso user, log in as sapsa and issue this command on both the
primary and standby servers:
grant select on asehostname to sso_role
• For ERP configuration, the sapsso user does not have the allow hadr login
privilege. This restriction prevents accidental changes on the standby server.
To unlock the sa login that is used for the Adaptive Server upgrade (and lock it afterwards):
1. Log in to the standby server as sapsa and issue:
grant allow hadr login to sso_role
2. Log in to the standby server as sapsso and unlock the sa login,
3. Log in to the standby server as the sa user and perform the upgrade steps.
4. Log in to the standby server as sapsso and lock the sa login.
5. Log in to the standby server as sapsa and issue:
See also
• Chapter 8, sp_hadr_admin Syntax on page 61
• Initializing the HADR Nodes on page 19
• Performing a Planned Failover on page 34
1. Log in to the standby Replication Server and suspend replication to the databases that are
participating in the HADR system:
suspend connection to server_name.database_name
For example, this suspends replication for the D01 and master databases on the
D01_standby server:
suspend connection to D01_standby.D01
suspend connection to D01_standby.master
2. Upgrade Adaptive Server following the instructions in the Adaptive Server Enterprise
Installation Guide for your platform.
3. Log in to the standby Replication Server and resume replication to the participating
databases:
resume connection to server_name.database_name
For example, this resumes replication for the master, SID, and saptools databases on
the D01_standby server:
resume connection to D01_standby.D01
resume connection to D01_standby.master
resume connection to D01_standby.saptools
SDK 15.7, Open Client 15.7, and Open Server 15.7 support Adaptive Server HADR.
DR Map Callback
When a DR map callback routine is installed on a server connection that supports DR map
messages, the callback routine is called asynchronously when the DR map changes.
The call signature:
CS_RETCODE CS_PUBLIC (*CS_DR_MAP_CB)(CS_CONNECTION
*conn, CS_INT info_count, CS_CTLINFO_T *info_ptr)
This callback routine must be installed before connecting to the server. Installing this callback
sets the CS_RESP_LIST_DR_MAP capability, which requests that the server send DR map
information messages.
If the server being connected to has existing map information, the routine is called during
ct_connect(). At anytime during the connection, including during the ct_close() call, the
callback routine may be invoked.
Client-Library has removed the need for the application to look at the parameter name unless it
is an unknown parameter that is added in the future release. Applications use CTL type
information to determine the parameter significance.
The message parameter contains the mapping information. To attach semantic meaning to the
various values, Client-Library examines the parameter names and map them to CTL types.
Then the application applies the defined meaning to the value. For example, Servername
for CS_CTL_DSNAME.
CS_CTLINFO_T Parameters
The expected parameter names that Adaptive Server sends correspond to the
CS_CTLINFO_T field.
Data Source Address A valid address for the CS_CTL_ADDRSTR Character string
most recently viewed
Data Source Name.
Multiple Data Source
Address parameters
can follow a Data
Source Name. The for-
mat of the address is
“protocol address”, for
example, tcp server-
host 3000.
…
}
}
validate values and perform post-processing
return CS_SUCCEED
}
Note: The group name and generation number can be examined before the for loop, since they
are expected to be the first two entries in the array. However, Open Client does not enforce this.
The only time you expect to see a map sent from the server with a previously seen generation
number is during login.
Capabilities Description
CS_RES_DR_NOKILL This response capability requests the server to not terminate the connec-
tion when terminating new commands sent to the primary server, if the
server is active or inactive.
Simultaneously, this capability also allows logins to the primary server.
The default connection of the server is inactive. The connection survives
until the server becomes active or a new primary server is chosen. The
server defines the usage of this capability.
This capability modifies the messages that an application receives, and
enables queue operation on the server. See the server documentation.
CS_ This response capability requests the server to send the DR map infor-
RES_LIST_DR_MAP mation at login or when the DR map is updated. This information may be
sent asynchronously from the server. This bit is set only if there is a
CS_DR_MAP_CALLBACK handler installed. Any direct attempt to set
this bit through ct_capability(), is silently ignored.
• None (or false) – jConnect does not record any HADR state change messages.
• HADR_MAP – jConnect requests the Adaptive Server to send the HADR address list to the
application upon login as well as asynchronously when the list is modified, informing the
application of the available primary and standby servers, and whether any companion
servers are available.
• HADR_NOKILL – by setting this property jConnect requests Adaptive Server, not to
terminate an existing connection while current primary is deactivating or deactivated. The
connection will not be reset by Adaptive Server, until a new server is made Primary.
• HADR_NOKILL_WITH_MAP – jConnect requests the Adaptive Server to not terminate the
connection. When cancelling new commands is issued by the connection while the
primary is in deactivated state or undergoing deactivation. Additionally,
HADR_NOKILL_WITH_MAP requests Adaptive Server to send the HADR address list to
the application upon login as well as asynchronously when the list is modified, informing
the application of the available primary and standby servers, and whether any companion
servers are available. HADR_NOKILL_WITH_MAP property is equivalent of setting
HADR_MAP and HADR_NOKILL properties.
• HADR_RECONNECT – jConnect implicitly sets HADR_NOKILL_WITH_MAP. jConnect
supports reconnection from the old primary to the newly activated primary if the HADR
configuration has at least one standby Adaptive Server. After the reconnection is done, an
exception JZ0F3 SQLState is thrown. To use this connection, the application must catch
the JZ0F3 SQLException, and restore the context, for example, whether the database in
use, set options if any, reprepare statements, cursors, and so on. If any transaction is
cancelled due to the force option used in the sp_hadr_admin deactivate command, the
application is informed, and must retry the transaction.
See Adaptive Server Documentation for force option.
See HADR reconnection in jConnect section.
The jConnect application must register the SybMessageHandler class using the
SybConnection.setSybMessageHandler(SybMessageHandler hndlr) method. jConnect
calls this handler whenever it receives any messages from Adaptive Server, or any other error
messages, including state change messages. See Messages about HADR state change in
jConnect and Adaptive Server ODBC Driver section for message list.
The example shows how to code the message handler:
jConnect application must extract HADR_LIST_MAP out of these properties, which returns:
LinkedHashMap<string, object>
To retrieve the HADR_LIST_MAP components from this LinkedHashMap, the keys are to be
retrieved:
GroupName
GenerationNumber
Primary
Standby_1
Standby_2
Standby_3
.
.
.
.
Standby_n
The GroupName, GenerationNumber, and Primary key names are fixed. To get the exact
number standby servers in the list (Standby_n), jConnect must execute props.size()-3. This
gives an exact number of standby servers in the list.
ResultSet rs1 =
conn.createStatement().executeQuery("select @@servername");
rs1.next();
System.out.println("ASE Name: " + rs1.getString(1));
InputStreamReader isReader = new
InputStreamReader(System.in);
BufferedReader reader = new BufferedReader(isReader);
Applications that do not monitor the information messages will still be notified of some of the
events as errors when executing statements. The connection property
DRNoKillDuringDeactivation controls the nature of the messages.
When a server becomes the new primary server, the server informs the client, then kills the
connection. It is the responsibility of the application to establish a new connection with the
new primary server. When the server completes deactivation, it sends the client a message
and rolls back any open transactions. There may be open transactions if the deactivation
was done with the force option, and if the timeout is triggered. If this server later becomes
the active server, the connection starts executing the commands in a new transaction.
If the data is copied, StringLengthPtr is set to the number of bytes used. ValuePtr must be
aligned on a 16-byte boundary.
• SQL_ATTR_HADR_LIST_CALLBACK – applications that link directly to the Adaptive
Server ODBC Driver can avoid polling by registering a callback function using
SQLSetConnectAttr and setting SQL_ATTR_HADR_LIST_CALLBACK to the address of
the callback function. This function is called when an updated list is received from the
server. The syntax of the callback function is:
void HADRListAllocCallback(HDBC conn, SQLINTEGER
generation_number,
SQLLEN size_needed);
where:
• conn – is the connection handle on which the message was received.
Struct SQLHADRDataSource
{
// The name of the data source. Regardless of the setting of
// SQL_OUTPUT_NTS, this name is null terminated.
SQLWCHAR* data_source_name;
// The number of address for this data source. Each address refers
// to the same data source (server)
SQLLEN number_of_addresses;
SQLLEN number_of_ha_companions;
2376 New primary has been ac- • Available through ODBC Client application
tivated. SQL_ATTR_DR_INFO_MSG or
must establish a new
SQL_ATTR_DR_INFO_CALL-
connection to the
BACK
newly activated pri-
mary.
• Available through jConnect Syb-
Connection.getClientInfo()
2378 Deactivation did not com- • Available through ODBC Client application
plete successfully. Pri- SQL_ATTR_DR_INFO_MSG or
may resume normal
mary is once again active. SQL_ATTR_DR_INFO_CALL-
processing.
BACK
• Available through jConnect Syb-
Connection.getClientInfo()
2379 Primary has been success- • Available through ODBC Client application
fully deactivated. SQL_ATTR_DR_INFO_MSG or
should roll back any
SQL_ATTR_DR_INFO_CALL-
open transactions and
BACK.
avoid any new trans-
actions.
• Available through jConnect Syb-
Connection.getClientInfo()
2380 Primary has been reactiva- • Available through ODBC Client application
ted. SQL_ATTR_DR_INFO_MSG or
may resume normal
SQL_ATTR_DR_INFO_CALL-
processing.
BACK
• Available through jConnect Syb-
Connection.getClientInfo()
9662 Unable to issue a check- Available through jConnect SybCon- See Adaptive Server
point on database '%.*s'. nection.getClientInfo() Enterprise System
Administration
Guide.
9663 The RepAgent Thread for Available through jConnect SybCon- See Adaptive Server
database '%.*s' is not run- nection.getClientInfo() Enterprise System
ning. Administration
Guide.
9664 At least one RepAgent Available through jConnect SybCon- See Adaptive Server
Thread did not complete nection.getClientInfo() Enterprise System
its processing of the trans- Administration
action log. Guide.
9665 Adaptive Server is run- Available through jConnect SybCon- See Adaptive Server
ning in 'Standby' mode. nection.getClientInfo() Enterprise Security
The user does not have 'al- Administration
low hadr login' privilege. Guide.
9666 Adaptive Server is run- Available through jConnect SybCon- See Adaptive Server
ning in 'Primary Inactive' nection.getClientInfo() Enterprise Security
mode. The user does not Administration
have 'allow hadr login' Guide.
privilege nor the
'hadr_gentle_cap' capabil-
ity is set on the connec-
tion.
9667 Adaptive Server is run- Available through jConnect SybCon- See Adaptive Server
ning in 'Primary Deacti- nection.getClientInfo() Enterprise Security
vating' mode. The user Administration
does not have 'allow hadr Guide.
login' privilege nor the
'hadr_gentle_cap' capabil-
ity is set on the connec-
tion.
9668 Login redirection to Pri- Available through jConnect SybCon- See Adaptive Server
mary server failed. nection.getClientInfo() Enterprise System
Administration
Guide.
9670 The truncation point of Available through jConnect SybCon- See Adaptive Server
database '%.*s' has not nection.getClientInfo() Enterprise System
been established with Administration
DBCC SETTRUNC. Guide.
9672 Server reached INAC- Available through jConnect SybCon- See Adaptive Server
TIVE state. nection.getClientInfo() Enterprise System
Administration
Guide.
9673 Initiating log drain mech- Available through jConnect SybCon- See Adaptive Server
anism. nection.getClientInfo() Enterprise System
Administration
Guide.
9674 User connections statis- Available through jConnect SybCon- See Adaptive Server
tics:: %d in xact, %d in nection.getClientInfo() Enterprise System
chained mode, %d in un- Administration
chained mode, %d hold- Guide.
ing server side cursors.
9671 Deactivation failed due to Available through jConnect SybCon- See Adaptive Server
%s. Resetting state to %s. nection.getClientInfo() Enterprise System
Administration
Guide.
3957 New transaction cannot be Available through jConnect SybCon- See Adaptive Server
started due to an ongoing nection.getClientInfo() Enterprise System
HADR deactivate opera- Administration
tion. The command could Guide.
not be completed.
3958 Ongoing transactions Available through jConnect SybCon- See Adaptive Server
have been rolled back due nection.getClientInfo() Enterprise System
to HADR deactivate. Administration
Guide.
15968 %s: parameter %d is not Available through jConnect SybCon- See Adaptive Server
specified. nection.getClientInfo() Enterprise System
Administration Guide
New Capabilities
Three new capabilities such as, CS_RES_DR_NOKILL, CS_RES_LIST_DR_MAP, and
CS_REQ_READONLY are added for Open Server. These are the same capabilities that
Client-Library has. When these capabilities are set, Open Server reports the setting of the
capabilities to the application.
Note: The externally visible values for these capabilities are the same for both Open Server
and Open Client.
DR message
Use the control information message named SRV_CTL_DRMAP with srv_send_ctlinfo().
Existing control parameters continue to provide address-related parameters while additional
control types are added which map to the above described parameters:
Control Parameter Type DR Map Message Parameter
SRV_CT_SERVERNAME Data Source Address
Syntax
Specifies the login name to use for HADR system communication.
sp_hadr_admin setlogin, 'login_name'
Creates the HADR group, setting the group name to group_name and the HADR server name
to local_HADR_server_name.
sp_hadr_admin init, 'group_name' [, 'local_HADR_server_name']
Distributes member list changes to all standby servers and hadr_list_cap enabled user
connections:
sp_hadr_admin propagate
Resumes user application transaction activity on the new primary member after fail over
completes:
sp_hadr_admin activate
Stops the deactivation process and moves the server back to an active state:
sp_hadr_admin cancel
Changes the mode of an inactive HADR member from primary to standby mode. If the state of
the primary server is not already inactive, use the deactivate parameter to change the state to
inactive before issuing standby:
sp_hadr_admin standby
Checks the progress of the deactivation process from primary and standby servers:
sp_hadr_admin status [, 'label']
Removes the specified HADR group and stops the local node from participating in an HADR
system:
sp_hadr_admin dropgroup, 'group_name'
Parameters
• setlogin – configures the login name to use for HADR system communication.
• login_name – specifies the name of the login account you are configuring for HADR
communication.
• init – creates an HADR group on the local machine.
• group_name – specifies the HADR group you are adding or dropping.
• local_HADR_server_name – specifies the HADR server name. The default is
@@servername.
• addserver – adds a server to the HADR system and member list.
• HADR_server_name – server you are adding to–or dropping from–the HADR system or
member list.
• pname – name specified in the interfaces file for the server named HADR_server_name.
• nopropagate – disables automatic propagation of the server name to the member list for
standby servers and to hadr_list_cap enabled user connections (user connections
with HADR capabilities).
• listserver – displays the local server's member list.
• propagate – distrubutes member list changes to standby servers and to
hadr_list_cap enabled user connections (user connections with HADR capabilities).
• dropserver – drops a server from the member list.
• primary – promotes the standby server to primary mode.
• force –
• Forces a standby server to the role of a primary server if some members of the HADR
system are unreachable, or,
• Forces a transition to an inactive state if there are ongoing (unprivileged or otherwise)
transactions when the timeout expires.
• activate – activates the inactive primary server, and allows it to resume transaction activity
by user applications.
• deactivate – moves the primary server to an inactive state. All transactional activity is
gracefully terminated on HADR and non-HADR databases by all connections (including
privileged connections), and the transaction logs for all HADR databases are drained.
• timeout_period – specifies the duration, in seconds, during which the primary server is
allowed to remain in the deactivating state. If timeout_period expires before the server
moves to the inactive state, it is moved back to the active mode. You must use quotes for the
numerical value.
• label –
• Specifies the string used by the log drain mechanism to mark the transaction logs of
those HADR databases that have been successfully drained by Replication Agent
during the deactivation or drain process, or,
• Specifies the string used to retrieve the status of transaction replication on the standby
server. label is ignored if you issue sp_hadr_admin status [,'label'] on the primary
server.
• nodrain – allows deactivation to occur without initiating a log drain. By default, if you do
not include the nodrain parameter, the server initiates a log drain.
• cancel – aborts the deactivation process.
• standby – moves the primary server to standby mode.
• drain – drains the transaction log.
• status – checks the progress of the deactivation process. The information status reports
depends on the mode of the server (primary or standby).
• map – retrieves information about client connections for which you have set
hadr_list_cap capabilities.
• dropgroup – drops the HADR group. You must drop all the HADR members before
issuing dropgroup.
• fail over_timeestimate – estimates the amount of time it takes to roll back open
transactions.
• standby_server_name – unused in this version.
Examples
• Example 1 – configures hadruser as the login for HADR communication:
create login hadruser with password hadruser123
go
grant role ‘sa_role’ to ‘hadruser’
go
sp_hadr_admin setlogin, ‘hadruser’
go
• Example 2 – initializes the HADR system and sets the HADR group name to IT_GROUP:
sp_hadr_admin init, 'IT_GROUP'
• Example 3 – initializes the HADR system, sets the HADR group name to IT_GROUP, and
sets the HADR server name to PARIS:
sp_hadr_admin init, 'IT_GROUP', 'PARIS'
• Example 4 – adds a server named PARIS to the member list:
sp_hadr_admin addserver, PARIS
(return status = 0)
Adding server 'PARISDR', physical name 'PARIS'
Server added.
Command 'addserver' successful.
(1 row affected
• Example 5 – adds the PARISDR server to the member list using the pname format
hostname:port:
sp_hadr_admin addserver, PARIS, 'daisy:4901'
(return status = 0)
Adding server 'PARISDR', physical name 'daisy:4901'
Server added.
Command 'addserver' successful.
(1 row affected)
• Example 6 – drops the server PARIS from the HADR group without propagating the
change to the other members in the group:
sp_hadr_admin dropserver, PARIS, 'nopropagate'
• Example 7 – displays the current member list:
sp_hadr_admin listserver
name network_name
------------ --------------------------------
LONDON lily:4901
PARIS daisy:4901
• Example 8 – propagates membership list changes to the standby server:
sp_hadr_admin propagate
(return status = 0)
(1 row affected)
(return status = 0)
(1 row affected)
(return status = 0)
Adding server 'LONDONDR', physical name 'lily:4901'
Server added.
Adding server 'PARISDR', physical name 'daisy:4901'
Server added.
(1 row affected)
(1 row affected)
(return status = 0)
(1 row affected)
(0 rows affected)
(return status = 0)
Command 'propagate' successful.
(1 row affected)
sp_hadr_admin listserver now displays the updated member list when issued on the
standby server:
sp_hadr_admin listserver
name
network_name
------------ --------------------------------
LONDON lily:4901
PARIS daisy:4901
• Example 9 – attempts to promote the server LONDON to primary mode, but the HADR
system cannot connect to the PARISDR server:
sp_hadr_admin primary
sp_hadr_admin standby
Command 'standby' successful.
(return status = 0)
• Example 15 – initiates the log drain using the string
scheduled_offline_07092013 as the label:
sp_hadr_admin drain, 'scheduled_offline_07092013'
Initiating log drain mechanism.
Command 'drain' successful.
(return status = 0)
• Example 16 – displays the HADR map for the current system:
sp_hadr_admin map
Group Name Generation Number
---------- -----------------
IT_GROUP 0
1 row affected)
(1 row affected)
dbid rep_drain_time
------ --------------
(0 rows affected)
------------------------------
NULL
(1 row affected)
Command 'fail over_timeestimate' successful.
(return status = 0)
Usage
• login_name must exist on all HADR servers and be granted the sa_role. Use
sp_addexternlogin to add login_name as an external login for each remote HADR server.
• If you do specify the pname, sp_hadr_admin uses the HADR_server_name. Use this
format to specify the host name or IP address and port for the HADR_server_name server:
• hostname:port
• ipaddress:port
• The server on which you issue the propagate command must be in primary mode (that is,
@@hadr_mode must return a value of 1).
• force does not promote the standby server to a primary server if the HADR system detects
an existing primary server. The administrator must first demote the existing primary server
before reissuing the force parameter.
• You can run sp_hadr_admin primary only on the standby server.
• You can issue sp_hadr_admin active only on the inactive primary server
• The deactivate parameter triggers a transition from the active to the deactivating state, and
then to the inactive state.
• sp_hadr_admin deactivate ignores the label parameter when you include the nodrain
parameter.
• If the deactivation cannot complete in the period of time indicated by timeout_period, the
server returns to active mode. Monitor the progress of replication by searching for the label
'scheduled offline' label in the Replication Server log.
• You can execute sp_hadr_admin cancel only on primary servers in a deactivating state
(that is, while sp_hadr_admin deactivate is executing).
• To initiate a log drain, the server must be in an inactive state. You must issue
sp_hadr_admin drain after issuing sp_hadr_admin deactivate nodrain.
• To check the label on the standby server and monitor the replication status, use the
sp_hadr_admin status parameter. To avoid confusion, use a different label for each
deactivation process. .
• sp_hadr_admin map retrieves HADR member information about client connections with
hadr_list_cap capabilities:
• Group name – group name that is associated with the HADR system.
• Generation number – the number for the most recent version of the member address
list.
• Data source name – name of the HADR node.
• Data source address – address for data source name.
See also
• Chapter 6, Upgrading Adaptive Server in an HADR System on page 39
• Initializing the HADR Nodes on page 19
• Performing a Planned Failover on page 34
Index
unplanned 33
@@hadr_mode global variable 7
@@servername for HADR server names 3
G
A
generation number 3
active mode 5 global variables
Adaptive Server @@hadr_mode 7, 8
adding users 18
validating 17
allow hadr login privilege 10 H
applications HADR login account 16
during failover 33 HADR mode configuration parameter 7, 8
in an HADR system 1 HADR server names
recommendations 3
C HADR system
capabilities adding members 22
hadr_list_cap 3 adding the HADR user login 19
checkpoint marker, transaction log 33 adding users 18
clients applications 1
during failover 33 configuring nodes 20
Component Integration Services 16 deactivating 13
configuration parameters description 1
HADR mode 7, 8 dropping members 22
connections failover 33
privileged 10 identifying members 3
initializing nodes 19
D installing Replication Server 21
member address list 3
databases member modes 5
and Replication Agent 15 member modes, determining 7
participating in the HADR system 15 naming nodes 19
dbcc settrunc 35 participating databases 15
deactivated mode 5, 13 planned failover 34
deactivating mode 5 privileges and roles 10
drain markers, recovering from unplanned failover quiescing 13
35 recovering from unplanned failover 35
drain progress, verifying 35 rolling upgrade 39
server name recommendations 3
E split brain, preventing 4
external mode 5 upgrading 39
upgrading the standby server 40
validating Adaptive Server 17
F HADR user login
failover adding 19
planned 33 hadr_list_cap capability 3