dblink命名时需注意的地方和GLOBAL_NAMES的含义

官方文档:

 

Typically, a database link has the same name as the global database name of the remote database that it references. For example, if the global database name of a database is sales.us.oracle.com, then the database link is also called sales.us.oracle.com.

When you set the initialization parameter GLOBAL_NAMES to TRUE, the database ensures that the name of the database link is the same as the global database name of the remote database. For example, if the global database name for hq is hq.acme.com, and GLOBAL_NAMES is TRUE, then the link name must be called hq.acme.com. Note that the database checks the domain part of the global database name as stored in the data dictionary, not the DB_DOMAIN setting in the initialization parameter file (see "Changing the Domain in a Global Database Name").

If you set the initialization parameter GLOBAL_NAMES to FALSE, then you are not required to use global naming. You can then name the database link whatever you want. For example, you can name a database link to hq.acme.com as foo.

Note:

Oracle recommends that you use global naming because many useful features, including Replication, require global naming.

After you have enabled global naming, database links are essentially transparent to users of a distributed database because the name of a database link is the same as the global name of the database to which the link points. For example, the following statement creates a database link in the local database to remote database sales:

CREATE PUBLIC DATABASE LINK sales.division3.acme.com USING 'sales1';

See Also:

Oracle Database Reference for more information about specifying the initialization parameter GLOBAL_NAMES

 

 

GLOBAL_NAMES的含义:

GLOBAL_NAMES

Property

Description

Parameter type

Boolean

Default value

false

Modifiable

ALTER SESSION, ALTER SYSTEM

Range of values

true | false

Basic

No

 

GLOBAL_NAMES specifies whether a database link is required to have the same name as the database to which it connects.

If the value of GLOBAL_NAMES is false, then no check is performed. If you use or plan to use distributed processing, then Oracle recommends that you set this parameter to true to ensure the use of consistent naming conventions for databases and links in a networked environment.

<think>好的,我现在需要解决用户提出的关于Oracle数据库中service_namesglobal_name不一致导致ORA-12514错误的问题。首先,我需要回顾用户提供的引用内容之前的对话,确保理解正确。 用户引用了四个参考资料,其中提到了DB_NAME、SID、service_namesglobal_name以及相关的配置问题。特别是引用[2][3]提到了service_nameglobal_name在配置中的重要性,以及它们与domain的关系。用户现在的问题是这两个参数不一致导致ORA-12514错误,需要解决方案。 首先,我需要明确service_namesglobal_name的区别联系。根据引用[1],DB_NAMESID在非RAC环境下默认相同,但在RAC环境下不同。而service_names是用于监听器注册的服务名,global_name则可能与domain有关。引用[3]指出,当listener.ora中的GLOBAL_DBNAME与tnsnames.ora的SERVICE_NAME不一致,会导致连接问题,比如ORA-12514。 接下来,我需要分析用户可能的配置错误。如果service_namesglobal_name不一致,可能导致客户端使用的服务名未被监听器识别。例如,客户端可能使用global_name作为SERVICE_NAME,但实际监听器注册的是service_names中的某个值,导致无法连接。 解决方案方面,用户可能需要调整service_namesglobal_name,使其一致,或者在配置文件中正确设置。同,检查监听器的动态注册是否正常,确保服务名正确注册到监听器。此外,还需注意domain的设置,因为global_name可能包含domain,而service_names如果也包含domain,需要确保客户端连接使用完整的名称。 另外,用户提到ORA-12514错误,可能涉及监听器配置、动态注册失败、服务名不匹配等问题。需要分步骤排查,如检查服务名配置,验证动态注册状态,调整参数,以及可能修改global_name或service_names。同,参考引用[4],可能需要设置global_names参数为TRUE,但这可能与其他问题相关,需进一步确认。 需要确保回答结构清晰,分步骤解决,并引用相关的参考资料。同,根据用户之前的问题,可能需要补充如何验证服务名、修改参数的方法,以及示例配置。还要注意中文化格式要求,如使用LaTeX公式,但此处可能更多涉及代码块配置示例。 最后,生成相关问题,帮助用户进一步理解可能遇到的关联问题,比如domain的影响、RAC环境下的处理等。</think>### **Oracle service_namesglobal_name 不一致的解决方案** ORA-12514 错误常因服务名配置不一致引发。以下是针对 `service_names` 与 `global_name` 不一致问题的具体分析解决方法: --- #### **一、核心概念与关系** 1. **`service_names`** - 定义数据库实例提供的服务名,可通过 `ALTER SYSTEM SET service_names = ...` 动态修改[^3]。 - 监听器通过此参数识别可连接的服务名,允许多个服务名指向同一实例[^1]。 2. **`global_name`** - 全局唯一标识符,由 `db_name` `db_domain` 组成(例如 `ORCLPDB.example.com`)[^2]。 - 通常用于分布式数据库环境(如 dblink),需与远程数据库的 `global_names` 参数匹配[^4]。 3. **不一致的影响** - 若 `service_names` 未包含 `global_name`,或客户端使用 `global_name` 作为连接服务名,可能导致监听器无法识别(ORA-12514)[^3]。 --- #### **二、分步解决方案** ##### **步骤1:验证当前配置** 1. **查询 `service_names` `global_name`** ```sql -- 查看服务名 SELECT value FROM v$parameter WHERE name = 'service_names'; -- 查看全局名称 SELECT * FROM global_name; -- [^2] ``` 2. **示例输出差异场景** - `service_names`: `ORCL_SERVICE` - `global_name`: `ORCL_GLOBAL.example.com` - 若客户端使用 `ORCL_GLOBAL.example.com` 作为服务名,但未在 `service_names` 中注册,则会触发 ORA-12514。 --- ##### **步骤2:调整参数实现一致性** **方案1:扩展 `service_names` 包含 `global_name`** ```sql -- 保留原有服务名,并添加 global_name ALTER SYSTEM SET service_names = 'ORCL_SERVICE, ORCL_GLOBAL.example.com'; -- [^3] ``` **方案2:修改 `global_name` 匹配 `service_names`** ```sql -- 需先禁用约束(谨慎操作) ALTER DATABASE RENAME GLOBAL_NAME TO ORCL_SERVICE; -- [^2] ``` **方案3:忽略 `global_name` 直接使用 `service_names`** - 在客户端连接字符串中显式指定 `service_names` 中的有效值(如 `ORCL_SERVICE`),避免依赖 `global_name`。 --- ##### **步骤3:配置监听器与客户端** 1. **确保监听器动态注册** - 检查监听器状态,确认服务名已注册: ```bash lsnrctl status ``` - 输出应包含 `service_names` 中定义的值(如 `ORCL_SERVICE`)[^1]。 2. **客户端连接配置示例** - `tnsnames.ora` 中显式指定 `service_names` 值: ```bash ORCL = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.100)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = ORCL_SERVICE) -- 与 service_names 一致 ) ) ``` --- ##### **步骤4:处理域(Domain)问题** 若 `global_name` 包含域名(如 `ORCL_GLOBAL.example.com`),需确保: 1. **客户端连接字符串包含完整域名** ```bash (SERVICE_NAME = ORCL_GLOBAL.example.com) ``` 2. **监听器配置兼容域名格式** - 检查 `listener.ora` 中是否允许长服务名格式[^2]。 --- ##### **步骤5:验证与测试** 1. **强制重新注册服务** ```sql ALTER SYSTEM REGISTER; -- 刷新监听器注册信息[^1] ``` 2. **使用 `tnsping` 测试连接** ```bash tnsping ORCL -- 验证 TNS 解析是否正常 ``` --- #### **三、总结流程图** ```mermaid graph TD A[ORA-12514] --> B{service_names 是否包含 global_name?} B -->|否| C[扩展 service_names 或修改 global_name] B -->|是| D{监听器是否注册?} D -->|否| E[检查动态注册配置] E --> F[执行 ALTER SYSTEM REGISTER] D -->|是| G[客户端使用正确 service_name] ``` --- ### **相关问题** 1. **如何通过 `db_domain` 参数影响 `global_name` `service_names`?** 2. **在 RAC 环境中如何统一多个节点的 `service_names` 配置?** 3. **`global_names=TRUE` 参数对分布式查询的影响是什么?** [^4]
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值