Remember your dreams

Remember your dreams
Remember your dreams

Wednesday, June 30, 2010

Display the number of processors on Linux

On a hyperthreaded system it can be confusing to determine exactly how many CPU's and Cores a machine has in use. Using the /proc/cpuinfo command will provide the information, but you want to isolate the processor id and core id information for an accurate count.

I am on Red Hat Enterprise 5

-- Type uname -r to display the kernel release
#
# uname -r
2.6.18-164.el5

-- cpuinfo provides the information.
# cat /proc/cpuinfo

-- Isolate the number of processors.
# grep "physical id" /proc/cpuinfo | sort -u | wc -l
2

-- Isolate the number of cores
# grep "core id" /proc/cpuinfo | sort -u | wc -l
4

Monday, June 28, 2010

Renaming a redo log member from .log to .rdo

Using dbca in 11gR2 will default the redo log names with the .log extension. This may cause confusion with other log files in the future, so to be safe they should be use the .rdo file extension. In my example I am have 3 redo groups with 2 members each. Some of the members ending up with the default extension of .log. I want to update those members to have the .rdo file extension.

  1. Query the current redo locations.
  2. Shutdown the database.
  3. Rename the redo log members on the server.
  4. Startup the database in mount.
  5. Rename the redo log members in the database.
  6. Open the database.
  7. Verify the redo log member names are correct.
SQL> select member from v$logfile;

MEMBER-------------------------------------------------------------------------------
/u02/oradata/prod/redo01a.log
/u03/oradata/prod/redo01b.rdo
/u02/oradata/prod/redo02a.log
/u03/oradata/prod/redo02b.log
/u02/oradata/prod/redo03a.log
/u03/oradata/prod/redo03b.rdo

6 rows selected.

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> !mv /u02/oradata/prod/redo01a.log /u02/oradata/prod/redo01a.rdo
SQL> !mv /u02/oradata/prod/redo02a.log /u02/oradata/prod/redo02a.rdo
SQL> !mv /u03/oradata/prod/redo02b.log /u03/oradata/prod/redo02b.rdo
SQL> !mv /u02/oradata/prod/redo03a.log /u02/oradata/prod/redo03a.rdo

SQL> startup mount

ORACLE instance started.
Database mounted.

SQL> alter database rename file '/u02/oradata/prod/redo01a.log' to '/u02/oradata/prod/redo01a.rdo';
Database altered.

SQL> alter database rename file '/u02/oradata/prod/redo02a.log' to '/u02/oradata/prod/redo02a.rdo';
Database altered.

SQL> alter database rename file '/u03/oradata/prod/redo02b.log' to '/u03/oradata/prod/redo02b.rdo';
Database altered.

SQL> alter database rename file '/u02/oradata/prod/redo03a.log' to '/u02/oradata/prod/redo03a.rdo';
Database altered.

SQL> alter database open;
Database altered.

SQL> select member from v$logfile;

MEMBER
--------------------------------------------------------------------------------
/u02/oradata/prod/redo01a.rdo
/u03/oradata/prod/redo01b.rdo
/u02/oradata/prod/redo02a.rdo
/u03/oradata/prod/redo02b.rdo
/u02/oradata/prod/redo03a.rdo
/u03/oradata/prod/redo03b.rdo

6 rows selected.

Friday, June 4, 2010

Data Pump. Moving tables to new schema, new tablespace.

I want to move a series of tables from one schema to another. At the same time I want to move them to a new tablespace. Data Pump is great for doing this.

The following data pump parameters allow for this. You can remap more then one tablespace at a time.

First export the tables.

Export parfile example (expdp_joe_tables.par):
USERID='/ as sysdba'
TABLES=(JOE.TABLE1, JOE.TABLE2, JOE.TABLE3)
DUMPFILE=joe_tables
LOGFILE=expdp_joe_tables

-- Run the expdp command
#expdp parfile=expdp_joe_tables.par

Import parfile example (impdp_joe_tables.par):
USERID='/ as sysdba'
TABLES=(JOE.TABLE1, JOE.TABLE2, JOE.TABLE3)
REMAP_SCHEMA=JOE:SAM
REMAP_TABLESPACE=USERJOE1:USERSAM1,USERJOE2:USERSAM2
DUMPFILE=joe_tables
LOGFILE=impdp_joe_tables

Import the tables to a new schema and tablespace.

-- Run the impdp command
#impdp parfile=impdp_joe_tables.par

Proactive Oracle DBA

This is a series of posts. I am working this to share some of the many scripts I schedule to automatically run to alert me of any current o...