Monday, August 1, 2016

How to use Redis(master-salve) as Web Cache?

Nowadays,Most Application use Redis as cache Service to improve user experience, now I will introduce how to use Redis(master-slave-sentinel) as web cache.

Firstly,
I'd like to introduce the application how to use the Redis(master-slave-sentinel), App will talk with Redis Sentinel and master/slave transient to application, so when have Redis master switch to slave, Application still work well,below is detail Sequence diagram.



















Secondly,
I'd like to introduce how to give one good Redis design to support business extends, I involved one concept "redis pool", that's includes "master-slave-sentinel", it maybe 1:1:3 or 1:2:3, so one pool can support one data centers all business or have several pools to service one data center business; anther is to ensure cache more simple, don't do data center redis pool replication, below is detail logic deployment Architecture.



Thirdly,
I'd like to introduce how to monitor the Redis health state, now we use python plug-in on collect to monitor the redis, below is detail work flow.





Huge Page Vs. Transparent Huge Page


Starting with RedHat6, RedHat7, OL6, OL7 SLES11 and UEK2 kernels, Transparent Huge Page are implemented and enabled (default) in an attempt to improve the memory management.  
Transparent Huge Page are similar to the Huge Page that have been available in previous Linux releases. The main difference is that the Transparent Huge Page are set up dynamically at run time by the khugepaged thread in kernel while the Huge Page(regular) had to be pre-allocated at the boot up time.

So once you setup Huge Page with Transparent for Oracle Database, it will downgrade the database performance suddenly,therefore we need disable the Transparent Huge Page, below is detail steps to disable Transparent Huge Page.

Add the following lines in /etc/rc.local and reboot the server (this still can be done on Redhat 7 although rc.local is being deprecated):


if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
   echo never > /sys/kernel/mm/transparent_hugepage/enabled
fi
if test -f /sys/kernel/mm/transparent_hugepage/defrag; then
   echo never > /sys/kernel/mm/transparent_hugepage/defrag
fi

Notes:
most of guys disable the Transparent Huge Page, but reboot's server still lost setup.

Reference:
Oracle Doc 1557478.1

How to Calculate Oracle Page Table Used Memory on Linux 64(bit)?

As DBA, you must know the concept of page table and huge page, because database's physical memory is huge and if you use common page(4K) to manage the memory, it will exhaust many physical memory on page table, Let's me introduce what's the problem on page table with common page(4K).

Firstly, I'd like introduce Linux x86_64 use 4 level page tables architecture.















Secondly,we know Linux x86_64 use 4 level page tables design and builds with PGD(9 bit),PUD(9 bit),PMD(9 bit),PTE (9 bit), page (12 bit), total 8 bytes(48 bits+16 bit unused).

thirdly, assume one Oracle Node Pre-Malloc physical memory is 96G,so used PTE(Page Table Entry) equals to 96(G)*1024*1024/4K =25,165,824,one PTE entry need 9 bits to descripte it,
So, that’s 27MB((25,165,824*9)/8/1024/1024=27M) of page table entries.

finally, assume one Oracle Node max support delicate sessions is 4000, that's meaning it have about 2675 oracle processes and each process which attaches to the SGA needs it's own copy of the page table, therefore it need about 70.5G(2675*27M) physical memory, that's why we need huge page to downgrade the page table used memory.

reference
https://lwn.net/Articles/106177/
https://docs.oracle.com/cd/E18283_01/server.112/e17110/initparams229.htm

Monday, July 13, 2015

Oracle Extended Distance Cluster which provide active-active mode for cross data center

What is an Extended Distance Oracle RAC Cluster?
 As the name implies, an Extended Distance Cluster is a cluster, in which most or all the nodes are not local and typically set up with a certain distance between them. Clusters of this kind have been referred to by many names, including “campus clusters”, “metro clusters”, “geo clusters”, “stretched clusters” and “extended clusters”. Some of these names imply a vague notion of distance range. This type of configuration will be referred to as either Oracle RAC on “Extended Distance Clusters” or “Stretched Clusters”, while the names will be used synonymous.
  If Oracle RAC One Node is concerned in a certain context, respective references will be made. Unlike classic Oracle RAC implementations, which are primarily designed as scalability and high availability solution that resides in a single data center, it is possible – under certain circumstances – to build and deploy an Oracle RAC system in which the nodes are separated by greater distances. For example, if a customer has a corporate campus, they might want to place the individual Oracle RAC nodes in separate buildings. This configuration provides a higher degree of disaster tolerance, in addition to the normal Oracle RAC high availability, since a fire in one building would not, if properly set up, stop the database from processing. Similar, many customers have two data centers in reasonable proximity.


Good article for host-based mirroring

https://bartsjerps.wordpress.com/2011/07/25/limitations-host-mirroring-clusters/

Sunday, June 28, 2015

Oracle SQLJ "ORA-29531 - no method ... in class ..."

Today, my colleague ask me to check one SQLJ error, "ORA-29531 - no method ... in class ...", all of right and the object status is valid, why still have the error? check the Oracle SQLJ Frequently Asked Questions,we found the root cause, when we define the "String" at java, it's java.lang.String, we need declare this at oracle procedure, otherwise it will use "java.sql.String", then raise the error.