Wednesday, February 27, 2013

Are you planning a database upgrade keeping in mind a back-out (downgrade) plan in mid?


Are you planning a database upgrade keeping in mind a back-out (downgrade) plan in mid? Here are a few very important MOS docs explains all about:

  • How To Downgrade From Database 11.2 To Previous Release (includes 11.2.0.3-11.2.0.1) [ID 883335.1]
  • Database Server Upgrade/Downgrade Compatibility Matrix [ID 551141.1]
  • Master Note For Oracle Database Downgrade [ID 1151427.1]
  • Downgrading Database Without Executing catdwgrd.sql (11.1.0.x to 10.2.0.x/10.2.0.x to 10.2.0.x) [ID 783643.1]
  • Complete Checklist For Downgrading The Database From 11.1 To Lower Releases [ID 443890.1]

Saturday, September 8, 2012

DBA Staffing Considerations

Staffing the DBA organization is not a simple matter. Several non trivial considerations must be addressed, including the size of the DBA staff and the reporting structure for the DBAs.

One of the most difficult things to determine is the optimal number of DBAs required to keep an organization’s databases online and operating efficiently. Many organizations try to operate with the minimal number of DBAs on staff; the idea being that fewer staff members lowers cost. However, that assumption may not be true. An overworked DBA staff can make mistakes that cause downtime and operational problems far in excess of the salary requirements of an additional DBA.

Determining how many DBAs is optimal is not a precise science. It depends on many factors, including:

Number of Databases: The more databases to be supported, the more complex the DBA job becomes. Each database needs to be designed, implemented, monitored for availability and performance, backed up, and administered. There is a limit to the number of databases that an individual DBA can control.

Size of the Databases: The larger the databases to be supported, the more difficult the DBA job. A larger database takes longer to create, maintain, and tune. In addition, more potential for confusion arises when SQL takes longer to execute—causing the DBA to spend more time working with developers to tune SQL.

Number of Users: As additional users are brought online, optimal database performance becomes more difficult to ensure. Additionally, as the number of users increases, the potential for increase in the volume of problems and calls increases, further complicating the DBA’s job.

Number of Applications: As more applications are brought online, additional pressure is exerted on the database in terms of performance, availability, and resources. As more applications are brought online, more DBAs may be required to support the same number of databases.

Type of Applications: The administrative needs of mission-critical applications differ from non-mission-critical applications. Mission-critical applications are more likely to require constant monitoring to ensure availability. Likewise, an OLTP application has different DBA requirements than an OLAP application. Each has administration challenges that require different DBA procedures and depending on the mix, can drive up the needed number of DBAs.

Service Level Agreements (SLAs): The more restrictive the SLA, the more difficult it becomes for the DBA to deliver the service. For example, a service level agreement requiring sub-second response time for transactions is more difficult to support than an agreement requiring one-second response time.

Availability Requirements: Database administration becomes easier if databases have an allowable period of scheduled downtime. Some DBA tasks either require an outage, or are easier when an outage can be taken. 24/7 considerations, such as supporting Web applications, drive the need for higher availability— and can increase the number of DBAs needed.

Impact of Downtime: The greater the financial impact of an unavailable database, the greater the pressure on the DBA to assure greater database availability.

Performance Requirements: As the requirements for database access become more performance oriented, DBA complexity rises.

Volatility: The frequency of database change requests is an important factor in the need for additional DBAs. A static database environment requiring few changes will not require the same level of DBA effort as a volatile, frequently changing database environment. Unfortunately, the level of volatility for most databases and applications tends to change dramatically over time, making it difficult to ascertain how volatile an overall database environment will be over its lifetime.

DBA Staff Experience: The skill of the existing DBA staff affects the need for additional DBAs. A highly skilled DBA staff will accomplish more than a novice team. Skills, more than experience, dictate DBA staffing requirements. A highly skilled DBA with two years of experience might outperform a veteran who is burned out or unmotivated.

Programming Staff Experience: If the application developers are not highly skilled in SQL programming, DBAs will need to be more involved in the development process; for example, in such tasks as composing complex SQL, analyzing SQL and application code, debugging, tuning, and ensuring connectivity. As the experience of the programming staff increases, the complexity of DBA requirements decreases.

End User Experience: When end users access databases directly with ad hoc SQL, their skill level has a direct impact on the complexity of DBA. If the end user has low SQL skills, the DBA will need to initiate more performance monitoring and tuning.

Variety of DBMSs: The more heterogeneous the environment, the more difficult it becomes to administer. For example, acquiring and maintaining expertise in both Oracle and DB2 is more difficult than gaining expertise in only one of them. As multiple DBMSs of different types are installed, DBA becomes more difficult. A shop with DB2 and IMS will have to possess both relational and hierarchical expertise.

DBA Tools: Tools that automate DBA tasks and make database administration easier can reduce DBA staffing needs. DBA tasks become less complex with the more tools available and the degree to which they are integrated.

This list of issues notwithstanding, creating a formula that will dictate the optimal number of DBAs to employ is difficult. No industry standard calculation exists and each organization will place different emphasis on different criteria. At any rate, coming up with a formula that works for your shop can be a worthwhile endeavour to add rigor to your DBA staffing decisions.

Monday, July 2, 2012

How to measure a DBA's workload?


For the past some days, I was thinking of ways to measure the workload of a DBA or team of DBAs in the context of operations. Metrics such as ticket counts, instance or database counts, etc. each have their own imperfections but they all have their advantages, too. Maybe you've got a simple formula that combines multiple metrics?

It all depends on what is the purpose. When planning DBA teams resourcing at one of my previous work place, we were using time because we know how much time we get from the team (minut vacations, overheads, training, internal projects and etc) and how much time we committed to the customers and the forecasts. I didn't see a single or a combination of dimensions that coule reliably give you universal indicator. If you take database count, for example, one customers would take 10 times more efforts per database compare to another but the environment and scope of work are different. It's always comparing apple to oranges.

When I managed a team, I split it into five tracks. Tickets (Issues/Problems), Projects, Learning, Admin and Timeoff. Time and effort expended in hours were the basic metrics. The key is to have a time forecast of loading or utilization based on historical trends of tickets, current projects being worked on, Admin and Timeoff so you can demonstrate the capacity of your team in a systematic way. We could learn a lot from the PM folks. They are always busy and they can prove it!! If you don't have this, you are going to be challenged on what the resources are doing and you will be overloaded. Run your group as a consulting busines and you will find it is the way to go.

I have done a little bit of research on the same before on this subject, please see http://www.khwajaimran.blogspot.com/2012/07/how-many-dbas-do-you-need-to-support.html

Essentially, I found that an average DBA can take care of 40 databases, up to 5 TB. Bigger data is harder to handle, so it isn't universal, but this is a good baseline. I know every shop is different, but I have been to at least a hundred different companies and this seems to hold relatively true, even across industries and vendors. Caveat emptor, there are always exceptions.

Were I measuring a team, I would come up with a baseline somewhat like this, but customized door our environment. Then I would look at whatever factors either increased revenue, decreased cost, or removed risk for the business in a quantitative way. Rank your people based on these, as they are the only things that your executive team cares about. If you can explain your teams actions in these terms you will be much better off.

From my experience as a DBA for over 8 years, I agree with the 40:1 ratio and DB Size but at the same time load on DB is also an major point where managers needs to keep eye's close and estimate head count requirement for respective Technology DBA's. I define DB Load as number of concurrent sessions and transactions. We may also see Data warehouse systems with us, but comparatively less concurrent sessions at the same time DB must be tuned is such a way that daily data loading and other process should complete within the agreed SLA limits so at that time DBA also have load on them. So, when I estimate the DBA requirement, I will mostly take care of 
  1. Technology DBA's 
  2. Number of DB/Instances
  3. Number of Servers 
  4. Each DB Size
  5. Load on Each DB/Instance 
  6. Capabilities of existing staff members 
  7. Expected average completion time for each task for Production DB Support 
  8. Projects In Hand (Other than the regular Production Support) 
  9. Expected Projects
  10. Project time lines 
  11. Staff (Scheduled Leaves & Unscheduled Leaves taken into consideration)
  12. Last but not the least Commercials: This is required for low cost projects and tasks should be done by junior staff and critical deliverable which impact business can be taken care by senior Staff.
Again, this is always tough to document and prove. I think it depends on the priorities from up top. For us, even though DB projects lag or never get done the executives don't really care about that metric. Nor do they care about the number of instances or databases managed per dba. They see the bottom line of everything is fine operationally so why add headcount? What they do value is development for our core product. If something were to slow down development (ie ticket turnaround for new/altered schema) then they would notice and react. Certainly not perfect or all encompassing, but developer tickets is right now the only way I've justified additional headcount.

For me the main measure is % completion within SLA. Of course this assumes that you have agreed SLAs for all your activities. For break/ fix, this is driven by the urgency assigned when the ticket is raised. For scheduled activities (new DB builds etc) this is pre-defined or agreed at the time the ticket is raised. If your team cannot deliver a consistent completion rate within SLA of 97% plus, then you maybe should be looking at the structure of your team.

One thing to also consider, is the type of application(s) running on the databases(s). A database serving up data for a well written application - no matter what size DB or load or anything else - is going to require a lot less time from a DBA compared to a database serving a poorly written application. I've seen many cases where a developers have general database skills and don't always design correctly for the database they're using. Then they release the application and 2 months later frantically phone the DBA team saying the database is slow ... I think we've all been there. The point is, database maintenance efforts have a direct relationship to the quality of the application running with it. Just another thing to consider along with the metrics.

A new question araises here, does this hold true for different types of databases? Teradata? SQL Server? MySQL? Sybase? DB2?

In my previous post, I suggests that SQL Server is somewhat easier to manage (i.e. more instances per DBA) but I think that has a smaller effect than other things. My own experience is that the type of database has less influence on the team's efficiency than other elements. For example, I two teams in comparable technical environments but widely varying efficiencies (60 instances per DBA versus 110). The differentiating factors seem to be non-technical: quality of documentation; maturity of ITIL processes, overhead induced by processes.

Sometimes, I have a different thought again like the number of DBA's depending upon size of the database doesn't help. In the era of big data size doesn't matter, number of tickets, average ticket resolution time, SLA trends etc, DB criticality (Tier 1,2,3) etc are very important when compared to the DB size. I find the size of the database has little to do with the workload of the DBA. We've got a number of smaller databases that require many hours of DBA work simply due to the activity levels of the business. Some of our internal clients are continually making changes or creating short-term applications (some of these are online games or projects related to broadcast programming). These projects usually have very tight deadlines and require considerable attention from our DBAs. 

I don't think you can base a DBAs workload on simply the number of tickets (one ticket might required 10 mins of work while another could be a week). Size of the database isn't necessarily an indicator of workload either. I think the best measurement is going to be the hours required to work on a given project or task. And, even then, the result may be different depending upon the amount of experience a DBA has. 

If you had a ticketing system that is rigorously used both for tracking and time spent and you were able to report on it by database, then that would be a proxy for what you are describing. Excellent.

Once again, there is no unique formula. Two major examples: 

1. If DBA # 1 works 1-hour on a ticket and DBA # 2 works also 1-hour on another ticket: Is the work they do the same? 
Answer: NO. 

2. If DBA # 1 handles daily 20 databases and so does DBA # 2: Are they equally busy? 
Answer: NO.

Measuring only on the basis of ticket is wrong. But if we add the complexity of tickets and client issue which were not resolved by others and one is consuming time of 8 hour to resolve where as deliverable is too much critical at the same time another DBA using 8 hours for small normal daily activity is also having same importance. In short DBA's are valued resource to the company and their respective managers have to decide depending on scenarios and current requirement what is fruitful for him/her.

DBA workload in my opinion should be measured on the complexity type of the tasks and the duration it takes to complete. 

For example, you can have a DBA work all day working on one big project, say 11g R2 Upgrade. 

You can have another DBA do 50 BAU tickets.

DBA workload should be measured on the DBA skill set level & how much Projects/BAU operations he/she can handle. Nowadays, it is not only the technical skills that matter, we have to measure them also on the soft skills they possess. If there is a gap in that area, projects does suffer due to communication issues. 

Long story short, we should categorize DBA workload as Level 1 (Entry Level), Level 2 (Medium), Level 3 (Complex). 

Measuring DBA workload will be kind of like a tuning exercise. You start with a baseline on your team strength and the tasks in hand and based on the upcoming activities, can easily compute whether you can handle the additional workload with the current resource pool (or) if you need to hire additional resources (or) limit projects.

I agree that the DBA workload should be measured as Entry, Medium or Complex. Most ticketing systems do not have such a meter used or if it exists its values are often questionable due to the reason that people who create, assign or approve DBA tickets cannot qualify the complexity of the work. Surprising enough, many generic managers still cannot comprehend the difference between compressing a file with WinZip and compressing a table with Oracle Advanced Compression.

Database Migrations Are Finally Becoming Simpler


Lately I have been getting quite a few inquiries on database migrations asking me about migration approaches, best practices, and tooling. Some of the reasons why companies are looking at migrations are because of staffing issues, scalability and security concerns, and cost-saving strategies. Migrations have always been complex, time consuming, and expensive, because each DBMS has proprietary data structures, data types, and SQL extensions. Once you choose a DBMS, you get locked into its platform, often creating a challenge when looking to migrate. Some companies told me that it took them more than a year to migrate some large and complex applications, which is not surprising. Although, tools and services have helped with migrations in the past, they have not been comprehensive and automated, which would make the process simple. Since, I'm an IT manager in the retail sector in my opinion I would say, “We did not want to spend a million dollars on tools and services just to save a million dollars on our database platform; it just didn’t make sense.”


The good news is that there is a new option that has recently emerged and has been gaining ground. Enter the “database compatibility layer,” which changes the way migrations are done. IBM DB2 9.7 for Linux, UNIX, and Windows offers out-of-the-box compatibility for Oracle’s PL/SQL and Sybase ASE, which allows many applications to run against DB2 without any application code changes. Although the database compatibility layer does not offer 100% compatibility today, based on customer feedback from more than two dozen interviews that I have conducted this year, one can usually expect 90% or more compatibility, requiring only minor code changes. This is huge, which makes migrations simpler, taking only days and weeks as opposed to months and years. IBM jointly developed the database compatibility layer technology with vendors EnterpriseDB (for Oracle compatibility) and ANTs (for Sybase ASE compatibility), who also offer their own database migration solutions.


The database compatibility layer finally opens up the door to more migrations, reducing risk and making them cost effective. I estimate that so far, some 300 companies have migrated their databases using the database compatibility layer, and this is likely to become the standard approach for database migrations in the future.


I would love to hear feedback on database migration experiences using the compatibility layer or other approaches -- things that have worked for you and things that did not. Also, are you looking to migrate anytime soon or holding back because of the risk involved?

How Many DBAs Do You Need To Support Databases?



I frequently get asked the question of how many databases a DBA typically manages. Over the past few years, I have done research on this topic with some of my friends in DBA Faternity, Senior DBA's and DBA Managers, asking them about their ratios and how they improved them. Typically I find that the current industry average is 40 databases to a DBA for large enterprises ($1 billion+ in revenue), with the lowest ratio seen around eight and the highest at 275. So, why this huge variation? There are many factors that I see in customer deployments that contribute to this variation, such as the size of a database, database tools, version of databases, DBA expertise, formalization of database administration, and production versus nonproduction.


This ratio is usually limited by the total size of all databases that a DBA manages. A terabyte-sized database remains difficult to manage compared to a database that's 100 GB in size. Larger databases often require extra tuning, backup, recovery, and upgrade effort. The average database-to-DBA ratio is often constrained by the total size of the databases being managed, which tends to be around five terabytes per DBA. In other words, one DBA can effectively manage 25 databases of 200 GB each or five 1 terabyte databases. And these include production and nonproduction databases.


What are the factors that can help improve the ratio? Cloud, tools, latest DBMS version (automation), and DBMS product used – Oracle, SQL Server, Teradata, DB2, MySQL, or Sybase. Although most DBMS vendors have improved on manageability over the years, based on customer feedback, Microsoft SQL Server tends to have the best ratios.


I believe that although you should try to achieve the 40:1 ratio and the 5 terabyte cap, consider establishing your own baseline based on the database inventory and DBAs and using that as the basis for improving the ratio over time.


I would love to hear about your database-to-DBA ratios and what's working and what's not in your organization when it comes to database administration.

Sunday, July 1, 2012

Is SQL Tuning worth in Production Database Environment?


In my opinion the DB/Instance Tuning is good for all DBA as most of the time we do not have the right to change the SQL in the application as application team is not willing to change he code and its style. Mostly the Dynamic SQL's.


SQL tuning generally delivers the most significant performance gains. Lack of experience or time, inability to change SQL and other barriers are mostly excuses. It might not be easy at time but it needs to be done. I think SQL Tuning is worth in every environment, not just in Production. My point is that there is good and not so good SQL Tuning. And tuning one SQL can un-tune several other SQLs.


SQL tuning is too good while the application is still under development where development team members and database analyst have to know how much data needs to be fetched and time statistics. In most of the production databases environments, I also see that the time spend for a query tuning is too much as compared to tweaking any parameter subject to the resource where he/she is having good knowledge of it. But again SQL Tuning should be taken care by Development team members where they know more about the application behavior. I could also see in my previous teams that they have pressure to release the change request (CR) and in a hurry they release the untuned code and ultimately when it is on production then blame game starts from here on.


In my opinion, whether it's developers of development DBAs or production DBAs, they should be armed to access production environments to assist with SQL diagnostics and tuning. How the changes to SQL are made is subject to your change management and development life cycle.


Again, SQL tuning is one of the biggest performance tweaks you can make. It's true, you don't always have the ability to change SQL if it's dynamically generated, comes from a vendor product, or developers just don't have time to work on it. Nonetheless, I believe it can have some of the biggest impact on databases, production or not, and provide some of the biggest performance improvements you might see. 


Certainly there can be other areas of tuning that can have a significant impact on performance - memory, CPU, buffer space, etc. But, after many years of being a DBA, the thing I've seen more times than anything else is inefficient SQL. It's worth knowing how to find such code and determine if anything can be done to improve it. While you may be limited to throwing hardware at performance issues, that's certainly not the best nor most cost effective way to improve performance. 


In our shop, we can look for areas in which SQL might be improved and if we see changes that need to be made to the SQL statement itself, we work with the development group to make and test such changes before pushing them into production.

TODAY'S IT INFRASTRUCTURE

I found the following once in a presentation. It gives you an idea of "Today's IT Infrastructure". ;-))))



Cheers,
Khwaja Imran
www.khwajaimran.com


Saturday, May 12, 2012

DBA Manager : Roles & Responsibilities


Dear DBA Managers,

Thanks for visiting my blog & most importantly this page. I would like to share here some of my experiences that I have had while working with the DBA team and the success we have achieved in delivering the best Database services.

You as a DBA Manager have invested all of your energy into building the right DBA team, however no IT Department or Unit can function for a long time without a team of productive employees who feel appreciated and that as a team their unit is progressing steadily.

Follow the guidelines outlined below which I have tried myself and worked in most of the situations. 
  • You will not succeed in managing a Database Administration section if you do not walk several steps ahead of your staff in database technologies. I have always indulged in nitty-gritty details of the activities of the section whether it is installation of new release like Oracle 11g, deploying RAC, testing a restore, writing batch scripts to automate RMAN jobs etc. You must know about each and every job first hand in order to succeed. Remember DBA Manager is not a general management position; it is 70-80% technical and far less managerial in compare to other job titles like Development or Systems Manager.
  • Never, I repeat ever confront your staff or criticize in general terms. Some of you may not agree with this logic. Your goal is to evaluate job performance and not the DBA as a person. If there is an issue with one of your staff, try to point out his mistakes by having a session with him and perform the same technical task yourself in front of him.
  • While conducting performance appraisals, avoid going to a very detailed review, rather focused on objectives which are achieved and never let employee feel that he is subjected to a review which makes him believe that he is responsible for all database faults as if he was a database engine by himself. Always remember the fact that Databases are prone to bugs and that is why database vendors release patches.
  • Always listen to what DBA's are suggesting and never pretend that you already know what they meant to say as if you are ahead of them. Let them take the ownership of the discussion and for a change act as if you are learning from their experience.
  • At least in a financial organization like banking industry, DBAs are supposed to support production problems after business hours, therefore, always show concern about their family life and jointly discuss solutions to try to create a balance. Discuss openly how he or she thinks about the job and what opportunities exist in future. I had a DBA who was performing very well but later he realized that he has far more potential in another technology sector. I had therefore helped him in his transition to that department which came out as a win-win situation for the company.
  • During a production problem stay calm and centred to the problem in hand. Later once the issue is resolved, sit with the concerned DBA and talk openly about how the problem could have been avoided and point out his mistakes in a manner that you are trying to improve the existing procedures by adopting better pro active measures which may also include having him or her repeat the job in a testing environment again and again until results are achieved.
  • I have always encouraged a developer turned DBA's, because I personally would not like to hire a DBA who does not have any programming experience. You can train a person to become Operating System Administrator from the start but this is not true for DBA's. The key to a successful DBA is to be able to understand and resolve Database problems from all angles including Program code, network and system issues. A DBA sits in the middle of all this, just like a middle-ware component and he or she needs to master end-to-end investigation techniques.
  • You should organize seminars within the team and send them to training abroad. Instead of sending them to local training centres, I strongly recommend to send staff to an Oracle Education/Training Partner or to Oracle University in your area or region.

Friday, May 11, 2012

Moved to IT Management role in February 2011

Dear All,

It has been a long time, I wrote an article on this blog. I last wrote an article on 6-September-2010. Due to my tight schedule & to settle in my new role, I hardly had any time to write an article on this blog.

In February 2011, I have moved to an IT Management role as "Project Manager - Midrange, Databases & Oracle ERP Applications" where in I was leading the Oracle ERP practice at Gazzaz (Saudi Arabia) & to manage, lead and supervise the Oracle ERP Applications team. Here, I had the end-to-end responsibility for database, storage, UNIX, backup operations & projects. One of my primary responsibilities also includes, managing a team of DBAs supporting mission-critical Oracle, Microsoft SQL Server & Oracle E-Business Suite databases. Within 6 months of joining due to creation of a new position, I was promoted as "IT Manager & Head of IT Operations" to lead a major business transformation at Gazzaz & its subsidiaries. This includes the implementation of Oracle ERP and the development of new business models, directing & managing the IT functions and activities in the company through the development of IT Strategies, Objectives and Policies, as well as monitoring the implementation of IT systems in order to ensure the provision of reliable, secure, high performance, cost effective IT services. Responsible for technology operations & data management. Operate a heavily outsourced environment with significant vendor management accountabilities. Responsible for the day-to-day operations of the IT Support Team that includes assigning tasks, prioritizing work, resource management & resolving staff issues. 

For years I have been a Unix Administrator, Oracle DBA & DBA Manager. I have been writing topics & articles related to Oracle Database Administration & some system administration topics in a DBA perspective.

From now on I will be writing articles related to IT Management, IT Strategy, Remote Infrastructure Management, Cloud Computing, Virtualization & emerging trend in IT.

Cheers!!!

Khwaja Imran
www.khwajaimran.com


Monday, September 6, 2010

Purging trace and dump files with 11g ADRCI

In previous versions of Oracle prior to 11g, we had to use our own housekeeping scripts to purge the udump, cdump and bdump directories.

In Oracle 11g, we now have the ADR (Automatic Diagnostic Repository) which is defined by the diagnostic_dest parameter.

So how are unwanted trace and core dump files cleaned out in 11g automatically?

This is done by the MMON background process.

There are two time attributes which are used to manage the retention of information in ADR. Both attributes correspond to a number of hours after which the MMON background process purges the expired ADR data.

LONGP_POLICY (long term) defaults to 365 days and relates to things like Incidents and Health Monitor warnings.

SHORTP_POLICY (short term) defaults to 30 days and relates to things like trace and core dump files

The ADRCI command show control will show us what the current purge settings are as shown below.

adrci> show control
ADR Home = /u01/app/oracle/diag/rdbms/ttrlwiki/ttrlwiki:
*************************************************************************
ADRID SHORTP_POLICY LONGP_POLICY LAST_MOD_TIME LAST_AUTOPRG_TIME LAST_MANUPRG_TIME ADRDIR_VERSION ADRSCHM_VERSION ADRSCHMV_SUMMARY ADRALERT_VERSION CREATE_TIME
-------------------- -------------------- -------------------- ---------------------------------------- ---------------------------------------- ---------------------------------------- -------------------- -------------------- -------------------- -------------------- ----------------------------------------
1095473802 720 8760 2010-07-07 08:46:56.405618 +08:00 2010-08-22 22:14:11.443356 +08:00 1 2 76 1 2010-07-07 08:46:56.405618 +08:00

In this case it is set to the defaults of 720 hours (30 days) for the Short Term and 8760 hours (One year) for the long term category.

We can change this by using the ADRCI command ‘set control’

In this example we are changing the retention to 15 days for the Short Term policy attribute (note it is defined in Hours)

adrci> set control (SHORTP_POLICY =360)
adrci> show control
ADR Home = /u01/app/oracle/diag/rdbms/ttrlwiki/ttrlwiki:
*************************************************************************
ADRID SHORTP_POLICY LONGP_POLICY LAST_MOD_TIME LAST_AUTOPRG_TIME LAST_MANUPRG_TIME ADRDIR_VERSION ADRSCHM_VERSION ADRSCHMV_SUMMARY ADRALERT_VERSION CREATE_TIME
-------------------- -------------------- -------------------- ---------------------------------------- ---------------------------------------- ---------------------------------------- -------------------- -------------------- -------------------- -------------------- ----------------------------------------
1095473802 360 8760 2010-08-27 09:36:09.385370 +08:00 2010-08-22 22:14:11.443356 +08:00 1 2 76 1 2010-07-07 08:46:56.405618 +08:00

We can also manually purge information from the ADR using the ‘purge’ command from ADRCI (note this is defined in minutes and not hours!).

In this example we are purging all trace files older than 6 days. We see that the LAST_MANUPRG_TIME column is now populated.

adrci> purge -age 8640 -type TRACE  
adrci> show control
ADR Home = /u01/app/oracle/diag/rdbms/ttrlwiki/ttrlwiki:
*************************************************************************
ADRID SHORTP_POLICY LONGP_POLICY LAST_MOD_TIME LAST_AUTOPRG_TIME LAST_MANUPRG_TIME ADRDIR_VERSION ADRSCHM_VERSION ADRSCHMV_SUMMARY ADRALERT_VERSION CREATE_TIME
-------------------- -------------------- -------------------- ---------------------------------------- ---------------------------------------- ---------------------------------------- -------------------- -------------------- -------------------- -------------------- ----------------------------------------
1095473802 360 8760 2010-08-27 09:36:09.385370 +08:00 2010-08-22 22:14:11.443356 +08:00 2010-08-27 09:50:07.399853 +08:00 1 2 76 1 2010-07-07 08:46:56.405618 +08:00

Using DBMS_XPLAN to obtain the EXPLAIN PLAN of a SQL Statement

Very often we run AWR, ASH and ADDM reports which does highlight the Top SQL statements by disk reads, CPU usage and elapsed time. But an important piece of information is missing which is the Explain Plan.

Using GUI tools like Enterprise Manager will enable us to drill down to the Explain Plan from an individual SQL statement, but how do we do it from the command line?

The answer is simply using DBMS_XPLAN.DISPLAY_AWR and provide to it as a parameter the SQL_ID in question (which can be picked up from the AWR or ASH report).

For example in the ASH report we see this section related to the Top SQL

Top SQL with Top Events     DB/Inst: FILESDB/filesdb  (Jul 19 13:23 to 13:38)

Sampled #
SQL ID Planhash of Executions % Activity
----------------------- -------------------- -------------------- --------------
Event % Event Top Row Source % RwSrc
------------------------------ ------- --------------------------------- -------
a9j69t1bh6982 2008213504 1 8.33
SQL*Net more data to client 8.33 TABLE ACCESS - FULL 8.33
SELECT x."CUST_ID",x."CUST_FIRST_NAME",x."CUST_LAST_NAME",x."CUST_GENDER",x."CUS
T_YEAR_OF_BIRTH",x."CUST_MARITAL_STATUS",x."CUST_STREET_ADDRESS",x."CUST_POSTAL_

We obtain the SQL_ID which is “a9j69t1bh6982″ and now to view the Explain Plan for this SQL statement we provide it as a parameter to the query as shown below.

SQL> set linesize 120
SQL> set pagesize 500
SQL> select * from TABLE(dbms_xplan.display_awr('a9j69t1bh6982'));

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
SQL_ID a9j69t1bh6982
--------------------
SELECT x."CUST_ID",x."CUST_FIRST_NAME",x."CUST_LAST_NAME",x."CUST_GENDER
",x."CUST_YEAR_OF_BIRTH",x."CUST_MARITAL_STATUS",x."CUST_STREET_ADDRESS"
,x."CUST_POSTAL_CODE",x."CUST_CITY",x."CUST_CITY_ID",x."CUST_STATE_PROVI
NCE",x."CUST_STATE_PROVINCE_ID",x."COUNTRY_ID",x."CUST_MAIN_PHONE_NUMBER
",x."CUST_INCOME_LEVEL",x."CUST_CREDIT_LIMIT",x."CUST_EMAIL",x."CUST_TOT
AL",x."CUST_TOTAL_ID",x."CUST_SRC_ID",x."CUST_EFF_FROM",x."CUST_EFF_TO",
x."CUST_VALID" FROM "SH"."CUSTOMERS" x

Plan hash value: 2008213504

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------

-------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | | 414 (100)| |
| 1 | TABLE ACCESS FULL| CUSTOMERS | 55500 | 9755K| 414 (1)| 00:00:05 |
-------------------------------------------------------------------------------

We can see that the query is performing a full table scan of the Customers table – something which is not very evident just my reading the AWR or ASH report.

Useful GoldenGate commands - SHELL, OBEY, HELP, HISTORY,VERSIONS

There are a number of other useful GoldenGate commands which we can run from the GGSCI interface. The GoldenGate Reference Guide has information in more detail, but I have tried out a few and found some to be very useful which I am highlighting below.


HISTORY: To view a list of the most recently issued GGSCI commands since the GGSCI session started


GGSCI (linux01.kim.com) 4> history
GGSCI Command History
1: show all
2: info all
3: start extract ext3
4: history


! : Use the ! command to execute a previous GGSCI command without modifications.


GGSCI (linux01.kim.com) 3> info extract ext3
EXTRACT EXT3 Last Started 2010-07-21 14:29 Status RUNNING
Checkpoint Lag 01:07:22 (updated 00:00:02 ago)
Log Read Checkpoint Oracle Redo Logs
2010-07-21 13:22:28 Seqno 188, RBA 49576960


GGSCI (linux01.kim.com) 4> !
info extract ext3
EXTRACT EXT3 Last Started 2010-07-21 14:29 Status RUNNING
Checkpoint Lag 01:07:22 (updated 00:00:04 ago)
Log Read Checkpoint Oracle Redo Logs
2010-07-21 13:22:28 Seqno 188, RBA 49576960

We can also use a combination of “!” and HISTORY to run a particular command listed in the history. For example, to run the command 3 listed in the history, we can just run “! 3″.


VERSIONS: to display operating system and database version information. Use DBLOGIN to connect to the database first


GGSCI (linux01.kim.com) 11> dblogin userid ggs_owner, password ggs_owner
Successfully logged into database.
GGSCI (linux01.kim.com) 12> versions
Operating System:
Linux
Version #1 SMP Mon Mar 29 20:19:03 EDT 2010, Release 2.6.18-194.el5PAE
Node: linux01.kim.com
Machine: i686
Database:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 – Production
PL/SQL Release 11.1.0.6.0 – Production
CORE 11.1.0.6.0 Production
TNS for Linux: Version 11.1.0.6.0 – Production
NLSRTL Version 11.1.0.6.0 – Production


SHELL: to execute shell commands from within the GGSCI interface.


GGSCI (linux01.kim.com) 13> shell ls -l /home/oracle/goldengate/dirdat/
total 50588
-rw-rw-rw- 1 oracle oinstall 985 Jul 16 14:57 lt000000
-rw-rw-rw- 1 oracle oinstall 9999629 Jul 19 13:09 lt000001


HELP: to obtain information about a GoldenGate command. The basic command returns a list of command categories and the associated commands.

GGSCI (linux01.kim.com) 15> help
GGSCI Command    Summary
SUBDIRS          CREATE SUBDIRS
ER               INFO ER, KILL ER, LAG ER, SEND ER, STATUS ER,
                START ER, STATS ER, STOP ER
EXTRACT          ADD, ALTER, CLEANUP, DELETE, INFO, KILL,
                LAG, SEND, START, STATS, STATUS, STOP
EXTTRAIL         ADD, ALTER, DELETE, INFO
GGSEVT           VIEW
MANAGER          INFO, REFRESH, SEND, START, STOP, STATUS
MARKER           INFO
PARAMS           EDIT, VIEW
REPLICAT         ADD, ALTER, CLEANUP, DELETE, INFO, KILL,
                LAG, SEND, START, STATS, STATUS, STOP
REPORT           VIEW
RMTTRAIL         ADD, ALTER, DELETE, INFO
TRACETABLE       ADD, DELETE, INFO
TRANDATA         ADD, DELETE, INFO
Database         DBLOGIN, LIST TABLES,
                ENCRYPT PASSWORD
DDL              DUMPDDL
CHECKPOINTTABLE  ADD CHECKPOINTTABLE, DELETE CHECKPOINTTABLE,
                CLEANUP CHECKPOINTTABLE, INFO CHECKPOINTTABLE
Miscellaneous    FC, HELP, HISTORY, INFO ALL, INFO MARKER, OBEY,
                SET, SHELL, SHOW, VERSIONS, !

For help on a specific command, type HELP  [command] [object]

Example: HELP ADD REPLICAT


OBEY: to process a file that contains a list of GoldenGate commands. OBEY is useful for executing commands that are frequently used in sequence. Suppose we want to run some Goldengate commands and execute those from a Unix shell script which can be called via say cron. So we have a start_goldgate.sh shell script which will use the GGSCI command OBEY to call a text file which has the Goldengate commands which we would like to run in sequence.


[oracle@linux01 goldengate]$ cat start_goldgate.sh
cd /home/oracle/goldengate
./ggsci < EOF
OBEY /home/oracle/goldengate/startup.txt
EOF


[oracle@linux01 goldengate]$ cat startup.txt
START MANAGER
START EXTRACT EXT3
START EXTRACT DPUMP
INFO ALL


[oracle@linux01 goldengate]$ ./start_goldgate.sh
Oracle GoldenGate Command Interpreter for Oracle
Version 10.4.0.19 Build 002
Linux, x86, 32bit (optimized), Oracle 11 on Sep 29 2009 08:50:50

Copyright (C) 1995, 2009, Oracle and/or its affiliates.  All rights reserved.

GGSCI (linux01.kim.com) 1>
GGSCI (linux01.kim.com) 2> START MANAGER

Manager started.

GGSCI (linux01.kim.com) 3> START EXTRACT EXT3

EXTRACT EXT3 is already running.

GGSCI (linux01.kim.com) 4> START EXTRACT DPUMP

EXTRACT DPUMP is already running.

GGSCI (linux01.kim.com) 5> INFO ALL

Program     Status      Group       Lag           Time Since Chkpt
MANAGER     RUNNING
EXTRACT     RUNNING     DPUMP       00:00:00      00:00:01
EXTRACT     ABENDED     EXT2        00:00:00      172:36:58
EXTRACT     RUNNING     EXT3        00:00:00      00:00:04

Oracle GoldenGate - how to connect to a particular database if there are multiple databases on the source or target server

Oracle GoldenGate - how to connect to a particular database if there are multiple databases on the source or target server

Steps to connect to GoldenGate if there are a number of databases running on the source server or on the target server. Or there could be a case where we have installed GoldenGate for Oracle 10g and we have both 10g as well as 11g Oracle Homes on the same machine and we want to connect to the Oracle 10g environment in particular.

We can do that in 2 ways, as far as my knowledge goes. Below are the steps:

1) Either set the right environment using .oraenv
or
2) Specify the right TNS alias in the Manager, Extract or Replicat parameter file where we have used the USERID keyword

For example, just to illustrate the same, I wrongly set the ORACLE_SID variable to a nonexistent value. The manager process will not start since it will try to connect with the username and password used in the manager parameter file to the LOCAL database for which the environment has been now set up and since the ORACLE_SID is wrong, there is no database running on the server with that SID.

$ export ORACLE_SID=xyz

GGSCI (vixen) 2> start manager

Manager started.

GGSCI (vixen) 3> status manager

Manager is DOWN!

This is what we will see in the GoldenGate logs:

2010-08-19 11:04:37 GGS ERROR 182 OCI Error beginning session (status = 1034-ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
SVR4 Error: 2: No such file or directory).

2010-08-19 11:04:37 GGS ERROR 190 PROCESS ABENDING.

To use a TNS alias, make sure that we are able to do a tnsping as well as connect via SQL*PLUS using that alias before we launch GGSCI.

In the relevant parameter file (in this example an extract parameter file) we just add the TNS alias to the USERID as shown below:

USERID ggs_owner@levengr2, PASSWORD ggs_owner

If the TNS connection is not defined properly, we can expect to see an error like this in the log file:

2010-08-19 11:09:46 GGS ERROR 182 OCI Error during OCIServerAttach (status = 12154-ORA-12154: TNS:could not resolve the connect identifier specified)
.
2010-08-19 11:09:46 GGS ERROR 190 PROCESS ABENDING
.

We can also use the same TNS alias method when we use DBLOGIN keyword to establish a database connection via GoldenGate

GGSCI (devastator) 2> dblogin userid ggs_owner@levengr2, password ggs_owner
Successfully logged into database.

Using GoldenGate to replicate between databases on same host

Steps to set up GoldenGate when both the source and target database are physically located on the same server:

Basically all we have do is to set up TNS aliases to connect to the source and target databases and make sure that before we do launch GGSCI, we are able to connect to both source and target databases from say SQL*PLUS in the environment from where we are running the GoldenGate software via GGSCI.

If both the source and target databases are Oracle, it would make more sense to perform the initial load using Oracle utilities like say Import/Export, Data Pump, SQL Loader etc because the performance of those utilities are far better as compared to the GoldenGate initial load. I think GoldenGate should come into the picture after the initial data load is done to keep the online changes taking place after that synchronized between source and target.

However just to demonstrate the concept, I will be performing an initial data load using GoldenGate. The source database is an Oracle 11g R2 database ‘ora11g’ and the target database is ‘ora10g’, both running on Solaris 10 box, sun01.

While we could have idealy have two separate GoldenGate installations on the same machine – one for the Oracle 11g database and one for the Oracle 10g database, I am testing the same using a single GoldenGate for Oracle 11g on 64 bit Solaris software installation.

Note however, that I have setup the GoldenGate schema in both source as well as target database and granted the required roles and privileges as well as ensure that the GGS_OWNER schema has got the required privileges on the SYSTEM.MYOBJECTS table which we are replicating here.

sun01:/export/home/oracle/goldengate $ ./ggsci

Oracle GoldenGate Command Interpreter for Oracle
Version 10.4.0.19 Build 002
Solaris, sparc, 64bit (optimized), Oracle 11 on Sep 18 2009 12:50:18

SOURCE

GGSCI (sun01) 9> dblogin userid ggs_owner@ora11g, password ggs_owner
Successfully logged into database.

GGSCI (sun01) 10> versions
Operating System:
SunOS
Version Generic_141444-09, Release 5.10
Node: sun01
Machine: sun4v

Database:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 – 64bit Production
PL/SQL Release 11.2.0.1.0 – Production
CORE 11.2.0.1.0 Production
TNS for Solaris: Version 11.2.0.1.0 – Production
NLSRTL Version 11.2.0.1.0 – Production

TARGET

GGSCI (sun01) 7> dblogin userid ggs_owner@ora10g, password ggs_owner
Successfully logged into database.

GGSCI (sun01) 8> versions
Operating System:
SunOS
Version Generic_141444-09, Release 5.10
Node: sun01
Machine: sun4v

Database:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 – 64bi
PL/SQL Release 10.2.0.4.0 – Production
CORE 10.2.0.4.0 Production
TNS for Solaris: Version 10.2.0.4.0 – Production
NLSRTL Version 10.2.0.4.0 – Production

SOURCE

ADD EXTRACT load1, SOURCEISTABLE

edit params load1

EXTRACT load1
USERID ggs_owner@ora11g, PASSWORD ggs_owner
RMTHOST sun01, MGRPORT 7809
RMTTASK replicat, GROUP load2
TABLE system.myobjects;

TARGET

ADD REPLICAT load2, SPECIALRUN

edit params load2

REPLICAT load2
USERID ggs_owner@ora10g, PASSWORD ggs_owner
ASSUMETARGETDEFS
MAP system.myobjects, TARGET system.myobjects;

SOURCE

GGSCI (sun01) 10> start extract load1

After the extract starts we can see that the extract process is already reading records from the source table which is SYSTEM.MYOBJECTS

GGSCI (sun01) 10> info extract load1
EXTRACT LOAD1 Last Started 2010-08-24 10:22 Status RUNNING
Checkpoint Lag Not Available
Log Read Checkpoint Table SYSTEM.MYOBJECTS
2010-08-24 10:23:21 Record 12269
Task SOURCEISTABLE

GGSCI (sun01) 12> info extract load1

EXTRACT LOAD1 Last Started 2010-08-24 10:22 Status RUNNING
Checkpoint Lag Not Available
Log Read Checkpoint Table SYSTEM.MYOBJECTS
2010-08-24 10:24:03 Record 26004
Task SOURCEISTABLE

GGSCI (sun01) 13> info extract load1

EXTRACT LOAD1 Last Started 2010-08-24 10:22 Status RUNNING
Checkpoint Lag Not Available
Log Read Checkpoint Table SYSTEM.MYOBJECTS
2010-08-24 10:24:45 Record 40207
Task SOURCEISTABLE

TARGET

On the target we can see that the Replicat process is also running – we did not have to explicitly start this initial load replicat process

GGSCI (sun01) 9> info replicat load2

REPLICAT LOAD2 Initialized 2010-08-24 10:21 Status RUNNING
Checkpoint Lag 00:00:00 (updated 00:02:06 ago)
Log Read Checkpoint Not Available
Task SPECIALRUN

Once the initial load process has completed, we will see that both the extract as well as the replicat process has stopped.

SOURCE

GGSCI (sun01) 22> info extract load1

EXTRACT LOAD1 Last Started 2010-08-24 10:22 Status STOPPED
Checkpoint Lag Not Available
Log Read Checkpoint Table SYSTEM.MYOBJECTS
2010-08-24 10:26:30 Record 76358
Task SOURCEISTABLE

TARGET

GGSCI (sun01) 23> send replicat load2 getlag

ERROR: REPLICAT LOAD2 not currently running.

Let us know test the same by connecting to the target database on the same machine

sun01:/export/home/oracle/goldengate $ sqlplus system@ora10g

SQL*Plus: Release 11.2.0.1.0 Production on Tue Aug 24 10:27:45 2010

Copyright (c) 1982, 2009, Oracle. All rights reserved.

Enter password:

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 – 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select count(*) from myobjects;

COUNT(*)
———-
76358

Sunday, September 5, 2010

PART II: Oracle Database Upgrade & ASM Upgrade

PART II: Oracle Database Upgrade & ASM Upgrade

I don’t have separate ASM home. I’m keeping ASM in ORACLE_HOME itself; So Now going to continue my database & asm upgrade.
1. From oracle user you need to exeucte “runInstaller” then you will get below screen shot.
2. Please make sure your ORACLE_HOME in your path.
3. Please check any listener running from all nodes; (Else it’s will create problem)
4. Please check any database/asm instance running (If yes; pls shutdown those instance)

For example:
[oracle@linux1 bin]$ ps -ef | grep pmon
oracle 11993 22392 0 13:16 pts/2 00:00:00 grep pmon

[oracle@linux1 bin]$ ps -ef | grep lsn
oracle 5155 1 0 11:06 ? 00:00:08
/u01/oracle/product/10.2.0/db_1/bin/tnslsnr LISTENER_LINUX1 -inherit
oracle 12000 22392 0 13:16 pts/2 00:00:00 grep lsn

[oracle@linux1 bin]$ lsnrctl stop LISTENER_LINUX1
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 19-JUL-2009 13:16:42

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

Connecting to

(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=linux1-vip.gen.com)(PORT=1521)(IP=FIRST)))

The command completed successfully

[oracle@linux2 bin]$ ps -ef | grep LISTENER_LINUX2
oracle 12726 1 0 13:29 ? 00:00:01
/u01/oracle/product/10.2.0/db_1/bin/tnslsnr LISTENER_LINUX2 -inherit
oracle 14894 8929 0 13:36 pts/1 00:00:00 grep LISTENER_LINUX2

[oracle@linux2 bin]$ lsnrctl stop LISTENER_LINUX2
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 19-JUL-2009 13:36:35

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

Connecting to

(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=linux2-vip.gen.com)(PORT=1521)(IP=FIRST)))

The command completed successfully


[oracle@linux2 bin]$ ps -ef | grep pmon

oracle 14993 8929 9 13:36 pts/1 00:00:00 grep pmon


[oracle@linux2 bin]$ ps -ef | grep lsn

oracle 15002 8929 0 13:36 pts/1 00:00:00 grep lsn


Before upgrade cluster status & Listener status


[root@linux1 bin]# ./crs_stat -t


Name Type Target State Host

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

ora.devdb.db application OFFLINE OFFLINE

ora....b1.inst application OFFLINE OFFLINE

ora....b2.inst application OFFLINE OFFLINE

ora...._taf.cs application OFFLINE OFFLINE

ora....db1.srv application OFFLINE OFFLINE

ora....db2.srv application OFFLINE OFFLINE

ora....SM1.asm application ONLINE ONLINE linux1

ora....X1.lsnr application ONLINE ONLINE linux1

ora.linux1.gsd application ONLINE ONLINE linux1

ora.linux1.ons application ONLINE ONLINE linux1

ora.linux1.vip application ONLINE ONLINE linux1

ora....SM2.asm application ONLINE ONLINE linux2

ora....X2.lsnr application ONLINE ONLINE linux2

ora.linux2.gsd application ONLINE ONLINE linux2

ora.linux2.ons application ONLINE ONLINE linux2

ora.linux2.vip application ONLINE ONLINE linux2


[oracle@linux1 bin]$ ps -ef | grep lsn


oracle 8117 1 0 03:17 ? 00:00:02

/u01/oracle/product/10.2.0/db_1/bin/tnslsnr LISTENER_LINUX1 -inherit

oracle 12039 10732 0 03:28 pts/3 00:00:00 grep lsn


[oracle@linux1 bin]$ lsnrctl stop LISTENER_LINUX1

LSNRCTL for Linux: Version 10.2.0.4.0 - Production on 25-JUL-2009 03:28:18

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

Connecting to

(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=linux1-vip.gen.com)(PORT=1521)(IP=FIRST)))

The command completed successfully


[oracle@linux1 bin]$ ps -ef | grep lsn

oracle 12085 10732 0 03:28 pts/3 00:00:00 grep lsn


[oracle@linux1 bin]$ ps -ef | grep pmon

oracle 8024 1 0 03:17 ? 00:00:03 asm_pmon_+ASM1

oracle 12162 10732 0 03:28 pts/3 00:00:00 grep pmon


[oracle@linux2 ~]$ cd /u01/oracle/product/10.2.0/crs/bin/

[oracle@linux2 bin]$ ps -ef | grep lsn

oracle 7134 1 0 03:19 ? 00:00:01

/u01/oracle/product/10.2.0/db_1/bin/tnslsnr LISTENER_LINUX2 -inherit

oracle 10678 10552 0 03:29 pts/2 00:00:00 grep lsn


[oracle@linux2 bin]$ lsnrctl stop LISTENER_LINUX2

LSNRCTL for Linux: Version 10.2.0.4.0 - Production on 25-JUL-2009 03:29:45

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

Connecting to

(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=linux2-vip.gen.com)(PORT=1521)(IP=FIRST)))

The command completed successfully


[oracle@linux2 bin]$ ps -ef | grep pmon

oracle 10784 1 21 03:29 ? 00:00:00 asm_pmon_+ASM2

oracle 10806 10552 0 03:30 pts/2 00:00:00 grep pmon


Step 2:
This is TWO Nodes cluster; that’s why you will get your cluster nodes names list.

Step 3:
If you want register you CSI Nr then you can otherwise ignore this slide

Step 4:
This is pre-request checking steps; in case any thing wrong here you will come to know all the details.

Step 5:
Once successfully completed your pre-request then continue the patch installation on cluster.

Step 6:
Now you need to execute below script for all nodes (Using root user)
/u01/oracle/product/10.2.0/db_1/root.sh

[root@linux1 bin]# /u01/oracle/product/10.2.0/db_1/root.sh

Running Oracle10 root.sh script...

The following environment variables are set as:

ORACLE_OWNER= oracle

ORACLE_HOME= /u01/oracle/product/10.2.0/db_1

Enter the full pathname of the local bin directory: [/usr/local/bin]:

The file "dbhome" already exists in /usr/local/bin. Overwrite it? (y/n)

[n]: y

Copying dbhome to /usr/local/bin ...

The file "oraenv" already exists in /usr/local/bin. Overwrite it? (y/n)

[n]: y

Copying oraenv to /usr/local/bin ...

The file "coraenv" already exists in /usr/local/bin. Overwrite it? (y/n)

[n]: y

Copying coraenv to /usr/local/bin ...

Entries will be added to the /etc/oratab file as needed by

Database Configuration Assistant when a database is created

Finished running generic part of root.sh script.

Now product-specific root actions will be performed.


[root@linux2 bin]# /u01/oracle/product/10.2.0/db_1/root.sh

Running Oracle10 root.sh script...

The following environment variables are set as:

ORACLE_OWNER= oracle

ORACLE_HOME= /u01/oracle/product/10.2.0/db_1

Enter the full pathname of the local bin directory: [/usr/local/bin]:

The file "dbhome" already exists in /usr/local/bin. Overwrite it? (y/n)

[n]: y

Copying dbhome to /usr/local/bin ...

The file "oraenv" already exists in /usr/local/bin. Overwrite it? (y/n)

[n]: y

Copying oraenv to /usr/local/bin ...

The file "coraenv" already exists in /usr/local/bin. Overwrite it? (y/n)

[n]: y

Copying coraenv to /usr/local/bin ...

Entries will be added to the /etc/oratab file as needed by

Database Configuration Assistant when a database is created

Finished running generic part of root.sh script.

Now product-specific root actions will be performed.

[oracle@linux1 bin]$ . oraenv

ORACLE_SID = [devdb1] ? devdb

[oracle@linux1 bin]$ export ORACLE_SID=devdb1

[oracle@linux1 bin]$ sqlplus '/as sysdba'

SQL*Plus: Release 10.2.0.4.0 - Production on Sat Jul 25 03:38:20 2009

Copyright (c) 1982, 2007, Oracle. All Rights Reserved.

Connected to an idle instance.


SQL> startup nomount

ORACLE instance started.

Total System Global Area 285212672 bytes

Fixed Size 1267044 bytes

Variable Size 100666012 bytes

Database Buffers 176160768 bytes

Redo Buffers 7118848 bytes

SQL>


SQL> show parameter clus

NAME TYPE VALUE

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

cluster_database boolean TRUE

cluster_database_instances integer 2

cluster_interconnects string


SQL> alter system set cluster_database=FALSE scope=spfile;

System altered.


SQL> shutdown

ORA-01507: database not mounted

ORACLE instance shut down.


SQL> exit

Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production

With the Partitioning, Real Application Clusters, OLAP, Data Mining

and Real Application Testing options


[oracle@linux1 bin]$ sqlplus '/as sysdba'

SQL*Plus: Release 10.2.0.4.0 - Production on Sat Jul 25 03:40:20 2009

Copyright (c) 1982, 2007, Oracle. All Rights Reserved.

Connected to an idle instance.


SQL> startup upgrade

ORACLE instance started.

Total System Global Area 285212672 bytes

Fixed Size 1267044 bytes

Variable Size 100666012 bytes

Database Buffers 176160768 bytes

Redo Buffers 7118848 bytes

Database mounted.

Database opened.

SQL>


SQL> show parameter cluster

NAME TYPE VALUE

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

cluster_database boolean FALSE

cluster_database_instances integer 1

cluster_interconnects string


SQL> spool /u01/patch.log


SQL> @$ORACLE_HOME/rdbms/admin/catupgrd.sql

...

..

......

No errors.

No errors.

TIMESTAMP

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

COMP_TIMESTAMP RUL 2009-07-25 11:54:47

DBUA_TIMESTAMP RUL VALID 2009-07-25 11:54:47

TIMESTAMP

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

COMP_TIMESTAMP UPGRD_END 2009-07-25 11:54:50

.

Oracle Database 10.2 Upgrade Status Utility 07-25-2009 11:54:50

.

Component Status Version HH:MM:SS

Oracle Database Server VALID 10.2.0.4.0 01:23:50

JServer JAVA Virtual Machine VALID 10.2.0.4.0 00:15:05

Oracle XDK VALID 10.2.0.4.0 00:02:21

Oracle Database Java Packages VALID 10.2.0.4.0 00:02:39

Oracle Text VALID 10.2.0.4.0 00:01:48

Oracle XML Database VALID 10.2.0.4.0 00:11:57

Oracle Real Application Clusters VALID 10.2.0.4.0 00:00:22

Oracle Workspace Manager VALID 10.2.0.4.3 00:04:23

Oracle Data Mining VALID 10.2.0.4.0 00:03:23

OLAP Analytic Workspace VALID 10.2.0.4.0 00:03:25

OLAP Catalog VALID 10.2.0.4.0 00:08:07

Oracle OLAP API VALID 10.2.0.4.0 00:06:20

Oracle interMedia VALID 10.2.0.4.0 00:31:09

Spatial VALID 10.2.0.4.0 00:13:33

Oracle Expression Filter VALID 10.2.0.4.0 00:02:04

Oracle Enterprise Manager VALID 10.2.0.4.0 00:12:57

Oracle Rule Manager VALID 10.2.0.4.0 00:01:11

.

Total Upgrade Time: 03:24:44

DOC>#######################################################################

DOC>#######################################################################

DOC>

DOC> The above PL/SQL lists the SERVER components in the upgraded

DOC> database, along with their current version and status.

DOC>

DOC> Please review the status and version columns and look for

DOC> any errors in the spool log file. If there are errors in the spool

DOC> file, or any components are not VALID or not the current version,

DOC> consult the Oracle Database Upgrade Guide for troubleshooting

DOC> recommendations.

DOC>

DOC> Next shutdown immediate, restart for normal operation, and then

DOC> run utlrp.sql to recompile any invalid application objects.

DOC>

DOC>#######################################################################

DOC>#######################################################################

DOC>#


SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL>


SQL> startup

ORACLE instance started.

Total System Global Area 285212672 bytes

Fixed Size 1267044 bytes

Variable Size 146803356 bytes

Database Buffers 130023424 bytes

Redo Buffers 7118848 bytes

Database mounted.

Database opened.


SQL> @$ORACLE_HOME/rdbms/admin/utlrp.sql

TIMESTAMP

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

COMP_TIMESTAMP UTLRP_BGN 2009-07-25 12:12:32

DOC> The following PL/SQL block invokes UTL_RECOMP to recompile invalid

.

...

.......

ERRORS DURING RECOMPILATION

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

0

PL/SQL procedure successfully completed.


SQL> show parameter cluster

NAME TYPE VALUE

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

cluster_database boolean FALSE

cluster_database_instances integer 1

cluster_interconnects string

SQL>


SQL> alter system set cluster_database=TRUE scope=spfile;

System altered.


SQL> alter system set cluster_database=TRUE scope=spfile;

System altered.


SQL> shutdown

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL>


SQL> startup

ORACLE instance started.

Total System Global Area 285212672 bytes

Fixed Size 1267044 bytes

Variable Size 163580572 bytes

Database Buffers 113246208 bytes

Redo Buffers 7118848 bytes

Database mounted.

Database opened.


SQL>


SQL> show parameter cluster

NAME TYPE VALUE

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

cluster_database boolean TRUE

cluster_database_instances integer 2

cluster_interconnects string


[oracle@linux1 bin]$ ./srvctl start instance -d devdb -i devdb1


[oracle@linux1 bin]$ ./crs_stat -t

Name Type Target State Host

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

ora.devdb.db application ONLINE ONLINE linux2

ora....b1.inst application ONLINE ONLINE linux1

ora....b2.inst application ONLINE OFFLINE

ora...._taf.cs application OFFLINE OFFLINE

ora....db1.srv application OFFLINE OFFLINE

ora....db2.srv application OFFLINE OFFLINE

ora....SM1.asm application ONLINE ONLINE linux1

ora....X1.lsnr application ONLINE ONLINE linux1

ora.linux1.gsd application ONLINE ONLINE linux1

ora.linux1.ons application ONLINE ONLINE linux1

ora.linux1.vip application ONLINE ONLINE linux1

ora....SM2.asm application ONLINE ONLINE linux2

ora....X2.lsnr application ONLINE ONLINE linux2

ora.linux2.gsd application ONLINE ONLINE linux2

ora.linux2.ons application ONLINE ONLINE linux2

ora.linux2.vip application ONLINE ONLINE linux2


[oracle@linux2 bin]$ ./srvctl start instance -d devdb -i devdb2


[oracle@linux1 bin]$ ./crs_stat -t

Name Type Target State Host

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

ora.devdb.db application ONLINE ONLINE linux2

ora....b1.inst application ONLINE ONLINE linux1

ora....b2.inst application ONLINE ONLINE linux2

ora...._taf.cs application OFFLINE OFFLINE

ora....db1.srv application OFFLINE OFFLINE

ora....db2.srv application OFFLINE OFFLINE

ora....SM1.asm application ONLINE ONLINE linux1

ora....X1.lsnr application ONLINE ONLINE linux1

ora.linux1.gsd application ONLINE ONLINE linux1

ora.linux1.ons application ONLINE ONLINE linux1

ora.linux1.vip application ONLINE ONLINE linux1

ora....SM2.asm application ONLINE ONLINE linux2

ora....X2.lsnr application ONLINE ONLINE linux2

ora.linux2.gsd application ONLINE ONLINE linux2

ora.linux2.ons application ONLINE ONLINE linux2

ora.linux2.vip application ONLINE ONLINE linux2


[oracle@linux2 bin]$ . oraenv

ORACLE_SID = [devdb] ?


[oracle@linux2 bin]$ sqlplus "/as sysdba"

SQL*Plus: Release 10.2.0.4.0 - Production on Sat Jul 25 12:45:02 2009

Copyright (c) 1982, 2007, Oracle. All Rights Reserved.

Connected to an idle instance.


SQL> conn sys@devdb1 as sysdba

Enter password:

Connected.

SQL>


SQL> select * from v$version where rownum=1;

BANNER

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

Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod


SQL> conn sys@devdb2 as sysdba

Enter password:

Connected.


SQL> select * from v$version where rownum=1;

BANNER

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

Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod

Real Application Cluster database upgrade from 10.2.0.1 to 10.2.0.4

Real Application Cluster database upgrade from 10.2.0.1 to 10.2.0.4

Database Version: 10.2.0.1
Operating System: Ret Hat linux 4 As & Vmware 5
Storage Type : ASM & RAW Storage
Pre-Request for upgrade:

Before upgrading any database we need take complete cold backup for database. Also we need to take backup of ORACLE_HOME, ORACLE_BASE & ORACLE_CRS_HOME

* In my case I have taken ORACLE_HOME & ORACLE_CRS_HOME backup’s using (for all nodes)

cd /u01/before_patch_backup

tar -cvf oracle_base_jul19.tar $ORACLE_BASE

tar -cvf oracle_home_jul19.tar $ORACLE_HOME

tar -cvf oracle_crs_home_jul19.tar $ORACLE_CRS_HOME

* Form storage level we need take backup’s. I used “dd” command for taking OCR & VOTING disk backups.
* Also using I have taken complete RMAN backup for my database & using “dd” command I taken RAW devices backups (I mean ASM)

PS: Make sure; before taking any backups you need to sotp your cluster don’t forgot. Using the below command you down your cluster.

[root@linux1 bin]# ./crsctl stop crs

Stopping resources.

Successfully stopped CRS resources

Stopping CSSD.

Shutting down CSS daemon.

Shutdown request successfully issued.


[root@linux1 bin]# ps -ef | grep pmon

root 27831 27206 0 08:26 pts/2 00:00:00 grep pmon

[root@linux1 bin]# ps -ef | grep lsn

root 27833 27206 0 08:26 pts/2 00:00:00 grep lsn


[root@linux2 bin]# ./crsctl stop crs

Stopping resources.

Successfully stopped CRS resources

Stopping CSSD.

Shutting down CSS daemon.

Shutdown request successfully issued.


[oracle@linux2 /]$ ps -ef | grep pmon

oracle 20613 19349 0 05:54 pts/1 00:00:00 grep pmon

[oracle@linux2 /]$

[oracle@linux2 /]$ ps -ef | grep lsn

oracle 20638 19349 0 05:54 pts/1 00:00:00 grep lsn

PS: In my test environment I don’t have separte ASM home; I’m using ORACLE_HOME itslef. If you have ASM home then you may need take backup of ASM home also.

Cluster Upgration: Now I’m going to upgrade my cluster database.

Step 1:
1. Down 10.2.0.4 patch set (Patch Nr: 6810189)
2. Extract your patch
3. From oracle user you need to exeucte “runInstaller” then you will get below screen shot.

Step 2:
Please confirm your CRS Home. Because first of all you need to upgrade cluster only (Not Oracle database or ASM Home)

Step 3:
This is TWO Nodes cluster; that’s why you will get your cluster nodes names list.

Step 4:
This is pre-request checking steps; in case any thing wrong here you will come to know all the details.

Step 5:
Once successfully completed your pre-request then continue the patch installation on cluster.

Step 6:
After succesfully installation you may need execute the below script from root user (in all nodes you need follow same steps)

/u01/oracle/product/10.2.0/crs/bin/crsctl stop crs
/u01/oracle/product/10.2.0/crs/install/root102.sh

Form Node 1:

[root@linux1 bin]# ./crsctl stop crs

Stopping resources.

Error while stopping resources. Possible cause: CRSD is down.

Stopping CSSD.

Unable to communicate with the CSS daemon.

[root@linux1 bin]# cd ..

[root@linux1 crs]# cd install

[root@linux1 install]# ./root102.sh

Creating pre-patch directory for saving pre-patch clusterware files

Completed patching clusterware files to /u01/app/oracle/product/10.2.0/crs

Relinking some shared libraries.

Relinking of patched files is complete.

WARNING: directory '/u01/oracle/product/10.2.0' is not owned by root

WARNING: directory '/u01/oracle/product' is not owned by root

WARNING: directory '/u01/oracle' is not owned by root

WARNING: directory '/u01' is not owned by root

Preparing to recopy patched init and RC scripts.

Recopying init and RC scripts.

Startup will be queued to init within 30 seconds.

Starting up the CRS daemons.

Waiting for the patched CRS daemons to start.

This may take a while on some systems.

.

.

.

.

10204 patch successfully applied.

clscfg: EXISTING configuration version 3 detected.

clscfg: version 3 is 10G Release 2.

Successfully accumulated necessary OCR keys.

Using ports: CSS=49895 CRS=49896 EVMC=49898 and EVMR=49897.

node :

node 1: linux1 linux1-priv linux1

Creating OCR keys for user 'root', privgrp 'root'..

Operation successful.

clscfg -upgrade completed successfully


From Node 2:

[root@linux2 bin]# ./crsctl stop crs

Stopping resources. This could take several minutes.

Successfully stopped CRS resources.

Stopping CSSD.

Shutting down CSS daemon.

Shutdown request successfully issued.

[root@linux2 bin]# cd ../install

[root@linux2 install]# ./root102.sh >> rootexecteation2.txt &

[1] 10282

[root@linux2 install]# tail -f rootexecteation2.txt

WARNING: directory '/u01/oracle/product/10.2.0' is not owned by root

WARNING: directory '/u01/oracle/product' is not owned by root

WARNING: directory '/u01/oracle' is not owned by root

WARNING: directory '/u01' is not owned by root

Preparing to recopy patched init and RC scripts.

Recopying init and RC scripts.

Startup will be queued to init within 30 seconds.

/etc/profile: line 55: ulimit: open files: cannot modify limit: Operation not permitted

/home/oracle/.bash_profile: line 30: ulimit: open files: cannot modify limit: Operation not

permitted

Starting up the CRS daemons.

Waiting for the patched CRS daemons to start.

This may take a while on some systems.

.

.

10204 patch successfully applied.

clscfg: EXISTING configuration version 3 detected.

clscfg: version 3 is 10G Release 2.

Successfully accumulated necessary OCR keys.

Using ports: CSS=49895 CRS=49896 EVMC=49898 and EVMR=49897.

node :

node 2: linux2 linux2-priv linux2

Creating OCR keys for user 'root', privgrp 'root'..

Operation successful.

clscfg -upgrade completed successfully


Cluster Status

[root@linux2 install]# cd ../bin

[root@linux2 bin]# ./crs_stat -t

Name Type Target State Host

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

ora.devdb.db application ONLINE OFFLINE

ora....b1.inst application OFFLINE OFFLINE

ora....b2.inst application ONLINE OFFLINE

ora...._taf.cs application OFFLINE OFFLINE

ora....db1.srv application OFFLINE OFFLINE

ora....db2.srv application OFFLINE OFFLINE

ora....SM1.asm application OFFLINE OFFLINE

ora....X1.lsnr application OFFLINE OFFLINE

ora.linux1.gsd application ONLINE ONLINE linux1

ora.linux1.ons application ONLINE ONLINE linux1

ora.linux1.vip application ONLINE ONLINE linux1

ora....SM2.asm application ONLINE ONLINE linux2

ora....X2.lsnr application ONLINE ONLINE linux2

ora.linux2.gsd application ONLINE OFFLINE

ora.linux2.ons application ONLINE ONLINE linux2

ora.linux2.vip application ONLINE ONLINE linux2

I am having some problem in Node2 that’s why GSD is down in node2.

ORA-07445: exception encountered: core dump [qmkmfreeUga()+27] [SIGSEGV] [Address

ORA-07445: exception encountered: core dump [qmkmfreeUga()+27] [SIGSEGV] [Address mapped to object] [0x4C] [] []

When upgrading from 10.2.0.1.0 to 10.2.0.4.0, a user may see this error when running catupgrd.sql

Cause: This is unpublished bug 6957077

Action: The database instance needs to be shutdown and restarted, then catupgrd.sql can be run and should complete successfully


SQL> shutdown immediate

SQL> startup upgrade

Tuesday, September 8, 2009

Oracle backup replication with Oracle Streams, Data Guard & RAC

As the world’s leading database, Oracle offers a wealth of options to replicate geographically distributed systems. Each method has its own features and it is the job of the Oracle professional to choose the one that makes sense for their business requirements:

  • Data Guard – Data Guard standby databases provide standby databases for failover in system that do not have a high downtime cost. In a data guard failover, the last redo log must be applied (up to 20 minutes to re-open the standby database), and if the last redo cannot be recovered from the crashed instance, the most recent updates may be lost.

  • Multi-Master Replication – See the excellent book for implementing multi-master replication. Uses advanced queuing to cross-pollinate many databases with updates. Has an advantage over Data Guard because the standby database can be used for updates, and a disadvantage that replication is not instantaneous and update collisions may occur.

  • Oracle Streams – See the comprehensive book on Oracle Streams Technology by Madhu Tumma. Ready for production use in Oracle 10g, Oracle Streams allows near real-time replication and support for master-to-master replication. Oracle Streams has no licensing costs (RAC costs extra) and it is less complex to configure than a RAC database. This disadvantage over RAC is that there is no continuous availability, update collisions may occur, replication is not instant, and application failover is usually done manually.

  • Real Application Clusters – The Cadillac of Oracle continuous availability tools, RAC allows for Transparent Application Failover (TAF) and RAC is de-rigueur for systems with a high cost of downtime and continuous availability on RAC.

Most shops will combine these technologies to provide replication that is easy to manage and reliable. Let’s explore such a scenario.

Why Replicate?

Oracle has sophisticated mechanisms to manage data concurrency and replication is normally used when we have geographically distributed systems with unreliable network connectivity between systems. In a perfect world, database would not be replicated, but the nature of worldwide networking mandates that global eCommerce system have replicated database to provide fast response time worldwide.

Because the Oracle Streams product is new, Oracle professionals are only now recognizing how Streams can be used to in a master-master replication architecture. Let’s take a closer look.

Oracle Streams for master-master replication

Oracle Streams is an ideal solution for systems that are geographically distributed and have a high-speed connection (e.g. a T1 line) between servers. As long as the server interconnect can keep-up with the changes you can implement systems that provide failover and disaster recovery, simply and reliably. However Oracle Streams replication is not for every database:

  • High update systems – Busy update database may spend excessive resources synchronizing the distributed databases.

  • Real-time replication required – If you require a two-phase commit (where the changes are committed on each database at exactly the same time), then RAC or on-commit replication are a better choice. For example, a banking system would require that all databases update each other simultaneously, and Oracle Streams might not be an ideal solution.

On the other had, Oracle Streams is perfect for geographically distributed applications where real-time synchronization is not required. Let’s explore master-master replication with a hypothetical example. Assume that we have a online database serving the US Federal government which is deployed using APEX making it accessible anywhere in the world with an internet-enabled web browser. Federal agencies will connect with either the California or the Texas server, based on their APEX shortcut URL. The two systems are cross-fed updates via Oracle Streams and the Texas server will use Data Guard to replicate to standby database in Kittrell North Carolina (Figure 1).










Figure 1 – Combining Oracle Streams and Oracle data Guard

Oracle Streams will provide near real-time replication of important information and in case of a server outage, updates are automatically stored in update queues and applied automatically when service is restored to the crashed Oracle server.

Providing reliable connectivity during network outages is very challenging and sophisticated, and Oracle has several tools that will aid TCI in their goals. In case of any type of outage we see alternative connection options:

  • Interconnect is down – All end-users will continue to operate independently and when the interconnect is restored the updates queues will synchronize each database.

  • California or Texas Server down – The end-user will have three icons on their desktop, and a California end-user simply clicks on the URL for the Texas database and continues working.

  • Major Disaster – In this case the Kittrell NC server will be synchronized using Data Guard (with a possible loss of the most recent redo log updates) and end-users with access to the internet can continue to work on the standby server. Upon restoration of service, the Kittrell server will flush all updates back to the main California and Texas databases.

Establishing the replication mechanisms is only part of the task. We also need detailed checks to alert the DBA staff when an outage has occurred. The end-user will have it easier, and know to simply log in to the surviving Oracle database. Let’s look at the replication alert mechanisms.

Streams replication failure alerts

This is a critical component of the replication so that Oracle staff can be aware when there has been a server or network failure. The alerts will include checks from the Kittrell, checks between Texas and California, and checks of the replication queues. Because the connectivity checks must be done outside from Oracle, the checks can be done using Linux cron entries.

  • Ping from standby server - The Kittrell standby server will check every 15 minutes for connectivity to all servers with a “ping” command. If the servers fail to respond a pager alert will be sent to support staff.

  • California and Texas connectivity checks – Each server will cross-check each other, first checking with tnsping, then ping, and sending appropriate alerts in cases of network failure.

Creating a self-synchronizing replication architecture

Once the Oracle Streams, Data Guard and alerts are in-place, the only challenge for the Oracle DBA is ensuring that the Streams replication queues have enough room to hold updates on the surviving Oracle instance.

For more information on using Oracle Streams and Multimaster Replication, we recommend these books and links:

Streams Replication Links: