首页 > 数据库 > Oracle > [20201231]RAC连接特定实例.txt
[20201231]RAC连接特定实例.txt
--//在RAC环境工作中有时候要连接特定的实例,一般我选择在服务端不使用连接串,这样保证连接正确。
--//缺点就是文本界面有时候操作不是特别方便。
--//远程可以通过真实IP访问,使用EZCONNECT连接,这样可以避免出现问题。
--//前一段事件我发现我们生产系统一些rac环境,真实IP的监听是关闭的。
--//查看grid用户下的$GRID_HOME/network/admin/endpoints_listener.ora内容:
$ cat $GRID_HOME/network/admin/endpoints_listener.ora
LISTENER_DM01DBADM01=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=dm01db01-vip)(PORT=1521)))) # line added by Agent
--//这样我必须通过scan地址连接特定的实例,而且有一些服务在特定环境是连接特定实例的,除非我定义一些服务,这样感觉有点麻烦。
--//才想起来我发现以前写的链接:http://blog.itpub.net/267265/viewspace-2150938/ =>[20180208]ezconnect语法.txt
connect username/password@[//]host[:port][/service_name][/server][/instance_name]
Element Description
// Optional. Specify // for a URL.
Host Required. Specify the host name or the IP address.
Port Optional. Specify the port or use the default (1521).
service_name Optional. Specify the service name. The default value is the host name of the database server.
server Optional. Also known as connect_type in OCI, specifies the type of service handler: dedicated, shared, or pooled.
instance_name Optional. Corresponds to the INSTANCE_NAME initialization parameter.
For URL or JDBC connections, prefix the connect identifier with a double slash (//):
connect username/password@[//][host][:port][/service_name]
--//简单测试如下:
$ rlsql -s -l sys/XXXX@192.168.aa.bb:1521/zzzzz/zzzzz1 as sysdba <<< 'select INSTANCE_NAME from v$instance ;'
INSTANCE_NAME
----------------
zzzzz1
$ rlsql -s -l sys/XXXX@192.168.aa.bb:1521/zzzzz/zzzzz2 as sysdba <<< 'select INSTANCE_NAME from v$instance ;'
INSTANCE_NAME
----------------
zzzzz2
--//补充删除head的写法:
$ rlsql -s -l sys/Yfyhrp_14@192.168.aa.bb:1521/zzzzz/zzzzz1 as sysdba <<< 'set head off ^Jselect INSTANCE_NAME from v$instance ;'
zzzzz1
$ rlsql -s -l sys/Yfyhrp_14@192.168.aa.bb:1521/zzzzz/zzzzz2 as sysdba <<< 'set head off ^Jselect INSTANCE_NAME from v$instance ;'
zzzzz2
--//其中 ^J 按 ctrl+v ctrl+j 输入。
--//注意IP地址必须使用scan ip的一个。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/267265/viewspace-2746885/ ,如需转载,请注明出处,否则将追究法律责任。