Forum Discussion
Matt_Breedlove_
Apr 24, 2007Nimbostratus
TCP Payload String Swap for Oracle HA
Hi,
I would like to use an iRule on a VIP that heads 4 Oracle DB RAC servers. Each server helps serve a single DB on SAN attached storage. However, Oracle requires that each rac host have a ...
Deb_Allen_18
Apr 24, 2007Historic F5 Account
Hi Matt --
Here's the basic iRule version of your pseudocode above:
rule RAC-SID-replacement_switch {
when CLIENT_ACCEPTED {
TCP::collect
}
when CLIENT_DATA {
set payload [TCP::payload]
}
when LB_SELECTED {
switch [LB::server addr] {
10.10.10.1 { ; IP addr of vfcudb01b
regsub -all "acmesid_vip" $payload "acmesid1" payload
TCP::payload replace 0 [TCP::payload length] $payload
}
10.10.10.2 { ; IP addr of vfcudb02b
regsub -all "acmesid_vip" $payload "acmesid2" payload
TCP::payload replace 0 [TCP::payload length] $payload
}
10.10.10.3 { ; IP addr of vfcudb03b
regsub -all "acmesid_vip" $payload "acmesid3" payload
TCP::payload replace 0 [TCP::payload length] $payload
}
10.10.10.4 { ; IP addr of vfcudb04b
regsub -all "acmesid_vip" $payload "acmesid4" payload
TCP::payload replace 0 [TCP::payload length] $payload
}
}
TCP::release
TCP::collect
}
}
For a more concise and scalable solution, you could instead use a class to maintain the relationship between IP, hostname, and sid value, and extract with "findclass" (Although in this example the hostname field is not necessary, it might be useful as a label/comment for admin purposes):class mySIDs {
type string
10.10.10.1 acmesid1 vfcudb01b
10.10.10.2 acmesid2 vfcudb02b
10.10.10.3 acmesid3 vfcudb03b
10.10.10.4 acmesid4 vfcudb04b
}
rule RAC-SID-replacement_findclass {
when CLIENT_ACCEPTED {
TCP::collect
}
when CLIENT_DATA {
set payload [TCP::payload]
}
when LB_SELECTED {
set mySID [getfield [findclass [LB::server addr] $::mySIDs] " " 2]
if {$mySID != ""}{
regsub -all "acmesid_vip" $payload "$mySID" payload
TCP::payload replace 0 [TCP::payload length] $payload
}
TCP::release
TCP::collect
}
}
Requests traversing either iRule will be forwarded to the VS's configured default pool regardless of whether any payload manipulation took place. The release/collect at the end ensures that subsequent requests on the same connection will be processed in the same manner.
HTH
(I'd be interested to hear back if this solved your problem so I can add it to the CodeShare.)
/deb
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects