Wednesday, June 23, 2010

-- How to manage AUDIT trails automatically in 11g before it grows out-of-control overtime --

By Ken Patel

11.2 has AUDIT trail turned on for lot of SYSTEM privileges. But there is no automatic purge job defined out-of-box, not only that SYS.AUD$ is located in SYSTEM tablespace which can cause space management problem unnecessarily.  
11.2 has new package DBMS_AUDIT_MGMT to manage this. one of good thing of this package, is that it allows DBA to setup automatic purge job (not to say, Oracle should have done this out-of-box with 7 days or some good interval just like AWR snapshots). this package also helps moving SYS.AUD$ to SYSAUX or any other tablespace DBA wants.

I think, DBA should manage this as soon as 11.2 Database is setup. Purging takes time if done after few weeks. I would do atleast this much after deploying 11.2 database for controlling audit trails ( Documentation has more details on various other package calls as well as different argument and their significance).

1.
-- this block initializes the clean up as well as moves SYS.AUD$ to SYSAUX tablespace

BEGIN
DBMS_AUDIT_MGMT.INIT_CLEANUP(AUDIT_TRAIL_TYPE => DBMS_AUDIT_MGMT.AUDIT_TRAIL_ALL,
DEFAULT_CLEANUP_INTERVAL => 12 );
END;
/

2.
-- manual clean up
BEGIN
  DBMS_AUDIT_MGMT.CLEAN_AUDIT_TRAIL(
   AUDIT_TRAIL_TYPE           =>  DBMS_AUDIT_MGMT.AUDIT_TRAIL_ALL,
   USE_LAST_ARCH_TIMESTAMP    =>  TRUE );
END;
/

2.
-- creating automatic purge job

BEGIN
  DBMS_AUDIT_MGMT.CREATE_PURGE_JOB (
   AUDIT_TRAIL_TYPE            => DBMS_AUDIT_MGMT.AUDIT_TRAIL_ALL,
   AUDIT_TRAIL_PURGE_INTERVAL  => 12,
   AUDIT_TRAIL_PURGE_NAME      => 'Sys_Audit_Purge_JOB',
   USE_LAST_ARCH_TIMESTAMP     => TRUE );
END;

Ken is a Senior Database Engineer at Comcast NETO DBE&O Solutions Engineering Team.

Wednesday, May 26, 2010

-- Sometimes you have no option but to use Multithreaded Servers --

A customer of mine was faced with the situation of having poor memory management even that ASMM was configured, I noticed poor buffer cache utilization 46%, low hit ratio 84% and the sqls were constantly reloading, when faced with the question of why we do not pin objects in the buffers the answer was that their Windows System is 32 bits and was maxed out due to the number of connections to the 3GB limit.

Although we all know that dedicated servers are faster that shared servers, we also know that the most expensive operation in a transaction is I/O, in the case of my customer I know his service time is about 20ms per I/O which is not the best (They use EMC Clarion). So in this case we need to sacrifice a bit of CPU to reduce I/O and do more cache utilization.

The most important factor when configuring MTS is to determinate the number of servers and dispatchers that you will need and this is a good rule of thumb.

For dispatchers of 1 per every 250 connections works well for typical systems, Being too aggressive in your estimates is not beneficial; configuring too many dispatchers can degrade performance.

For shared servers typical systems seem to stabilize at a ratio of 1 shared server for every 10 connections. On NT, exercise care when setting MTS_MAX_SERVERS to too a high value because as mentioned, each server is a thread in a common process. The optimal values for these settings can change based on your configuration; these are just estimates of what seems to work for typical configurations.

Example OLTP Application: If you expect to require 2,000 concurrent connections, begin with 200 shared servers or 1 shared server for every 10 connections. Set MTS_MAX_SERVERS to 400.

Because MTS uses your large_pool for storing MTS related UGA information , we recommend to increase and explicitly set the minimum large_pool_size. If you do not set a value for LARGE_POOL_SIZE, Oracle uses the shared pool for MTS user session memory.

Some important views that will help you to tune your servers / dispatchers ratio:

-  V$DISPATCHER  This view gives information about dispatcher processes.

-  V_$SHARED_SERVER This view gives information about shared server processes.  

-  V$CIRCUITS  This view gives information about the virtual circuits. Virtual circuits are state objects that act as repositories of all the user related state information that needs to be accessed during a database session. There is one virtual circuit per client connection.

-  V$QUEUE This view gives information about messages in the common message queue and the dispatcher message queues. 

- V$DISPATCHER_RATE This view gives information and statistics about the rate at which each dispatcher is receiving and handling messages, events, and so on.

The following initialization parameters control shared server operation:
  • SHARED_SERVERS: Specifies the initial number of shared servers to start and the minimum number of shared servers to keep. This is the only required parameter for using shared servers.
  • MAX_SHARED_SERVERS: Specifies the maximum number of shared servers that can run simultaneously.
  • SHARED_SERVER_SESSIONS: Specifies the total number of shared server user sessions that can run simultaneously. Setting this parameter enables you to reserve user sessions for dedicated servers.
  • DISPATCHERS: Configures dispatcher processes in the shared server architecture.
  • MAX_DISPATCHERS: Specifies the maximum number of dispatcher processes that can run simultaneously. This parameter can be ignored for now. It will only be useful in a future release when the number of dispatchers is auto-tuned according to the number of concurrent connections.
  • CIRCUITS: Specifies the total number of virtual circuits that are available for inbound and outbound network sessions.

=======================================================

One of  my readers posted the followintg comment and I decided to share it, thanks Mitra for the tip

" I used to administer quite a few 32 bit oracle boxes on windows and faced the same problem. Its annoying but the solution I found is to resuce the stack size of the "oracle.exe" and the "listener.exe" with the orastack utility. I believe that the default is 1 MB and for oltp applications 128KB works great. Please try this next time and I bet it will get some extra millage for you"

Yes, reducing the Oracle stack size is definitively an option, reducing it too much will produce the error “ORA-03113: end-of-file on communication channel” errors. Oracle supplies the ORASTACK utility to allow customers to modify the default stack size of a thread / session when created in the Oracle executable.

When ORASTACK is run against specific executables it alters the part of the binary header that defines the default stack size used by the create thread API.

Below are examples of setting the stack to 500K for the main executables :



orastack oracle.exe 500000
orastack tnslsnr.exe 500000

orastack svrmgrl.exe 500000

orastack sqlplus.exe 500000


Wednesday, October 14, 2009

-- Oracle Opeworld Keynotes --

Hello Everybody

I have been this week at the Oracle Openworld, I will be posting some of the technical information, 11.2 highlights and pictures I got soon. Today is the day where we expect the annual speech from Larry Ellison with great products and news of whatever is to come.



To check what is going on here on daily basis click  Here

The Keynote was started by S. Gopalakrishnan from Infosys, he was talking about the game changing trends of IT leads to innovation.

  • Simplicity on Organizational Complexity.
  • Value Webs (Creating better customer insight, Innovation through Co-creation,
  • Smarter Organization (Better learning through collaboration and personalization)
Were some of his most important highlights.

Larry starting talking about how the Linux business is important for Oracle, they have now more than 4,000 customers running OEL or Oracle VM.

He spend some time talking about the "Database Machine" (Exadata 2), It is a Sun Sparc server
- World fastest machine for OLTP, it contains 5TB, and yes that is TB of flash memory data. More than 400TB for DRAM, yes it is impressive, never the less very costly too.

As per Ellison he said that it is 4 times fastest than the faster IBM server for the same cost, been more green and taking a lot less space and energy consumption. Exadata offers columnar D/W compression which in query mode archives 10x compression, in Archive mode it achieves 15x compression. You can add capacity as needed to the database machine, they offer a massive parallel grid and there is not single point of failure. The database machine comes pre-configured, it is ready to use on day one, it eliminates months of configuration troubleshooting and tuning, as per Ellison you do not have to do any changes to it.

The database machine comes on different sizes and prices stating with the simple configuration at a value of $110,000 which is not fault tolerant.

As per Ellison the database machine offers the fastest OLTP and DW performance, offers best cost performance, is fault tolerant and scalable on demand.


  The Governor of California Arnold did a surprised entrance in the middle of Larry's speech and spoke about the importance of technology and how technology has helped him on his career and the importance for the future of California and humanity in general. He mentioned that California is 40% more energy efficient than any other state in the US.






 
Larry next topic was about proactive product problem detection, so Oracle can notify you of potential problems in your installation and patches that they recommend for you to apply.

There was as well a presentations of Oracle Enterprise Manager 11g and some of the new features.  To close the keynotes Larry spoke about Oracle Fusion coexisting strategy, he plead to the current customers to move to this new platform so they can make use of the new technology, however he was clear saying that the customers has the choice to not move and they will continue to get supported.

Wednesday, September 2, 2009

Oracle 11g upgrading tips


The following is a compilation of interesting tips I found when upgrading to 11g.

Things you may not know:

- SQL Developer is installed by default when you use one of the templates from DBCA.
- Oracle XML DB will be installed as well when the DB gets created.
- Oracle Data mining creation schema is now part of catproc.sql
- Your can upgrade directly to 11g using DBUA from 9.2.0.4 or higher, 10.1.0.2 or higher or
10.2.0.1 or higher.
- If your optimizer statistics are stale, then DBUA will recommend for you to exit and collect
statistics before you continue.
- If you did not applied the time zone patches to your 9i or 10g database then DBUA will fail to
upgrade the database until you apply the required patches.
- A new parameter called "diagnostic_dest" determinate where your log files will be created, this
parameter replaces background_dump_dest, user_dump_dest and core_dump_dest.
- DBUA will give you the option to move files from file system to file system, from file system to
ASM and from ASM to file system.
- DBUA will also give you the option to recompile invalid objects after the upgrade.
- If you need to restore and you let DBUA do the backup for you, your restore files are located
on $ORACLE_BASE/admin//backup.


Personal and optional Advice

- Although it is possible to install and upgrade your database to 11g at the same time, please abstain from it as you may face problems during the install.

- Be sure you have a good install before trying to perform the upgrade, I advice as well to create a small new database, just to be sure the software is working properly and you have all the parameters in place.

- If you have never tested your backups before, now would be a good idea to do it. Also if you are like me that do not trust the tape library, then try the restore in a different server and document your restore process. If you need to restore you will have a lot of eyes in your shoulders, and if you start checking the manual for restore you are not going to transmit a lot of confidence to them.

- DBUA will present you to do the backup of your database for you, however I recommend you do your own.

RMAN> shutdown immediate
RMAN> startup restrict
RMAN> backup database plus archivelog format '' tag pre-upgrade;
RMAN> shutdown immediate
RMAN> startup

If you need to restore

startup nomount
run {
restore controlfile from '';
alter database mount;
restore database from tag pre-upgrade
recover database noredo;
alter database open resetlogs;
}

After the restore is complete, you need to point your environment variables to the old Oracle sofware location.

- Do another backup after you successfully upgrade.

- Check your DB alert.log after the upgrade for any errors.

- Check the DBA_REGISTRY view to make sure all the components reflect the new version.

- The issues I frequently find while upgrading are tablespace space and memory, be sure you have
enough of both. After you upgrade you can bet your footprint will take more memory and many times
more disk.

- before you upgrade do dump the control file to trace:

SQL> alter database backup controlfile to trace;


These are a must

- Backup your binaries and database before trying to upgrade.
- Check the release notes, most of the time they tell you what errors can you expect.
- Read the upgrade manual.
- DBUA logs are by default located at $ORACLE_HOME/cfgtoolslogs/dbua/db_name, tail the
log files during the upgrade and check them again after the upgrade.

UpgradeResults.htm = Summary of what DBUA will upgrade
Post_Upgrade.log = Log file for post upgrade work.
Oracle_Server.log = Detail of the migration execution
Trace.log = Detail tracing information of the upgrade process.

- Check that your redo log file size are bigger than 4MB. The upgrade will fail if they are not.

- Run the pre-upgrade information tool $ORACLE_HOME/rdbms/admin/utlu111i.sql this will
will tell you if you need to change anything to go to 11g.

- After you are done with the upgrade and post upgrade activities check for invalid objects and compile, you can use the view dba_invalid_objects for this.

- Collect statistics for your tables.

New 11g Parameters

- asm_preferred_read_failure_groups
- client_result_cache_lg
- client_result_cache_size
- commit_logging
- commit_wait
- control_management_pack_access
- db_lost_write_protect
- db_secure_file
- db_ultra_safe
- ddl_lock_timeout
- diagnostic_dest
- global_txn_process
- java_jit_enabled
- ldap_directory_sysauth
- memory_max_target
- memory_target
- optimizer_capture_sql_plan_baselines
- optimizer_use_invisible_indexes
- optimizer_use_pending_statistics
- optimizer_use_sql_plan_baselines
- parallel_io_cap_enabled
- plscope_setting
- redo_transport_user
- resource_manager_cpu_allocation
- result_cache_max_result
- result_cache_max_size
- result_cache_mode
- result_cache_remote_expiration
- sec_case-sensitive_logon
- sec_max_failed_login_sttempts
- sec_protocol_error_further_action
- sec_protocol_error_trace_action
- sec_return_server_release_banner
- xml_db_events

Deprecated 11g parameters

- background_dump_dest
- core_dump_dest
- user_dump_dest
- commit_write
- commit_wait
- instance_groups
- log_archive_local_first
- plsql_debug
- plsql_v2_compatibility
- remote_os_authent
- standby_archive_dest
- transaction_lag

Obsolete parameters in 11g

- ddl_wait_for_locks
- logmnr_max_persistent_sessions
- plsql_compiler_flags









Thursday, August 13, 2009

Oracle11g Best Practices with Thomas Kyte

Today I had the opportunity of assisting to this presentation at Bridgewater NJ with Thomas Kyte, as usual Tom's presentation was excellent, he always transmit that sense that he knows what we go through day to day and you actually feel identified with him , he has that something that you only get with many years of been in the field and experienced that, that something that you don't get just reading books, keeps you attention and make you have a good time. I wanted to share with you some of the points he covered and I consider very important. As a matter of fact I will look to implement some of this technologies / features in the next few months and offer them as part of the portfolio of services we have at OraProfessionals.

- Tom suggested the use of Physical DG in 11g for Testing, in 11gR2 you can use your physical DG for doing destructive test, after you are done you Flashback the DB to the point before the test and continue business as usual. I think this is great as I have plenty of DG databases, however I struggle with the developers to get time on the test database.

- Tom suggested as well the use of logical standby as a reporting solution, and I ask myself why no more people is using this technology. Nowadays probably the most common solution for a reporting server is Oracle Streams, however we know how fragile and heavy to maintain it can be. We rarely have any problems with Oracle DG, however I can't say the same for streams.

- 11gR2 will allow you to re-route in an automatic way your read only queries to a standby database. This will make the developers happy as they won't need to change their application code. Apparently this is configurable so if your standby is behind more than so many minutes, Oracle will resolve the query on the primary database.

- 11gR2 has a feature when using Real Application Testing (RAT) that allows you to use the sql performance analyzer (dbms_sqlpa) to compare the performance of your regressed SQLs with the new ones (assuming you are testing some database changes). RAT is one of the technologies that we plan to explore in the next few months. I want to clarify that RAT is not the product that will allow you to test some application functionality, this product will just tell you how your database will behave with similar workload. RAT requires for your objects in the source and the target to be identical.

- 11gR2 also has a Data Recovery advisor, you don't longer have to think what are the different ways that you can recover the database and try to determinate which one is the most efficient. The advisor will layout your options and give you an educated guesstimate of how long it will take for each option. RMAN will even create the script for you to restore depending of the option you selected; To me this is a priceless feature, I lost track of the times my customers requires to know how long will it take to restore their databases, and the answer is not always easy to provide due to the variables involved.

- Use of flashback database for application upgrades: You upgrade your application, if something goes wrong you flashback to the point before the upgrade. I actually like very much this idea, however be careful if you do not have a fast I/O subsystem, as enabling flashback database can deteriorate your performance up to 30%. If your application is sensitive to performance then this may not be a good idea for you.

- Flashback Data Archive: Allows you to have an easily accessible archive of historical data, that you can access using standard SQLs. (looking forward to hear more about it).

- 11g Automatic provisioning of partitions: Very good feature, you actually provision the new partitions once new rows are available to insert on them, so there is no need for the DBA to pre-allocate the partitions. I wish this was available in 1ogR2, as I could immediately use it.

During the meeting Oracle Support spoke about the upgrade paths to 10gR2, something to keep in mind If you are upgrading from a version such as 10.2.0.1, you can upgrade to 11g directly, however if you need to downgrade you need to go to 10.2.0.3 and from there to your original release, ex: 10.2.0.1

11g bring several nice new features, however I have been told that Oracle 11g brings as well stability, Oracle solved several bugs, and enhanced features that were difficult to work with.

Enjoy the rest of the summer :-)







-

Saturday, March 28, 2009

The Oracle Optimizer & Philosophycal discussions

In Oracle 10.2.x I have found recently very often that some of our systems are slowing down in performance, when looking at the specific SQLs that are causing the problem to our surprise we see poor plan execution, when looking at the tables involved we found that the table has not been analyzed for a while and that puzzle me.

Starting 10g Oracle has a default job process called GATHER_STATS_JOB that using DBMS_STATS.GATHER_DATABASE_STATS_JOB_PROC suppose to intelligent decide whether or not collect stats for a table depending of the changes on that table.

I find that job is not working as it suppose to work, we have been replacing that job for explicit analyze using the following command.

EXEC DBMS_STATS.gather_schema_stats (ownname => '', cascade =>true, estimate_percent => dbms_stats.auto_sample_size);

When you specify the cascade parameters equal true explicitly it will include indexes

Oracle Corporation recommend setting the ESTIMATE_PERCENT parameter of the gathering procedures to DBMS_STATS.AUTO_SAMPLE_SIZE. This will maximize performance gains while achieving good statistical accuracy.

I know I may be opening Pandora's Box with the following topic, but I want to set my stand on this clear.

While doing the changes above for the analyze on multiple systems (about 15 production databases), one database presented performance degradation in 2 tables. This particular application was written by a famous software house of billing systems called "A M * * C S" you fill in the stars. When looking to what is causing the problem we found that the particular query has a column in the predicate that was not indexed, and we found that they added a tremendous amount of hidden parameters that modify the optimizer behavior without authorization. When questioned about why they introduced those parameters they said that although they don't know what they do, it has worked for some other customers (It is up to your to decide if that is a valid argument, but it is not for me) . The vendor told the client that the reason for the performance degradation is that the tables were analyzed. They said verbally that we should never analyze this two tables because they do not change much. When asked about number of daily changes we found that in 8 days 11% of the table will change and in a month 41.25% of the table will change (too much for a no changing table in my opinion).

This is my stand, "tables should always be analyzed". If you don't want a particular table to be analyzed for x or y reason you must lock the stats on those tables and document it. The Oracle optimizer picks the right execution plan 90% to 95% of the times (this is only true if you have a decent developer and you understand how the Oracle architecture works). For the other 5% to 10% of the code you need to use hint, SQL Profiles and other artifacts that Oracle provides so you can get a good execution plan.

"Changing the optimizer behavior so 5% to 10% of your code runs properly is just not a good idea nor makes any sense."

I will advice to change the optimizer behavior just when you exhausted any other option, you are dealing with an small set of tables that you know works well with the change, and you know you will not add more code or tables to that database.

As usual I respect the opinion of those people that think that "if it is no broken don't fix it", the fact is that if you are a DBA you better you better get your hands dirty and understand well how the application uses your database, what are your heaviest tables, what are your problematic queries, etc, etc. The vendor will leave after they finish the application code, data will change and you will have a ticking boom in your hands.

Sunday, March 22, 2009

Rovio

Rovio is an amazing robot created by WowWee,
The beauty about Rovio is that it allows you keep in contact
with your family while you are away. Rovio has a video camera
on the top that has 3 levels and can be managed remotely through the internet
using a browser; but it does not stop there it allows you to talk
to your family using full duplex communication.


The UI that Rovio uses is very intuitive, the best of all is loaded into the device itself, you do not have to deal with complex setup of web servers or anything like that. The UI allows you to move Rovio in any possible direction, switch the camera to 3 different levels, setup the sound, video quality and brightness.


The quality of the picture is amazing, the sound is not bad but it only works with Internet Explorer, there is not plug in for any other browser. It allows you to grant guest accounts to your family, in that way they will not be able to mess with the setup, but will be able to use it. Rovio is powered by rechargeable batteries that gets charged through a base that comes with the device. The auto docking features of the device is just amazing, it uses a beacon of light reflected on the roof of the room to guide itself into the docking station with the push of a button.


Rovio is propelled by 3 sets of wheels each wheel has several mini wheels, that gives Rovio and amazing moving flexibility. I am not clear about the price, I have seen it going from $130 at BJS to over $400 on the internet while I think at $130 is a fair price I would not pay for it $400, but I can't understand why such a difference in the price.

Pros & Cons

Pros:
  • Amazing moving flexibility.
  • Good quality picture.
  • Very intuitive user interface.
  • Very easy to setup.
Cons:
  • Once in a while it loses the network signal and needs manual reboot.
  • The battery could last longer.
  • It should come with additional beacons so you can preset way points to different parts of the house.
  • You should be able to move the video camera up and down on demand rather than having preset position.


Rating: 4 out of 5