Wednesday, August 19, 2015

Oracle Database installation silent mode (Noninteractive)

- Sources:
http://hugepang.wordpress.com/2011/06/21/oracle-11gr2-silent-installation/
http://gruffdba.wordpress.com/2013/01/10/silent-install-of-oracle-11-2-0-3-on-redhat-6-0/
http://www.oracle-base.com/articles/misc/oui-silent-installations.php
http://www.redbooks.ibm.com/redpapers/pdfs/redp9131.pdf [PDF]
http://dbaora.com/install-oracle-in-silent-mode-11g-release-2-11-2/

- Environment info
    Hostname: demo1.localdomain
    IP Address: 1.0.3.61
    OS: Oracle Enterprise Linux 5 update 4 x86
    DB: Oracle Database Enterprise 11.2.0.3

>>>>>>>>>>>>>>>>>>>>>> prepare environment to Oracle installation <<<<<<<<<<<<<<<<<<<<<<<

- Checking the Hardware Requirements
    # grep MemTotal /proc/meminfo      - determine the RAM size
    # uname -m                         - determine whether the system architecture 
    # grep SwapTotal /proc/meminfo     - determine the size of the configured swap space
    # free                             - determine the available RAM and swap space
    # df -h /dev/shm/                  - determine the amount of shared memory available
    # df -h /tmp                       - determine the amount of disk space available in /tmp
    # df -h                            - determine the amount of free disk space
    # df -k                            - display information about all mounted file systems

-Checking the Software Requirements
    # cat /proc/version                - determine the distro and version
    # uname -r                         - determine whether the required kernel
    # lsb_release -rd                  - determine system distro and version

- Generate ssh keys in physical machine
    $ ssh-keygen (physical machine)

- Copy ssh key to virtual machine (Oracle Database server)
    $ ssh-copy-id -i .ssh/id_rsa.pub root@1.0.3.61 

- Login to Oracle database virtual machine (demo1.localdomain)
    $ ssh -Y root@1.0.3.61

- Set hostname to "/etc/hosts" file if not using DNS domain server
    # vim /etc/hosts # (as root)
    1.0.3.61    demo1.localdomain   demo1

- Set Gateway and hostname to file "/etc/sysconfig/network"
    # vim /etc/sysconfig/network # (as root)
    NETWORKING=yes
    NETWORKING_IPV6=no
    HOSTNAME=demo1.localdomain
    Gateway=1.0.3.2

- Set IP Address settings to file "ifcfg-eth0"
    # vim  /etc/sysconfig/network-scripts/ifcfg-eth0 # (as root)

- Restart Network services
    # /etc/init.d/network restart

- Check network settings
    [root@demo1 ~]# hostname
    demo1.localdomain
    [root@demo1 ~]# ifconfig 
    eth0    Link encap:Ethernet  HWaddr 00:0C:29:8F:06:9A  
            inet addr:1.0.3.61  Bcast:1.0.3.255  Mask:255.255.255.0

- Install Packages Enterprise Linux 5 from DVD
    # cd /media/Enterprise Linux dvd 20100405/Server
    rpm -Uvh binutils-2.*
    rpm -Uvh compat-libstdc++-33*
    rpm -Uvh compat-libstdc++-33*.i386.rpm
    rpm -Uvh elfutils-libelf*
    rpm -Uvh gcc-4.*
    rpm -Uvh gcc-c++-4.*
    rpm -Uvh glibc-2.*
    rpm -Uvh glibc-common-2.*
    rpm -Uvh glibc-devel-2.*
    rpm -Uvh glibc-headers-2.*
    rpm -Uvh ksh*
    rpm -Uvh libaio-0.*
    rpm -Uvh libaio-devel-0.*
    rpm -Uvh libgomp-4.*
    rpm -Uvh libgcc-4.*
    rpm -Uvh libstdc++-4.*
    rpm -Uvh libstdc++-devel-4.*
    rpm -Uvh make-3.*
    rpm -Uvh sysstat-7.*
    rpm -Uvh unixODBC-2.*
    rpm -Uvh unixODBC-devel-2.*
    rpm -Uvh numactl-devel-*
    cd /
    eject

- Create user "Oracle" and it's groups
    # groupadd oinstall
    # groupadd dba
    # groupadd oper
    # groupadd asmadmin
    # groupadd asmdba
    # groupadd asmoper
    # useradd -g oinstall -G dba,oper,asmadmin,asmoper,asmdba oracle
    # passwd oracle 

- Creating Required Directories
    # mkdir -p /u01/oracle/app/product/11203/db_1
    # chown -R oracle:oinstall /u01
    # chmod -R 775 /u01

- Configuring kernel parameters and resource limits
    # vim /etc/sysctl.conf
    # kernel parameters for 11g installation
    fs.suid_dumpable = 1
    fs.aio-max-nr = 1048576
    fs.file-max = 6815744
    kernel.shmall = 2097152
    kernel.shmmax = 1591103488
    kernel.shmmni = 4096
    # semaphores: semmsl, semmns, semopm, semmni
    kernel.sem = 250 32000 100 128
    net.ipv4.ip_local_port_range = 9000 65500
    net.core.rmem_default=262144
    net.core.rmem_max=4194304
    net.core.wmem_default=262144
    net.core.wmem_max=1048586

- Apply kernel parameters changes to the current session
    # /sbin/sysctl -p

- Change system resource Limits to user "Oracle"
    # vim /etc/security/limits.conf 
    oracle              soft    nproc   2047
    oracle              hard    nproc   16384
    oracle              soft    nofile  4096
    oracle              hard    nofile  65536
    oracle              soft    stack   10240

- Set user a"Oracle" profile settings
    # vim /home/oracle/.bash_profile
    # oracle database settings
    export TMPDIR=/tmp
    export ORACLE_HOSTNAME=`hostname`
    export ORACLE_UNQNAME=demo1
    export ORACLE_BASE=/u01/app/oracle
    export DB_HOME=$ORACLE_BASE/product/11203/db_1
    export ORACLE_HOME=$DB_HOME
    export ORACLE_SID=demo1
    export ORACLE_TERM=xterm
    export BASE_PATH=/usr/sbin:$PATH
    export PATH=$ORACLE_HOME/bin:$BASE_PATH
    export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
    export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib

>>>>>>>>>>>>>>>>>>>>>> Install Oracle database software binaries <<<<<<<<<<<<<<<<<<<<<

 - Copy Oracle software files to virtual machine
    $ scp -v p10404530_112030_LINUX_{1..2}of7.zip oracle@1.0.3.61:/tmp (physical machine)

- Extract Oracle software files in "/tmp" directory
    [oracle@demo1 ~]$ unzip p10404530_112030_LINUX_1of7.zip && unzip p10404530_112030_LINUX_2of7.zip 

- Remove compressed files after extract
    [oracle@demo1 ~]$ rm -rf p10404530_112030_LINUX_*

- Export Oracle Base & Oracle Home variables
    $ export ORACLE_BASE=/u01/app/oracle;
    $ export ORACLE_HOME=$ORACLE_BASE/product/11203/db_1;

- Change to software source files directory
    $ cd /tmp/database/

- Copy response file to "/tmp" directory
    $ cp -fv  /tmp/database/response/db_install.rsp /tmp/db11ginstall.rsp

- Edit response file "/tmp/db11ginstall.rsp"
    $ vim /u01/download/db11ginstall.rsp
    oracle.install.option=INSTALL_DB_SWONLY
    UNIX_GROUP_NAME=oinstall
    INVENTORY_LOCATION=/u01/app/OraInventory
    ORACLE_HOME=/u01/app/oracle/product/11203/db_1
    ORACLE_BASE=/u01/app/oracle
    oracle.install.db.InstallEdition=EE
    oracle.install.db.DBA_GROUP=dba
    oracle.install.db.OPER_GROUP=dba
    DECLINE_SECURITY_UPDATES=true

- Install Oracle Database software binaries using updated response file
    $ ./runInstaller -silent -noconfig -responseFile /tmp/db11ginstall.rsp

>>>>>>>>>>>>>>>>>>>>>> Install Oracle database Instance <<<<<<<<<<<<<<<<<<<<<

- Setup Oracle database listener in silent mode
    [oracle@demo1 ~]$ netca -silent -responsefile /u01/app/oracle/product/11203/db_1/assistants/netca/netca.rsp

- Check listener status
    $ lsnrctl status

- Specify an Instance Identifier (SID)
    $ export ORACLE_SID=demo1;

- Install Oracle Database instance "demo1"
    [oracle@demo1 ~]$ dbca -silent -createDatabase -characterSet AL32UTF8 -continueOnNonFatalErrors false -disableSecurityConfiguration ALL -emConfiguration NONE -gdbName demo1.localdomain -listeners LISTENER -memoryPercentage 40 -sid demo1 -SysPassword oracle -SystemPassword oracle -sampleSchema true -templateName General_Purpose.dbc
    Copying database files
    1% complete
    3% complete
    11% complete
    18% complete
    37% complete
    Creating and starting Oracle instance
    40% complete
    45% complete
    50% complete
    55% complete
    56% complete
    57% complete
    60% complete
    62% complete
    Completing Database Creation
    66% complete
    70% complete
    73% complete
    85% complete
    96% complete
    100% complete
    Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/demo1/demo1.log" for further details.

- View installation logs from separate terminal
    $ watch cat /u01/app/oracle/cfgtoollogs/dbca/demo1/demo1.log

- Checking Oracle database instance status
    [oracle@demo1 ~]$ sqlplus / as sysdba

    SQL> col product format a40;
    SQL> col version format a15;
    SQL> col status format a20;
    SQL> select * from product_component_version;

    PRODUCT                         VERSION     STATUS
    ---------------------------------------- --------------- --------------------
    NLSRTL                         11.2.0.3.0  Production
    Oracle Database 11g Enterprise Edition      11.2.0.3.0  Production
    PL/SQL                         11.2.0.3.0  Production
    TNS for Linux:                    11.2.0.3.0  Production

    SQL> select instance_name,status,database_status,archiver,version from v$instance;

    INSTANCE_NAME  STATUS        DATABASE_STATUS ARCHIVE     VERSION
    ---------------- -------------   ----------------  --------- ---------------
    demo1       OPEN        ACTIVE      STOPPED     11.2.0.3.0

>>>>>>>>>>>>>>>>>>>>>> Install Oracle database Enterprise Manager DBConsole <<<<<<<<<<<<<<<<<<<<<

- Change and unlock required accounts needed for installation
    SQL> alter user dbsnmp identified by oracle account unlock;

    User altered.

    SQL> alter user system identified by oracle account unlock;

    User altered.

    SQL> alter user sys identified by oracle account unlock;

    User altered.

    SQL> alter user sysman identified by oracle account unlock;

    User altered.

- Configure Oracle database Enterprise Manager dbconsole
    [oracle@demo1 database]$ emca -config dbcontrol db
    Enter the following information:
    Database SID: demo1
    Listener port number: 1521
    Listener ORACLE_HOME [ /u01/app/oracle/product/11203/db_1 ]: 
    Password for SYS user:  
    Password for DBSNMP user:  
    Password for SYSMAN user:  
    Do you wish to continue? [yes(Y)/no(N)]: Y

- Testing installation
    - open URL: https://demo1.localdomain:1158/em
    - from terminal
    $ emctl status dbconsole


>>>>>>>>>>>>>>>>>>>>>> ToDO after Install Oracle database <<<<<<<<<<<<<<<<<<<<<

- Edit file "/etc/oratab"
    [oracle@demo1 ~]$ vim /etc/oratab 
    demo1:/u01/app/oracle/product/11203/db_1:Y

- Create pfile as backup to spfile;
    [oracle@demo1 ~]$ sqlplus / as sysdba
    SQL> create pfile from spfile;

- Configure Oracle database to use archivelog mode, force logging and controlfiles trace
    SQL> shutdown immediate
    SQL> startup mount;
    SQL> alter database archivelog;
    SQL> alter database force logging;
    SQL> alter database backup controlfile to trace;
    SQL> alter database open';

- Get a clean backup of Oracle database
    RMAN> report schema; # check schema
    RMAN> configure controlfile autobackup on; # set controlfiles to be backup with database
    RMAN> backup database plus archivelog; # backuped database with archivelogs  

>>>>>>>>>>>>>>>>> Create a script to startup & shutdown Oracle database & Enterprise Manager <<<<<<<<<<<<<<<<<<<<<
- Create a file called "/etc/init.d/dbora" as the root user, containing the following.
 
    # vim /etc/init.d/dbora
    #!/bin/sh
    # chkconfig: 345 99 10
    # description: Oracle auto start-stop script.
    #
    # Set ORA_OWNER to the user id of the owner of the 
    # Oracle database software.

    ORA_OWNER=oracle

    case "$1" in
    'start')
    # Start the Oracle databases:
    # The following command assumes that the oracle login 
    # will not prompt the user for any values
    # Remove "&" if you don't want startup as a background process.
    su $ORA_OWNER -c "/home/oracle/scripts/startup.sh >> /home/oracle/scripts/startup_shutdown.log 2>&1" &

    touch /var/lock/subsys/dbora
    ;;
    'stop')
    # Stop the Oracle databases:
    # The following command assumes that the oracle login 
    # will not prompt the user for any values
    su $ORA_OWNER -c "/home/oracle/scripts/shutdown.sh >> /home/oracle/scripts/startup_shutdown.log 2>&1"
    rm -f /var/lock/subsys/dbora
    ;;
    esac

- Use the chmod command to set the privileges to 750.
 
    # chmod 750 /etc/init.d/dbora

- Associate the "dbora" service with the appropriate run levels and set it to auto-start using the following command.
 
    # chkconfig dbora on

- create the "startup.sh" and "shutdown.sh" scripts in the "/home/oracle/scripts". First create the directory.
 
    # mkdir -p /home/oracle/scripts
    # chown oracle.oinstall /home/oracle/scripts

- The "/home/oracle/scripts/startup.sh" script should contain the following commands.
 
    # vim /home/oracle/scripts/startup.sh
    #!/bin/bash

    export TMP=/tmp
    export TMPDIR=$TMP
    export PATH=/usr/sbin:/usr/local/bin:$PATH
    export ORACLE_HOSTNAME=demo1.localdomain
    export ORACLE_UNQNAME=demo1

    export ORACLE_SID=demo1
    ORAENV_ASK=NO
    . oraenv
    ORAENV_ASK=YES

    # Start Listener
    lsnrctl start

    # Start Database
    sqlplus / as sysdba << EOF
    STARTUP;
    EXIT;
    EOF
    
    # Start Enterprise Manager
    emctl start dbconsole

- The "/home/oracle/scripts/shutdown.sh" script is similar.
 
    # vim /home/oracle/scripts/shutdown.sh
    #!/bin/bash

    export TMP=/tmp
    export TMPDIR=$TMP
    export PATH=/usr/sbin:/usr/local/bin:$PATH
    export ORACLE_HOSTNAME=demo1.localdomain
    export ORACLE_UNQNAME=demo1

    export ORACLE_SID=demo1
    ORAENV_ASK=NO
    . oraenv
    ORAENV_ASK=YES

    # stop Enterprise Manager
    emctl stop dbconsole

    # Stop Database
    sqlplus / as sysdba << EOF
    SHUTDOWN IMMEDIATE;
    EXIT;
    EOF

    # Stop Listener
    lsnrctl stop

- Make sure the permissions and ownership of the files is correct.
 
    # chmod u+x /home/oracle/scripts/startup.sh /home/oracle/scripts/shutdown.sh
    # chown oracle.oinstall /home/oracle/scripts/startup.sh /home/oracle/scripts/shutdown.sh

- Test them using the following command as the "root" user.
 
    # service dbora start
    # service dbora stop


No comments:

Post a Comment