Step Install Oracle 10g R2 on Solaris 10 x86

Checking Requirement:

—————————-

#/usr/sbin/prtconf | grep “Memory size” [Check RAM size]
# /usr/sbin/swap -s [check swap]
# df -k /tmp [check /tmp size (>400mb)]
# uname -r [check solaris version]

# pkginfo -i SUNWarc SUNWbtool SUNWhea SUNWlibm SUNWlibms SUNWsprot SUNWsprox SUNWtoo SUNWi1of SUNWi1cs SUNWi15cs SUNWxwfnt

# cat /etc/nsswitch.conf | grep hosts
# hostname
# domainname

RUN INSTALL:
—————-
A. create group name “dba”, oracle inventory group “oinstall” and “oracle” user

# /usr/sbin/groupadd oinstall
# /usr/sbin/groupadd dba

{Determine oracle user exist or not
# id -a oracle
{if exist, should be look like this=
uid=440(oracle) gid=200(oinstall) groups=201(dba),202(oper)

{create oracle user=
# useradd -d /export/home/oracle -g dba -G oinstall -m -s /bin/ksh oracle

#mkdir /export/home/oracle
#chown oracle:dba /export/home/oracle

{set password=
# passwd -r files oracle

{to determine nobody user=
# id nobody
# /usr/sbin/useradd nobody >>run if does not exist

B. EDIT FILE /export/home/oracle/.profile
————————————–
umask 022
TMP=/tmp
TMPDIR=$TMP
DISPLAY=localhost:0.0
export TMP TMPDIR DISPLAY
ORACLE_BASE=/u01/app/oracle [replace with ur Oracle base Directory]
ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1 [replace with ur Oracle home Directory]

ORACLE_SID=jktdb [replace with your database]
PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH

C. Configure Kernel Parameter
—————————–
Note: Do not follow the official installation instruction, they contain misleading and out errors of fact!

#projadd oracle [This command will create a new ‘resource project’]
edit the /etc/user_attr file:
adm::::profiles=Log Management
lp::::profiles=Printer Management
root::::auths=solaris.*,solaris.grant;profiles=Web Console Management,All;lock_after_retries=no

oracle::::project=oracle [add this line]

then:

#su – oracle
$ id -p
$ prctl -n project.max-shm-memory -i project oracle

The display look like this:
project: 100: oracle
NAME PRIVILEGE VALUE FLAG ACTION RECIPIENT
project.max-shm-memory
privileged 126MB – deny –
system 16.0EB max deny –

leaving the oracle user still connected in the original one Then, as root in the new terminal, you can issue this command:

#prctl -n project.max-shm-memory -v 4gb -r -i project oracle [create max memory to 4GB]

As soon as you’ve issued that command, switch back to the oracle user’s session and re-issue the earlier command:

$ prctl -n project.max-shm-memory -i project oracle

Note:
#prctl -n project.max-shm-memory -v 4gb -r -i project oracle [this setting will lost after reboot]
to set permanently, run this: #projmod -s -K “project.max-shm-memory=(priv,4gb,deny)” oracle

D. Performing the Oracle Installation
————————————-
#su – oracle
$xhost +
$export DISPLAY=localhost;0.0
$ xhost +<your-remote-pc-ipaddress> >>run this if you install from remote PC
$ cd /export/home/database/ [the source unzipped here]

./runInstaller

FOR SOLARIS SPARC:
====================
$ gunzip ship_rel10_sol64_db.cpio.gz
$ cpio -idm < ship_rel10_sol64_db.cpio

$./runInstaller

If you found unsufficient SWAP disk space on your disk, create folder under / then run this command:
—————————————————
$ TMP=/directory
$ TMPDIR=/directory
$ export TMP TMPDIR

Follow the screen>>NEXT>>NEXT

last, run this as root user:
—————————-
/u01/app/oracle/oraInventory/orainstRoot.sh
/u01/app/oracle/product/10.2.0/db_1/root.sh

Create db:
———-
orc1
jktdb

E. 6.0 On-going Administration
——————————–
Finally, it’s time to get the web-based Enterprise Manager database administration tool up and running.
Since we’re using 10g Release 2, you should be able to launch a browser (Launch -> Web Browser) and simply navigate to : http://localhost:1158/em

If you do not know the correct port number to use, look for the following line in the $ORACLE_HOME/install/portlist.ini file.

in order to be able to log on as SYS with a password of whatever you supplied to the first screen of the Oracle installation wizard. In fact, getting a meaningful result at this point relies on three things having been performed successfully:

1. starting a listener (lsnrctl start)
2. opening the database (sqlplus / as sysdba then startup)
3. starting the Enterprise Manager agent (emctl start dbconsole)

F. Automating Database Startup
———————————————–
edit file “/var/opt/oracle/oratab” script to find lines with ‘Y’ at their ends
Create file “/etc/init.d/dbora”
——-
#!/bin/sh
ORA_HOME=/u01/app/oracle/product/10.2.0/db_1
ORA_OWNER=oracle

if [ ! -f $ORA_HOME/bin/dbstart ]
then
echo “Oracle startup: cannot start”
exit
fi

case “$1” in
‘start’)
su – $ORA_OWNER -c “$ORA_HOME/bin/dbstart”
;;
‘stop’)
su – $ORA_OWNER -c “$ORA_HOME/bin/dbshut”
;;
esac

———
#chmod 777 /etc/init.d/dbora
#/etc/init.d/dbora stop

To integrate dbora file to standart Solaris startup and shutdown process:
————————————————————————
#ln -s /etc/init.d/dbora /etc/rc0.d/K01dbora
#ln -s /etc/init.d/dbora /etc/rc2.d/S99dbora

IF u found error this:
———————–
ORACLE_HOME_LISTNER is not SET, unable to auto-stop Oracle Net Listener

edit file “dbstart” & “dbshut”, find line $ORACLE_HOME_LISTNER=$1

and change to = $ORACLE_HOME_LISTNER=/u01/app/oracle/product/10.2.0/db_1

RECOMMENDED DIRECTORY STRUCTURE:
———————————————-

[Oracle Base Directory:]
/u01/app/oracle
/u01/app/orauser
/opt/oracle/app/oracle

[Oracle Inventory Directory:]
ORACLE_BASE/oraInventory

[Oracle Home Directory:]

ORACLE_BASE/product/10.2.0/db_1

[Identify an existing oracle base directory:]
#more /var/opt/oracle/oraInst.loc
[the output should be:]

inventory_loc=/u01/app/oracle/oraInventory
inst_group=oinstall

# more /var/opt/oracle/oratab

*:/u03/app/oracle/product/10.2.0/db_1:N

*:/opt/orauser/infra_904:N

*:/oracle/9.2.0:N

COMMON INSTALLATION ERROR:
===========================
Unable to convert from “UTF-8” to “646” for NLS!
Solution: Install SUNWuiu8 package.

error adduser:
———————
UX: useradd: ERROR: Inconsistent password files. See pwconv(1M)

This is because the /etc/passwd and /etc/shadow files are out of synchronization on your machine. [CSCdi74894]
To fix this, run the pwconv command, and then rerun cwconfigure.

try to run:

wc -l /etc/passwd /etc/shadow

————–
ERROR Checking monitor: must be configured to display at least 256 colors >>> Could not execute auto check for
display colors using command /usr/openwin/bin/xdpyinfo. Check if the DISPLAY variable is set. Failed <<<<
Some requirement checks failed. You must fulfill these requirements before continuing with theinstallation, at which time they will be rechecked.

Solution(s):
1. Install SUNWxwplt package
2. Set DISPLAY variable
3. Execute xhost + on target (set in DISPLAY) computer

———————————————————-
Exception in thread “main” java.lang.UnsatisfiedLinkError:
… libmawt.so: ld.so.1: java: fatal: libXm.so.4: open failed: No such file or directory

Solution: Install the SUNWmfrun package.

—————————————————————————————————-
Can’t load ‘/usr/perl5/5.8.4/lib/i86pc-solaris-64int/auto/Sun/Solaris/Project/Project.so’ for module
Sun::Solaris::Project: ld.so.1: perl: fatal: libpool.so.1: open failed: No such file or directory at
/usr/perl5/5.8.4/lib/i86pc-solaris-64int/DynaLoader.pm line 230. at /usr/sbin/projadd line 19 Compilation
failed in require at /usr/sbin/projadd line 19. BEGIN failed–compilation aborted at /usr/sbin/projadd line 19.

Solution: Install the SUNWpool SUNWpoolr packages.

———————————————————————–
bash-3.00$ /u01/app/oracle/product/10.2.0/db_1/bin/./emctl start dbconsole
Exception in getting local host
java.net.UnknownHostException: -a: -a
at java.net.InetAddress.getLocalHost(InetAddress.java:1191)
at oracle.sysman.emSDK.conf.TargetInstaller.getLocalHost(TargetInstaller.java:4977)
at oracle.sysman.emSDK.conf.TargetInstaller.main(TargetInstaller.java:3758)
Exception in getting local host

Solution : check server hostname and /etc/hosts
————————————————————————-

UNINSTALL ORACLE 10G:
———————
1. remove all database, by running $dbca
2. stop any oracle process running:
Database Control : $ORACLE_HOME/bin/emctl stop dbconsole
Oracle Net listener : $ORACLE_HOME/bin/lsnrctl stop
iSQL*Plus : $ORACLE_HOME/bin/isqlplusctl stop
Ultra Search : $ORACLE_HOME/bin/searchctl stop

3. Start Oracle Universal installer:

$ORACLE_HOME/oui/bin/runInstaller

4. In the Welcome window, click Deinstall Products.
5. In the Inventory screen, select the Oracle home and the products that you want to remove,
then click Remove.

RMAN Command reference

===================================
R-M-A-N =
===================================
Connect:
$rman target /
$rman nocatalog target /
$rman nocatalog target sys/aziz@JKTDB2
$rman target sys/aziz@JKTDB2

RMAN> shutdown;
RMAN> shutdown immediate;

RMAN> startup mount; >>startup an instance and mounting database
RMAN> startup nomout; >>startup an instance without mounting database
RMAN> startup restrict; >>restricting access to an instance at startup
RMAN> ALTER SYSTEM DISABLE RESTRICTED SESSION; >>disable the restricted session
RMAN> STARTUP FORCE; >>forcing an instance to start
RMAN> STARTUP OPEN RECOVER >>Starting an Instance, Mounting a Database,
and Starting Complete Media Recovery
RMAN> connect target sys/aziz@jktdb2;
RMAN> startup mount;
RMAN> register database; >>register target database to recovery catalog
RMAN> reset database; >>create new database incarnation record in the

recovery catalog
RMAN> backup database;
RMAN> backup current controlfile;
RMAN> backup database plus archivelog;
RMAN> backup archivelog all;
RMAN> list backup; >>list all file that was backed up
RMAN> list backup summary;
RMAN> restore database;
RMAN> restore archivelog all;
RMAN> recover database;
RMAN> restore datafile ‘C:\ORACLE\ORADATA\JKTDB2\USERS01.DBF’;
RMAN> recover datafile ‘C:\ORACLE\ORADATA\JKTDB2\USERS01.DBF’;
RMAN> Recover database until cancel using backup controlfile;
RMAN> Alter database open resetlogs;
RMAN> allocate channel for maintenance type disk;
RMAN> crosscheck backup of database;
RMAN> delete expired backup of database;
RMAN> crosscheck backup of archivelog all;
RMAN> delete expired backup of archivelog all;
RMAN> change archivelog all crosscheck;
RMAN> resync catalog;
RMAN> crosscheck backup of archivelog all;
RMAN> sql ‘alter tablespace USERS offline immediate’;
RMAN> recover tablespace USERS;
RMAN> sql ‘alter tablespace USERS online’;

—————————————————————
configure =
—————————————————————
RMAN>configure default device type to ‘sbt_tape’; >>to tape
RMAN>configure default device type to DISK; >>to disk
rman>configure controlfile autobackup format for device type ‘sbt_tape’ to ‘%F’;
RMAN>configure controlfile autobackup on;
RMAN>CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;

RMAN>CONFIGURE RETENTION POLICY TO REDUNDANCY 3; >>Retain three backups of each datafile:
RMAN> resync catalog;

—————————————————————
Restore & Recover The Whole Database=
—————————————————————
run {
shutdown immediate; # use abort if this fails
startup mount;
restore database;
recover database;
alter database open;
}
—————————————————————-
Restore & Recover A Subset Of The Database
A subset of the database can be restored in a similar fashion:
—————————————————————-
run {
sql ‘ALTER TABLESPACE users OFFLINE IMMEDIATE’;
restore tablespace users;
recover tablespace users;
sql ‘ALTER TABLESPACE users ONLINE’;
}
—————————————————————–
SAMPLE RMAN RUN BLOCK (as file:backup_full.rman)

run {
allocate channel d1 type disk;
backup full database format ’/export/rman/rman_%n_%T_%s_%p.bus’;
}

then run it :
$ rman nocatalog target / \
> cmdfile=’backup_full.rman’ log=’/export/rman/rman.log’
RMAN> 2> 3> 4> 5>
—————————————————————–
Crosscheck backupset:
RMAN> allocate channel for maintenance type ‘sbt_tape’;
RMAN> crosscheck backupset of database;

Delete expired backups:
RMAN> allocate channel for maintenance type ‘sbt_tape’;
RMAN> delete expired backupset of database;
—————————————————————–

#############################
===================================
S-Q-L P-L-U-S=
===================================
#################################
Connect:
$sqlplus /nolog >>start sqlplus withaut connecting to database
$sqlplus “/ as sysdba”
CONNECT username/password AS SYSDBA
CONNECT sys/password@jktdb2 AS SYSDBA
Enter username: sys/aziz as sysdba

SQL> alter database archivelog; >>turn on archivelog
SQL> alter database noarchivelog; >>turn off archivelog
SQL> alter database open;
SQL> select log_mode from v$database;
SQL> select DEST_NAME,STATUS,DESTINATION from V$ARCHIVE_DEST;
SQL> archive log list

SQL> startup nomount;
SQL> alter database mount;
SQL> select * from all_users;
SQL> select status from v$instance;
SQL> alter database open;
SQL> select * from DBA_ROLE_PRIVS;
SQL> ALTER USER “BENR” IDENTIFIED BY “passwd”; >>change password user benr
SQL> select * from DBA_ROLE_PRIVS where grantee = ’BEN’;
SQL> grant resource to ben;
SQL> revoke resource from ben;
SQL> select FILE#,STATUS,ENABLED,NAME from v$datafile;
SQL> SELECT LOG_MODE FROM SYS.V$DATABASE;
SQL> select FILE#,STATUS,ENABLED,NAME from v$datafile;
{jika ada yang offline, online dengan command:}
SQL> alter database datafile ’/u02/oradata/cuddle/users01.dbf’ online;
SQL> alter tablespace USERS online;

SQL> startup pfile=/u01/app/oracle/product/10.1.0/db_1/dbs/spfiletesting.ora
SQL> alter database open resetlogs;

————————
this used for FLASHBACK:
SQL> alter system set DB_FLASHBACK_RETENTION_TARGET=4320; >>Retention 4320 minutes (or 72 hours)
SQL> alter system set DB_RECOVERY_FILE_DEST_SIZE=536870912; >>a recovery file size of 512MB
SQL> alter system set DB_RECOVERY_FILE_DEST=’/u02/fra’; >>location for the file recovery area

(FRA)
SQL> alter database flashback on;
SQL> alter database open;
————————

RESTORE CONTROLFILE
===================================
sqlplus “/ as sysdba”
SQL>startup nomout;

RMAN>set DBID=2231352083
RMAN>CONNECT TARGET
RMAN>run
2>{
3>set controlfile autobackup format for device type ‘sbt_tape’ to ‘%F’;
4>allocate channel t1 device type ‘sbt_tape’;
5>restore controlfile from autobackup MAXSEQ 5 MAXDAYS 9;
6> mount database;
7> } [enter]

executing command: SET CONTROLFILE AUTOBACKUP FORMAT

allocated channel: t1
channel t1: sid=10 devtype=SBT_TAPE
channel t1: VERITAS NetBackup for Oracle – Release 5.0GA (2002111220)

Starting restore at 25-JAN-07

channel t1, looking for controlfile autobackup on day: 20070125
channel t1, controlfile autobackup found: c-2231352083-20070125-01
channel t1, controlfile autobackup restore complete
replicating controlfile
input filename=C:\ORACLE\ORADATA\JKTDB2\CONTROL01.CTL
output filename=C:\ORACLE\ORADATA\JKTDB2\CONTROL02.CTL
output filename=C:\ORACLE\ORADATA\JKTDB2\CONTROL03.CTL
Finished restore at 25-JAN-07

database mounted
released channel: t1

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

ORACLE COMMAND FOR UNIX
———————–
./emca > run Oracle Enterprise Manager
./dbca > run database configuration assistant
./dbstart > start database
. ./dev.env > script buat link $ORACLE_HOME
. ./oraenv > script buat link $ORACLE_HOME
./lsnrctl <stop|start> > start and stop the listener control utility
./cmctl <stop|start> > the Oracle connection manager utility
./netca > Oracle Net configuration Assistant GUI
./netmgr > Oracle net Manager
./odma > Oracle Data Migration Assistant
./owm > Oracle Wallet Manager
agentctl stop > stop Agent Configuration Assistan
./oemapp console > run Oracle Enterprise Manager Console

bash-2.05# /usr/sbin/./prtconf | grep size >>cek RAM

TESTING COMMAND:
================

RMAN> show all;

RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO ‘SBT_TAPE’;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE ‘SBT_TAPE’ TO ‘%F’;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO ‘%F’; # default
CONFIGURE DEVICE TYPE SBT_TAPE PARALLELISM 1; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE SBT_TAPE TO 1; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE SBT_TAPE TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO ‘C:\ORACLE\ORA90\DATABASE\SNCFJKTDB2.ORA’
; # default

RMAN>

STEP BACKUP
=============
DATAFILE
ARCHIVELOG
CONTROLFILE

STEP RESTORE
==============
CONTROLFILE
ARCHIVELOG
DATAFILE

connected to target database: JKTDB2 (DBID=2231352083)