Oracle NZ - Francisco Munoz Alvarez

25. September 2008

How to find all user Roles and Privileges?

Filed under: Oracle FAQ, Security, Questions — admin @ 03:56

Here is the scripts to help you to get this information:

PROMPT 

PROMPT 

PROMPT ******************************************** ROLES AND PRIVILEGES 

PROMPT 

PROMPT ******************************************** USER ROLES 

SELECT grantee user, granted_role, admin_option, default_role 

FROM dba_role_privs 

WHERE grantee IN (SELECT username FROM dba_users)

AND       grantee NOT LIKE ‘%SYS%’

AND       grantee NOT IN (‘DBSNMP’,‘OUTLN’

ORDER BY grantee; 

PROMPT 

PROMPT ******************************************** USER PRIVILEGES 

SELECT grantee user, privilege, admin_option 

FROM dba_sys_privs 

WHERE    grantee IN (SELECT username FROM dba_users)

AND      grantee NOT LIKE ‘%SYS%’

AND      grantee NOT IN (‘DBSNMP’,‘OUTLN’

ORDER BY grantee; 

set pages 58 

column role         format a19 heading ‘User or Role’ 

column admin_option format a3  heading ‘Ad?’ 

column owner        format a7 heading ‘Owner’ 

column table_name   format a26 heading ‘Table name’ 

column privilege    format a21 heading ‘Priv, Grant or Role’ 

column r_ord noprint 

break on role start

titel132 ‘ORACLE ROLES REPORT’ 

select    2 r_ord, b.role role, b.owner owner, b.table_name,  

b.privilege privilege, b.grantable admin_option 

from sys.role_tab_privs b 

union 

select    1 r_ord, a.role role, ‘N/A’ owner, ‘N/A’ table_name,   

a.privilege privilege, a.admin_option admin_option  

from sys.role_sys_privs a 

union 

select    3 r_ord, c.role role, ‘N/A’ owner, ‘N/A’ table_name,   

c.granted_role privilege, c.admin_option admin_option 

from sys.role_role_privs c 

order by role,r_ord; 

set flush on term on pagesize 22  linesize 80 

clear columns 

clear breaks 

ttitle off 

pause Press enter to continue

Cheers,

Francisco Munoz Alvarez

24. September 2008

How to migrate from 32 bit to 64 bit using RMAN?

Filed under: Oracle FAQ, Upgrade/Migration, Tutorials, Questions — admin @ 02:07

This procedure can be used for single instance or RAC (9i to 11g):

In the 32 bit source server :

Start making a full backup of the database including all archivelogs:

RMAN> run  {  

allocate channel c1 type disk;  

allocate channel c2 type disk;  

backup database plus archivelog;  

backup current controlfile;  }


In the target 64 bit server:

1) Copy backup files from source server
2) Create the pfile or copy the pfile fromsourceserver
3) Startup nomount the new instance.
4) Connect to rman and set the dbid:

$ rman target / nocatalog RMAN> set dbid=<dbid from the 32 server>;

5) Restore the controlfile:

RMAN> restore controlfile from ‘/disk1/backup_32/backup_piece_name’;

RMAN> alter database mount;

RMAN> restore database;

6) Identify the archivelog till you want to do the recovery and check if you have all the backups you need to do it and run:

RMAN> run {

set until sequence xxxx;

recover database;

}

RMAN> exit

7) Now Migrating to 64 bit:

SQL> recover database until cancel using backup controlfile;

cancel

SQL> alter database open resetlogs migrate;

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

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

SQL> shutdown immediate;

SQL> startup

Note: Also please take a look in other methods in the following Metalink Note:

  • Migration of Oracle Instances Across OS Platforms - Doc ID: Note:733205.1

Cheers,

Francisco Munoz Alvarez

16. September 2008

How to Start and Stop a RAC Environment

Filed under: Oracle FAQ, RAC, Questions — admin @ 10:28

Auto Start/Stop

The Oracle Cluster Services handle the automatic start and stop of the Cluster, Listener, ASM and the Database.

For the Grid Control Agent, the auto start- stop is handled via the /etc/init.d/dbora script.  On server boot the dbora script starts the agent with /home/oracle/scripts/start_agent. On server shutdown the dbora script calls /home/oracle/scripts/stop_agent

Manual Start/Stop

Each database instance may be manually started and stopped using standard sqlplus scripts. However, it is highly recommended that the srvctl command interface be used in a RAC environment. Note that srvctl commands can be run remotely from any node in the cluster.

Nodeapps

srvctl start nodeapps –n hostname

srvctl stop nodeapps –n hostname 

Listener

srvctl start listener –n hostname

srvctl stop listener –n hostname 

Database

srvctl start database –d edwdev

srvctl stop database –d edwdev –o immediate

Instance

srvctl start instance –d edwdev –i edwdev1

srvctl start instance –d edwdev –i edwdev2

srvctl stop instance –d edwdev –i edwdev1

srvctl stop instance –d edwdev –i edwdev2

ASM

srvctl start asm –n hostname

srvctl stop asm –n hostname 

Grid Control Agent

Set environment to ‘agent’ using . oraenv

$ORACLE_HOME/bin/emctl start agent

$ORACLE_HOME/bin/emctl stop agent 

Regards,

Francisco Munoz Alvarez

Grid Control (GC) Cheat Sheet

Filed under: Grid Control — admin @ 10:05

  

  1. Ensure the Oracle database version can be monitored by Grid Control in Metalink article “Note 412431.1  Oracle Enterprise Manager 10g Grid Control Checker”.
  2. Request firewall ports to be opened for 2 way traffic between your target and your Grid Control server. Test by issuing telnet commands on port 4889 from your target to your Grid Control server.
  3. Download the appropriate agent software version according to the Metalink note above. The downloads are about 500Mb and are here http://www.oracle.com/technology/software/products/oem/htdocs/agentsoft.html
  4. Install the software according to Oracle’s installation documentation on their website. When the installer asks for the Repository server, add the IP of your Grid Control server port 4889.  The agent registration password is the current SYSMAN password5.      Ensure an “agent” entry has been added to the Oratab file on your target server. If not, add one yourself 

Post Installation Configuration: 

  1. Add your target machine name to the grid control server hosts table.
  2. Add GC machine name to target hosts table.
  3. All licensed options are selected by default when you add install a new agent. To remove them go into SETUP – MANAGEMENT PACK ACCESS. “Search Database” and ensure all boxes are unchecked. “Search Host” and ensure all boxes are unchecked.
  4. Logon to Grid Control and add passwords in PREFERENCES – PREFERRED CREDENTIALS. Enter passwords for HOST, DATABASE and ASM (if using ASM)
  5. Now add the DBSNMP monitoring password. Go to TARGETS - ALL TARGETS - “Targets Not Configured”. Click on the number next to “Targets Not Configured” which is a hyperlink. Locate the target from your new server and click Configure. Then you will then enter DBMSP password. Set this is the SYS password. Save click NEXT, SUBMIT, OK.
  6. Turn on default Alerts on PREFERENCES – RULES. Check “Database Availability and Critical States” and click CREATE LIKE. Copy this rule and append your site name to the rule name, eg “Database Availability and Critical States XXXX”. Save this new rule and check PUBLIC. Click SETUP-ADMINISTRATORS-CREATE and add a new SYSMAN account and email address to receive these alerts. Eg XXXX_SYSMAN.
  7. If desired customize your database alert log monitoring. Follow Metalink Note:405396.1 and Note:330996.1. 

 Cheers,

Francisco Munoz Alvarez

How can I start a trace?

Filed under: Oracle FAQ, Questions — admin @ 05:58

Here are some possible ways to setup Trace:

To Enable trace at instance level

1) Set the parameter sql_trace in the pfile or spfile. It will enable trace for all sessions and the background processes

sql_trace = TRUE to enable it or to disable trace use sql_trace = FALSE

2)To enable tracing without restarting the databasejust run the following command using sqlplus:

SQL> ALTER SYSTEM SET trace_enabled = TRUE; To start trace
SQL> ALTER SYSTEM SET trace_enabled = FALSE; To stop trace

To enable trace at session level

If need generate trace at your own sesion use:

SQL>ALTER SESSION SET sql_trace = TRUE; to strat the trace
SQL>ALTER SESSION SET sql_trace = FALSE; to stop the trace


or

SQL>EXECUTE dbms_session.set_sql_trace (TRUE); to start trace
SQL>EXECUTE dbms_session.set_sql_trace (FALSE); to stop trace


or

SQL>EXECUTE dbms_support.start_trace; to start trace
SQL>EXECUTE dbms_support.stop_trace; to stop trace

To Enable trace in a different session

Find out the SID and SERIAL# from v$session using:

SQL>SELECT * FROM v$session WHERE osuser = OSUSER;


and use:

SQL>EXECUTE dbms_support.start_trace_in_session (SID, SERIAL#); to start trace
SQL>EXECUTE dbms_support.stop_trace_in_session (SID, SERIAL#); to stop trace


or

SQL>EXECUTE dbms_system.set_sql_trace_in_session (SID, SERIAL#, TRUE); to start trace
SQL>EXECUTE dbms_system.set_sql_trace_in_session (SID, SERIAL#, FALSE); to stop trace

On 10g you can also use DBMS_MONITOR:

BEGIN

->Enable/Disable Client Identifier Trace.

DBMS_MONITOR.client_id_trace_enable (client_id => ‘my_id’); 

DBMS_MONITOR.client_id_trace_disable (client_id => ‘my_id’);  

->Enable/Disable Service, Module and Action Trace. 

DBMS_MONITOR.serv_mod_act_trace_enable (    service_name  => ‘my_service’);  

DBMS_MONITOR.serv_mod_act_trace_enable (    service_name  => ‘my_service’,    module_name   => ‘my_module’); 

DBMS_MONITOR.serv_mod_act_trace_enable (    service_name  => ‘my_service’,    module_name   => ‘my_module’,    action_name   => ‘INSERT’);  

DBMS_MONITOR.serv_mod_act_trace_disable (    service_name  => ‘my_service’,    module_name   => ‘my_module’,    action_name   => ‘INSERT’); 

->Enable/Disable Session Trace .  

DBMS_MONITOR.session_trace_enable; 

DBMS_MONITOR.session_trace_enable (    session_id => 12,    serial_num => 1011);  

DBMS_MONITOR.session_trace_disable (    session_id => 12,    serial_num => 1011);

END;

/

For more information regarding DBMS_MONITOR, please refer to the following link:

Also take a look on this link:


Cheers,
Francisco Munoz Alvarez

How to setup a Basic Audit?

Filed under: Oracle FAQ, Security, Questions — admin @ 05:46

For any Oracle versions prior to 9i you will need to set audit_trail parameter in the pfile ie.g.:

audit_trail = DB

For later Oracle Versions:

SQL>alter system set audit_trail = DB;

To enable auditing for a specific object run the following command:

SQL>AUDIT SELECT, INSERT, UPDATE, DELETE ON SCHEMA.TABLE;

To stop auditing use:

SQL>NOAUDIT SELECT, INSERT, UPDATE, DELETE ON SCHEMA.TABLE;

Or to audit any statement that queries, delete, insert or updates any table, issue the following statement:

AUDIT SELECT TABLE, DELETE TABLE, INSERT TABLE, UPDATE TABLE;

If you want to audit a specific user will need to run the following commands:
AUDIT ALTER TABLE, SELECT TABLE, INSERT TABLE, … ,GRANT PROCEDURE by <USERNAME>;
To stop the audit for the user you will need to run:
NOAUDIT ALTER TABLE, SELECT TABLE, INSERT TABLE, … ,GRANT PROCEDURE by <USERNAME>;

To see the results of the auditing use please run:

SQL> select * from dba_audit_trail;

This is an excellent Oracle documentation to learn how to implement it:


Also I’ll recommend you to take a look on the following links:


Cheers,
Francisco Munoz Alvarez

7. September 2008

Oracle Application Server (10.1.2) Reference Tips - Part I

Filed under: Application Server — admin @ 16:25

Starting an OracleAS infrastructure 

  1. Start the database listener: # lsnrctl start
  2. Start the repository database: # sql> startup
  3. Start the processes of the Oracle Infrastructure instance: # opmnctl startall
  4. Start the OracleAS Console: # emctl start iasconsole - then try it http://host:1810  

Stop an OracleAS infrastructure 

  1. Stop the OracleAS Console: # emctl stop iasconsole
  2. Stop the processes of the Oracle Infrastructure instance: # opmnctl stopall
  3. Stop the repository database: # sql> shutdown immediate;
  4. Stop the database listener: # lsnrctl stop  

Access OracleAS infrastructure 

  1. To Portal welcome page: http://host:port/pls/portal
  2. To Reports Services: http://host:port/reports/rwservlet
  3. To Forms Services: http://host:port/forms90/f90servlet  

Stop and start OracleAS infrastructure 

  1. # opmnctl startall – use the Oracle Process Monitoring and Notification to start
  2. # opmnctl stopall – use the Oracle Process Monitoring and Notification to stop 

To change or maintain OracleAS infrastructure use

  • # dcmctl 

Start and Stop an OracleAS Control on Windows 

Use one of the following methods: 

  • From the Windows Start menu, navigate to the Oracle Enterprise Manager Menu item for the Oracle home and select Start AS Console or Stop AS Console. 
    • For example, to start the Application Server Control on Windows 2000, select Start > Programs > Oracle - Oracle_Home Enterprise Manager > Start AS Console.
  • From the Windows Services control panel:  
    1. Open the Services from control panel. 
      • Locate the Application Server Control in the list of services.  For example, on Windows 2000, select Start > Settings > Control Panel > Administrative Tools and then double-click the Services icon. 
    2. Locate the Application Server Control in the list of services.
      • The name of the service is consists of “Oracle,” followed by the name of the home directory you specified during the installation, followed by the word “ASControl.” For example, if you specified AS10g as the Oracle home, the Service name would be: 
        • OracleAS10gASControl 
    3. After you locate the service, you can use the Services control panel to start or stop the Application Server Control service.
      •   By default, the Application Server Control service is configured to start automatically when the system starts. 

Check if OracleAS Control is Running 

To verify if the OracleAS Control is started, you just need to pointe your browser to the OracleAS Control Console URL:  http://hostname.domain:port 
For example: 

  • http://hostname.domain:1156 

There are two ways to locate the OracleAS Control Console port number: 

  • Review the contents of the portlist.ini file, which is located in the following directory in the OracleAS Oracle home: 
    • (UNIX) ORACLE_HOME/install/portlist.ini
    • (Windows) ORACLE_HOME\install\portlist.ini 

  • Or enter the following command: 
    • (UNIX) ORACLE_HOME/bin/emctl status iasconsole
    • (Windows) ORACLE_HOME\bin\emctl status iasconsole

Note: Next week more tips for you.

Overview of the Oracle Application Server (10.1.2) - Part I

Filed under: Application Server — admin @ 15:48

Oracle Application Server is a complete and integrated platform to develop, deploy, and administer a fast, scalable Internet application through built-in Web caching, load balancing and clustering capabilities. 

The Oracle Application Server solution areas are: 

  • J2EE, and Internet Applications:J2EE enables the use of a comprehensive and flexible framework that allows you to design, develop, and deploy dynamic Web sites, portals, and transactional applications using familiar programming languages and technologies (as servlets, JavaServer pages, XML, PL/SQL Server Pages, and SOAP). Oracle Application Server also provides comprehensive Web services to expose business functions to authorized parties over the Internet from any Web device.
  • Portals: You can build, deploy, and maintain self-service by using portals in the Oracle Application Server. It also includes Oracle Instant Portal, a custom application built with OracleAS Portal that provides smaller enterprises an opportunity to build simple portals in a short amount of time.
  • Caching: It caches both static and dynamically-generated Web content significantly improving the performance and scalability of heavily loaded Web sites.
  • Wireless: It simplifies development and deployment of an application in a wireless environment.
  • Intelligence: Business: it provides a dynamic personalized content to both registered and anonymous visitors.
  • E-Business Integration: provide communications and integration capabilities for e-business applications including many non-Oracle data sources.
  • Availability and Scalability: Provides a flexible deployment model that allows you to architect your system for high availability and scalability using a variety of options for improving availability and scalability, and provides features for implementing fault tolerance, death detection, and failover. Additionally you can use options as cold failover clusters and active failover clusters.
  • System Management: Provides a set of management facilities to simplify all aspects of Web site and application server administration. Using this capabilities, you can:
    • Configure and monitor Oracle Application Server instances from a centralized console
    • Monitor and manage your entire suite with OEM
    • Real-time, graphical information about your processes with Topology Viewer
    •  Have your HTTP port management automated
    • Create and manage application server clusters
    • Deploy and configure applications
    • Start and stop the application server and its components
    •  Respond to problem conditions from a centralized console
    •  Use encrypted secure sockets layer (SSL) connections, user and client certificate-based authentication, and single sign-on across all applications
    • Implement Oracle Internet Directory, an LDAP-compliant directory

  • Identity Management: The Oracle Application Server identity management infrastructure allows you to manage user identity throughout the application security life cycle. Oracle Application Server provides components for handling authentication, security services, authorization, and user provisioning to ensure the security of your Internet applications.  

OracleAS 10.1.2 Administration Guide


 The OracleAS Middle-Tier components and solutions are: 

  •  J2EE and Internet Applications
    • Oracle HTTP sever
    • OracleAS Containers for J2EE
    • OracleAS TopLink
    • OracleAS Framework
    • Oracle JDeveloper
    • OracleAS Web Services
    • Oracle XML Developer’s Kit
    • Oracle PL/SQL
    • Oracle Content Management SDK
    • OracleAS MapViewer
  • Business Intelligence
    • OracleAS Reports Services
    • OracleAS Forms Services
    • Oracle Business Intelligence  Discoverer
    • OracleAS Personalization
  • Portal
    • OracleAS Portal
    • OracleAS Portal Developer Kit
    • Oracle Ultra Search
  • Wireless
    • OracleAS Wireless
    • OracleAS Wireless Developer Kit
  • Caching
    •  OracleAS Web Cache
  • E-Business Integration
    • OracleAS InterConnect
    • OracleAS B2B
    • OracleAS Adapters
    • Oracle BPEL Process Manager
    •  Oracle BPEL Process Analytics
  • System Management
    •  OEM 10g
  • Identity Management and Security
    • OracleAS Single Sign-On
    • OracleAS Certificate Authority
    • Java Authentication and Authorization Service
    • OID
    • Oracle Security Developer Tools
  • High Availability
    • OracleAS Guard
    • OracleAS Backup and Recover Tool
    • OracleAS Disaster Recovery Tool
  • Installation and Upgrade
    • OracleAS Metadata Repository Creation Assistant
    • OracleAS Upgrade Assistant
    • OracleAS Metadata Repository Upgrade Assistant

Note: Next Week I’ll go over each component and solution in detail.

6. September 2008

Some Good or Bad news, I’m not sure Yet…

Filed under: News — admin @ 07:24

The company I work for here in New Zealand is not currently supporting me and overloading me of work because they have only interest on explore my new ACE status to get new clients and projects, due to this situation I’m currently suffering a severe asthma problem triggered by severe stress.

Last week I had a meeting where force me to make some decisions about my future in this company. As most of my colleagues already know (and they know the full list of reasons, that by legal matters I can’t express on my blog yet), I have made the decision that our paths should diverge. At this time we are trying to set the best way to this happen.

As result of this is that some time very soon I’ll have to get off myself and find a new job or contract. I’ll be looking for any good opportunity to keep growing my knowledge and allow me to keep trying to help other fellows DBAs in the Oracle Community. Probably I’ll start given some training clases and Seminars again…let see what will came on my future :)

Francisco Munoz Alvarez Oracle ACE

Oracle is the #1 Relational Database

Filed under: News — admin @ 06:32

Gartner 2007 Worldwide RDBMS Market Share Reports 48.6% Share for Oracle (*)

Gartner has published their market share numbers by operating system for 2007 based on total software revenues. According to Gartner, Oracle

  • Has 48.6 percent share (up from 47.9 percent in 2006) growing at 14.9 percent
  • Is growing faster than the market average of 13.3 percent with US$8.29 Billions in revenues
  • Continues to hold more market share than its two closest competitors combined

(*) Source: Market Share: Relational Database Management System Software by Operating System, Worldwide, 2007 - Colleen Graham, Bhavish Sood, Horiuchi Hideaki, Dan Sommer - July 11, 2008

 DW Oracle #1

Next Page »

Powered by WordPress