CentOS7靜默安裝數據庫oralce11gR2

一、系統版本

操作系統: CentOS Linux release 7.3.1611 (Core)

二、oracle軟件版本

oracle版本:linux.x64_11gR2
linux.x64_11gR2_database_1of2.zip
linux.x64_11gR2_database_2of2.zip

三、創建用戶、組

A) 創建用戶和組

groupadd oinstall
groupadd dba
useradd -g oinstall -G dba oracle
passwd oracle

B) 創建數據庫安裝目錄

mkdir -p /opt/oracle ##$ORACLE_BASE
mkdir -p /opt/oracle/product/112010/db_1 ##$ORACLE_HOME
mkdir /opt/oracle/oradata ##存放數據庫目錄
mkdir /opt/oracle/inventory
mkdir /opt/oracle/flash_recovery_area
chown -R oracle:oinstall /opt/oracle
chmod -R 775 /opt/oracle

C) 將oracle使用者加入到sudo羣組中
vi /etc/sudoers
輸入上面的命令後,打開sudoers文件進行編輯,找到
root ALL=(ALL) ALL

這行,並且在底下再加入以下命令:
oracle ALL=(ALL) ALL

四、修改系統參數、及環境變量

1、關閉selinux
vi /etc/selinux/config
修改: SELINUX=disabled

2、關閉防火牆
systemctl stop firewalld.service #停止服務|firewall
systemctl disable firewalld.service #禁止firewall開機啓動

3、修改/etc/hosts文件
vi /etc/hosts
10.143.200.188 DATAFS

4、修改內核參數
vi /etc/sysctl.conf

修改以下內容
kernel.shmall = 2097152
kernel.shmmax = 1073741824

添加以下內容
fs.aio-max-nr = 1048576
fs.file-max = 6815744
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

#sysctl -p

5、修改用戶限制文件

#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

6、關聯設置
vi /etc/pam.d/login
行末添加以下內容:
session required /lib64/security/pam_limits.so
session required pam_limits.so

7、修改/etc/profile
#vi /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

source /etc/profile

8、Oralce用戶修改用戶環境變量

#vi /home/oracle/.bash_profile
在最底下加入以下內容
#For Oracle
export ORACLE_BASE=/opt/oracle;
export ORACLE_HOME=/opt/oracle/product/112010/db_1
export ORACLE_SID=orcl
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
export LC_ALL="en_US"
export LANG="en_US"
export NLS_LANG="AMERICAN_AMERICA.ZHS16GBK"
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"

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

fi

source /home/oracle/.bash_profile
查看命令:# env

五、安裝依賴包

安裝依賴包比較多,最好服務器能夠訪問外網,這樣就簡單多了,如果真的無法訪問外網只能下載對應的rpm包安裝了.

yum -y install binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel glibc glibc-common glibc-devel gcc gcc-c++ libaio-devel libaio libgcc libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel pdksh ksh libaio.i686 glibc.i686 compat-libstdc++-33.i686 libaio-devel.i686 libgcc.i686 libstdc++.i686 unixODBC.i686 unixODBC-devel.i686

rpm包安裝:#rpm -ivh * --force --nodeps

六、正式開始安裝數據庫

1、安裝包解壓命令(使用oracle用戶解壓 )

$unzip linux.x64_11gR2_database_1of2.zip
$unzip linux.x64_11gR2_database_2of2.zip
修改目錄所屬用戶
chown -R oracle:oinstall database

解壓完成後會生成database目錄,解壓後的文件中database/response下有有db_install.rsp、dbca.rsp和netca.rsp三個應答文件,分別數據庫安裝文件、建立數據庫實例和監聽配置安裝文件,在下面的步驟中會用到這3個文件.

2、編輯數據庫安裝文件db_install.rsp
vi db_install.rsp
20 oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
29 oracle.install.option=INSTALL_DB_SWONLY #安裝類型
37 ORACLE_HOSTNAME=DATAFS #主機名稱
42 UNIX_GROUP_NAME=oinstall #安裝組
47 INVENTORY_LOCATION=/opt/oracle/inventory #INVENTORY目錄
78 SELECTED_LANGUAGES=en,zh_CN #選擇語言
83 ORACLE_HOME=/opt/oracle/product/112010/db_1 #oracle_home
88 ORACLE_BASE=/opt/oracle #oracle_base
99 oracle.install.db.InstallEdition=EE ##oracle版本
108 oracle.install.db.isCustomInstall=true
142 oracle.install.db.DBA_GROUP=dba #dba用戶組
147 oracle.install.db.OPER_GROUP=dba #oper用戶組
160 oracle.install.db.config.starterdb.type=GENERAL_PURPOSE #數據庫類型
165 oracle.install.db.config.starterdb.globalDBName=orcl #globalDBName
170 oracle.install.db.config.starterdb.SID=orcl #SID
200 oracle.install.db.config.starterdb.memoryLimit=800 #自動管理內存的最小內存(M)
233 oracle.install.db.config.starterdb.password.ALL=oracle #設定所有數據庫用戶使用同一個密碼
385 DECLINE_SECURITY_UPDATES=true #設置安全更新

3、安裝數據庫軟件(使用oracle用戶)
#su - oracle
進入剛纔的database目錄
./runInstaller -silent -responseFile /ghca/database/response/db_install.rsp -ignorePrereq
Starting Oracle Universal Installer...

Checking Temp space: must be greater than 120 MB. Actual 13773 MB Passed
Checking swap space: must be greater than 150 MB. Actual 2047 MB Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2018-09-20_09-16-02PM. Please wait ...

接下來就是等待(有點長,不要着急!!!),快的話10分鐘左右,慢一點可能需要30分鐘左右,要看服務器配置。

安裝過程中,如果提示[WARNING]不必理會,此時安裝程序仍在後臺進行,如果出現[FATAL],則安裝程序已經停止了。
可以在以下位置找到本次安裝會話的日誌。
安裝失敗會打印一下信息
[FATAL] [INS-32076] English cannot be removed from the selected languages list.
CAUSE: An attempt was made to remove English from the selected languages list.
ACTION: Select English as one of the selected product languages.
A log of this session is currently saved as: /tmp/OraInstall2018-09-20_09-16-02PM/installActions2018-09-20_09-16-02PM.log. Oracle recommends that if you want to keep this log, you should move it from the temporary location to a more permanent location.

查看log日誌信息:
cat /tmp/OraInstall2018-09-20_09-16-02PM/installActions2018-09-20_09-16-02PM.log. Oracle

正常安裝日誌信息:
[oracle@DATAFS database]$ [WARNING] [INS-32055] The Central Inventory is located in the Oracle base.
CAUSE: The Central Inventory is located in the Oracle base.
ACTION: Oracle recommends placing this Central Inventory in a location outside the Oracle base directory.
[WARNING] [INS-32055] The Central Inventory is located in the Oracle base.
CAUSE: The Central Inventory is located in the Oracle base.
ACTION: Oracle recommends placing this Central Inventory in a location outside the Oracle base directory.
You can find the log of this install session at:
/opt/oracle/inventory/logs/installActions2018-09-20_09-47-28PM.log

tail -f /opt/oracle/inventory/logs/installActions2018-09-20_09-47-28PM.log

安裝成功的日誌如下:
The following configuration scripts need to be executed as the "root" user.
#!/bin/sh
#Root scripts to run

/opt/oracle/inventory/orainstRoot.sh
/opt/oracle/product/112010/db_1/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

4、 安裝後操作,按照要求執行腳本
打開新的終端,以root身份登錄,執行腳本:

#/opt/oracle/inventory/orainstRoot.sh
#/opt/oracle/product/112010/db_1/root.sh

[root@DATAFS db_1]# /opt/oracle/inventory/orainstRoot.sh
Changing permissions of /opt/oracle/inventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.

Changing groupname of /opt/oracle/inventory to oinstall.
The execution of the script is complete.
[root@DATAFS db_1]# /opt/oracle/product/112010/db_1/root.sh
Check /opt/oracle/product/112010/db_1/install/root_DATAFS_2018-09-20_22-36-50.log for the output of root script

完成後,返回原來的終端按下回車鍵,等待程序安裝完成.

七、監聽器配置

執行命令 : netca /silent /responseFile /ghca/database/response/netca.rsp ###----此處必須寫絕對路徑
[oracle@DATAFS response]$ netca /silent /responseFile /ghca/database/response/netca.rsp

Parsing command line arguments:
Parameter "silent" = true
Parameter "responsefile" = /ghca/database/response/netca.rsp
Done parsing command line arguments.
Oracle Net Services Configuration:
Configuring Listener:LISTENER
Listener configuration complete.
Oracle Net Listener Startup:
Running Listener Control:
/opt/oracle/product/112010/db_1/bin/lsnrctl start LISTENER
Listener Control complete.
Listener started successfully.
Profile configuration complete.
Oracle Net Services configuration successful. The exit code is 0

查看端口是否佔用:
[root@DATAFS ~]# ss -tnl|grep 1521
LISTEN 0 128 :::1521 :::*
[root@DATAFS ~]#

查看監聽狀態:

[oracle@DATAFS response]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 21-SEP-2018 12:22:08

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=DATAFS)(PORT=1521)))
STATUS of the LISTENER

Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 21-SEP-2018 12:20:29
Uptime 0 days 0 hr. 1 min. 41 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /opt/oracle/product/112010/db_1/network/admin/listener.ora
Listener Log File /opt/oracle/diag/tnslsnr/DATAFS/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=DATAFS)(PORT=1521)))
The listener supports no services
The command completed successfully

八、安裝數據庫實例

1 修改/ghca/database/response/dbca.rsp響應文件中的重要參數

本次安裝過程中設置了下列參數:(注意下面參數視情況而定,不要照抄,原文件都有說明的)
RESPONSEFILE_VERSION ="11.2.0" #不能更改

OPERATION_TYPE ="createDatabase"

GDBNAME ="orcl" #數據庫的名字

SID ="ORCL" ##對應的實例名字

TEMPLATENAME ="General_Purpose.dbc" ##建庫用的模板文件

SYSPASSWORD ="oracle" ##SYS管理員密碼

SYSTEMPASSWORD ="oracle" ##SYSTEM管理員密碼

SYSMANPASSWORD= "oracle"

DBSNMPPASSWORD= "oracle"

DATAFILEDESTINATION =/opt/oracle/oradata ##數據文件存放目錄

RECOVERYAREADESTINATION=/opt/oracle/flash_recovery_area ##恢復數據存放目錄

CHARACTERSET ="ZHS16GBK" ##字符集,重要!!!建庫後一般不能更改,所以建庫前要確定清楚。

TOTALMEMORY ="1638" #1638MB,物理內存2G*80%。

2、 開始安裝數據庫實例
dbca -silent -responseFile /ghca/database/response/response/dbca.rsp
[oracle@DATAFS response]$ dbca -silent -responseFile /ghca/database/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 "/opt/oracle/cfgtoollogs/dbca/orcl/orcl.log" for further details.

到此數據庫實例安裝就完成了.

九、監聽配置報錯

配置監聽時,沒有使用netca.rsp相應的文件的絕對路徑
[oracle@DATAFS response]$ netca /silent /responseFile netca.rsp

Parsing command line arguments:
Parameter "silent" = true
Parameter "responsefile" = ./netca.rsp
Oracle Net Configuration Assistant could not find the Response File at the given location.
Oracle Net Services configuration failed. The exit code is 1

十、數據庫啓停

登錄數據庫 sqlplus / as sysdba
啓動:SQL> startup
停止:SQL> shutdown immediate;

十一、創建表空間以及用戶、權限等

1、管理員用戶創建表空間保存數據
create tablespace IDR_TS datafile '/opt/oracle/oradata/orcl/IDR_TS01.dbf' size 1024m;

2、創建用戶數據操作用戶

create user operator identified by "123456"
default tablespace operator
temporary tablespace TEMP
profile DEFAULT
quota unlimited on IDR_TS;

以下權限是可選的,根據自己需要給用戶賦權
grant connect to operator;
grant dba to operator;
grant javasyspriv to operator;
-- Grant/Revoke system privileges
grant create any sequence to operator;
grant create any table to operator;
grant create any view to operator;
grant unlimited tablespace to operator;
-- Grant/Revoke role privileges
grant connect to operator;
grant dba to operator;
grant exp_full_database to operator;
grant imp_full_database to operator;
grant javasyspriv to operator;
grant resource to operator;
-- Grant/Revoke system privileges
grant create any sequence to operator;
grant alter any table to operator;
grant alter any trigger to operator;
grant alter session to operator;
grant alter system to operator;
grant alter tablespace to operator;
grant alter user to operator;
grant analyze any to operator;
grant create any procedure to operator;
grant create any synonym to operator;
grant create any table to operator;
grant create any trigger to operator;
grant create cluster to operator;
grant create database link to operator;
grant create procedure to operator;
grant create public synonym to operator;
grant create role to operator;
grant create sequence to operator;
grant create session to operator;
grant create synonym to operator;
grant create table to operator;
grant create any view to operator;
grant delete any table to operator;
grant drop any index to operator;
grant drop any synonym to operator;
grant drop any table to operator;
grant drop any trigger to operator;
grant drop public synonym to operator;
grant execute any procedure to operator;
grant insert any table to operator;
grant lock any table to operator;
grant select any table to operator;
grant unlimited tablespace to operator;
grant update any table to operator;
到此就可以使用operator登錄進行數據操作了.數據庫完整的安裝就結束了.

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< installation is complete >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章