oracle 10g服务器端RAC负载均衡配置代码
前面我们介绍了RAC的客户端负载均衡配置,接下来就到了服务器端RAC负载均衡配置的具体代码介绍了,通过两方面的配置和测试之后,整个负载均衡才能完全的设置好。那么就让我们赶紧来看一下啊具体的服务器端RAC负载均衡配置内容吧。 从Oracle 10g开始,服务器端
前面我们介绍了RAC的客户端负载均衡配置,接下来就到了服务器端RAC负载均衡配置的具体代码介绍了,通过两方面的配置和测试之后,整个负载均衡才能完全的设置好。那么就让我们赶紧来看一下啊具体的服务器端RAC负载均衡配置内容吧。
从Oracle 10g开始,服务器端负载均衡可以根据RAC中各节点的负荷及连接数情况,而判定将新的客户端连接分配到负荷最小的节点上去?RAC中各节点的PMON进程每3秒会将各自节点的负荷(包括LOAD?最大LOAD?CPU使用率)及连接数更新到service_register里面,然后假如节点的负荷有发生变化,将会通知到监听程序,由监听程序再决定新的客户端连接分配至哪个节点?假如RAC中一个节点的监听失败了,PMON每一分钟会去检查一次是否已经恢复正常?
服务器端的监听配置是在各节点的tnsnames.ora里面添加一个连接到各个节点监听的条目,然后再在初始化参数里面设置remote_listeners这个参数?
1?测试客户端的TNS
修改客户端tnsnames.ora的文件,内容如下:
<ol> <li><span>RACDB = </span></li> <li><span> (DESCRIPTION = </span></li> <li><span> (ADDRESS_LIST = </span></li> <li><span> (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.170)(PORT = 1521)) </span></li> <li><span> ) </span></li> <li><span> (CONNECT_DATA = </span></li> <li><span> (SERVICE_NAME = racdb.chenxu.yo2.cn) </span></li> <li><span> ) </span></li> <li><span> ) </span></li> </ol>
测试连接:
<ol> <li><span><span>SQL> conn sys/chenxu@racdb </span><span>as</span><span> sysdba </span></span></li> <li><span>已连接? </span></li> <li><span>SQL> </span></li> <li><span>SQL> show parameter instance_name </span></li> <li><span> </span></li> <li> <span>NAME</span><span> TYPE VALUE </span> </li> <li> <span>------------------------------------ ----------- --------------------- </span><span> </span> </li> <li><span>instance_name string RACDB1 </span></li> </ol>
2?配置服务器端TNS
服务器端的监听配置是在各节点的tnsnames.ora里面添加一个连接到各个节点监听的条目(红色代码),在服务器端每个节点的tnsnames.ora里面的内容如下:
<ol> <li><span>[root@NODE01 admin]# pwd </span></li> <li><span>/orac/orahome/oracle/product/10.2.0/db_1/network/admin </span></li> <li><span>[root@NODE01 admin]# </span></li> <li><span>[root@NODE01 admin]# more tnsnames.ora </span></li> <li><span># tnsnames.ora Network Configuration File: /orac/orahome/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora </span></li> <li> <span># Generated </span><span>by</span><span> Oracle configuration tools. </span> </li> <li><span> </span></li> <li><span>RACDB1 = </span></li> <li><span> (DESCRIPTION = </span></li> <li><span> (ADDRESS = (PROTOCOL = TCP)(HOST = vip01)(PORT = 1521)) </span></li> <li><span> (CONNECT_DATA = </span></li> <li><span> (SERVER = DEDICATED) </span></li> <li><span> (SERVICE_NAME = RACDB.chenxu.yo2.cn) </span></li> <li><span> (INSTANCE_NAME = RACDB1) </span></li> <li><span> ) </span></li> <li><span> ) </span></li> <li><span> </span></li> <li><span>RACDB = </span></li> <li><span> (DESCRIPTION = </span></li> <li><span> (ADDRESS = (PROTOCOL = TCP)(HOST = vip01)(PORT = 1521)) </span></li> <li><span> (ADDRESS = (PROTOCOL = TCP)(HOST = vip02)(PORT = 1521)) </span></li> <li><span> (LOAD_BALANCE = yes) </span></li> <li><span> (CONNECT_DATA = </span></li> <li><span> (SERVER = DEDICATED) </span></li> <li><span> (SERVICE_NAME = RACDB.chenxu.yo2.cn) </span></li> <li><span> ) </span></li> <li><span> ) </span></li> <li><span> </span></li> <li><span>LISTENERS_RACDB = </span></li> <li><span> (ADDRESS_LIST = </span></li> <li><span> (ADDRESS = (PROTOCOL = TCP)(HOST = vip01)(PORT = 1521)) </span></li> <li><span> (ADDRESS = (PROTOCOL = TCP)(HOST = vip02)(PORT = 1521)) </span></li> <li><span> ) </span></li> <li><span> </span></li> <li><span>RACDB2 = </span></li> <li><span> (DESCRIPTION = </span></li> <li><span> (ADDRESS = (PROTOCOL = TCP)(HOST = vip02)(PORT = 1521)) </span></li> <li><span> (CONNECT_DATA = </span></li> <li><span> (SERVER = DEDICATED) </span></li> <li><span> (SERVICE_NAME = RACDB.chenxu.yo2.cn) </span></li> <li><span> (INSTANCE_NAME = RACDB2) </span></li> <li><span> ) </span></li> <li><span> ) </span></li> </ol>
3?在初始化参数中设置参数remote_listeners
<ol> <li><span><span>SQL> conn sys/chenxu@racdb </span><span>as</span><span> sysdba </span></span></li> <li><span>已连接? </span></li> <li><span>SQL> show parameter remote_listener </span></li> <li><span> </span></li> <li> <span>NAME</span><span> TYPE VALUE </span> </li> <li> <span>------------------------------------ ----------- ------------------------ </span><span> </span> </li> <li><span>remote_listener string </span></li> <li><span>SQL> </span></li> <li> <span>SQL> </span><span>alter</span><span> system </span><span>set</span><span> remote_listener=</span><span>'LISTENERS_RACDB'</span><span> sid=</span><span>'*'</span><span>; </span> </li> <li><span>#(reset命令可以撤销设置,恢复默认值) </span></li> <li><span>系统已更改? </span></li> <li><span>SQL> </span></li> <li><span>SQL> show parameter remote_listener </span></li> <li> <span>NAME</span><span> TYPE VALUE </span> </li> <li> <span>------------------------------------ ----------- --------------------- </span><span> </span> </li> <li><span>remote_listener string LISTENERS_RACDB </span></li> </ol>
正确配置参数后,通过lsnrctl status命令看到在监听启动以后,可以看到监听器上有2个instance?
<ol> <li><span>[root@NODE01 bin]# lsnrctl status </span></li> <li> <span>LSNRCTL </span><span>for</span><span> Linux: Version 10.2.0.1.0 - Production </span><span>on</span><span> 18-</span><span>DEC</span><span>-2008 05:40:08 </span> </li> <li> <span>Copyright (c) 1991, 2005, Oracle. </span><span>All</span><span> rights reserved. </span> </li> <li> <span>Connecting </span><span>to</span><span> (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521)) </span> </li> <li> <span>STATUS </span><span>of</span><span> the LISTENER </span> </li> <li> <span>------------------------ </span><span> </span> </li> <li><span>Alias LISTENER_NODE01 </span></li> <li> <span>Version TNSLSNR </span><span>for</span><span> Linux: Version 10.2.0.1.0 - Production </span> </li> <li> <span>Start </span><span>Date</span><span> 18-</span><span>DEC</span><span>-2008 00:18:07 </span> </li> <li> <span>Uptime 0 days 5 hr. 22 </span><span>min</span><span>. 1 sec </span> </li> <li> <span>Trace </span><span>Level</span><span> </span><span>off</span><span> </span> </li> <li> <span>Security </span><span>ON</span><span>: </span><span>Local</span><span> OS Authentication </span> </li> <li> <span>SNMP </span><span>OFF</span><span> </span> </li> <li><span> </span></li> <li><span>Listener Parameter File /orac/orahome/oracle/product/10.2.0/db_1/network/admin/listener.ora </span></li> <li><span>Listener Log File /orac/orahome/oracle/product/10.2.0/db_1/network/log/listener_node01.log </span></li> <li><span>Listening Endpoints Summary... </span></li> <li><span> (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.170)(PORT=1521))) </span></li> <li><span> (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.180)(PORT=1521))) </span></li> <li> <span> (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(</span><span>KEY</span><span>=EXTPROC))) </span> </li> <li><span> </span></li> <li><span>Services Summary... </span></li> <li> <span>Service </span><span>"+ASM"</span><span> has 1 instance(s). </span> </li> <li> <span> Instance </span><span>"+ASM1"</span><span>, status BLOCKED, has 1 handler(s) </span><span>for</span><span> this service... </span> </li> <li> <span>Service </span><span>"+ASM_XPT"</span><span> has 1 instance(s). </span> </li> <li> <span> Instance </span><span>"+ASM1"</span><span>, status BLOCKED, has 1 handler(s) </span><span>for</span><span> this service... </span> </li> <li> <span>Service </span><span>"RACDB.chenxu.yo2.cn"</span><span> has 2 instance(s). </span> </li> <li> <span> Instance </span><span>"RACDB1"</span><span>, status READY, has 2 handler(s) </span><span>for</span><span> this service... </span> </li> <li> <span> Instance </span><span>"RACDB2"</span><span>, status READY, has 1 handler(s) </span><span>for</span><span> this service... </span> </li> <li> <span>Service </span><span>"RACDBXDB.chenxu.yo2.cn"</span><span> has 2 instance(s). </span> </li> <li> <span> Instance </span><span>"RACDB1"</span><span>, status READY, has 1 handler(s) </span><span>for</span><span> this service... </span> </li> <li> <span> Instance </span><span>"RACDB2"</span><span>, status READY, has 1 handler(s) </span><span>for</span><span> this service... </span> </li> <li> <span>Service </span><span>"RACDB_XPT.chenxu.yo2.cn"</span><span> has 2 instance(s). </span> </li> <li> <span> Instance </span><span>"RACDB1"</span><span>, status READY, has 2 handler(s) </span><span>for</span><span> this service... </span> </li> <li> <span> Instance </span><span>"RACDB2"</span><span>, status READY, has 1 handler(s) </span><span>for</span><span> this service... </span> </li> <li><span>The command completed successfully </span></li> </ol>
这时在客户端用sqlplus连接服务器数据库可能会出现如下错误:
<ol> <li><span>ERROR: </span></li> <li><span>ORA-12545: 因目标主机或对象不存在,连接失败 </span></li> </ol>
4?解决ORA-12545连接失败问题
配置客户端的Hosts文件
通过在客户端的Hosts文件中加入对两个服务名的名字解析可以解决ORA-12545问题?在windows下Hosts文件在C:\WINDOWS\system32\drivers\etc目录下,在linux修改/etc/hosts文件的内容?添加如下内容:
<ol> <li><span>192.168.1.170 node01 </span></li> <li><span>192.168.1.171 node02 </span></li> <li><span>其中node01?node02为服务器节点的主机名? </span></li> <li><span>[root@NODE01 bin]# hostname </span></li> <li><span>NODE01 </span></li> </ol>
5?通过客户端测试RAC负载均衡配置
<ol> <li><span>开启sqlplus_1: </span></li> <li> <span>SQL> conn sys/chenxu@racdb </span><span>as</span><span> sysdba </span> </li> <li><span>已连接? </span></li> <li><span>SQL> show parameter instance_name </span></li> <li> <span>NAME</span><span> TYPE VALUE </span> </li> <li> <span>------------------------------------ ----------- --------------- </span><span> </span> </li> <li><span>instance_name string RACDB1 </span></li> </ol>
开启sqlplus_2:
<ol> <li><span><span>SQL> conn sys/chenxu@racdb </span><span>as</span><span> sysdba </span></span></li> <li><span>已连接? </span></li> <li><span>SQL> show parameter instance_name </span></li> <li> <span>NAME</span><span> TYPE VALUE </span> </li> <li> <span>------------------------------------ ----------- ------------- </span><span> </span> </li> <li><span>instance_name string RACDB2 </span></li> </ol>
可以看到客户端能够连接到实例RACDB2,说明基于服务器端RAC负载均衡配置成功?

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The retention period of Oracle database logs depends on the log type and configuration, including: Redo logs: determined by the maximum size configured with the "LOG_ARCHIVE_DEST" parameter. Archived redo logs: Determined by the maximum size configured by the "DB_RECOVERY_FILE_DEST_SIZE" parameter. Online redo logs: not archived, lost when the database is restarted, and the retention period is consistent with the instance running time. Audit log: Configured by the "AUDIT_TRAIL" parameter, retained for 30 days by default.

The Oracle database startup sequence is: 1. Check the preconditions; 2. Start the listener; 3. Start the database instance; 4. Wait for the database to open; 5. Connect to the database; 6. Verify the database status; 7. Enable the service (if necessary ); 8. Test the connection.

The amount of memory required by Oracle depends on database size, activity level, and required performance level: for storing data buffers, index buffers, executing SQL statements, and managing the data dictionary cache. The exact amount is affected by database size, activity level, and required performance level. Best practices include setting the appropriate SGA size, sizing SGA components, using AMM, and monitoring memory usage.

To find the number of occurrences of a character in Oracle, perform the following steps: Get the total length of a string; Get the length of the substring in which a character occurs; Count the number of occurrences of a character by subtracting the substring length from the total length.

Oracle database server hardware configuration requirements: Processor: multi-core, with a main frequency of at least 2.5 GHz. For large databases, 32 cores or more are recommended. Memory: At least 8GB for small databases, 16-64GB for medium sizes, up to 512GB or more for large databases or heavy workloads. Storage: SSD or NVMe disks, RAID arrays for redundancy and performance. Network: High-speed network (10GbE or higher), dedicated network card, low-latency network. Others: Stable power supply, redundant components, compatible operating system and software, heat dissipation and cooling system.

Oracle can read dbf files through the following steps: create an external table and reference the dbf file; query the external table to retrieve data; import the data into the Oracle table.

Since the launch of ChatGLM-6B on March 14, 2023, the GLM series models have received widespread attention and recognition. Especially after ChatGLM3-6B was open sourced, developers are full of expectations for the fourth-generation model launched by Zhipu AI. This expectation has finally been fully satisfied with the release of GLM-4-9B. The birth of GLM-4-9B In order to give small models (10B and below) more powerful capabilities, the GLM technical team launched this new fourth-generation GLM series open source model: GLM-4-9B after nearly half a year of exploration. This model greatly compresses the model size while ensuring accuracy, and has faster inference speed and higher efficiency. The GLM technical team’s exploration has not

The amount of memory required for an Oracle database depends on the database size, workload type, and number of concurrent users. General recommendations: Small databases: 16-32 GB, Medium databases: 32-64 GB, Large databases: 64 GB or more. Other factors to consider include database version, memory optimization options, virtualization, and best practices (monitor memory usage, adjust allocations).
