Starting Oracle Enterprise Manager

For the oracle database Enterprise Manager (EM) runs on port 1158. But it needs to be started by itself.

Linux

Login as oracle and run:

$ORACLE_HOME/bin/emctl start dbconsole

On some systems a xserver session needs to be running for the graphs to be created correctly.  The best solution for this is to run vncserver on port 5910 and set the display to use :10.

Run:

vncserver :10

set DISPLAY=localhost:10

Then start EM.

Oracle XE Backup

After installing Oracle XE you should setup backups.

Backups for XE

For Oracle XE there is ready a backup script that uses Oracle’s RMAN.

 

Setup Archive Log Mode

After installing the database change it to archivelog mode:

[oracle@localhost ~]$ sqlplus /nolog

SQL*Plus: Release 10.2.0.1.0 - Production on Sun May 25 01:28:00 2008

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

SQL> connect / as sysdba
Connected.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area  289406976 bytes
Fixed Size                  1258488 bytes
Variable Size              92277768 bytes
Database Buffers          192937984 bytes
Redo Buffers                2932736 bytes
Database mounted.
SQL> alter database archivelog;

Database altered.

SQL> alter database open;

Database altered.

SQL>

To make sure the database is really in archive log mode run the following sql statement:

SQL> SELECT LOG_MODE FROM SYS.V$DATABASE;

LOG_MODE
------------
ARCHIVELOG

SQL>

Run the Initial Backup

Windows run $ORACLE_HOME/bin/Backup.bat

Linux run $ORACLE_HOME/config/scripts/backup.sh

[oracle@localhost ~]$ $ORACLE_HOME/config/scripts/backup.sh 
Doing online backup of the database.
Backup of the database succeeded.
Log file is at /usr/lib/oracle/xe/oxe_backup_current.log.
Press ENTER key to exit
[oracle@localhost ~]$

 

Run the Backups Daily

Windows add the $ORACLE_HOME/bin/Backup.bat to a job scheduler.

  • Make sure the user running the job is the same user who installed Oracle.

 

Linux add the $ORACLE_HOME/config/scripts/backup.sh to cron.daily

  • Remove the user notification line from the end of the script

 

Backing up files

Make sure that your backup script backups up the $ORACLE_HOME directory.  On windows make sure the oradata directory is excluded since this might cause file locking issues.

Checking for a User in OID

Test to see if a user is already in OID

The following java code checks to see if there is a user in OID, returning true if they are there.

 

import oracle.ldap.util.*;

import oracle.ldap.util.jndi.*;
import java.io.*;
import java.util.*;
import javax.naming.*;

import javax.naming.directory.*;

 

public class Application1 {

InitialDirContext ctx;
public Application1() throws NamingException {
// Create InitialDirContext

try {

ctx  = ConnectionUtil.getDefaultDirCtx(“linux02”, “389”, “cn=orcladmin”, “orcladmin1”);

} catch (NamingException e) {

throw e;

}

}
public static void main(String[] args) throws NamingException {

Application1 appl1 = new Application1();

if (appl1.exec(“cn=mark.allen,cn=Users,dc=markcallen,dc=com”))

System.out.println(“Found mark.allen”);

if (! appl1.exec(“cn=unknown,cn=Users,dc=markcallen,dc=com”))

System.out.println(“Could not find unknown”);
}
public boolean exec(String userId) {

try {

Util.getUserDn(ctx, userId, Util.IDTYPE_DN, null);
} catch (oracle.ldap.util.NoSuchUserException e) {

return false;

}

catch (UtilException e) {

throw e;

}

return true;

}

}