Linux環境下安裝Oracle 11g
安裝前配置
p13390677_112040_Linux-x86-64_1of7.zip
p13390677_112040_Linux-x86-64_2of7.zip
解決sqlplus下亂碼問題的安裝包:
rlwrap-0.42-1.el7.x86_64.rpm
虛擬記憶體在30G以上,不然後續資料庫安裝記憶體不足
Linux使用的是Oracle的orcl_linux7.3-V834394-01.iso映象
使用root使用者配置本地yum源:
[root@localhost ~]# mkdir -p /etc/yum.repos.d/bak_repo
[root@localhost ~]# mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak_repo/
配置yum的庫檔案
[[email protected] ~]# vi /etc/yum.repos.d/local.repo
[local_server]
name=This is local yum repo
baseurl=file:///media/CentOS/
enabled=1
gpgcheck=0
掛載光碟機iso檔案,並安裝所需rpm包
[root@localhost ~]# mount /dev/sr0 /mnt
[root@localhost ~]# mkdir /media/CentOS/
[root@localhost ~]# cp -fr /mnt/* /media/CentOS/
[root@localhost ~]# yum -y install oracle-rdbms-server* xclock iotop rlwrap-0.42-1.el7.x86_64.rpm unzip bc elfutils-libe*
[root@localhost ~]# umount /mnt
掛載期間,虛擬機器要處於連線映象狀態
在結束掛載後要取消連結
不然重啟虛擬機器中的Linux系統時會重新安裝系統。
若rlwrap未能安裝,參考centos7 安裝rlwrap
使用root使用者修改主機名
[root@localhost ~]# hostnamectl --static set-hostname oa-orcl
[root@localhost ~]# vi /etc/hosts
在hosts後增加一行:本機IP號 主機名,例如:
10.0.1.166 oa-orcl
使用root使用者關閉防火牆和selinux
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld
[root@localhost ~]# sed -i s#SELINUX=enforcing#SELINUX=disabled#g /etc/selinux/config
[root@localhost ~]# setenforce 0
使用root使用者配置oracle安裝環境
[root@localhost ~]# mkdir -p /u01/app/oracle/product/11.2.0.4/db
[root@localhost ~]# unzip p13390677_112040_Linux-x86-64_1of7.zip
[root@localhost ~]# unzip p13390677_112040_Linux-x86-64_2of7.zip
[root@localhost ~]# mv database/ /u01
[root@localhost ~]# chown -R oracle.oinstall /u01
修復預檢查失敗 問題
[root@localhost ~]# vi /u01/database/stage/cvu/cv/admin/cvu_config
將檔案中CV_ASSUME_DISTID=OEL4 替換為:CV_ASSUME_DISTID=OEL6
切換到oracle使用者進行使用者環境變數配置
修改oracle使用者密碼
[root@localhost ~]# echo "oracle" | passwd --stdin oracle
[root@localhost ~]# su - oracle
編輯oracle使用者環境變數
[oracle@oa-orcl ~]$ vi .bash_profile
在檔案末尾新增如下內容
umask 022
TMP=/tmp
TMPDIR=$TMP
ORACLE_SID=orcl
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=$ORACLE_BASE/product/11.2.0.4/db
PATH=$ORACLE_HOME/bin:$PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export TMP TMPDIR ORACLE_BASE ORACLE_HOME ORACLE_SID PATH LD_LIBRARY_PATH CLASSPATH NLS_LANG
#解決sqlplus亂碼問題
stty erase ^h
alias sqlplus="rlwrap sqlplus"
alias rman="rlwrap rman"
安裝資料庫軟體
本文安裝資料庫時,是通過VPN方式連線到資料庫伺服器,下列資料庫安裝流程,都是基於vpn的網路環境下進行。在進行安裝操作前,請確保本地(windows客戶端)安裝了xmanager,並啟用Xmanager
啟用時遠端登入一定要使用oracle使用者登陸,不然會報錯
[oracle@oa-orcl ~]$ cd /u01/database
[oracle@oa-orcl ~]$ ./runInstaller
彈出介面Configure Security Updates中,去掉 √,點選next,在彈出介面中點選yes
Download Software Updates中,選擇Skip software updates,點選next
Installation Option中,選擇 Install database software only,點選next
Grid Installation Options中,選擇 Single instance database installation,點選next
Product Languages中,點選next
Database Edition中,點選next
Installation Location,點選next
Create Inventory中,點選next
Operating System Groups中,第二項下拉選擇oinstall,點選next
Prerequisite Checks中,應該是沒有任何報錯資訊,如果有報錯提示,請解決問題後,點選next
接下來就進入安裝介面
注意:
1、在安裝進度條執行到到86%時,報錯
解決辦法:
[[email protected] ~]# vi /u01/app/oracle/product/11.2.0.4/db/sysman/lib/ins_emagent.mk
在命令模式輸入/NMECTL 進行查詢,快速定位要修改的行,在後面追加引數 -lnnz11 ,修改後值為$(MK_EMAGENT_NMECTL) -lnnz11 儲存退出後點擊頁面中Retry按鈕。
2、在進度條執行到94%時,頁面彈出:
需要root使用者,依次執行當前頁面中2條shell指令碼項。執行完成後,資料庫軟體安裝完成。
監聽安裝
在剛才oracle使用者執行 ./runInstaller命令的終端中輸入netca,在彈出的介面中,一直點選next按鈕,直到出現下面介面為止(與初始介面很相似,比初始介面多一個finish的選項)
建立資料庫:
oracle使用者在執行netca的終端下,輸入dbca進入資料庫安裝介面,進行資料庫安裝:
Welcome,點選next
1、Operations,點選next
2、Database Templates,點選next
3、Database Idengigication,輸入和環境變數ORACLE_SID一致的值,這裡為orcl,點選next
4、Management Options,在Enterprise Manger選項卡中勾上Configure Enterprise Manager另一選項卡不管,點選next
5、Database Credentials,選擇 Use the Same Adminitrative Password for All Accounts,然後輸入密碼,點選next
6、Database File Locations,選擇預設選項Use Database File Locations from Template,點選next
7、Recovery Configuration,取消勾選 Specify Fast Recovery Area,點選next
8、Database Content,在Sample Schemas選項卡中勾選Sample Shemas
9、Initialization Parameters頁面中有4個選項卡,其中
Memory 選擇Custom,SGASize 輸入19000,PGASize 輸入8000
Sizing 預設是150,改為2500
Character Sets 選擇Choose from the list of character sets,在下拉框中選擇ZHS16GBK-GBK 16-bit Simplified Chinese字符集。
Connection Mode 預設即可
10、Database Storage,點選Next
11、Creation Options,預設選項
配置完成後點選Finish按鈕
彈出Confirmation,點選OK,即可進入到安裝介面;
當顯示上圖時,表示安裝結束,點選Exit即可。
資料庫測試
在oracle使用者下,先啟動監聽器,並檢視其狀態是否正常
[[email protected] database]$ lsnrctl start
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 28-AUG-2018 09:41:08
Copyright (c) 1991, 2013, Oracle. All rights reserved.
TNS-01106: Listener using listener name LISTENER has already been started
[[email protected] database]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 28-AUG-2018 09:41:25
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oa-orcl)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date 28-AUG-2018 09:10:57
Uptime 0 days 0 hr. 30 min. 28 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0.4/db/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/oa-orcl/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oa-orcl)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "orcl" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclXDB" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully
若在狀態查詢中報錯:The listener supports no services
參考(總結)Oracle啟動監聽報錯:The listener supports no services解決 中的方法一,其中的檔案listener.ora在ORACLE_HOME/network/admin/listener.ora
監聽器正常後,啟動sqlplus
[oracle@oa-orcl database]$ sqlplus / as sysdba
SQL> startup
ORACLE instance started.
Total System Global Area 1.9842E+10 bytes
Fixed Size 2261728 bytes
Variable Size 3355446560 bytes
Database Buffers 1.6442E+10 bytes
Redo Buffers 42962944 bytes
Database mounted.
Database opened.
這樣資料庫就啟動了,之後就可以進行增刪查改等操作了。
注意
在關閉資料庫時,要先shotdown,再退出(exit/quit)