技能创建器
skill-creator
创建、改进和评估自定义技能,把专业流程转化为可重复使用的 AI 能力。
sap-sqlserver-alwayson【数据与研究】SQL Server Always On Availability Groups under SAP NetWeaver — listener-based connection configuration (SAPDBHOST, dbs/mss/server, MSSQL_SERVER, MultiSubnetFailover and the case-sensitive JDBC parameter), why logins must be created by SWPM "Configure additional Always On Node" and never manually, the readable-secondary rules including the unsupported…
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Source of record. SAP Note 1772688 — SQL Server Always On Availability Groups and SAP NetWeaver-based applications, version 25, released 21.01.2026, component BC-DB-MSS [V] — fetched and read directly.
🛑 This Note is the only supported source
Note 1772688, verbatim: "This SAP Note centralizes the setup and configuration details for AlwaysOn. Only the procedures explained here in this SAP Note are supported for SAP installations on AlwaysOn. As of July 2020, please do not use external blogs, other SAP Notes, or outdated SAP installation and upgrade guides when working with SAP NetWeaver on AlwaysOn." [V]
That is unusually strict, and it applies to this skill too. Treat this file as a map to the Note, not a replacement for it — read the live Note before executing a lifecycle procedure.
Scope: NetWeaver-based products only. For non-NetWeaver products (SAP BusinessObjects, SAP Redwood) this Note does not apply — find the documentation for that application area. [V]
| NetWeaver | AlwaysOn supported from 7.0 and all later releases [V] |
| SQL Server 2012+ | AlwaysOn — strongly recommended over Database Mirroring [V] |
| SQL Server 2008 R2 or earlier | Use Database Mirroring instead (SAP Note 965908) [V] |
| JDBC | Automatic failover via the listener name needs Microsoft JDBC 4.0 or later [V] |
WSFC is required, but shared disks are not. AlwaysOn relies on the Windows Server Failover Cluster framework for health detection and failover triggering rather than a third witness instance. "A cluster configuration without any shared disk would be sufficient." [V]
Distance. "Given the nature of SAP workload, any distance larger than 60 miles (96.5 km) between AlwaysOn nodes will add latency that impacts performance visibly." [V] That is guidance for synchronous replication. The Note also warns that the mileage rule blurs once a node sits in a public or private cloud, because virtualization layers you cannot monitor sit underneath — so test throughput before deployment rather than trusting the number.
Transaction-log I/O latency on the secondary. With synchronous replication the primary waits on the secondary's log write, so "an I/O latency of 5 milliseconds for write actions significantly impacts the primary replica and the SAP application compared to having just 1 millisecond." [V] The secondary's log LUN is in your primary's commit path — size it accordingly.
ABAP profile parameters [V]:
SAPDBHOST = <listenername> # or <listenername>,<static_port>
dbs/mss/server = <listenername> # or <listenername>,<static_port>
dbs/mss/conn_opts = MultiSubnetFailover=yes
In TP_DOMAIN_<SID>.PFL: set <SID>/DBHOST to the listener name (or <listener>,<port>).
Environment variables for <sid>adm [V]:
MSSQL_SERVER = <listenername>
MSSQL_CONNOPTS = MultiSubnetFailover=yes
DBCON (remote SQL Server in an availability group) — add CON_ENV using the shorthand [V]:
;COP=MultiSubnetFailover=yes
Java [V]: set SAPDBHOST, dbs/mss/server and j2ee/dbhost to the listener name, and in the
config tool's secure store append to the connection URL:
jdbc:sqlserver://<Listenername>:<static_port>;databasename=<DB>;multiSubnetFailover=true
⚠️ The Java parameter is case-sensitive — and fails silently
Note 1772688: "Caution: This is case-sensitive. Make sure the character case is exactly as shown here. If it's not the exact same as indicated here, the Microsoft JDBC client ignores the parameter." [V]
multiSubnetFailover=true— lower-casem, capitalS, capitalF. Get it wrong and nothing errors; you simply lose automatic failover, and only discover it during a real failover.
Note the asymmetry: ABAP uses MultiSubnetFailover=yes, Java uses multiSubnetFailover=true.
🛑 "Do not create logins manually or using any tSQL script in the secondary replicas." [V]
SWPM creates the login <sid> (ABAP) or SAP<SID>DB (Java) in the secondary replicas with the
same globally unique security identifier (SID) as the primary. A hand-made login has a different
SID and breaks the connection after failover — this is the documented root cause of the most
common AlwaysOn incident (§7).
Correct procedure [V]:
Choose the local SQL Server instance name, not the availability group listener name.
Use SWPM from NetWeaver 7.1 or higher media — even when installing a system based on NetWeaver 7.0. [V]
AlwaysOn offers three read-only settings per replica: No, Read-intent only, Yes.
🛑 Never set an SAP
<SID>database secondary replica toYes"It's not supported to set any SAP NetWeaver SID database secondary replicas to 'Yes.'" [V]
Yesaccepts every connection and makes them all read-only. SAP work processes assume more than read-only access, and their behaviour cannot be customised. If a work process connects accidentally, it fails the moment it tries to modify data. The local SAP<SID>database's secondaries may beNoorRead-intent only— neverYes.
Synchronous does not mean readable-and-current. "Synchronous data replication acknowledges the successful writing into the transaction log… However, this doesn't mean that the changes transmitted have already been applied to the actual data of the secondary replica." [V] So even a synchronous readable secondary can serve stale data while log records are still being applied. Asynchronous is worse and unpredictable.
Remote DBCONs: always connect to the primary. The Note documents two real customer failures — a process tuned against a synchronous remote secondary that degraded when the link was later changed to asynchronous, and one that stopped meeting its time budget as the system grew. Conclusion: "always connect to the primary node of a remote SQL Server availability group replica." [V]
A cautionary tale worth repeating to customers. SAP Development Support saw a primary database reach in four months the size projected for two years. Cause: versioned records created by non-SAP processes running on readable secondaries, combined with poor I/O throughput that slowed the ghost-record cleanup. [V] If you enable readable secondaries, monitor database size and I/O throughput deliberately.
"Many customers don't test all nodes in their AlwaysOn landscape. When a failover emergency occurs, secondary nodes may not be configured properly. As a result, SAP NetWeaver can't start. This issue affects many customers and leads to immediate production downtime and escalation." [V]
ABAP: DBACOCKPIT → Configuration → SQL Server Always On Check — verifies logins and jobs
and reports configuration errors. [V]
Java: no tool exists. You must fail over to each node and confirm the Java application server connects. [V]
Both: fail over to each node, one at a time, and log in after each. Then [V]:
Do this after initial setup and after any change to the landscape.
1. SAP cannot connect after failover (ABAP), or the Java config tool cannot scan the database.
<sid> / SAP<SID>DB login was created manually in the secondary replicas. [V]2. SWPM "Configure additional Always On Node" fails with
Creation of a new database is not allowed / MDB-05702.
| Topic | File |
|---|---|
| Install / system copy / refresh / dual-stack split / SUM upgrade sequences, monitoring, Database Mirroring | references/alwayson-lifecycle.md |
sap-backup-recovery — SQL Server backup/restore; the NORECOVERY restores that seed replicas.sap-db-command-reference — SQL Server service control, sqlcmd, Windows specifics.sap-system-lifecycle — stopping application servers before AlwaysOn node configuration.The other five database HA/DR skills — different technologies, no commands transfer:
sap-hana-system-replication — HANA System Replication (hdbnsutil, HSR).sap-ase-hadr — ASE HADR / Always-On (Replication Server, RMA sap_*).sap-oracle-dataguard — Oracle Data Guard (physical standby, DGMGRL).sap-db2-hadr — Db2 HADR (HADR_SYNCMODE, SA MP / Pacemaker).sap-maxdb-ha — MaxDB / liveCache (Hot Standby, shadow database, cluster failover).Every command executed must be traceable to one of exactly three things:
If a command is backed by none of those, do not run it — say what backing is missing and stop. "It's probably fine", "this is standard", and "I recall the syntax" are not backing. When the backing is a source, name it (page or Note number) alongside the command; when it is the user, quote the instruction.
If executing would require assuming anything the user did not state, you are obliged to confirm first. Never fill a gap with a plausible default. Common gaps that force a stop:
A wrong assumption here is not a typo — it is the difference between reading a log and stopping production.
Asking the user for something the system can answer is a failure. Before you raise a question, ask the user to go and look, or request Computer Use / GUI access, you must first try to determine it programmatically. Only what genuinely cannot be derived — intent, authorization, a business decision, a value that exists only in the user's head — is a legitimate question.
| Determine programmatically (do NOT ask) | Ask the user (cannot be derived) |
|---|---|
Which DB — echo $dbms_type, profile dbms/type | Which client to act on |
SIDs / instances / hosts / ports — sapcontrol … GetSystemInstanceList, ls /usr/sap | Whether this system is in scope / approved |
Is it up, is the DB up — GetProcessList, R3trans -d | PRD change approval, downtime window |
Kernel / release / patch — disp+work -version, saphostexec -version | The intended recovery point or retention policy |
Which clients exist — table T000 | Which of those clients is meant |
Free space, log locations, parameter values — df -h, sappfpar, profile | Business impact / urgency |
Order, always: verify programmatically → ask only what remains → never assume.
Work down this ladder. Take the highest rung that does the job — and within that rung, the lowest privilege that suffices. Never skip a rung because you assume it is unavailable (see the burden of proof below).
| # | Path | Privilege | Notes |
|---|---|---|---|
| 1 | REST / OData — GET first | Narrowest. Scoped service user | Read-only by construction when you stay on GET. $metadata gives you the contract |
| 2 | SOAP / web service | Scoped service user | Typed contract via ?wsdl. Client-cert auth where offered — no password in a script |
| 3 | RFC / BAPI (creds exec, JCo, pyrfc) | RFC user with S_RFC | For ABAP writes, prefer this over 1–2: BAPIs have real commit/rollback semantics and land in SM19/SM20 |
| 4 | OS shell as the correct user → DB utility | ⚠️ Escalates — see below | The chain matters more than the rung |
| 5 | Browser automation (headless or in-app) | Interactive user | Session-based UIs only. Fragile across releases |
| 6 | Computer Use / screen driving | Interactive user | Last resort. Not repeatable, not diffable, breaks on any UI change |
⚠️ Rung 4 is a chain, and each link widens the blast radius
ssh <host> ← host access → su - <sid>adm ← SAP admin: can stop/start the system → su - ora<sid> / syb<sid> ← DB owner: can drop data → sudo / root ← everything → hdbsql | isql | dbmcli | sqlplus | db2 ← the actual commandStop at the least-privileged user that can run the command. Most read-only checks need only
<sid>adm; DB utilities usually need the DB owner; root is almost never the right answer andsaproot.shis the rare legitimate exception. Say which user you used and why.
Two axes, and they do not agree
The ladder ranks by automation quality — repeatable, reviewable, loggable, diffable. Privilege runs on a different axis and is worst in the middle: rung 4 (OS/root) can destroy a system, while rung 6 (Computer Use) is merely an interactive user clicking. So Computer Use ranks last for reproducibility, not because it is the most dangerous.
The practical rule: prefer the highest rung, but never escalate privilege to climb it. A read-only OData call beats an RFC that needs a write-capable user; an
<sid>admshell beats a root shell. If climbing a rung requires more privilege than the task needs, stay where you are and say so.
🛑 You must demonstrate the absence of a programmatic path, not assume it
"There is no API for this" is a finding that requires evidence, not a default. Before dropping to rung 5 or 6, actually probe:
- HTTP status codes tell you the access mode.
401→ Basic auth works, scriptable.302regardless of credentials → session UI, browser needed.404→ not deployed.503→ deployed but stopped.- Look for a contract: append
?wsdl,$metadata,/api,?sap-client=and see what answers.- Ask the platform what it exposes:
sapcontrol -function J2EEGetApplicationAliasList,hdbcons help,btp --help,xs help,<tool> -h.- A Swing or WebDynpro UI being un-automatable does not mean the objects are. The editor and the API are different doors — check for the second before declaring the first is the only one.
Programmatic execution is repeatable, reviewable, loggable and diffable; screen-driving is none of those. When you do drop to a lower rung, say which rung you are on and what you probed to rule out the higher ones — so the user can correct you if they know of a path you missed.
Work that produces evidence (logs, traces, command output, screenshots, reports) has two reasonable endings. Ask which the user wants rather than guessing:
Don't dump large output into the conversation unasked, and don't silently discard evidence either — for troubleshooting and any change with a rollback, (a) is usually the right default to offer.
Identify the right OS user before running anything, and switch with a login shell. Wrong-user
execution is a top cause of SAP failures, and the damage outlives the command: files created by root
under /usr/sap, /sapmnt or a DB directory break every later start by the real owner. A login shell
also matters because each user carries the environment the tools need (SAPSYSTEMNAME, ORACLE_HOME/
ORACLE_SID, SYBASE, DB2INSTANCE, library paths) — without it, commands fail or act on the wrong system.
| What you're operating | UNIX user | Windows |
|---|---|---|
SAP instances — sapcontrol, startsap/stopsap, tp, R3trans, disp+work, sappfpar, cleanipc | <sid>adm (lower-case SAP SID) | <SID>adm; services run as SAPService<SID> |
SAP HANA — HDB, hdbsql, hdbnsutil | <sid>adm of the HANA SID (e.g. h10adm — may differ from the SAP SID) | n/a (HANA server is Linux-only) |
Oracle — sqlplus, lsnrctl, BR*Tools | ora<dbsid> (BR*Tools also runs as <sid>adm; generic installs may use oracle) | <SID>adm; DB runs as a service |
SAP ASE — isql, startserver, Backup Server | syb<dbsid> | syb<dbsid> / SAPService<SID> |
IBM Db2 — db2start/db2stop, db2 CLP | db2<dbsid> (the instance owner = DB2INSTANCE) | same; Db2 runs as a service |
SAP MaxDB / liveCache — dbmcli, x_server | sdb (software owner, group sdba) + a DBM operator at DB level | install/service account |
MS SQL Server — sqlcmd, service control | n/a (Windows-only for SAP) | <SID>adm / the SQL Server service account |
SAP Host Agent — saphostexec, saphostctrl | root | Administrator / SAPHostExec service |
Rules
su - <user> (the - is what loads the environment) or sudo -iu <user>.
Windows: use the correct account, or an elevated shell only where documented.root only where the procedure explicitly says so — e.g. saproot.sh after a kernel extract, SAP Host
Agent install/upgrade. Never as a shortcut around a permission error; that is how root-owned files get
created and break the system later.whoami / id, plus the env actually being set (echo $SAPSYSTEMNAME,
echo $ORACLE_SID, echo $DB2INSTANCE, echo $SYBASE).<sid>adm:"), and if the required user is not
available, say so and stop — do not substitute another user.SAP Notes supersede this file. Landscapes differ by release, patch level, DB and OS, and SAP changes procedures via Notes/KBAs between doc revisions.
If the SAP Notes MCP is configured, use it before acting on anything version-specific — especially any destructive step, or when a command here doesn't behave as documented:
search the topic (e.g. the component + symptom, or a Note number cited below).fetch the promising Note IDs for the current text, validity (affected releases/components),
prerequisites and side effects.attachments array. SAP routinely puts the actual deliverable in an attachment rather
than the Note body — sizing guides, SQL script collections, configuration PDFs, spreadsheets. A Note
whose text says "see the attached document" is not fully read until you have it.Downloading an attachment: fetch returns attachments[].url and attachments[].filename;
fetch_attachment retrieves the bytes. Pass the URL verbatim — the URLs are opaque and cannot be
constructed. If your MCP build predates that tool, open the URL in a signed-in browser instead and say the
file was fetched manually.
⚠️ Two ways a hand-rolled fetch goes wrong — both verified. 1. Trusting the status code. An unauthenticated request returns HTTP 200 with a small HTML login stub, not an error. Check the content type and magic bytes, or you save a JavaScript redirect page under a
…/services/attachment.htm?iv_key=…&iv_guid=…— so the URL basename isattachment.htmeven when the payload is a 24-page PDF. Take the name fromattachments[].filenameor the response'sContent-Dispositionheader, never from the URL path.
No MCP available? Look the Note up on me.sap.com/notes/<id> and say the check was skipped rather than
assuming this file is current.
| # | Source | Read |
|---|---|---|
| [AO1] | SAP Note 1772688 — SQL Server Always On Availability Groups and SAP NetWeaver-based applications, v25, 21.01.2026, BC-DB-MSS | [V] — planning, lifecycle sequences, profile/env parameters, login procedure, restrictions and troubleshooting all read directly |
| [AO2] | SAP Note 965908 — SQL Server Database Mirroring and SAP Applications (the pre-2012 predecessor) | [G] |
| [AO3] | SAP Note 2137130 — How to set MSSQL_SERVER and MSSQL_CONNOPTS for SQL Server AlwaysOn and Mirroring | [G] |
| [AO4] | SAP Note 1907868 — SAP system cannot connect to SQL Server after AlwaysOn/Mirroring failover | [G] |
| [AO5] | SAP Note 3679673 — "The target database … is participating in an availability group and is currently not accessible for queries." Logon Error: 976 | [G] |
| [AO6] | SAP Note 2153963 — DBACOCKPIT (DB13 and DB12) not working correctly with SQL Server AlwaysOn and Mirroring | [G] |
| [AO7] | SAP Note 3590454 — How to remove 'SQL Server AlwaysOn' from an existing SAP NetWeaver system installation | [G] |
| [AO8] | SAP Note 2446660 — System Copy with HA does not set AlwaysOn profile/env parameters | [G] — explains a common post-copy failure |
| [AO9] | SAP Note 1031096 — Installing Package SAPHostagent (needed manually on secondaries with no SAP instance) | [G] |
| [AO10] | SAP Note 2303398 — SAP on SQL Server in Microsoft Azure Virtual Machines; 2116801 — Performance Monitor for AlwaysOn | [G] |
| [AO11] | SAP Help Portal — Updating SAP ABAP Systems on Windows: Microsoft SQL (SUM guide; see Update Schedule Planning and Database-Specific Aspects) | [G] |
| [AO12] | Microsoft Learn — SQL Server Azure Virtual Machines DBMS deployment for SAP workload; Configure read-only access to a secondary replica; Offload read-only workload to secondary replica | [G] |
Currency. v25 was released 21.01.2026 and the Note is actively maintained — SAP explicitly centralised this material in 2020 and asks that nothing else be used. Re-read it before any lifecycle action; this file records what v25 said, not a standing truth.
Azure-specific features (Distributed Network Names / DNN, and other cloud specifics) are deliberately out of scope here — Note 1772688 routes them to Microsoft's documentation and the SAP on Azure blog. [V]