Load Balancing (LB) detailed

Source: Internet
Author: User
Second, LB

LoadBalance is the allocation of load balance to the nodes of the cluster, thus improving the overall throughput capacity. Oracle 10g RAC provides two means to implement the payload, one of which is to assign the user to a different node according to an algorithm by connection balancing, and the other is to spread the application level by service.

Connection Balancing

Connection balancing This load balancing is done at the level of user connections, that is, when a user requests a connection, the connection is assigned to the instance based on each load. Once the connection is established, all operations of the session are completed on this strength, and are not allocated to other instances.

Client balance (client-side LB)

Client-side equalization (Client-side LB) is the method used by Oracle 8i, and the configuration method is to add Load_balance=yes entries to the client's Tnsnames.ora file. When a client initiates a connection, a random selection is selected from the Address list, and then a random algorithm is used to spread the connection request to each instance.

An example of TNS configuration for a client-side lb is as follows:

Taf_server =

(DESCRIPTION =

(address= (PROTOCOL = TCP) (HOST = FELIX1-VIP) (PORT = 1521))

(address= (PROTOCOL = TCP) (HOST = FELIX2-VIP) (PORT = 1521))

(load_balance= Yes)

(Connect_data =

(SERVER = dedicated)

(service_name = taf_server)

(Failover_mode =

(TYPE = SELECT)

(method = BASIC)

(retries = 180)

(DELAY = 5)

)

)

)

The disadvantage of this method is obvious, because the true load of each node is not taken into account when allocating the connection, the final allocation result is not necessarily balanced, and the random algorithm requires a long time slice, and if multiple connections are initiated in a short time, these connections are likely to be assigned to a node; even worse, The connection may be assigned to the failed node. So Oracle introduced the server-side (server-side LB) approach.

Summary: The biggest disadvantage of client-side equalization is that it cannot distribute user connections according to the real load of each instance.

Server-side equalization (Server-side)

the implementation of server-side load balancing relies on the load information of the listener (listening) handset. During the operation of the database, the Pmon background process will be able to register the load information of the mobile system and then enroll in the listener. At least one minute, up to 10 minutes Pmon is to be updated with information, and if the load of the node is higher, the update frequency is higher to ensure that listener can grasp the accurate load of each node. If the listener is closed, the Pmon process will check every 1 tricks to see if the listener is restarted, and in addition to this automatic, scheduled update task, the user can also use the Altersystem Register command to perform this process manually. This automatic update action can be seen from the listener log. Note: When the instance starts, the first registration process of the Pmon process is called server-rgister, and then the update process is called service-update;

Tnslsnr for linux:version 10.2.0.5.0-productionon 03-jun-2014 11:51:54

Copyright (c) 1991, Oracle. All rights reserved.

System parameter File Is/u01/oracle/10.2.0/db_1/network/admin/listener.ora

Log messages Written To/u01/oracle/10.2.0/db_1/network/log/listener.log

Trace Information Written TO/U01/ORACLE/10.2.0/DB_1/NETWORK/TRACE/LISTENER.TRC

Trace level is currently 0

Started with pid=25371

Listening on: (Description= (Address= (protocol=tcp) (host=felix1) (port=1521))

Listener completed notification to CRS on start

TIMESTAMP * CONNECT DATA [* PROTOCOL INFO] * event[* SID] * return CODE

03-jun-2014 11:51:54 * (Connect_data= (cid= (program=) (host=felix1) (user=oracle)) (Command=status) (ARGUMENTS=64) ( Service=listener) (version=169870592)) * Status * 0

03-jun-2014 11:52:15 * Service_register * felix2 *0

03-jun-2014 11:52:15 * Service_register * felix1 *0

03-jun-2014 11:52:15 * service_update * felix1 * 0

03-jun-2014 11:52:15 * Service_register * +ASM1 *0

Although the Listener log records the registration and update action of the Pmon process, but the content of the registration is not embodied, in order to obtain these content, can be obtained through various 1025 events, this time is with the Pmon activities.

Sql> alter session SET Events ' 10257 trace namecontext forever,level 16 ';

Session altered.

Sql>

Get trace file:

CREATE OR REPLACE FUNCTION get_trace return varchar is

RESULTVARCHAR2 (4000);

Begin

Dbms_output.enable (1000000);

Begin

For x in (SELECT d.value

||' /'

|| LOWER (RTRIM (i.instance, CHR (0)))

||' _ora_ '

|| P.spid

||'. Trc

Trace_file_name

From (SELECT p.spid

From V$mystat m, v$session s,v$process p

WHERE m.statistic# = 1 and s.sid= m.sid and p.addr = s.paddr) p,

(SELECT t.instance

From V$thread T, V$parameter v

WHERE v.name = ' thread '

and (v.value = 0 OR t.thread# = to_number (v.value))) I,

(SELECT VALUE

From V$parameter

WHERE NAME = ' user_dump_dest ') (d) loop

result:= Result | | X.trace_file_name;

End Loop;

End;

Return (substr (result, 1, 4000));

End Get_trace;

Select Get_trace from dual;

Get_trace

--------------------------------------------------------------------------------

/u01/oracle/admin/felix/udump/felix1_ora_27465.trc

The Pmon process not only recalls local listener registrations, but it can also register listener with other nodes. But exactly where to register is determined by the parameters of Remote_listener and Local_listener. Local_listener is not set, and remote needs to be set, the parameter value is a tnsnames item.

Sql> Show Parameter Listener

NAME TYPE VALUE

------------------------------------ -----------------------------------------

Local_listener string listener_felix1

Remote_listener string Listeners_felix

Sql>

The contents of the corresponding Listeners_felix in Tnsnames.ora are as follows:

Listeners_felix =

(address_list=

(address= (PROTOCOL = TCP) (HOST = FELIX1-VIP) (PORT = 1521))

(address= (PROTOCOL = TCP) (HOST = FELIX2-VIP) (PORT = 1521))

)

With the automatic registration mechanism of Pmon, the listener of each node of the cluster grasps the load state of all nodes, and when the client's connection request is received, the connection is transferred to the least load node, which may or may not be the other node, That is, listener will forward requests for user connections. Listener node selection methods vary depending on how the user is requesting the connection:

A If the user requests a dedicate proprietary connection, listener first selects the node with the least load, and selects the instance with the least load if multiple nodes load the same;

b If the user requests a shared server share connection, in addition to doing a node load comparison and instance load comparisons, select the smallest dispatcher for forwarding on the selected instance.

two kinds of lb configuration methods:

For Client-side LB, you need to add load_balance=yes to the customer's TNSNames entry. For Server-side LB, you need to configure Remote_listener this parameter.

one thing to note when configuring LB is that the default Sid_list_listener_name entries need to be dropped from the LISTENER files of each instance, so that the information obtained by LISTENER is dynamically registered, not static information read from the file.

Before modification:

[Oracle@felix2 admin]$ Cat Listener.ora

# listener.ora.felix2 Network Configuration file:/u01/oracle/10.2.0/db_1/network/admin/listener.ora.felix2

# Generated by Oracle configuration tools.

Listener_felix2 =

(Description_list =

(DESCRIPTION =

(address = (PROTOCOL = TCP) (HOST = FELIX2-VIP) (PORT = 1521) (IP = i)

(address = (PROTOCOL = TCP) (HOST = 192.168.10.102) (PORT = 1521) (IP =first))

)

)

 

----------------------------------------

Sid_list_listener_felix2 =

(sid_list=

(Sid_desc =

(Sid_name = Plsextproc)

(Oracle_home =/u01/oracle/10.2.0/db_1)

(program = Extproc)

)

)

[Oracle@felix2 admin]$

After modification, configure the following:

[Oracle@felix2 admin]$ Catlistener.ora

# listener.ora.felix2 Network Configuration file:/u01/oracle/10.2.0/db_1/network/admin/listener.ora.felix2

# Generated by Oracle configuration tools.

Listener_felix2 =

(Description_list =

(DESCRIPTION =

(address = (PROTOCOL = TCP) (HOST = FELIX2-VIP) (PORT = 1521) (IP = i)

(address = (PROTOCOL = TCP) (HOST = 192.168.10.102) (PORT = 1521) (IP =first))

)

)

[Oracle@felix2 admin]$

Distribute load with service

Connection balancing approach, Oracle's cluster "share everything" architecture, all nodes share one copy of the disk data. The performance of RAC is limited to the performance of cache fusion because of data synchronization between instances through cachefusion mechanism. Therefore, to improve the performance of RAC can start from two aspects, on the one hand, improve the ability of cache fusion, this can be through better interconnection equipment, such as the G-class private network, or the use of InfiniBand and other DRA technology; Can minimize the cache fusion flow, reduce the interdependence between the instances. and service is the latter kind of thinking on the basis of development.

First look at the partition technology that is very similar to the service. If the amount of data in a table is large, oralce suggests using partition table, which is dispersed to multiple physical segments (Segment) in a certain way, so that access to the data is limited to some local Segment.

The "Decentralized data" thought machine, in the RAC environment, if the data can be separated according to the application, consider the following scenario: An ERP application includes production, sales, supply chain management modules. Suppose the database uses a 2-node RAC before "data dispersal" is made, two users use the Sales module, then the two users may be assigned to two nodes, in the course of operation, sales data will be in the cache fusion, the role of continuous transfer between two nodes, If there are two other production module users, the two users are assigned to two nodes, in the process of operation, the production part of the data in the cache fusion with the assistance of the two strength between the synchronization.

Thus, if there is only one mechanism for connectionbalance, it appears that the user is assigned to a different instance, and the load seems to be dispersed. But this decentralization is not combined with the business needs of each user, is a pure technical means (so it can be called a pure technical means of dispersion).

If you change the idea of a solution, if you assign the user of the Sales module to Node 1, the user of the production module is assigned to Node 2, assuming that the data between the two modules is not much cross, this is the Sales module data are concentrated on Node 1, the Production Library module data are concentrated on Node 2, Cachefusion's workload will be drastically reduced, which fundamentally solves the problem of performance.

This idea is based on the basic idea of a service dispersed load. By dividing the application into service according to functional modules, each service is fixed on some RAC nodes, thus providing the system's performance fundamentally. This decentralized approach can be accomplished not only by DBAs, but by DBAs and developers who understand the characteristics of business data to see the effects.

In a RAC environment, service is not a must, but if the use of service to the application of the Division, I believe that the overall performance of the system to improve the benefits. There is another benefit of using service: You can create TAF parameters for the service within the database, and if you connect the database to the client through the service, you no longer need many of the Fail-over settings in the client Tnsnames.ora.

If you use the service method, the client configuration requires the use of a service_name entry, such as the following Red Word section:

Taf_server =

(DESCRIPTION =

(address= (PROTOCOL = TCP) (HOST = FELIX1-VIP) (PORT = 1521))

(address= (PROTOCOL = TCP) (HOST = FELIX2-VIP) (PORT = 1521))

(Connect_data =

(SERVER = dedicated)

(service_name = taf_server)

)

)

The detailed inquiry reference "Dahua RAC" John Zhang P238~242, speaks specially good ....

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.