not like upper('%'+name+'%')
The copy-pastes and explanations blog for SQL code, errors and daily cases! This blog is a 'list' of actions that always good to have available. The copy-paste concept here is short and clear explanations and descriptions (no long stories!) and - of course - the code to take (copy) and use (paste). The blog deals in the database (mostly) and software issues.
Labels
Exclude records from a select according to a comma separate list is a string
SAP Replication Server Routing
- Two replication servers are installed and started.
- All target databases must have the same columns and Primary key.
- No identity in the target table (or subscription that know to update identity column).
- The passwords to all RSs in the process should be the same.
- The RepAgent has to use a known servers names (in the ini files).
- Source and target tables must have a primary keys.
- Edit the ini file in the new server with:
- Current (new) RS.
- ASE instance of the RSSD.
- ASE instance of the replicatec(=target) database.
- First (=source) RS.
- Edit the ini of the first (=source) RS with:
- New RS.
- ASE instance of the source RSSD.
- Run rs_init:
- Two ways to do that:
- run rs_init
- create <SAP_RS_FOLSER>/REP-16_0/init/rs/RS2.rs (copied and edited from install.rs) and run it
- ./rs_init -r ../init/rs/RS2.rs
- In rs_init we define the servers, databases, RSSDs, users, etc.
- Two ways to do that:
- Check that RS is up:
- isql64 -S RSFOG2 -Usa -P<password>
- admin version
go - admin who
go
# |
RS1 (source
RS) |
RSSD
of RS1 (RS1_RSSD) |
RS2 (second
RS) |
Target
replicated database |
|
1 |
Create route |
alter
connection to SERVERNAME.RS1_RSSD set log transfer ON |
|
|
|
1.a |
Monitor the
new route until it became active |
|
1>
rs_helproute |
|
|
2 |
add
connection RS2 (second RS) → target database |
|
Use rs_init |
|
|
3 |
Configure
a rep_agent to the RSSD |
|
1> use
RS1_RSSD |
|
|
4 |
Grant
permissions in the target database |
|
|
|
1> grant
all on FirstTable to <target
database name>_maint |
5 |
create a
subscription to the replicate connection in the second RS |
|
|
1> create
subscription subTest3 for repdefTest with primary at
PRIMARYDBSERVERNAME.PRIMARYDB with replicate at TARGETDBSERVER.TARGETDBNAME
without materialization |
|
SAP RS - The Replication Process
Before declare a Replication
We should have:
- Databases installations (SPA ASE or others), primary and replicates.
- Instances were set in sql.ini.
- RSSD database.
The Replication Process
1. Add a table to Replication
Create connections to the primary and replicated server. – (using rs_init)
Create replication definition
Create (and validate) publication
Create (and validate) subscription
Add table to replication - sp_setreptable FirstTable, true (without true/false – just display the current status)
The replicated table must have a primary key!
- In both sides – primary and replicated
- It’s part of the replication definition, and the replication won’t work without the PK.
2. Replication Agent - Rep Agent
Transactions to be replicated are extracted from the source database transaction log.
The component that do that is the RepAgent.
REP Agent is a component that scans the transaction log of the source database and picks up the changes for replication.
3. From Rep Agent to Distributer
SQM – Stable Queue Manager
- Write the changes to the queue.
In Bound Queue
- Store changes until they will be distributed.
- There is one inbound queue per primary database.
- contains data rows and transactions that have begun at the primary database but have no yet been committed (SQT will pass to the next steps only committed transactions).
- Transactions will be stored in IBQ until a copy will be distributed to all subscriptions (out-bound queue).
SQT – Stable Queue Transaction
- Alert the Distributer that changes are available.
- Move from the IBQ to the next steps only committed transactions
Distributer
The Distributer read transaction and determine who is subscribing to it.
Thread forward the transaction to the next SQM “on the way” to the out-bound Queue.
4. Distribute to target databases
SQM
A SQM for the out-bound queue - Writes the transaction to the out bound queue if there are subscription.
Out-bound Queue
There is one outbound queue for each RDB.
DSI / RSI
DSI / RSI “translate” between the source and target servers.
- DSI – Data Server Interface – the target is database.
- RSI – Replication Server Interface – the target is replication server.
SAP Replication Server Overview
- From a primary (= source) database [one primary database].
- To one or more replicate (= target) databases [one or more replicate databases].
- DML/DDL
- Which table/s
- What in the table:
- Columns
- Data (where salary > 1000 )
- etc.
- Descriptions of replicated data and related information.
- Security records for Replication Server users.
- Routing information for other sites.
- Access methods for the local databases.
- Other administrative information.
SAP RS - Data is not replicated, although all definitions looks OK
Can be more than one reason, try to check:
- Check definition of databases and servers – all those definitions can be very confusing… (names, IPs, etc. [sql.ini])
- Check PKs in both sides – as already mentioned above: primary and replicated
- Permissions issues
- RS permissions – example: grant role replication_role to sa (RSSD database)
- Primary DB
- Replicated DB – example: GRANT INSERT, UPDATE, DELETE ON replicated table to the maintanance user of RS (_maint)
- Network and connections issues – permissions to inbound/outbound access to/from the servers.
- don’t forget after fixing a problem to resume connection the server.database
- LTM is not set to the correct “locator” value.
- rs_zeroltm, dbcc settrunc(ltm, valid)