第一步下載問題
centos 下要用wget 下載,發(fā)現(xiàn)老要登錄直接wget 是不行的。
wget --http-user=[oracle網(wǎng)站登錄賬號] --http-password=[oracle 網(wǎng)站登錄密碼] --no-check-certificate --output-document=linux.zseries64_11gR2_database_1of2.zip "https://download.oracle.com/otn/linux/oracle11g/R2/linux.x64_11gR2_database_1of2.zip?AuthParam=1556897560_f2690b16de8954cc6d804e61753c6838"
關鍵就是最后那個 AuthParam 怎么拿到呢?
用Chrome,或者Firefox 直接在?https://oracle.com/technetwork/database/enterprise-edition/downloads/index.html?點擊下載文件,之后暫停下載。chrome://downloads/? 復制出來的鏈接就行了。

第二步解壓問題
cat linux.zseries64_11gR2_database_1of2.zip linux.zseries64_11gR2_database_1of2.zip > linux.zseries64_11gR2_database.zip
unzip linux.zseries64_11gR2_database.zip
第三步依賴解決
yum -y install binutils \
compat-libstdc++-33 \
elfutils-libelf \
elfutils-libelf-devel \
expat \
gcc \
gcc-c++ \
glibc \
glibc-common \
glibc-devel \
glibc-headers \
libaio \
libaio-devel \
libgcc \
libstdc++ \
libstdc++-devel \
make \
pdksh \
sysstat \
unixODBC \
unixODBC-devel
然后是檢查是否有包沒安裝成功
rpm -q binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel expat gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers libaio libaio-devel libgcc libstdc++ libstdc++-devel make pdksh sysstat unixODBC unixODBC-devel|grep "not installed"
centos 7 必定會報?pdksh not? installed
wget http://vault.centos.org/5.11/os/x86_64/CentOS/pdksh-5.2.14-37.el5_8.1.x86_64.rpm
rpm -ivh pdksh-5.2.14-37.el5_8.1.x86_64.rpm
第四步Oracle 用戶設置
添加oracle用戶組及用戶
groupadd oinstall
groupadd dba
groupadd asmadmin
groupadd asmdba
useradd -g oinstall -G dba,asmdba oracle -d /home/oracle
添加完成后,查看oracle用戶
id oracle
初始化oracle用戶的密碼
passwd oracle
限制Oracle 用戶shell權限
修改 Oracle 用戶 ~/.bash_profile
umask 022
export ORACLE_BASE=/apps/svr/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db
export ORACLE_SID=orcl
export TNS_ADMIN=$ORACLE_HOME/network/admin
export ORA_NLS10=$ORACLE_HOME/nls/data
export PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export SQLPATH=$ORACLE_HOME/sqlplus/admin:/home/oracle/admin/sql
ulimit -u 16384 -n 63536 #linux
export ORACLE_HOSTNAME=centos-oracle
export LC_ALL="en_US"
export LANG="en_US"
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"
由于Oracle 官方文檔里面有個 /u01/app/oracle 這樣的例子,結果網(wǎng)上很多都照抄,其實可以不要那個/u01,據(jù)說是為了兼容老機器。
修改/etc/security/limits.conf 添加如下內(nèi)容:?
oracle? ? ? ? ? ? ? soft? ? ?nproc? ?2047
oracle? ? ? ? ? ? ? hard? ? nproc? 16384
oracle? ? ? ? ? ? ? soft? ? ?nofile? ?1024
oracle? ? ? ? ? ? ? hard? ? nofile? ?65536
修改驗證登錄文件
vim /etc/pam.d/login
session required pam_limits.so
session required /lib64/security/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
? ? umask 022
fi
創(chuàng)建oracle軟件安裝目錄
mkdir -p /apps/svr/oracle
chown -R oracle:oinstall?/apps/svr/oracle
chmod -R 775 /opt
內(nèi)核參數(shù)優(yōu)化
kernel.shmmax oracle 文檔說設置為物理內(nèi)存的一半;1073741824 這個值是1G 自己乘一下即可。
其他參數(shù)是Oracle 建議值。
修改/etc/sysctl.conf 文件 添加如下內(nèi)容:
vim?/etc/sysctl.conf?
添加以下參數(shù)
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 4294967296
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
退出編輯后執(zhí)行以下命令應用修改
/sbin/sysctl -p
交換分區(qū)設置(非必有)
由于我在阿里云安裝系統(tǒng)的時候沒有設置交換分區(qū)。在安裝過程中發(fā)現(xiàn)沒有交換分區(qū)走不下去。
于是必須先創(chuàng)建個交換分區(qū)。
交換分區(qū)創(chuàng)建
先檢查一下, 是否已經(jīng)有交換分區(qū)
swapon -s
如沒有則執(zhí)行下面的命令創(chuàng)建,8192 是8G 的意思,Oracle 要求 交換分區(qū) >= 物理內(nèi)存
dd if=/dev/zero of=/swapfile bs=1M count=8192
chown root:root /swapfile
chmod 0600 /swapfile
mkswap /swapfile
swapon /swapfile
啟動自動掛載
vim /etc/fstab
添加這行進去
/swapfile????swap????swap????default???0 0
前戲到這里才結束
為了方便切換 Oracle 用戶 修改 vim ~/.bashrc?
添加這句 alias suo='su - oracle', 然后 source?~/.bashrc?
編輯安裝默認應答文件
應答文件在 解壓包的 response 目錄下。copy 一份出來找個地方放
/apps/svr/etc/response/db_install.rsp 按照下面這個改
https://blog.51cto.com/loofeer/1119713
ORACLE_HOSTNAME 自己配置在 /etc/hosts 里面的值舉個例子
127.0.0.1 centos_oracle
安裝前必定要做的, 指定Oracle 安裝清單保存位置,不然會報錯安裝不下去。
vim /etc/oraInst.loc
添加這兩行
inventory_loc=/apps/svr/oraInventory
inst_group=oinstall
編輯好 db_install.rsp 之后運行cd 到一開始解壓的文件夾我的路徑是/apps/svr/database
su oracle
./runInstaller -silent -debug -force -noconfig -IgnoreSysPreReqs -ignorePrereq -responseFile /apps/svr/etc/response/db_install.rsp
debug 在安裝過程中會展示日志。安裝的時候其實有些錯誤,沒仔細看,回頭補一下【mark】
$ The following configuration scripts need to be executed as the "root" user.
#!/bin/sh
#Root scripts to run
/apps/svr/oracle/product/11.2.0/db/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
su 到root 之后添加兩個環(huán)境變量,不然跑了會報錯。
vim /etc/profile
export ORACLE_OWNER = oracle
export ORACLE_HOME =? /apps/svr/oracle/product/11.2.0/db
網(wǎng)友 文章里有?orainstRoot.sh 這個,需要跑,但是我安裝完沒有這個文件 有點擔心~~
配置默認監(jiān)聽
netca /silent /responsefile /apps/svr/etc/response/netca.rsp
查看監(jiān)聽狀態(tài)
netstat -tnulp | grep 1521
靜默安裝數(shù)據(jù)庫實例
編輯dbca 應答文件
vim?/apps/svr/etc/response/dbca.rsp
主要參考:https://blog.csdn.net/Kenny1993/article/details/75038670
source ~/.bash_profile
dbca -silent -responseFile /apps/svr/etc/response/dbca.rsp
完了之后在命令行輸入
sqlplus / as sysdba 登錄查看實例信息?!具@里也踩了個坑,看問題三】
順便設置 scott 密碼
alter user scott account unlock;
lter user scott identified by tiger;
設置oracle 開機啟動
回到root 用戶,修改 dbstart
vim?$ORACLE_HOME/bin/dbstart
ORACLE_HOME_LISTNER=$ORACLE_HOME
修改 dbshut
vim?$ORACLE_HOME/bin/dbshut
ORACLE_HOME_LISTNER=$ORACLE_HOME
vim /etc/oratab
orcl:/db/app/oracle/product/11.2.0:Y
vim /etc/rc.d/init.d/oracle
輸入以下內(nèi)容,注意修改自己的路徑
#! /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=/apps/svr/oracle/product/11.2.0/db
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
連接Oracle 客戶端
采坑歷程
我遇到也是這個報錯信息
問題1 :
[FATAL] [INS-32035] Unable to create a new central inventory at the specified location.
CAUSE: The central inventory location provided is not empty.
ACTION: Please provide another location for the inventory, or clean up the current location.
問題2:
[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.
問題3
dbstart 報錯
/apps/svr/oracle/product/11.2.0/db/bin/dbstart: Starting up database "orcl"
Sat May? 4 18:51:18 CST 2019
SP2-0642: SQL*Plus internal error state 2021, context 1:1821:0
Unsafe to proceed
SP2-1503: Unable to initialize Oracle call interface
SP2-0152: ORACLE may not be functioning properly
root: Error: Database instance "orcl" NOT started.
發(fā)現(xiàn)是日期環(huán)境變量寫錯了,這個是正確的在 oracle 用戶目錄下的
vim /home/oracle/.bash_profile
export NLS_DATE_FORMAT='YYYY-MON-DD HH24:MI:SS
參考文章
Oracle 官方安裝文檔
https://docs.oracle.com/cd/E11882_01/install.112/e24326/toc.htm#BHCBCFDI
Oracle中文安裝文檔
https://www.oracle.com/technetwork/cn/articles/revitt-oem-096363-zhs.html#2
比較完整的安裝文檔:
http://www.itdecent.cn/p/b4200e721bfd
http://blog.itpub.net/22664653/viewspace-1062585
https://blog.csdn.net/Kenny1993/article/details/75038670
https://blog.51cto.com/niubdada/2164071
分配交換分區(qū)的方法
https://blog.51cto.com/lianlianw/1742472
db_install.rsp 詳細解析
https://blog.51cto.com/loofeer/1119713
創(chuàng)建數(shù)據(jù)庫實例
https://blog.51cto.com/hbxztc/1884833
https://blog.51cto.com/hbxztc/1906532
運行?sqlplus / as sysdba 報錯解決