CentOS7靜默安裝oracle11g


操作系統:

[root@cyylog ~]# uname -m
x86_64
[root@cyylog ~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)


安裝前的準備:

1. 修改主機名


#sed -i "s/HOSTNAME=localhost.localdomain/HOSTNAME=oracledb/" /etc/sysconfig/network


2.添加主機名與IP對應記錄


# vim /etc/hosts 
192.168.0.9 oracledb


3.關閉Selinux

# sed -i "s/SELINUX=enforcing/SELINUX=disabled/" /etc/selinux/config 

# setenforce 0

4.檢查是否有swap分區.

(我的機器是沒有這個,所有後面有報錯) Linux一切皆文件,沒有就自己造一個

1、檢查 Swap 空間在設置 Swap 文件之前,有必要先檢查一下系統裡有沒有既存的 Swap 文件。運行以下命令:

# swapon -s
如果返回的信息概要是空的,則表示 Swap 文件不存在。

2、檢查文件系統在設置 Swap 文件之前,同樣有必要檢查一下文件系統,看看是否有足夠的硬盤空間來設置 Swap 。運行以下命令:

# df -hal

3、創建並允許 Swap 文件下面使用 dd 命令來創建 Swap 文件。檢查返回的信息,還剩餘足夠的硬盤空間即可。

# dd if=/dev/zero of=/swapfile bs=1024 count=512k
參數解讀:if=文件名:輸入文件名,缺省為標準輸入。即指定源文件。< if=input file >of=文件名:輸出文件名,缺省為標準輸出。即指定目的文件。< of=output file >bs=bytes:同時設置讀入/輸出的塊大小為bytes個字節count=blocks:僅拷貝blocks個塊,塊大小等於bs指定的字節數。

4、格式化並激活 Swap 文件上面已經創建好 Swap 文件,還需要格式化後才能使用。運行命令:


# mkswap /swapfile

激活 Swap ,運行命令:

# swapon /swapfile
以上步驟做完,再次運行命令:

# swapon -s

你會發現返回的信息概要:

1 Filename Type Size Used Priority
2 /swapfile file 524284 0 -1


如果要機器重啟的時候自動掛載 Swap ,那麼還需要修改 fstab 配置。用 vim 打開 /etc/fstab 文件,在其最後添加如下一行:

/swapfile swap swap defaults 0 0
最後,賦予 Swap 文件適當的權限:

# chown root:root /swapfile
# chmod 0600 /swapfile

5.安裝常用工具,配置阿里源

(個人習慣,在使用的主機上面配置這些常用工具)


# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
# curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
# yum clean all
# yum makecache fast

# yum install -y wget ntpdate net-tools vim bash-completion ShellCheck

# ntpdate -b ntp1.aliyun.com


安裝軟件包:

參考官方:http://docs.oracle.com/cd/E11882_01/install.112/e24326/toc.htm#BHCCADGD

  • The following or later version of packages for Oracle Linux 7, and Red Hat Enterprise Linux 7 must be installed:
binutils-2.23.52.0.1-12.el7.x86_64 
compat-libcap1-1.10-3.el7.x86_64
compat-libstdc++-33-3.2.3-71.el7.i686
compat-libstdc++-33-3.2.3-71.el7.x86_64
gcc-4.8.2-3.el7.x86_64
gcc-c++-4.8.2-3.el7.x86_64
glibc-2.17-36.el7.i686
glibc-2.17-36.el7.x86_64
glibc-devel-2.17-36.el7.i686
glibc-devel-2.17-36.el7.x86_64
ksh
libaio-0.3.109-9.el7.i686
libaio-0.3.109-9.el7.x86_64
libaio-devel-0.3.109-9.el7.i686
libaio-devel-0.3.109-9.el7.x86_64
libgcc-4.8.2-3.el7.i686
libgcc-4.8.2-3.el7.x86_64
libstdc++-4.8.2-3.el7.i686
libstdc++-4.8.2-3.el7.x86_64
libstdc++-devel-4.8.2-3.el7.i686
libstdc++-devel-4.8.2-3.el7.x86_64
libXi-1.7.2-1.el7.i686
libXi-1.7.2-1.el7.x86_64
libXtst-1.2.2-1.el7.i686
libXtst-1.2.2-1.el7.x86_64
make-3.82-19.el7.x86_64
sysstat-10.1.5-1.el7.x86_64
unixODBC-2.3.1-6.el7.x86_64 or later
unixODBC-2.3.1-6.el7.i686 or later
unixODBC-devel-2.3.1-6.el7.x86_64 or later
unixODBC-devel-2.3.1-6.el7.i686 or later
CentOS7靜默安裝oracle11g

binutils-2.23.52.0.1-12.el7.x86_64 
compat-libcap1-1.10-3.el7.x86_64
compat-libstdc++-33-3.2.3-71.el7.i686
compat-libstdc++-33-3.2.3-71.el7.x86_64
gcc-4.8.2-3.el7.x86_64
gcc-c++-4.8.2-3.el7.x86_64
glibc-2.17-36.el7.i686
glibc-2.17-36.el7.x86_64
glibc-devel-2.17-36.el7.i686
glibc-devel-2.17-36.el7.x86_64
ksh
libaio-0.3.109-9.el7.i686
libaio-0.3.109-9.el7.x86_64
libaio-devel-0.3.109-9.el7.i686
libaio-devel-0.3.109-9.el7.x86_64
libgcc-4.8.2-3.el7.i686
libgcc-4.8.2-3.el7.x86_64
libstdc++-4.8.2-3.el7.i686
libstdc++-4.8.2-3.el7.x86_64
libstdc++-devel-4.8.2-3.el7.i686
libstdc++-devel-4.8.2-3.el7.x86_64
libXi-1.7.2-1.el7.i686
libXi-1.7.2-1.el7.x86_64
libXtst-1.2.2-1.el7.i686
libXtst-1.2.2-1.el7.x86_64
make-3.82-19.el7.x86_64
sysstat-10.1.5-1.el7.x86_64
unixODBC-2.3.1-6.el7.x86_64 or later
unixODBC-2.3.1-6.el7.i686 or later
unixODBC-devel-2.3.1-6.el7.x86_64 or later
unixODBC-devel-2.3.1-6.el7.i686 or later

用yum進行安裝

yum -y install binutils compat-libcap1 compat-libstdc++-33 compat-libstdc++-33*i686 compat-libstdc++-33*.devel compat-libstdc++-33 compat-libstdc++-33*.devel gcc gcc-c++ glibc glibc*.i686 glibc-devel glibc-devel*.i686 ksh libaio libaio*.i686 libaio-devel libaio-devel*.devel libgcc libgcc*.i686 libstdc++ libstdc++*.i686 libstdc++-devel libstdc++-devel*.devel libXi libXi*.i686 libXtst libXtst*.i686 make sysstat unixODBC unixODBC*.i686 unixODBC-devel unixODBC-devel*.i686


檢測是否31個包都有安裝

CentOS7靜默安裝oracle11g

開放源碼綠色藍色按鈕樣式

[root@cyylog ~]# rpm -q binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libXi libXtst make sysstat unixODBC unixODBC-devel
binutils-2.23.52.0.1-55.el7.x86_64
compat-libcap1-1.10-7.el7.x86_64
compat-libstdc++-33-3.2.3-72.el7.x86_64
compat-libstdc++-33-3.2.3-72.el7.i686
gcc-4.8.5-4.el7.x86_64
gcc-c++-4.8.5-4.el7.x86_64
glibc-2.17-106.el7_2.8.x86_64
glibc-2.17-106.el7_2.8.i686
glibc-devel-2.17-106.el7_2.8.x86_64
glibc-devel-2.17-106.el7_2.8.i686
ksh-20120801-22.el7_1.3.x86_64
libaio-0.3.109-13.el7.x86_64
libaio-0.3.109-13.el7.i686
libaio-devel-0.3.109-13.el7.x86_64
libaio-devel-0.3.109-13.el7.i686
libgcc-4.8.5-4.el7.x86_64
libgcc-4.8.5-4.el7.i686
libstdc++-4.8.5-4.el7.x86_64
libstdc++-4.8.5-4.el7.i686
libstdc++-devel-4.8.5-4.el7.x86_64
libstdc++-devel-4.8.5-4.el7.i686
libXi-1.7.2-2.1.el7.x86_64
libXi-1.7.4-2.el7.i686
libXtst-1.2.2-2.1.el7.x86_64
libXtst-1.2.2-2.1.el7.i686
make-3.82-21.el7.x86_64
sysstat-10.1.5-7.el7.x86_64
unixODBC-2.3.1-11.el7.x86_64
unixODBC-2.3.1-11.el7.i686
unixODBC-devel-2.3.1-11.el7.x86_64
unixODBC-devel-2.3.1-11.el7.i686
CentOS7靜默安裝oracle11g

計算機代碼πόλη ποτάμιου τοπίου

版本號只能大於規定的版本,不能小於。


創建oinstall和dba組

# groupadd oinstall
# groupadd dba

創建oracle用戶

# useradd -g oinstall -G dba oracle

設置oracle用戶密碼

# passwd oracle

驗證創建是否正確

[root@cyylog ~]# id oracle
uid=1000(oracle) gid=1000(oinstall) groups=1000(oinstall),1001(dba)


配置內核參數

[root@cyylog ~]# vim /etc/sysctl.conf 

# System default settings live in /usr/lib/sysctl.d/00-system.conf.
# To override those settings, enter new settings here, or in an /etc/sysctl.d/<name>.conf file
#
# For more information, see sysctl.conf(5) and sysctl.d(5).
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 536870912 #最低:536870912,最大值:比物理內存小1個字節的值,建議超過物理內存的一半
kernel.shmmni = 4096

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 = 1048576/<name>


參數的值不能小於上面的配置,這是oracle官方建議的最小值,生產環境建議調整這些參數,以優化系統性能。

修改後使之生效

# sysctl -p


修改用戶限制

vim /etc/security/limits.conf

#在末尾添加
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
oracle hard stack 10240
CentOS7靜默安裝oracle11g

在/etc/pam.d/login 文件中,使用文本編輯器或vi命令增加或修改以下內容

session required /lib64/security/pam_limits.so
session required pam_limits.so

在/etc/profile 文件中,使用文本編輯器或vi命令增加或修改以下內容

if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi


CentOS7靜默安裝oracle11g

使之生效

# source /etc/profile


創建安裝目錄

# mkdir -p /u01/app/
# chown -R oracle:oinstall /u01/app/
# chmod -R 775 /u01/app/


配置環境變量

[oracle@cyylog ~]$ vim ~/.bash_profile 

export ORACLE_BASE=/u01/app/oracle
export ORACLE_SID=dbsrv2

使之生效

source ~/.bash_profile

解壓oracle軟件

[root@cyylog src]# unzip linux.x64_11gR2_database_1of2.zip
[root@cyylog src]# unzip linux.x64_11gR2_database_2of2.zip

複製響應文件模板

[oracle@cyylog ~]$ mkdir etc
[oracle@cyylog ~]$ cp /usr/local/src/database/response/* /home/oracle/etc/
[oracle@cyylog ~]$ ls etc
dbca.rsp db_install.rsp netca.rsp

設置響應文件權限

[oracle@cyylog ~]$ su - root

[root@cyylog ~]# chmod 700 /home/oracle/etc/*.rsp


靜默安裝Oracle軟件

su - oracle

修改安裝Oracle軟件的響應文件/home/oracle/etc/db_install.rsp

oracle.install.option=INSTALL_DB_SWONLY // 安裝類型
ORACLE_HOSTNAME=oracledb // 主機名稱(hostname查詢)
UNIX_GROUP_NAME=oinstall // 安裝組
INVENTORY_LOCATION=/u01/app/oraInventory //INVENTORY目錄(不填就是默認值)
SELECTED_LANGUAGES=en,zh_CN,zh_TW // 選擇語言
ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1 //oracle_home
ORACLE_BASE=/u01/app/oracle //oracle_base
oracle.install.db.InstallEdition=EE     // oracle版本
oracle.install.db.isCustomInstall=false   //自定義安裝,否,使用默認組件
oracle.install.db.DBA_GROUP=dba /  / dba用戶組
oracle.install.db.OPER_GROUP=oinstall // oper用戶組
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE //數據庫類型
oracle.install.db.config.starterdb.globalDBName=orcl //globalDBName
oracle.install.db.config.starterdb.SID=dbsrv2 //SID
oracle.install.db.config.starterdb.memoryLimit=81920 //自動管理內存的內存(M)
oracle.install.db.config.starterdb.password.ALL=oracle //設定所有數據庫用戶使用同一個密碼
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false //(手動寫了false)
DECLINE_SECURITY_UPDATES=true   //設置安全更新(貌似是有bug,這個一定要選true,否則會無限提醒郵件地址有問題,終止安裝。PS:不管地址對不對)
CentOS7靜默安裝oracle11g

oracle.install.option=INSTALL_DB_SWONLY // 安裝類型
ORACLE_HOSTNAME=oracledb // 主機名稱(hostname查詢)
UNIX_GROUP_NAME=oinstall // 安裝組
INVENTORY_LOCATION=/u01/app/oraInventory //INVENTORY目錄(不填就是默認值)
SELECTED_LANGUAGES=en,zh_CN,zh_TW // 選擇語言
ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1 //oracle_home
ORACLE_BASE=/u01/app/oracle //oracle_base
oracle.install.db.InstallEdition=EE     // oracle版本
oracle.install.db.isCustomInstall=false   //自定義安裝,否,使用默認組件
oracle.install.db.DBA_GROUP=dba /  / dba用戶組
oracle.install.db.OPER_GROUP=oinstall // oper用戶組
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE //數據庫類型
oracle.install.db.config.starterdb.globalDBName=orcl //globalDBName
oracle.install.db.config.starterdb.SID=dbsrv2 //SID
oracle.install.db.config.starterdb.memoryLimit=81920 //自動管理內存的內存(M)
oracle.install.db.config.starterdb.password.ALL=oracle //設定所有數據庫用戶使用同一個密碼
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false //(手動寫了false)
DECLINE_SECURITY_UPDATES=true   //設置安全更新(貌似是有bug,這個一定要選true,否則會無限提醒郵件地址有問題,終止安裝。PS:不管地址對不對)


開始靜默安裝

[oracle@cyylog database]$ ./runInstaller -silent -responseFile /home/oracle/etc/db_install.rsp

新開一個終端 查看安裝日誌

# tail -f /u01/app/oraInventory/logs/installActions2016-08-31_06-56-29PM.log

出現類似如下提示表示安裝完成:

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

The following configuration>

/u01/app/oraInventory/orainstRoot.sh /u01/app/oracle/product/11.2.0/db_1/root.sh To execute the configuration>

  1. Open a terminal window
  2. Log in as "root"
  3. Run the>
  4. Return to this window and hit "Enter" key to continue

Successfully Setup Software.

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

使用root用戶執行腳本

$ su - root
# /u01/app/oraInventory/orainstRoot.sh
# /u01/app/oracle/product/11.2.0/db_1/root.sh

增加或修改oracle的環境變量

# su - oracle
# vim ~/.bash_profile


#for oracle
export ORACLE_BASE=/u01/app/oracle
export ORACLE_SID=dbsrv2
export ROACLE_PID=ora11g
#export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
export PATH=$PATH:$ORACLE_HOME/bin

export LANG="zh_CN.UTF-8"
export NLS_LANG="SIMPLIFIED CHINESE_CHINA.AL32UTF8"
export NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss'


刷新環境變量
# source ~/.bash_profile

配置監聽程序

[oracle@cyylog ~]$ netca /silent /responsefile /home/oracle/etc/netca.rsp

Parsing command line arguments:
Parameter "silent" = true
Parameter "responsefile" = /home/oracle/etc/netca.rsp
Done parsing command line arguments.
Oracle Net Services Configuration:
Profile configuration complete.
Oracle Net Listener Startup:
Running Listener Control:
/u01/app/oracle/product/11.2.0/db_1/bin/lsnrctl start LISTENER
Listener Control complete.
Listener started successfully.
Listener configuration complete.
Oracle Net Services configuration successful. The exit code is 0

啟動監控程序

[oracle@cyylog ~]$ lsnrctl start

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 01-SEP-2016 11:23:31

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

Starting /u01/app/oracle/product/11.2.0/db_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/cyylog/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=cyylog)(PORT=1521)))

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 01-SEP-2016 11:23:31
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/cyylog/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=cyylog)(PORT=1521)))

The listener supports no services
The command completed successfully

靜默dbca建庫

[oracle@cyylog ~]$ vi etc/dbca.rsp
[GENERAL]
RESPONSEFILE_VERSION = "11.2.0"
OPERATION_TYPE = "createDatabase"
[CREATEDATABASE]
GDBNAME = "dbsrv2"
SID = "dbsrv2"
TEMPLATENAME = "General_Purpose.dbc"
CHARACTERSET = "AL32UTF8"

建庫(我的finashell會閃屏,但是不影響使用)

[oracle@cyylog ~]$ dbca -silent -responseFile etc/dbca.rsp

Enter SYS user password:

Enter SYSTEM user password:

sh: /bin/ksh: No such file or directory
sh: /bin/ksh: No such file or directory
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
57% complete
60% complete
62% complete
Completing Database Creation
66% complete
70% complete
73% complete
74% complete
85% complete
96% complete

100% complete
Look at the log file Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/orcl11g/orcl11g.log" for further details.
CentOS7靜默安裝oracle11g

[oracle@cyylog ~]$ dbca -silent -responseFile etc/dbca.rsp

Enter SYS user password:

Enter SYSTEM user password:

sh: /bin/ksh: No such file or directory
sh: /bin/ksh: No such file or directory
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
57% complete
60% complete
62% complete
Completing Database Creation
66% complete
70% complete
73% complete
74% complete
85% complete
96% complete
100% complete
Look at the log file Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/orcl11g/orcl11g.log" for further details.

查看輸出日誌

[oracle@cyylog ~]$ tailf /u01/app/oracle/cfgtoollogs/dbca/silent.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/orcl11g.
Database Information:
Global Database Name:orcl11g.us.oracle.com
System Identifier(SID):dbsrv2
CentOS7靜默安裝oracle11g

至此完成數據庫實例的創建。


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

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

附:

刪除實例:

[oracle@cyylog ~]$ dbca -silent -deleteDatabase -sourcedb dbsrv2

文章來源:https://www.cnblogs.com/zydev/p/5827207.html


分享到:


相關文章: