| tenant-type | | slug | multi-ip-connection-obclient |
OBClient supports configuring multiple IP addresses for connection in various ways. If one IP address fails to connect, it automatically switches to another.
Method 1: Single-IP connection (default)
obclient -h100.88.109.130 -P38884 -utest@oracle -Dtest -ptest
Method 2: Configure multiple IPs using TNS
By setting the TNS_ADMIN environment variable, you can define multiple IP addresses in a TNS configuration file.
Set the environment variable:
export TNS_ADMIN=/dataConfigure in the
/data/tnsnames.orafile:MYTEST= (DESCRIPTION= (ADDRESS_LIST= (OBLB_STRATEGY=SERVERAFFINITY) (ADDRESS=(PROTOCOL=tcp)(HOST=100.88.109.1)(PORT=38884)(WEIGHT=1)) (ADDRESS=(PROTOCOL=tcp)(HOST=100.88.109.130)(PORT=38884)(WEIGHT=2))) (CONNECT_DATA=(SERVICE_NAME=TEST)) )OBLB_STRATEGYsupports three strategies:Strategy valueDescriptionSERVERAFFINITYWeight-based strategy, selects based on the WEIGHT value RANDOMRandom selection ROTATIONRound-robin selection Connect using the TNS service name:
obclient -h100.88.109.130 -P38884 -utest@oracle -Dtest -ptest --ob-service-name=MYTEST
During the connection process, all IP:port combinations are traversed and connected to one by one. The connection ends either with a successful connection or after all attempts fail.
Method 3: Specify multiple IPs in the -h parameter
Multiple IPs can also be directly specified in the -h parameter (the parameter must contain commas):
obclient -h[fe80::42:acff:fe11:2%eth0]:38884,[fe80::42:acff:fe11:2%eth0]:38882,[100.88.109.130]:2222,100.88.109.130:38884 -P38884 -utest@oracle -Dtest -ptest
Format: -h[ip1]:port1,[ip2]:port2,ip3:port3...
View the currently used IP
After a successful connection, you can use the \s or status command to view the currently used IP:
obclient> \s
