My Youtube Channel

Please Subscribe

Flag of Nepal

Built in OpenGL

Word Cloud in Python

With masked image

Showing posts with label oracle. Show all posts
Showing posts with label oracle. Show all posts

Thursday, February 1, 2024

Steps to install oci8 on centos 8

The following steps is valid for Oracle 11g, you can modify as per your oracle version in a similar fashion.

1. Install the Oracle Instant Client:

   - Download the Oracle Instant Client RPM packages for your architecture from the Oracle website (https://www.oracle.com/database/technologies/instant-client/linux-x86-64-downloads.html). You'll need  oracle-instantclient-basic ,  oracle-instantclient-devel and oracle-instantclient-sqlplus packages.

   - Transfer the downloaded RPM packages to your CentOS 8 system if you downloaded them on a different machine.

Note: for centos, it is better to download “.rpm” file rather than “.zip”

2. Install the Oracle Instant Client RPM packages:

Go to the directory where you downloaded the oracle instant-client files and install those files:

Let’s take example for version oracle instant-client 11.2,

sudo dnf install oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm 

sudo dnf install oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64

sudo dnf install oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64

To verify whether the Oracle Instant Client "devel" package is installed on your CentOS system, you can use the package management tool rpm or dnf. Here's how you can check for the presence of the Oracle Instant Client devel package:

Using ‘rpm’:

rpm -qa | grep oracle-instantclient-devel

Using ‘dnf’:

dnf list installed | grep oracle-instantclient-devel

 

3. Verify the ORACLE_HOME environment variable:

echo $ORACLE_HOME

Ensure that the ORACLE_HOME environment variable is set correctly and points to the location where you installed the Oracle Instant Client. If it's not set correctly, you can set it as follows:

export ORACLE_HOME=/path/to/instant/client

During the installation process, you may be prompted to provide the path to the Oracle Instant Client library. If prompted, enter the correct path:

Enter the path: instantclient,/usr/lib/oracle/19.20/client64/lib

 

4. Set the environment variables required for OCI8 and PHP:

 

$ export ORACLE_HOME=/usr/lib/oracle/11.2/client64

$ export LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64/lib

sudo ldconfig

Once you are done with above steps, the environment is set for oci8 installation, follow the bellows steps now,

5. Stop Apache and uninstall older version of OCI8 if any (stopping Apache is very important):

 service httpd stop

 pecl uninstall oci8

 

6. Install php-pear and php devel:

 sudo yum install php-pear php-devel

 pear download pecl/oci8

7. The next commands depend on the version of oci8 downloaded above.

$ tar xvzf oci8-2.2.0.tgz

$ cd oci8-2.2.0/

$ phpize

$ export PHP_DTRACE=yes

$ sudo dnf install libnsl

$ sudo dnf install epel-release

$ setenforce 0

 

8. Make sure of the instantclient path below... mine was version 11.2 so it was located in this folder... Also make note some tutorials ask for the ORACLE_HOME folder which theoretically is /usr/lib/oracle/11.2/client64 but if its instantclient then put the lib folder underneath it (worked for me at least:)

$ ./configure --with-oci8=instantclient,/usr/lib/oracle/12.2/client64/lib/

$ make

$ make install

$ sudo pecl install oci8-3.3.0 instantclient,$ORACLE_HOME/lib

$ sudo systemctl restart httpd

$ sudo systemctl restart php-fpm

$ sudo systemctl restart mysqld 

9. NOW an .so file built in: /usr/lib64/php/modules/oci8.so

10. check whether oci8 has been successfully installed or not:

php -m | grep oci8

The steps may not be needed in most of the cases. If indeed, it is required in your case go through these steps as well (though it is suggested to first try running before implementing the below steps):

# THIS STEP NOT NEEDED if SELinux disabled on your server/box, but if SELinux is enabled run: setsebool -P httpd_execmem 1

# NOW add:   extension=oci8.so    at the bottom of your php.ini file (probably in /etc/php.ini)

# Add extension_dir=/usr/lib64/php/modules/


Tuesday, August 22, 2023

Physical IP Vs Virtual IP Vs SCAN IP (with Examples)

Physical IP, Virtual IP, and SCAN IP are terms often used in the context of networking and IT infrastructure. Let's break down the differences between these concepts:


1. Physical IP (Internet Protocol):

A physical IP address is a unique numerical label assigned to each device (like computers, routers, servers, etc.) connected to a network. It serves as an identifier that helps in routing data packets to the correct destination. Physical IP addresses are associated with the hardware of the device and are typically static, meaning they don't change frequently.


2. Virtual IP (VIP):

A virtual IP address is an IP address that is not associated with a specific physical device, but rather with a service or a group of devices that provide redundancy or load balancing. Virtual IPs are often used to ensure high availability and fault tolerance in server clusters. When a client requests a service, the virtual IP redirects the request to one of the available physical servers in the cluster, helping to distribute the workload evenly and providing redundancy in case one server fails.


3. SCAN IP (Single Client Access Name):

SCAN IP is a concept used in Oracle Real Application Clusters (RAC), which is a technology that allows multiple servers to work together as a single system to provide high availability and scalability for databases. SCAN IP provides a single DNS entry for clients to connect to the database cluster. This single DNS entry resolves to multiple IP addresses (usually three) that are associated with different nodes in the RAC cluster. This helps distribute the database client connections across the nodes and simplifies connection management.


In summary:

- Physical IP addresses are unique identifiers assigned to individual devices on a network.

- Virtual IP addresses are used for load balancing and high availability, directing client requests to a group of devices.

- SCAN IP is specific to Oracle RAC, providing a single DNS entry that resolves to multiple IP addresses for load distribution and easier client connection management to the database cluster.



Examples to make it more clear:


1. **Physical IP Address**:

Imagine you have a small office network with three computers: Computer A, Computer B, and Computer C. Each of these computers has a physical IP address assigned to it.


- Computer A: IP Address - 192.168.1.2

- Computer B: IP Address - 192.168.1.3

- Computer C: IP Address - 192.168.1.4


These IP addresses uniquely identify each computer on the network. When data packets need to be sent from one computer to another, they use these IP addresses to ensure the packets reach the correct destination.


2. **Virtual IP Address (VIP)**:

Let's say you have a web application that runs on a cluster of servers to handle incoming user requests. To ensure that the workload is distributed evenly and to provide fault tolerance, you set up a virtual IP address for the cluster. This IP address isn't tied to any specific physical server but rather represents the entire cluster.


- Virtual IP Address: 10.0.0.100


You have three physical servers in your cluster:


- Server 1: IP Address - 10.0.0.101

- Server 2: IP Address - 10.0.0.102

- Server 3: IP Address - 10.0.0.103


When a user tries to access your web application using the virtual IP address (10.0.0.100), the load balancer associated with that VIP will distribute the incoming request to one of the physical servers (e.g., Server 1). If Server 1 becomes overloaded or experiences issues, the load balancer can redirect traffic to Server 2 or Server 3, ensuring the application remains available.


3. **SCAN IP (Single Client Access Name)**:

Consider a scenario where you're using Oracle Real Application Clusters (RAC) to manage a database that serves a large number of clients. In this setup, you can use SCAN IP to simplify client connections.


You have an Oracle RAC cluster with three nodes:


- Node 1: IP Address - 192.168.1.10

- Node 2: IP Address - 192.168.1.11

- Node 3: IP Address - 192.168.1.12


With SCAN IP, you have a single DNS entry:


- SCAN IP Address: scan.mydatabase.com


When clients want to connect to the Oracle database, they use the SCAN IP address (scan.mydatabase.com). Behind the scenes, the DNS resolution for this SCAN IP results in the three node IP addresses. This simplifies client connection setup and load distribution, as clients don't need to know the individual node addresses.


So, if a client connects to scan.mydatabase.com, the DNS system resolves this to one of the three IP addresses (e.g., 192.168.1.10), enabling the client to communicate with one of the nodes in the Oracle RAC cluster.


In summary, these concepts highlight how IP addressing can be used to manage and optimize network resources, distribute workloads, and simplify client connections in various scenarios.

Tuesday, July 25, 2023

What is Archive logs in Oracle database?

An archive log is a term commonly used in the context of database management systems, particularly with relation to Oracle Database.


In a database system, the archive log refers to a copy of a redo log file that has been filled with data and then archived (backed up) to a storage location, such as a separate disk or tape. The redo log files store a record of changes made to the database, and these changes are essential for recovering the database in the event of a failure or for performing certain types of backups (e.g., hot backups).


Here's a brief overview of how archive logs work in Oracle Database:


1. Redo Log Files: When changes are made to the database, they are first written to the redo log files in a circular fashion. These files are crucial for maintaining a record of all transactions that modify the database.


2. Log Switch: Once a redo log file is filled with data, a log switch occurs, and the database starts writing to a new redo log file. The filled redo log file is now ready for archiving.


3. Archiving: The filled redo log file is copied (archived) to a separate location known as the archive log destination. This process ensures that a copy of the redo log is preserved even after a log switch, which helps in data recovery and backup operations.


4. Backup and Recovery: By regularly archiving the redo logs, database administrators can use them to recover the database to a specific point in time in case of a system failure or data corruption. Additionally, archive logs are necessary for performing consistent backups while the database remains operational (hot backups).


It's essential to manage archive logs properly to avoid running out of disk space and to ensure database recoverability. Administrators often set up proper archiving policies and regularly back up archived logs to free up space and safeguard critical data.

Saturday, June 3, 2023

Differences between Datafile and Tablespace



 

Datafile

Tablespace

Definition

Physical file used by the DBMS to store data

Logical storage container within a database

Purpose

Stores actual data, indexes, and other database objects

Provides a logical organization and management structure for storing and accessing data

Location

Resides on a storage device (e.g., hard drive, SAN)

Exists within the database

Managed by

Operating system

Database management system

Unit of storage

Individual file

Collection of one or more datafiles

Allocation

Datafiles are allocated to tablespaces

Tables, indexes, and other database objects are allocated space within tablespaces

Administrative control

File-level management

Logical-level management

Separation

Represents physical storage

Provides a logical grouping of data

Usage

Accessed by the DBMS for reading and writing data

Used by the DBMS to organize and manage data


 




Friday, June 2, 2023

Real Application Clusters (RAC) in database

RAC stands for Real Application Clusters, and it is a feature of Oracle Database that allows multiple instances (database servers) to simultaneously access and manage a single database. This distributed architecture provides several benefits in terms of high availability, scalability, and performance.

In a RAC configuration, multiple servers are interconnected, forming a cluster. Each server runs its own instance of the Oracle Database software, and all instances share access to a common set of data files residing on a shared storage system. This shared storage can be a Storage Area Network (SAN) or Network Attached Storage (NAS).



Let's dive into the details:

1. High Availability: RAC provides a robust high-availability solution for Oracle databases. By having multiple instances running on separate servers, RAC ensures that if one server or instance fails, the database service continues uninterrupted. Other instances in the cluster take over the workload, providing automatic failover. This architecture minimizes downtime and ensures continuous availability for critical applications.


2. Scalability: RAC allows organizations to scale their database infrastructure horizontally. Additional servers or nodes can be added to the cluster, enabling the database to handle larger workloads and accommodate increased user demand. RAC provides a shared-nothing architecture, where each instance manages a subset of the data, allowing for distributed processing and improved performance as the cluster grows.


3. Load Balancing: RAC intelligently distributes the database workload across multiple instances. Incoming database requests are evenly distributed among the available nodes, ensuring optimal resource utilization and performance. This load balancing capability helps prevent bottlenecks and allows the system to handle more concurrent users and transactions.


4. Shared Storage: RAC relies on shared storage, such as a Storage Area Network (SAN) or Network Attached Storage (NAS), to provide simultaneous access to the database files. All instances in the cluster can read and write to the shared storage, ensuring data consistency across the cluster. This shared storage allows for seamless data synchronization and facilitates data access from any node in the cluster.


5. Cache Fusion: Cache Fusion is a key technology in RAC that enables efficient data sharing among instances. It leverages a high-speed interconnect network between the nodes to allow direct access to each other's memory caches. When one instance requires data that resides in another instance's cache, Cache Fusion facilitates the transfer of data blocks between the instances without the need for disk I/O. This greatly reduces latency and enhances overall performance.


6. Transparent Application Failover (TAF): RAC includes Transparent Application Failover, which enables uninterrupted connectivity and session failover for applications. In case of instance or server failure, the application connections are automatically redirected to surviving instances within the cluster. This failover process occurs transparently to the application, minimizing disruption and providing seamless continuity.


7. Administration and Management: RAC provides a set of management tools and utilities to simplify the administration of the cluster. Oracle Clusterware, a component of RAC, manages cluster resources, handles node failure detection, and facilitates automated recovery. Oracle Enterprise Manager (Grid Control) offers a comprehensive interface for monitoring, configuration, and performance tuning of the RAC environment.


Implementing and managing a RAC database requires careful planning, design, and configuration. Proper load balancing, fault tolerance, and performance optimization techniques should be employed to fully leverage the benefits of RAC. It's important to note that RAC is an enterprise-level feature of Oracle Database and may require additional licensing and specialized expertise to deploy and maintain effectively.