As we can see, there is a INPUT rule #1 that accept all sources/destination but only in some states. And ther is a INPUT rule #5 that reject everything. So, we have to disable firewall or add iptable rule to accept Oracle port 1521.
I've added this part because when I tried to restore my database, I'd problems with Character Set. So I decided to add this advanced configuration topic.
2.5.1. How to force Oracle XE to "reset" configuration and reconfigure
It is an Oracle XE script premisse that the file "/etc/sysconfig/oracle-xe" exists then database is configured. So, let's use a little cheat trick to hide file from scripts and reset configurations.
# echo "Stop service ..."
# /etc/init.d/oracle-xe stop
#
# echo "Try to configure, but it's already configured :-( ..."
# /etc/init.d/oracle-xe configure
Oracle Database 11g Express Edition is already configured
# echo "Force reconfigure ..."
# mv /etc/sysconfig/oracle-xe /etc/sysconfig/oracle-xe.bkp.2014-09-11
# /etc/init.d/oracle-xe configure
- Step#2: How to customize configurations script
There are majors scripts used during installation:
- /etc/init.d/oracle-xe: Here you can change configurations like ORACLE_SID=XE
- $ORACLE_HOME/config/scripts/XE.sh: creates "/u01/app/oracle/admin/XE/' directory structures. Here you can change path.
- $ORACLE_HOME/config/scripts/XE.sql: Call "CloneRmanRestore.sql", rmanRestoreDatafiles.sql", "cloneDBCreation.sql", "postScripts.sql" and "postDBCreation.sql"
- $ORACLE_HOME/config/scripts/init.ora: Default Pfile used during database clone
Oracle XE installation scripts use template database restored by RMAN. This backup brings some schema ( 'HR', 'CTXSYS', 'OUTLN', 'MDSYS', 'FLOWS_FILES') used as demo. Owners users comes locked by default.
2.5.2. How to create Oracle XE database manually
#
# echo "Logged as 'root' shutdown database (if running) ..."
# /etc/init.d/oracle-xe stop
Shutting down Oracle Database 11g Express Edition instance.
Stopping Oracle Net Listener.
- Step#2: Backup 'init.ora' and 'old datafiles' from existing database (if exists )
# echo "Login or sudo as 'oracle' ..."
# su - oracle
$
$ echo "Backup init.ora and old datafiles before custom changes ..."
$
$ ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe
$ cp $ORACLE_HOME/config/scripts/init.ora $ORACLE_HOME/config/scripts/init.ora.bkp.2014-09-12
$ mv /u01/app/oracle/oradata/XE /u01/app/oracle/oradata/XE.bkp.2014-09-12
$ mkdir /u01/app/oracle/oradata/XE
- Step#3: Customize 'init.ora'
$
$ echo "Customize init.ora (if necessary) ..."
$ vim $ORACLE_HOME/config/scripts/init.ora
:
:
###########################################
# Database Identification
###########################################
db_name=XE
:
#memory_target=414187520
memory_target=780824576
:
- Step#4: Create a new database instance
$
$ echo "Setting Oracle Environment variables ..."
$ source /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh
$
$ echo "Run SqlPlus but do *not* connect because database will be recreated ..."
$
$ sqlplus /nolog
SQL*Plus: Release 11.2.0.2.0 Production on Fri Sep 12 16:24:21 2014
Copyright (c) 1982, 2011, Oracle. All rights reserved.
SQL> CONN / AS SYSDBA
Connected to an idle instance.
SQL> STARTUP NOMOUNT PFILE='/u01/app/oracle/product/11.2.0/xe/config/scripts/init.ora';
ORACLE instance started.
Total System Global Area 780824576 bytes
Fixed Size 2230568 bytes
Variable Size 461375192 bytes
Database Buffers 314572800 bytes
Redo Buffers 2646016 bytes
SQL>
SQL> SPOOL /u01/app/oracle/product/11.2.0/xe/config/log/CreateManuallyDB.log
SQL>
SQL> CREATE DATABASE XE
USER SYS IDENTIFIED BY oracle123
USER SYSTEM IDENTIFIED BY oracle123
LOGFILE GROUP 1 ('/u01/app/oracle/oradata/XE/redo01.log') SIZE 100M,
GROUP 2 ('/u01/app/oracle/oradata/XE/redo02.log') SIZE 100M,
GROUP 3 ('/u01/app/oracle/oradata/XE/redo03.log') SIZE 100M
MAXLOGFILES 5
MAXLOGMEMBERS 5
MAXLOGHISTORY 1
MAXDATAFILES 100
CHARACTER SET WE8ISO8859P15
NATIONAL CHARACTER SET AL16UTF16
EXTENT MANAGEMENT LOCAL
DATAFILE '/u01/app/oracle/oradata/XE/system01.dbf' SIZE 1G REUSE
SYSAUX DATAFILE '/u01/app/oracle/oradata/XE/sysaux01.dbf' SIZE 325M REUSE
DEFAULT TABLESPACE users
DATAFILE '/u01/app/oracle/oradata/XE/users01.dbf'
SIZE 500M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
DEFAULT TEMPORARY TABLESPACE tempts1
TEMPFILE '/u01/app/oracle/oradata/XE/temp01.dbf'
SIZE 500M REUSE
UNDO TABLESPACE UNDOTBS1
DATAFILE '/u01/app/oracle/oradata/XE/undotbs01.dbf'
SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;
Database created.
- Step#5: Run scripts to build data dictionary views
SQL> CONN / AS SYSDBA
SQL> @?/rdbms/admin/catalog.sql
SQL> @?/rdbms/admin/catproc.sql
SQL>
SQL> CONN SYSTEM/*******
SQL>
SQL> @?/sqlplus/admin/pupbld.sql