Tabs

Thursday, January 15, 2015

Users recreation with quotas, privileges and roles

It is quite often in some Oracle shops to refresh databases or a specific schemas of a database using the traditional exp/imp method while retaining the same roles and privileges and other resources is a nerve racking job. Here are some scripts to make life easy for such a DBA to retain the user quotas, privileges and roles (QPR). These scripts generate the sql statements to recreate the QPRs and are named in a sequential order and are to be run in the same sequetial order. Its a known fact that there are misspellings in the script names, which were created when it was a real tizzy situation.

------------------------------
--- 01_useR_recreation.sql ---
------------------------------

set line 150
select 'create user '||username||' identified by values '||
''''||password||''''||' default tablespace '||
DEFAULT_TABLESPACE||' temporary tablespace '||
TEMPORARY_TABLESPACE||' profile '||PROFILE||';' from dba_users 
order by username;

-------------------------------------
--- 02_useR_Quota_recreateion.sql ---
-------------------------------------

set serveroutput on size 1000000 
set line 150
declare
a number;
cursor q is select username,max_bytes,tablespace_name 
from dba_ts_quotas order by username;
begin
for i in q
loop
if i.max_bytes=-1 then
dbms_output.put_line('alter user '||i.username||
' quota unlimited'||' on '||i.tablespace_name||';');
else
dbms_output.put_line('alter user '||i.username||
' quota '||i.max_bytes||' on '||i.tablespace_name||';');
end if;
end loop;
end;
/

---------------------------------------
--- 03_useR_sys_priv_recreation.sql ---
---------------------------------------

set serveroutput on size 1000000
set line 150
declare
cursor user_name is select username from dba_users 
order by 1;
cursor priv (user_nm in varchar2) is select 
distinct(grantee),privilege from dba_sys_privs where 
grantee=user_nm and grantee not in 
('CONNECT','SYSTEM','RESOURCE','SYS','EXP_FULL_DATABASE',
'TSMSYS','RECOVERY_CATALOG_OWNER','SCHEDULER_ADMIN',
'AQ_ADMINISTRATOR_ROLE','DIP','OEM_ADVISOR','DBA',
'IMP_FULL_DATABASE','OEM_MONITOR','DBSNMP','OUTLN') 
order by grantee;
a number;
b varchar2(100);
begin
for i in user_name
loop
for j in priv(i.username)
loop
dbms_output.put_line('grant '||j.privilege||' to '
||i.username||';');
end loop;
end loop;
end;
/

------------------------------------
--- 04_uSer_role_recreateion.sql ---
------------------------------------

set serveroutput on size 1000000
set line 150
declare
cursor user_name is select username from dba_users order 
by 1;
cursor role (user_nm in varchar2) is select distinct 
GRANTEE,granted_role from dba_role_privs where grantee 
not in ('DBSNMP','DIP','OUTLN','SYS','SYSTEM','TSMSYS',
'EXP_FULL_DATABASE','DBA','SELECT_CATALOG_ROLE',
'IMP_FULL_DATABASE','EXECUTE_CATALOG_ROLE',
'LOGSTDBY_ADMINISTRATOR') and grantee=user_nm order by 
grantee;
a number;
b varchar2(100);
begin
for i in user_name
loop
for j in role(i.username)
loop
dbms_output.put_line('grant '||j.granted_role||' to '
||i.username||';');
end loop;
end loop;
end;
/

-----------------------------------------
--- 05_user_tab_privs_recreateion.sql ---
-----------------------------------------

set serveroutput on size 1000000
set line 150
declare
cursor user_name is select username from dba_users 
order by 1;
cursor tab_priv (user_nm in varchar2) is select 
distinct(grantee),owner,table_name,privilege
from dba_tab_privs where grantee not in ('SYSTEM',
'PUBLIC','SELECT_CATALOG_ROLE','GATHER_SYSTEM_STATISTICS',
'EXP_FULL_DATABASE','SYS','EXECUTE_CATALOG_ROLE',
'DELETE_CATALOG_ROLE','LOGSTDBY_ADMINISTRATOR',
'AQ_USER_ROLE','AQ_ADMINISTRATOR_ROLE','HS_ADMIN_ROLE',
'DBA','IMP_FULL_DATABASE','OEM_MONITOR','DBSNMP',
'OUTLN') and grantee=user_nm order by grantee,owner;
a number;
b varchar2(100);
begin
for i in user_name
loop
for j in tab_priv(i.username)
loop
dbms_output.put_line('grant '||j.privilege||' on '||j.owner
||'.'||j.table_name||' to '||i.username||';');
end loop;
end loop;
end;
/
Here is a bonus script to only recreate the passwords of users in a database.

----------------------------------------
--- user_old_password_recreation.sql ---
----------------------------------------
set pages 0
set line 100
select 'alter user '||username||' identified by values '||
''''||password||''''||';' from dba_users order by username;

Wednesday, January 14, 2015

RMAN: target database incarnation is not current in recovery catalog

A surprising database backup failure report was delivered to my mailbox, upon checking with the log revealed the below pasted RMAN- errors. This left me wondering as to how come the rman backup would fail for no reason with an error like this, there is something fishy about the situation.

RMAN> 
RMAN-00571: ====================================================
RMAN-00569: ========== ERROR MESSAGE STACK FOLLOWS ============= 
RMAN-00571: ====================================================
RMAN-06004: ORACLE error from recovery catalog database:
RMAN-20011: target database incarnation is not current in recovery catalog

Here are the steps below that were performed to fix the issue of incarnation.

UNIX:~/dba/log > rman target / catalog rman_user/rman_pass@rcat.acme.com

Recovery Manager: Release 10.2.0.1.0 - Production on Mon Jan 26 06:45:20 2009

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

connected to target database: PROD (DBID=2706003900)
connected to recovery catalog database

RMAN>  list incarnation of database;

RMAN> exit
 
as you can see above, no incarnations listed.
 
UNIX:~/dba/log >  . oraenv
ORACLE_SID = [oracle] ? PROD
UNIX:~/dba/log > rman target / nocatalog
 
Recovery Manager: Release 10.2.0.1.0 - Production on Mon Jan 26 06:46:58 2009
 
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
 
connected to target database: PROD (DBID=2706003900)
using target database control file instead of recovery catalog
 
RMAN> list incarnation of database;
List of Database Incarnations
DB Key Inc Key DB Name DB ID      STATUS  Reset SCN Reset Time
------ ------- ------- ---------- ------- --------- ----------
  1      1      PROD   2706003900 CURRENT    1      07-FEB-07
 
RMAN> exit

The database PROD with the DBID (2706003900) and DBINC_KEY (875312) has to 
be reset in the recovery catalog and re-registered for its backups to 
resume.
 
UNIX:~/dba/log > rman target / catalog rman_user/rman_pass@rcat.acme.com
 
Recovery Manager: Release 10.2.0.1.0 - Production on Mon Jan 26 07:00:56 2009
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
connected to target database: PROD (DBID=2706003900)
connected to recovery catalog database
 
RMAN> RESET DATABASE TO INCARNATION 875312;
 
database reset to incarnation 875312
 
RMAN> register database;
 
starting full resync of recovery catalog
  
full resync complete
 
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of register command on default channel at 05/26/2009 07:40:05
RMAN-20002: target database already registered in recovery catalog
 
RMAN>
RMAN> list incarnation of database; 
List of Database Incarnations 

DB Key Inc Key DB Name DB ID      STATUS    Reset SCN  Reset Time
------ ------- ------- ---------- ------- ------------ ----------
875311 875312  PROD    2706003900 CURRENT            1  07-FEB-07
875311 9179422 PROD2   2706003900 ORPHAN 6203845546338 24-MAY-09 

RMAN> exit 
Recovery Manager complete.

Cloud Computing

I have read a  article on Cloud Computing and decided to post it. This article is written by one of the famous s/w engineer Gagan Kundra .

Cloud computing is a marketing term for technologies that provide computation, software, data access, and storage services that do not require end-user knowledge of the physical location and configuration of the system that delivers the services. A parallel to this concept can be drawn with the electricity grid, wherein end-users consume power without needing to understand the component devices or infrastructure required to provide the service.

Apple CEO Steve Jobs whenever someone comes on stage, the world is alarmed. Who let this time show little device that will change people's lives. Why is Apple the company, who gave us a iPod, Macintosh and iPhone are such tools. Jobs done something like this again. The only difference was that he did not have any tools. Just talked about a similar service to the people on the entire data and information from different devices can. Aiclaud Apple is the name of the service. But it's not actually Apple, but shows the power of cloud computing. Service's name may be, whether the service to be Apple, or Google, or Microsoft, but cloud computing in the coming days will sputter. Tech - pundits say that it will change our lives. Companies like Infosys have been predicted that almost all the work in the coming days the world will be on clouds. Just remember that no water in these clouds, but digital data - like - is filled with such information and other associated material. And the clouds in the sky, but on a giant computer - the server is called - are found.

Cloud computing is getting to be too much nowadays, but it is not a new thing. If you are on the Internet, so that - unconsciously you will also have to use it. I can not believe the e-mail as simple as taking the example of an Internet service. Most people e-mail on your computer, do not download, but leave it on the internet to see. Who your computer's hard drive to the e-mail wants to fill? But you never thought that this e-mail that you have left over the Internet or the Web, Where saving is kept, so you whenever you want your e-mail account, going to see it. The answer is simple - to cloud. You probably do not know, but nearly every time you leave something on the web, the data contained on these clouds. Whether it be a picture on Facebook, you - a video on the tube, or a new article on your blog. If he left you on the web, you are using cloud computing. You will have noticed that you leave the stuff on the internet, on any computer or cell phone or a tablet-like device can see. After all, your e-mail or Facebook Most office and home computer or your phone may get. This is the greatest power of cloud computing and specialty. It kept you on the Internet, its content or data from anywhere, anytime viewing and gives the ability to change.

 A few years ago was meant to use any software to download it to your computer or cellphone. Then the software could only be played on computers or cell phones. Today, via cloud computing could use the same software, with nothing to download, virtually any device - phone, tablet, computer or even from television. Consider that the cloud has taken the place of your computer. Now, Google's Google Docs, which runs entirely on the internet and gives you almost the same features you get with Microsoft Office, there is no need to download. It will remain on the files and documents, you can look at any computer or cellphone. and Google Docs is just an example. Dozens of world power and benefits of cloud computing companies trying to use it are given. Amazon's cloud service to their customers, keep your favorite songs have the chance. 

Microsoft has put many products on the cloud and its famous office software is also put on some cloud. And now Apple has also stepped into cloud computing. Aiclaud service people like him - look at the software and information and to use the facility will offer many tools. Interestingly, many are free of cloud computing service. To use Google Docs and Aiclaud you do not have light pockets at all. like - like an increasing number of software will run on the web, anyway - so we will run the digital cloud. Our work on certain devices, but will depend on our Internet connection. The Internet will be able to do or where we will be able to satisfy yourself. Whether we are or tablet computer, or cell phone, or TV, or game console, or to connect to the Internet even if the clock. Your work and be entertained, where would the internet. He will not be tied to a device.

=========================================================================
The simple definition: It’s a style of computing based on shared, elastic resources delivered to users in a self-service, metered manner using web technologies. Yet, if you ask five people “what is cloud computing?” you can expect five different answers. Why? Because what matters to them is not what cloud computing is, but what it does for them.

To fully understand cloud computing across an enterprise, you need to understand the different functional benefits driving cloud’s popularity. Let’s look at cloud through the lens of different roles in an enterprise, and then think about how to craft a cohesive cloud strategy that works for everyone in the enterprise. Let’s start with these important roles.
Business Leaders
This group wants cloud for modern, personalized applications. In the digital economy, companies must execute in real-time, from providing customer experiences to building talent-centric HCM strategies. Your customers want to seamlessly interact with their brand, wherever and whenever they want on social media, mobile, in-store, through the call center, on your website, and when making a purchase online. Speed, integrated processes, and analytics are vital. For these people, cloud often means " SaaS-based applications " that are fast, simple, and give the business side more control.
IT Leaders
IT also sees enormous value in the cloud, particularly in the application and platform services that let internal IT groups offload technology management. CIOs cannot forget existing infrastructure requirements when they evaluate cloud computing, and cloud services such as" PaaS and IaaS "can help them integrate applications and create consistent workflows across multiple systems—both on premises and in the cloud—while maintaining security and performance. As a result, IT can move away from technology administration and concentrate on business innovation.
Cloud Builders
Private cloud deployment is booming, as companies see the benefits of faster provisioning, on demand access, and scalability. Cloud builders can help their IT department become agile, cost-efficient private cloud providers. They view cloud from a lifecycle management perspective, from resource management and monitoring to capacity planning and chargeback mechanisms.
Developers
For this group, moving development and testing environments to" PaaS "platforms allows them to cut significant time from the development cycle by removing management tasks, cutting complexity, and increasing developer productivity.
Total Cloud
The key then is to build a cloud strategy that helps every group define not only what cloud computing means to them, but also how to best use it.
The best use might be to build a cloud behind your firewall. Or it could be to subscribe to cloud applications and compute services from a trusted cloud vendor. Another option is to use infrastructure or application that is dedicated to your organization but hosted by a vendor or a local partner.
Most likely, you’ll be using several of the above of the above scenarios at once. So it makes sense to choose a cloud provider with solutions that are preintegrated and tested to work across the entire stack, whether in your data center or in the cloud. That way, even though cloud computing means different things to different people, you will have a single, complete, and integrated platform to serve them all.


Database
Your Oracle Database in the Cloud
Oracle Database Cloud Services gives you the power and flexibility of the Oracle Database in the cloud.  You choose whether you want a dedicated database instance with direct network connections and full administrative control, or a dedicated schema with a full development and deployment platform managed by Oracle.
Database Backup
Secured, protected, elastic cloud storage for Oracle database backups
Oracle Database Backup Service is the cloud storage solution for all your Oracle Database backup needs. It offers reliable and scalable object storage solution for storing and accessing your ever growing Oracle database backup data.