linux靜默安裝oracle

1 安裝前環(huán)境:

? 操作系統(tǒng):CetnOS6.4x64 最小化安裝,已配置好網(wǎng)絡(luò)IP:172.18.10.213,物理內(nèi)存4GB,硬盤(pán)100GB。

? 已下載: linux.x64_11gR2_database_1of2.zip

? ? ? ? ? ? ? linux.x64_11gR2_database_2of2.zip

? 位于目錄: /sharedisk/11G/


2 準(zhǔn)備工作

root用戶登錄后

# yum install unzip? ? ? //下載unzip,用來(lái)解壓上述兩個(gè)壓縮文件

# cd /sharedisk/11G? ? ? ? //切換當(dāng)前目錄到oracle壓縮文件所在目錄

# unzip linux.x64_11gR2_database_1of2.zip //解壓

# unzip linux.x64_11gR2_database_2of2.zip

解壓后新增一個(gè)/sharedisk/11G/database目錄,里面是解壓后的所有oracle安裝文件。

在/etc/hosts文件中增加主機(jī)名(通過(guò)hostname獲得)到回環(huán)IP的映射如下:

# vi /etc/hosts

127.0.0.1? localhost localhost.localdomain localhost4 localhost4.localdomain4

::1? ? ? ? localhost localhost.localdomain localhost6 localhost6.localdomain6

172.18.10.213? ora11g

# vi /etc/selinux/confg? 設(shè)置 SELINUX=disabled

# setenforce 0? //關(guān)閉selinux

# service iptables stop //臨時(shí)關(guān)閉防火墻

3 安裝必須的包

# yum install nfs-utils? ? //可以掛載nfs server

#yum install gcc make binutils gcc-c++ compat-libstdc++-33 elfutils-libelf-devel elfutils-libelf-devel-static ksh libaio libaio-devel numactl-devel sysstat unixODBC unixODBC-devel pcre-devel

4 準(zhǔn)備安裝用戶及用戶組

# groupadd oinstall

# groupadd dba

# useradd -g oinstall -G dba oracle

# passwd oracle? ? ? ? ? //設(shè)置oracle密碼

5 修改內(nèi)核參數(shù)配置文件

# vi /etc/sysctl.conf 在文件最后增加(根據(jù)文檔要求kernel.shmmax設(shè)成物理內(nèi)存的一半最合理)

fs.aio-max-nr = 1048576

fs.file-max = 6553600

kernel.shmall = 2097152

kernel.shmmax = 2147483648

kernel.shmmni = 4096

kernel.sem = 250 32000 100 128

net.ipv4.ip_local_port_range = 1024 65000

net.core.rmem_default = 262144

net.core.rmem_max = 4194304

net.core.wmem_default = 262144

net.core.wmem_max = 1048586

保存文件。

# /sbin/sysctl -p? ? ? ? ? //讓參數(shù)生效

6 修改用戶的限制文件

# vi /etc/security/limits.conf 在文件后增加

oracle? ? ? ? ? soft? ? nproc? ? ? ? ? 2047

oracle? ? ? ? ? hard? ? nproc? ? ? ? ? 16384

oracle? ? ? ? ? soft? ? nofile? ? ? ? ? 1024

oracle? ? ? ? ? hard? ? nofile? ? ? ? ? 65536

oracle? ? ? ? ? soft? ? stack? ? ? ? ? 10240

保存文件。

修改/etc/pam.d/login文件,增加如下:

session? required? /lib64/security/pam_limits.so? //64位系統(tǒng)時(shí),千萬(wàn)別寫(xiě)成錯(cuò)/lib/security/pam_limits.so? //否則導(dǎo)致無(wú)法登錄

session? ? required? ? ? pam_limits.so

修改/etc/profile,增加:

if [ $USER = "oracle" ]; then

? if [ $SHELL = "/bin/ksh" ]; then

? ulimit -p 16384

? ulimit -n 65536

? else

? ulimit -u 16384 -n 65536

? fi

fi

7 創(chuàng)建安裝目錄和設(shè)置文件權(quán)限

#mkdir -p /home/app/oracle/product/11.2.0? //數(shù)據(jù)庫(kù)系統(tǒng)安裝目錄

#mkdir /home/app/oracle/oradata? //數(shù)據(jù)庫(kù)數(shù)據(jù)安裝目錄

#mkdir /home/app/oracle/inventory

#mkdir /home/app/oracle/fast_recovery_area

#chown -R oracle:oinstall /home/app/oracle

#chmod -R 775 /home/app/oracle

設(shè)置環(huán)境變量: 修改/home/oracle/.bash_profile文件,增加如下

# su - oracle

ORACLE_BASE=/home/app/oracle

ORACLE_HOME=$ORACLE_BASE/product/11.2.0

ORACLE_SID=ora11

PATH=$PATH:$ORACLE_HOME/bin

export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH

8 編輯靜默安裝響應(yīng)文件

# su - oracle

$ cp -R /home/database/response /home/oracle? //復(fù)制一份模板

$ cd /home/oracle/response

$ vi db_install.rsp? ? //開(kāi)始修改這個(gè)安裝響應(yīng)文件,此文件只是安裝數(shù)據(jù)庫(kù)軟件

需要設(shè)置的選項(xiàng)如下:

oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0? //系統(tǒng)生成的,不要修改

oracle.install.option=INSTALL_DB_SWONLY? ? ? ? ? ? ? //只安裝軟件,不安裝啟動(dòng)數(shù)據(jù)庫(kù)

ORACLE_HOSTNAME=ora11g? ? ? ? ? ? //通過(guò)hostname命令獲得

UNIX_GROUP_NAME=oinstall

INVENTORY_LOCATION=/home/app/oracle/inventory

SELECTED_LANGUAGES=en,zh_CN

ORACLE_HOME=/home/app/oracle/product/11.2.0

ORACLE_BASE=/home/app/oracle

oracle.install.db.InstallEdition=EE

oracle.install.db.isCustomInstall=false


oracle.install.db.customComponents=oracle.server:11.2.0.1.0,oracle.sysman.ccr:10.2.7.0.0,oracle.xdk:11.2.0.1.0,oracle.rdbms.oci:11.2.0.1.0,oracle.network:11.2.0.1.0,oracle.network.listener:11.2.0.1.0,oracle.rdbms:11.2.0.1.0,oracle.options:11.2.0.1.0,oracle.rdbms.partitioning:11.2.0.1.0,oracle.oraolap:11.2.0.1.0,oracle.rdbms.dm:11.2.0.1.0,oracle.rdbms.dv:11.2.0.1.0,orcle.rdbms.lbac:11.2.0.1.0,oracle.rdbms.rat:11.2.0.1.0

oracle.install.db.DBA_GROUP=dba

oracle.install.db.OPER_GROUP=dba

DECLINE_SECURITY_UPDATES=true? ? ? ? ? ? ? ? //一定要設(shè)置為true

9 根據(jù)響應(yīng)文件安裝oracle

$cd /home/database

$./runInstaller -silent -responseFile /home/oracle/response/db_install.rsp -IgnorePrereq

安裝過(guò)程中,如果提示[WARNING]不必理會(huì),此時(shí)安裝程序仍在進(jìn)行,如果出現(xiàn)[FATAL],則安裝程序已經(jīng)停止了。打開(kāi)另一個(gè)終端,執(zhí)行

#tail -100f /home/app/oracle/inventory/logs/installActions......log

可以實(shí)時(shí)跟蹤查看安裝日志,了解安裝的進(jìn)度。

當(dāng)出現(xiàn)如下提示,既安裝成功:

be executed as the "root" user.

#!/bin/sh

#Root scripts to run

/home/app/oracle/inventory/orainstRoot.sh

/home/app/oracle/product/11.2.0/root.sh

To execute the configuration scripts:

? ? ? ? 1. Open a terminal window

? ? ? ? 2. Log in as "root"

? ? ? ? 3. Run the scripts

? ? ? ? 4. Return to this window and hit "Enter" key to continue

Successfully Setup Software.

表示安裝成功了。按照其提示操作。

$exit? //退回到root

# sh /home/app/oracle/inventory/orainstRoot.sh

# sh /home/app/oracle/product/11.2.0/root.sh

10 靜默配置監(jiān)聽(tīng)

$netca /silent /responsefile /home/oracle/response/netca.rsp

Parsing command line arguments:

? ? Parameter "silent" = true

? ? Parameter "responsefile" = /home/oracle/response/netca.rsp

Done parsing command line arguments.

Oracle Net Services Configuration:

Profile configuration complete.

Oracle Net Listener Startup:

? ? Running Listener Control:

? ? ? /home/app/oracle/product/11.2.0/bin/lsnrctl start LISTENER

? ? Listener Control complete.

? ? Listener started successfully.

Listener configuration complete.

Oracle Net Services configuration successful. The exit code is 0

成功運(yùn)行后,在/home/app/oracle/product/11.2.0/network/admin目錄下生成sqlnet.ora和listener.ora兩個(gè)文件。

通過(guò)netstat –tlnp? 命令,看到? 、如果無(wú)法啟動(dòng)檢查日志文件,或修改linsten配置,然后lsnrclt手動(dòng)啟動(dòng)

tcp? 0? ? 0? :::1521? :::*? LISTEN? ? ? 10760/tnslsnr?

說(shuō)明監(jiān)聽(tīng)器已經(jīng)在1521端口上開(kāi)始工作了。

11 靜默建立新庫(kù)(同時(shí)也建立一個(gè)對(duì)應(yīng)的實(shí)例)

修改/home/oracle/response/dbca.rsp,設(shè)置如下:

[GENERAL]

RESPONSEFILE_VERSION = "11.2.0"? //不能更改

OPERATION_TYPE = " createDatabase "

[CREATEDATABASE]

GDBNAME = "ora11"? //數(shù)據(jù)庫(kù)的名字

SID = "ora11"? ? //對(duì)應(yīng)的實(shí)例名字

TEMPLATENAME = "General_Purpose.dbc" //建庫(kù)用的模板文件

SYSPASSWORD = "oracle"? //SYS管理員密碼

SYSTEMPASSWORD = "oracle"? //SYSTEM管理員密碼

DATAFILEDESTINATION = /home/app/oracle/oradata? ? ? //數(shù)據(jù)文件存放目錄

RECOVERYAREADESTINATION=/home/app/oracle/fast_recovery_area? //恢復(fù)數(shù)據(jù)存放目錄

CHARACTERSET = "ZHS16GBK"? //字符集,重要!!! 建庫(kù)后一般不能更改,所以建庫(kù)前要確定清楚。

TOTALMEMORY = "3276"? ? //oracle內(nèi)存3276MB(allmem*80%)

靜默建庫(kù)命令如下

$dbca -silent -responseFile /home/oracle/response/dbca.rsp

Copying database files

1% complete

3% complete

11% complete

18% complete

26% complete

37% complete

Creating and starting Oracle instance

40% complete

45% complete

50% complete

55% complete

56% 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 "/home/app/oracle/cfgtoollogs/dbca/ora11/ora11.log" for further details.

查看日志文件

$ cat /home/app/oracle/cfgtoollogs/dbca/ora11/ora11.log

Copying database files

DBCA_PROGRESS : 1%

DBCA_PROGRESS : 3%

DBCA_PROGRESS : 11%

DBCA_PROGRESS : 18%

DBCA_PROGRESS : 26%

DBCA_PROGRESS : 37%

Creating and starting Oracle instance

DBCA_PROGRESS : 40%

DBCA_PROGRESS : 45%

DBCA_PROGRESS : 50%

DBCA_PROGRESS : 55%

DBCA_PROGRESS : 56%

DBCA_PROGRESS : 60%

DBCA_PROGRESS : 62%

Completing Database Creation

DBCA_PROGRESS : 66%

DBCA_PROGRESS : 70%

DBCA_PROGRESS : 73%

DBCA_PROGRESS : 85%

DBCA_PROGRESS : 96%

DBCA_PROGRESS : 100%

Database creation complete. For details check the logfiles at:

/u01/app/oracle/cfgtoollogs/dbca/ora11.

Database Information:

Global Database Name:ora11

System Identifier(SID):ora11

建庫(kù)后實(shí)例檢查:

$ ps -ef | grep ora_ | grep -v grep

oracle? 11279? ? 1? 0 12:04 ?? ? ? ? 00:00:00 ora_pmon_ora11

oracle? 11281? ? 1? 1 12:04 ?? ? ? ? 00:00:02 ora_vktm_ora11

oracle? 11285? ? 1? 0 12:04 ?? ? ? ? 00:00:00 ora_gen0_ora11

oracle? 11287? ? 1? 0 12:04 ?? ? ? ? 00:00:00 ora_diag_ora11

oracle? 11289? ? 1? 0 12:04 ?? ? ? ? 00:00:00 ora_dbrm_ora11

oracle? 11291? ? 1? 0 12:04 ?? ? ? ? 00:00:00 ora_psp0_ora11

oracle? 11293? ? 1? 0 12:04 ?? ? ? ? 00:00:00 ora_dia0_ora11

oracle? 11295? ? 1? 0 12:04 ?? ? ? ? 00:00:00 ora_mman_ora11

oracle? 11297? ? 1? 0 12:04 ?? ? ? ? 00:00:00 ora_dbw0_ora11

oracle? 11299? ? 1? 0 12:04 ?? ? ? ? 00:00:00 ora_lgwr_ora11

oracle? 11301? ? 1? 0 12:04 ?? ? ? ? 00:00:01 ora_ckpt_ora11

oracle? 11303? ? 1? 0 12:04 ?? ? ? ? 00:00:00 ora_smon_ora11

oracle? 11305? ? 1? 0 12:04 ?? ? ? ? 00:00:00 ora_reco_ora11

oracle? 11307? ? 1? 1 12:04 ?? ? ? ? 00:00:02 ora_mmon_ora11

oracle? 11309? ? 1? 0 12:04 ?? ? ? ? 00:00:01 ora_mmnl_ora11

oracle? 11311? ? 1? 0 12:04 ?? ? ? ? 00:00:00 ora_d000_ora11

oracle? 11313? ? 1? 0 12:04 ?? ? ? ? 00:00:00 ora_s000_ora11

oracle? 11323? ? 1? 0 12:04 ?? ? ? ? 00:00:01 ora_qmnc_ora11

oracle? 11340? ? 1? 0 12:04 ?? ? ? ? 00:00:01 ora_cjq0_ora11

oracle? 11342? ? 1? 0 12:04 ?? ? ? ? 00:00:01 ora_q000_ora11

oracle? 11344? ? 1? 0 12:04 ?? ? ? ? 00:00:00 ora_q001_ora11

查看監(jiān)聽(tīng)狀態(tài)

$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 26-AUG-2014 12:07:54

Copyright (c) 1991, 2009, Oracle.? All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))

STATUS of the LISTENER

------------------------

Alias? ? ? ? ? ? ? ? ? ? LISTENER

Version? ? ? ? ? ? ? ? ? TNSLSNR for Linux: Version 11.2.0.1.0 - Production

Start Date? ? ? ? ? ? ? ? 26-AUG-2014 11:11:10

Uptime? ? ? ? ? ? ? ? ? ? 0 days 0 hr. 56 min. 44 sec

Trace Level? ? ? ? ? ? ? off

Security? ? ? ? ? ? ? ? ? ON: Local OS Authentication

SNMP? ? ? ? ? ? ? ? ? ? ? OFF

Listener Parameter File? /u01/app/oracle/product/11.2.0/network/admin/listener.ora

Listener Log File? ? ? ? /u01/app/oracle/diag/tnslsnr/ora11g/listener/alert/log.xml

Listening Endpoints Summary...

? (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

? (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ora11g)(PORT=1521)))

Services Summary...

Service "ora11" has 1 instance(s).

? Instance "ora11", status READY, has 1 handler(s) for this service...

Service "ora11XDB" has 1 instance(s).

? Instance "ora11", status READY, has 1 handler(s) for this service...

The command completed successfully

12 修改數(shù)據(jù)庫(kù)為歸檔模式(歸檔模式才能熱備份,增量備份)

$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Tue Aug 26 13:37:34 2014

Copyright (c) 1982, 2009, Oracle.? All rights reserved.

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup mount

ORACLE instance started.

Total System Global Area 1603411968 bytes

Fixed Size? ? ? ? ? ? ? ? ? 2213776 bytes

Variable Size? ? ? ? ? ? 402655344 bytes

Database Buffers? ? ? ? 1191182336 bytes

Redo Buffers? ? ? ? ? ? ? ? 7360512 bytes

Database mounted.

SQL> alter database archivelog;

Database altered.

SQL> alter database flashback on;

Database altered.

SQL> alter database open;

Database altered.

SQL> execute utl_recomp.recomp_serial();

PL/SQL procedure successfully completed.

SQL> alter system archive log current;

System altered.

SQL> exit

13 修改oracle啟動(dòng)配置文件

$vi /etc/oratab

ora11:/home/app/oracle/product/11.2.0:Y

這樣就可以通過(guò)dbstart 啟動(dòng)此實(shí)例,也可以通過(guò)dbshut關(guān)閉此實(shí)例了。

$ dbshut /home/app/oracle/product/11.2.0

Processing Database instance "ora11": log file /home/app/oracle/product/11.2.0/shutdown.log

此時(shí)所有oracle的進(jìn)程關(guān)閉,監(jiān)聽(tīng)器也停止。

$dbstart /home/app/oracle/product/11.2.0

Processing Database instance "ora11": log file /home/app/oracle/product/11.2.0/startup.log

此時(shí)監(jiān)聽(tīng)器工作,hello實(shí)例運(yùn)行,再次查看監(jiān)聽(tīng)器狀態(tài)。

$ lsnrctl status

開(kāi)機(jī)啟動(dòng)方法:

方法1:

要想讓oracle服務(wù)隨著系統(tǒng)啟動(dòng)而自動(dòng)啟動(dòng),需要在/etc/rc.local文件中增加如下:

su - oracle -c "/home/app/oracle/product/11.2.0/bin/dbstart /home/app/oracle/product/11.2.0"

方法2:建立啟動(dòng)腳本

# vi /etc/rc.d/init.d/oracle

#!/bin/bash

# oracle: Start/Stop Oracle Database 11g R2

#

# chkconfig: 345 90 10

# description: The Oracle Database is an Object-Relational Database Management System.

#

# processname: oracle

. /etc/rc.d/init.d/functions

LOCKFILE=/var/lock/subsys/oracle

ORACLE_HOME=/home/app/oracle/product/11.2

ORACLE_USER=oracle

case "$1" in

'start')

? if [ -f $LOCKFILE ]; then

? ? ? echo $0 already running.

? ? ? exit 1

? fi

? echo -n $"Starting Oracle Database:"

? su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl start"

? su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"

? su - $ORACLE_USER -c "$ORACLE_HOME/bin/emctl start dbconsole"

? touch $LOCKFILE

? ;;

'stop')

? if [ ! -f $LOCKFILE ]; then

? ? ? echo $0 already stopping.

? ? ? exit 1

? fi

? echo -n $"Stopping Oracle Database:"

? su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl stop"

? su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbshut"

? su - $ORACLE_USER -c "$ORACLE_HOME/bin/emctl stop dbconsole"

? rm -f $LOCKFILE

? ;;

'restart')

? $0 stop

? $0 start

? ;;

'status')

? if [ -f $LOCKFILE ]; then

? ? ? echo $0 started.

? ? ? else

? ? ? echo $0 stopped.

? fi

? ;;

*)

? echo "Usage: $0 [start|stop|status]"

? exit 1

esac

exit 0

#service oracle on

----------------------------------------------------------------------------------------------

增加交換空間:

1. 查看當(dāng)前分區(qū)情況

free -m?

2. 增加 swap 大小, 2G 左右

dd if=/dev/zero of=/var/swap bs=1024 count=2048000?

3. 設(shè)置交換文件

mkswap /var/swap?

4. 立即激活啟用交換分區(qū)

swapon /var/swap?

5. 添加系統(tǒng)引導(dǎo)時(shí)自啟動(dòng)運(yùn)行

vi /etc/fstab?

添加一行

/var/swap? ? ? ? ? ? ? swap? ? ? ? ? ? ? ? ? ? swap? ? defaults? ? ? ? 0 0?

6. 收回 swap 空間

swapoff /var/swap?

7. 從文件系統(tǒng)中回收

rm /var/swap?

-----------------------------------------------------------------------------------------

開(kāi)啟端口:

firewall-cmd --zone=public --add-port=80/tcp --permanent

命令含義:

--zone #作用域

--add-port=80/tcp? #添加端口,格式為:端口/通訊協(xié)議

--permanent? #永久生效,沒(méi)有此參數(shù)重啟后失效

重啟防火墻

firewall-cmd --reload

--------------------------------------------------------------------------------------

環(huán)境配置:

export JAVA_HOME=/usr/javak1.7.0_79

export JRE_HOME=/usr/javak1.7.0_79/jre

export ORACLE_HOME=/home/oracle_11/app/product/11.2.0home_1

export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin:$ORACLE_HOME/bin

export CLASSPATH=.:$JAVA_HOMEb/dt.jar:$JAVA_HOMEb/tools.jar:$JRE_HOMEb

export JAVA_HOME JRE_HOME PATH CLASSPATH ORACLE_HOME

export NLS_LANG="SIMPLIFIED CHINESE_CHINA.ZHS16GBK"

--------------------

使環(huán)境變量生效

source 配置文件

如:#source /etc/profile

-----------------------------------------------------------------------

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容