【Oracle學(xué)習(xí)02】CentOS6靜默安裝Oracle12c

【Oracle學(xué)習(xí)02】CentOS6靜默安裝Oracle12c

文章來源: 陶老師運維筆記- 微信公眾號

oracle_install2.jpg

?? Oracle Database橙数,又名Oracle RDBMS恨樟,或簡稱Oracle。是甲骨文公司的一款關(guān)系型數(shù)據(jù)庫管理系統(tǒng)橙依。

Oracle官方文檔:
https://www.oracle.com/index.html
https://docs.oracle.com/en/database/oracle/oracle-database/index.html
https://docs.oracle.com/en/database/oracle/oracle-database/12.2/install-and-upgrade.html

Oracle12c安裝要求:
硬件: Disk >8G, 內(nèi)存>2G,若安裝 Oracle Grid>8G。

操作系統(tǒng): Linux 7.2: 3.10.0-327.el7.s390x or later, Linux 6.6: 2.6.32-504.el6.s390x or later

軟件包依賴: https://docs.oracle.com/en/database/oracle/oracle-database/12.2/cwlin/supported-red-hat-enterprise-linux-6-distributions-for-x86-64.html#GUID-3B53A308-3EC2-4173-98A0-0FFD68994E90

1. 安裝環(huán)境

1.1 系統(tǒng)環(huán)境

OS Hostname IP 硬件
CentOS6.6 Oracle-01 192.122.132.37 空閑磁盤>8G,內(nèi)存>2G,SWap分區(qū)>2G裙秋。

1.2 軟件下載

下載Oracle12.2.0.1.0版本操软,選擇Linux x86-64安裝包详瑞。(下載需要Oracle賬號)。
https://www.oracle.com/technetwork/cn/database/enterprise-edition/downloads/index.html

下載地址: https://www.oracle.com/database/technologies/oracle12c-linux-12201-downloads.html

oralce

檢查下載文件:

$cksum oracle_linuxx64_12201_database.zip
4170261901 3453696911 oracle_linuxx64_12201_database.zip

上面的輸出信息中校驗碼為 4170261901 , 文件大小為3453696911,和官方圖示相同粘我。

2. 安裝介紹

https://docs.oracle.com/en/database/oracle/oracle-database/12.2/tutorials.html
https://docs.oracle.com/en/database/oracle/oracle-database/12.2/install-and-upgrade.html

2.1 安裝方法

oracle 安裝使用OUI(Oracle Universal Installer )鼓蜒。

OUI介紹 :
https://docs.oracle.com/cd/E26854_01/em.121/e37799/ch1_introduction.htm#OUICG107
https://oracle-base.com/articles/misc/oui-silent-installations
https://www.2cto.com/database/201110/107339.html 深入理解OUI
OUI 三種模式(Modes of Installation):

1) OUI圖形化安裝

Oracle Universal Installer (OUI)圖形化安裝痹换。Interactive Mode

2)靜默安裝

靜默安裝 Silent Mode 都弹。在無圖形界面或命令行批量部署時可靜默(Silent Mode)安裝 oracle ,用命令行創(chuàng)建db,配置netca等,快速完成oracle部署娇豫。

$ORACLE_HOME/runInstaller -h
./runInstaller [-silent] [-noconfig]  -responseFile responsefilename

3)克隆安裝

若是有配置相同的機器需要安裝,這時可以進行clone安裝畅厢。

2.2 安裝目錄

OFA 中有幾個關(guān)鍵目錄需要知道冯痢。介紹: https://blog.csdn.net/m0_37814112/article/details/77373863
如下:

  • oracle inventory 目錄:保存本機上所安裝的Oracle 軟件的目錄清單,本機上安裝的所有Oracle軟件都需要并且共享使用這個目錄框杜。
  • oracle Base 目錄 (ORACLE_BASE):
    Oracle Base 目錄是Oracle軟件安裝的最頂層目錄浦楣。這個目錄下可以安裝多個版本的Oracle軟件,OFA標準里的Oracle Base目錄是這樣的:通尺淙瑁可能這樣:/u01/app/oracle
  • Oracle Home 目錄 (ORACLE_HOME): oracle的產(chǎn)品目錄,類似 /u01/app/oracle/product/11.2.0/db_1
  • Oracle Network 目錄 (TNS_ADMIN)
    Automatic Diagnostic Repository (ADR_HOME) 自動診斷庫
  • GRID 目錄: Grid 的ORACLE_BASE 和ORACLE_HOME有所不同椒振,GRID的ORACLE_HOME不能是ORACLE_BASE的子目錄,否則安裝會報錯梧乘。
  • ORACLE_BASE澎迎、ORACLE_HOME環(huán)境變量
    grid、Oracle 兩個用戶各自的設(shè)置是不同的:
#grid选调、Oracle 兩個用戶各自的設(shè)置是不同的:
$env |grep ORA -i
GRID用戶的環(huán)境變量設(shè)置:
export ORACLE_BASE=/u01/app/grid
export ORACLE_HOME=/u01/app/12.2.0.1/grid
path=$ORACLE_HOME/bin:$PATH:$HOME/bin

oracle 用戶的環(huán)境變量設(shè)置:
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/12.2.0.1/dbhome_1
path=$ORACLE_HOME/bin:$PATH:$HOME/bin

3. 安裝的先決條件

3.1 軟件包準備

依賴軟件: https://docs.oracle.com/en/database/oracle/oracle-database/12.2/cwlin/supported-red-hat-enterprise-linux-6-distributions-for-x86-64.html#GUID-3B53A308-3EC2-4173-98A0-0FFD68994E90

yum install -y bc
yum install -y compat-libcap1*
yum install -y compat-libcap*
yum install -y binutils 
yum install -y compat-libstdc++-33 
yum install -y elfutils-libelf 
yum install -y elfutils-libelf-devel 
yum install -y gcc 
yum install -y gcc-c++ 
yum install -y glibc-2.5 
yum install -y glibc-common 
yum install -y glibc-devel 
yum install -y glibc-headers 
yum install -y ksh libaio 
yum install -y libaio-devel 
yum install -y libgcc 
yum install -y libstdc++ 
yum install -y libstdc++-devel 
yum install -y make 
yum install -y sysstat 
yum install -y unixODBC 
yum install -y unixODBC-devel
yum install -y binutils*
yum install -y compat-libstdc*
yum install -y elfutils-libelf*
yum install -y gcc*
yum install -y glibc*
yum install -y ksh*
yum install -y libaio*
yum install -y libgcc*
yum install -y libstdc*
yum install -y make*
yum install -y sysstat*
yum install -y libXp*
yum install -y glibc-kernheaders
yum install -y net-tools-*

或?qū)懺谝黄稹?br> 檢查軟件包安裝情況:

$rpm -q --queryformat "%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n"  \
bc compat-libcap1* compat-libcap* binutils  compat-libstdc++-33  elfutils-libelf  elfutils-libelf-devel  gcc  gcc-c++  glibc-2.5  glibc-common  glibc-devel  glibc-headers  ksh libaio  libaio-devel  libgcc  libstdc++  libstdc++-devel  make  sysstat  unixODBC  unixODBC-devel binutils* compat-libstdc* elfutils-libelf*  glibc* ksh* libaio* libgcc* libstdc* sysstat* libXp* glibc-kernheaders net-tools-* \
| grep not | grep -v grep | awk '{print "yum install -y " $2 }'

#結(jié)果,缺少的軟件包就會列出來,如下夹供。
...
yum install -y glibc-2.5
yum install -y gcc*

3.2 修改OS參數(shù)

3.2.1 修改內(nèi)核參數(shù)

修改/etc/sysctl.conf 在末尾加上如下代碼。

$vim /etc/sysctl.conf 
kernel.shmmax = 277495689510912
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048586
fs.file-max = 6815744
kernel.shmall = 4294967296
net.ipv4.tcp_max_tw_buckets = 6000
net.ipv4.ip_local_port_range = 9000 65500
net.ipv4.tcp_tw_recycle = 0
net.ipv4.tcp_tw_reuse = 1
net.core.somaxconn = 262144
net.core.netdev_max_backlog = 262144
net.ipv4.tcp_max_orphans = 262144
net.ipv4.tcp_max_syn_backlog = 262144
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 1
net.ipv4.tcp_fin_timeout = 1
net.ipv4.tcp_keepalive_time = 30
net.ipv4.tcp_keepalive_probes = 6
net.ipv4.tcp_keepalive_intvl = 5
net.ipv4.tcp_timestamps = 0
fs.aio-max-nr = 1048576
net.ipv4.conf.all.rp_filter = 2
net.ipv4.conf.default.rp_filter = 2

#檢查配置
$/etc/sysctl.conf |grep -v '#' |grep -v '^$'

修改后使之生效執(zhí)行如下代碼仁堪。

$sysctl -p

3.2.2 修改文件 limits.conf

$vi /etc/security/limits.conf

oracle   soft   nofile    1024
oracle   hard   nofile    65536
oracle   soft   nproc    16384
oracle   hard   nproc    16384
oracle   soft   stack    10240
oracle   hard   stack    32768
oracle   hard   memlock    134217728
oracle   soft   memlock    134217728

3.2.3 修改 /etc/pam.d/login

增加如下兩條

vim /etc/pam.d/login
session required /lib64/security/pam_limits.so
session required pam_limits.so

3.2.4 關(guān)閉SELINUX

$vi /etc/selinux/config
# 將`SELINUX`修改為disabled
SELINUX=disabled
SELINUXTYPE=targeted
#臨時關(guān)閉
$setenforce 0 

3.2.5 禁用防火墻

為了避免不必要的問題哮洽,可以關(guān)閉防火墻。

iptables -L
cat  /etc/sysconfig/iptables
iptables-save > /etc/sysconfig/iptables
#永久關(guān)閉防火墻
service iptables stop
chkconfig iptables off
service ip6tables stop
chkconfig ip6tables off
##centos7 
systemctl stop firewalld
systemctl disable firewalld

4. 創(chuàng)建用戶及組

4.1 創(chuàng)建用戶及安裝目錄

創(chuàng)建用戶:

#添加用戶組:(組id最好在500以后的值弦聂, 500前為系統(tǒng)用戶鸟辅。)
$groupadd -g 54321 oinstall
$groupadd -g 54322 dba
$groupadd -g 54323 oper
#groupadd oracle
$useradd -g oinstall -G dba,oper oracle
#
$id oracle 
uid=54321(oracle) gid=54321(oinstall) groups=54321(oinstall),54322(dba),54323(oper)
#usermod -a -G GroupName UserName

創(chuàng)建oracle安裝目錄:
官方是類似/u01/app/oracle目錄,但是作者是data1磁盤最大莺葫,安裝在data1盤中匪凉。如下:

#mkdir -p /u01/app/oracle
#環(huán)境是data1盤最大,沒有安裝在/
mkdir -p /data1/u01/app/oracle
mkdir -p /data1/u01/app/oraInventory
ln -s /data1/u01 /u01
chown -R oracle.oinstall /data1/u01
chmod -R 775 /data1/u01/app/oracle
chown -R oracle.oinstall /u01

修改oracle用戶的密碼:

$passwd oracle  #oracleoracle

說明:不必非要叫oinstall捺檬,和dba再层,只不過一般文檔上就這么叫:oinstall組用于安裝數(shù)據(jù)庫 , dba組用于管理數(shù)據(jù)庫。-g表示這個用戶的主組 , -G標識這個用戶的其它組堡纬。一個用戶可以屬于多個用戶組聂受,但是一個用戶只能指定一個組作為其主組。

5. Oracle環(huán)境變量

su - oracle 切換到oracle賬戶烤镐,修改 .bash_profile 文件,$env |grep ORA -i查看蛋济。

su - oracle
vim /home/oracle/.bash_profile  
#oracle
export EDITOR=vi
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_SID=orcl
export ORACLE_BASE=/data1/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/12.2.0.1/db_1
export INVENTORY_LOCATION=/data1/u01/app/oraInventory
export TNS_ADMIN=$ORACLE_HOME/network/admin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss'
export PATH=$ORACLE_HOME/bin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:$PATH:$HOME/bin
umask 022
#export PS1=$LOGNAME@`hostname`:'$PWD>'
export SQLPATH=$ORACLE_HOME/sqlplus/admin:/home/oracle/admin/sql
alias ohome="cd $ORACLE_HOME"
alias sql='sqlplus "/"'
alias sqln="sqlplus /nolog"
#生效
$source .bash_profile
$env |grep ORA -i
#測試umask
$umask -S

6. Oracle靜默安裝

6.1 上傳軟件

將下載的linuxx64_12201_database.zip上傳到Linux系統(tǒng)/home/oracle目錄下解壓,解壓后目錄為database炮叶。

cd /home/oracle
wget 'xxx' 
unzip linuxx64_12201_database.zip

6.2 修改靜默響應(yīng)文件

6.2.1 配置說明

靜默響應(yīng)文件位于database/response/db_install.rsp 碗旅。數(shù)據(jù)庫安裝響應(yīng)文件db_install.rsp修改的地方鹊杖,參見Oracle Universal Installer (OUI) Silent Installations中12cR2進行設(shè)置。

靜默安裝的參數(shù)含義:

https://oracle-base.com/articles/misc/12cR2.rsp
https://oracle-base.com/articles/misc/oui-silent-installations
https://docs.oracle.com/cd/E26854_01/em.121/e37799/ch3_response_file.htm#OUICG184

oracle  軟件靜默安裝的參數(shù)含義如下:
-silent       表示以靜默方式安裝,不會有任何提示
-force        表示允許安裝到一個非空目錄
-noconfig     表示不運行配置助手netca
-responseFile 表示使用哪個響應(yīng)文件,必需使用絕對路徑
oracle.install.responseFileVersion  響應(yīng)文件模板的版本,該參數(shù)不要更改
oracle.install.option               安裝模式選項,本例只安裝oracle軟件,該參數(shù)不要更改
DECLINE_SECURITY_UPDATES            是否需要在線安全更新,設(shè)置為false,該參數(shù)不要更改
UNIX_GROUP_NAME oracle              用戶用于安裝軟件的組名
INVENTORY_LOCATION                  oracle 產(chǎn)品清單目錄
SELECTED_LANGUAGES                  oracle 運行語言環(huán)境,一般包括引文和簡繁體中文
ORACLE_HOME                         oracle安裝目錄
ORACLE_BASE                         oracle基礎(chǔ)目錄
oracle.install.db.InstallEdition    安裝版本類型,一般是企業(yè)版
oracle.install.db.isCustomInstall   是否定制安裝,默認Partitioning,OLAP,RAT都選上扛芽。根據(jù)自己的需要選擇組件骂蓖。
oracle.install.db.customComponents  定制安裝組件列表:除了以上默認的,可加上Label Security和Database Vault
oracle.install.db.DBA_GROUP         oracle 用戶用于授予osdba權(quán)限的組名
oracle.install.db.OPER_GROUP        oracle 用戶用于授予osoper權(quán)限的組名

6.2.2 修改響應(yīng)文件

可以使用軟件帶的db_install.rsp修改,但為了簡單直接使用https://oracle-base.com/articles/misc/12cR2.rsp 進行修改川尖。
12cR2.rsp文件:

#解壓軟件后的db_install.rsp
$cat response/db_install.rsp |grep -v '#' |grep -v '^$' |grep -v '=$'
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v12.2.0

#把https://oracle-base.com/articles/misc/12cR2.rsp 下載放在~/12cR2.rsp
$cat ~/12cR2.rsp |grep -v '#' |grep -v '^$' 
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v12.2.0
oracle.install.option=INSTALL_DB_SWONLY
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u01/app/oraInventory
ORACLE_HOME=/u01/app/oracle/product/12.2.0.1/db_1
ORACLE_BASE=/u01/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.OSDBA_GROUP=dba
oracle.install.db.OSOPER_GROUP=dba
oracle.install.db.OSBACKUPDBA_GROUP=dba
oracle.install.db.OSDGDBA_GROUP=dba
oracle.install.db.OSKMDBA_GROUP=dba
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false
DECLINE_SECURITY_UPDATES=true

修改:
修改Response File登下,把INVENTORY_LOCATION,ORACLE_HOME,ORACLE_BASE目錄修改下就可。 讀者依自已實際路徑情況修改叮喳!

cp  12cR2.rsp ~/12cR2_u01.rsp
vim  ~/12cR2_u01.rsp 
#增加data1
INVENTORY_LOCATION=/data1/u01/app/oraInventory  
ORACLE_HOME=/data1/u01/app/oracle/product/12.2.0.1/db_1  
ORACLE_BASE=/data1/u01/app/oracle   

12cR2_u01.rsp

最終響應(yīng)文件配置:
最終12cR2_u01.rsp文件如下被芳。

$cat 12cR2_u01.rsp |grep -v '#' |grep -v '^$' 
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v12.2.0
oracle.install.option=INSTALL_DB_SWONLY
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/data1/u01/app/oraInventory
ORACLE_HOME=/data1/u01/app/oracle/product/12.2.0.1/db_1
ORACLE_BASE=/data1/u01/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.OSDBA_GROUP=dba
oracle.install.db.OSOPER_GROUP=dba
oracle.install.db.OSBACKUPDBA_GROUP=dba
oracle.install.db.OSDGDBA_GROUP=dba
oracle.install.db.OSKMDBA_GROUP=dba
oracle.install.db.OSRACDBA_GROUP=
oracle.install.db.rac.configurationType=
oracle.install.db.CLUSTER_NODES=
oracle.install.db.isRACOneInstall=
oracle.install.db.racOneServiceName=
oracle.install.db.rac.serverpoolName=
oracle.install.db.rac.serverpoolCardinality=
oracle.install.db.config.starterdb.type=
oracle.install.db.config.starterdb.globalDBName=
oracle.install.db.config.starterdb.SID=
oracle.install.db.ConfigureAsContainerDB=
oracle.install.db.config.PDBName=
oracle.install.db.config.starterdb.characterSet=
oracle.install.db.config.starterdb.memoryOption=
oracle.install.db.config.starterdb.memoryLimit=
oracle.install.db.config.starterdb.installExampleSchemas=
oracle.install.db.config.starterdb.password.ALL=
oracle.install.db.config.starterdb.password.SYS=
oracle.install.db.config.starterdb.password.SYSTEM=
oracle.install.db.config.starterdb.password.DBSNMP=
oracle.install.db.config.starterdb.password.PDBADMIN=
oracle.install.db.config.starterdb.managementOption=
oracle.install.db.config.starterdb.omsHost=
oracle.install.db.config.starterdb.omsPort=
oracle.install.db.config.starterdb.emAdminUser=
oracle.install.db.config.starterdb.emAdminPassword=
oracle.install.db.config.starterdb.enableRecovery=
oracle.install.db.config.starterdb.storageType=
oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=
oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=
oracle.install.db.config.asm.diskGroup=
oracle.install.db.config.asm.ASMSNMPPassword=
MYORACLESUPPORT_USERNAME=
MYORACLESUPPORT_PASSWORD=
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false
DECLINE_SECURITY_UPDATES=true
PROXY_HOST=
PROXY_PORT=
PROXY_USER=
PROXY_PWD=
COLLECTOR_SUPPORTHUB_URL=

6.3 執(zhí)行靜默安裝

6.3.1檢查響應(yīng)文件

檢查12cR2_u01.rsp及.bash_profile 文件中路徑設(shè)置是否一致。

$cat /home/oracle/.bash_profile 
$cat 12cR2_u01.rsp |grep -v '#' |grep -v '^$' |grep -v '=$'

6.3.2執(zhí)行安裝

示例: https://oracle-base.com/articles/misc/oui-silent-installations

#[https://oracle-base.com/articles/misc/oui-silent-installations](https://oracle-base.com/articles/misc/oui-silent-installations)
#The OS group name parameters were renamed in 12cR2 to include a prefix of "OS" and the OSRACDBA parameter is now mandatory, as shown below.
# 12cR2.
$./runInstaller -ignoreSysPrereqs -ignorePrereq -waitforcompletion -showProgress -silent \
    -responseFile /tmp/database/response/db_install.rsp \
    oracle.install.option=INSTALL_DB_SWONLY \
    ORACLE_HOSTNAME=${ORACLE_HOSTNAME} \
    UNIX_GROUP_NAME=oinstall \
    INVENTORY_LOCATION=${ORA_INVENTORY} \
    SELECTED_LANGUAGES=en,en_GB \
    ORACLE_HOME=${ORACLE_HOME} \
    ORACLE_BASE=${ORACLE_BASE} \
    oracle.install.db.InstallEdition=EE \
    oracle.install.db.OSDBA_GROUP=dba \
    oracle.install.db.OSBACKUPDBA_GROUP=dba \
    oracle.install.db.OSDGDBA_GROUP=dba \
    oracle.install.db.OSKMDBA_GROUP=dba \
    oracle.install.db.OSRACDBA_GROUP=dba \
    SECURITY_UPDATES_VIA_MYORACLESUPPORT=false \
    DECLINE_SECURITY_UPDATES=true

執(zhí)行安裝:
把示例中的變量進行更換即可馍悟。 命令行的設(shè)置優(yōu)先級高于xx.rsp文件畔濒。所以也可以直接用12cR2.rsp文件!

$./runInstaller -ignoreSysPrereqs -ignorePrereq -waitforcompletion -showProgress -silent \
    -responseFile /home/oracle/12cR2.rsp \
    oracle.install.option=INSTALL_DB_SWONLY \
    ORACLE_HOSTNAME=Oracle-01 \
    UNIX_GROUP_NAME=oinstall \
    INVENTORY_LOCATION=/data1/u01/app/oraInventory \
    SELECTED_LANGUAGES=en,en_GB \
    ORACLE_HOME=/data1/u01/app/oracle/product/12.2.0.1/db_1 \
    ORACLE_BASE=/data1/u01/app/oracle \
    oracle.install.db.InstallEdition=EE \
    oracle.install.db.OSDBA_GROUP=dba \
    oracle.install.db.OSBACKUPDBA_GROUP=dba \
    oracle.install.db.OSDGDBA_GROUP=dba \
    oracle.install.db.OSKMDBA_GROUP=dba \
    oracle.install.db.OSRACDBA_GROUP=dba \
    SECURITY_UPDATES_VIA_MYORACLESUPPORT=false \
    DECLINE_SECURITY_UPDATES=true

#
Checking Temp space: must be greater than 500 MB.   Actual 5498 MB    Passed
Checking swap space: must be greater than 150 MB.   Actual 8391 MB    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2019-11-13_02-57-42PM. 
Please wait ...You can find the log of this install session at:
 /data1/u01/app/oraInventory/logs/installActions2019-11-13_02-57-42PM.log

Prepare in progress.
..................................................   8% Done.

Prepare successful.

Copy files in progress.
..................................................   17% Done.
..................................................   22% Done.
...
..................................................   75% Done.
..................................................   80% Done.
....................
Copy files successful.

Link binaries in progress.
..........
Link binaries successful.

Setup files in progress.
..............................
Setup files successful.

Setup Inventory in progress.

Setup Inventory successful.

Finish Setup successful.
The installation of Oracle Database 12c was successful.
Please check '/data1/u01/app/oraInventory/logs/silentInstall2019-11-13_02-57-42PM.log' for more details.

Setup Oracle Base in progress.

Setup Oracle Base successful.
..................................................   95% Done.

As a root user, execute the following script(s):
        1. /data1/u01/app/oraInventory/orainstRoot.sh
        2. /data1/u01/app/oracle/product/12.2.0.1/db_1/root.sh

執(zhí)行腳本:

$sh  /data1/u01/app/oraInventory/orainstRoot.sh
Changing permissions of /data1/u01/app/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.
Changing groupname of /data1/u01/app/oraInventory to oinstall.
The execution of the script is complete.
##
$sh /data1/u01/app/oracle/product/12.2.0.1/db_1/root.sh
Check /data1/u01/app/oracle/product/12.2.0.1/db_1/install/root_Oracle-02_2019-11-13_17-21-28-301583782.log for the output of root script
#
$tail -f /data1/u01/app/oracle/product/12.2.0.1/db_1/install/root_Oracle-02_2019-11-13_17-21-28-301583782.log
   Copying oraenv to /usr/local/bin ...
   Copying coraenv to /usr/local/bin ...
Creating /etc/oratab file...
Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root script.
Now product-specific root actions will be performed.
Oracle Trace File Analyzer (TFA) is available at : /data1/u01/app/oracle/product/12.2.0.1/db_1/suptools/tfa/release/tfa_home/bin/tfactl 

6.3.3 測試結(jié)果

目錄結(jié)構(gòu):

$cd /data1/u01/app
$tree -L 2
.
├── oracle
│   ├── checkpoints
│   ├── diag
│   └── product
└── oraInventory
    ├── ContentsXML
    ├── logs
    ├── oraInst.loc
    ├── orainstRoot.sh
    └── oui

sqlplus登錄:
執(zhí)行命令su - oracle ; sqlplus / as sysdba

$su - oracle
$sqlplus -v 
$sqlplus / as sysdba
Connected to an idle instance.
SQL> 

$ps aux |grep ora -i
oracle   11627  0.0  0.0 115800 12904 pts/0    S+   17:45   0:00 sqlplus   as sysdba
oracle   11630  0.0  0.0 432292 17820 ?        Ss   17:45   0:00 oracleorcl (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))

7.創(chuàng)建數(shù)據(jù)庫

可以使用DBCA或OMF等方式建數(shù)據(jù)庫锣咒。

7.1 DBCA 靜默建庫

https://docs.oracle.com/database/121/ADMIN/create.htm#ADMIN11124
數(shù)據(jù)庫配置助手DBCA靜默模式下創(chuàng)建數(shù)據(jù)庫:

$dbca  -help
$cat $ORACLE_HOME/dbs/init.ora #查看參數(shù)侵状。
#totalMemory設(shè)置為8G,
$dbca -silent -createDatabase \
 -templateName $ORACLE_HOME/assistants/dbca/templates/General_Purpose.dbc \
 -gdbname cdb1 -sid cdb1 -responseFile NO_VALUE \
 -characterSet AL32UTF8 \
 -sysPassword OraPasswd1 \
 -systemPassword OraPasswd1 \
 -createAsContainerDatabase true \
 -numberOfPDBs 1 \
 -pdbName pdb1 \
 -pdbAdminPassword OraPasswd1 \
 -databaseType MULTIPURPOSE \
 -automaticMemoryManagement false \
 -totalMemory 8192 \
 -storageType FS \
 -datafileDestination "/data1/u01/app/oracle/oradata/" \
 -useOMF true \
 -redoLogFileSize 50 \
 -emConfiguration NONE \
 -ignorePreReqs

##輸出信息
Copying database files
1% complete
13% complete
25% complete
Creating and starting Oracle instance
26% complete
Creating Pluggable Databases
55% complete
75% complete
Executing Post Configuration Actions
100% complete
Look at the log file "/data1/u01/app/oracle/cfgtoollogs/dbca/cdb1/cdb10.log" for further details.
#查看
$tail -f /data1/u01/app/oracle/cfgtoollogs/dbca/cdb1/cdb10.log
 /data1/u01/app/oracle/cfgtoollogs/dbca/cdb1.
Database Information:
Global Database Name:cdb1
System Identifier(SID):cdb1

說明: 命令中的totalMemory不能小于2G,否則會失敗毅整。

結(jié)果:

sqlplus / as sysdba

啟動TNSLSNR:

lsnrctl start
LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 14-NOV-2019 14:46:46
Copyright (c) 1991, 2016, Oracle.  All rights reserved.
Starting /data1/u01/app/oracle/product/12.2.0.1/db_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Log messages written to /data1/u01/app/oracle/diag/tnslsnr/Oracle-02/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=Oracle-02)(PORT=1521)))

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date                14-NOV-2019 14:46:48
Uptime                    0 days 0 hr. 0 min. 1 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Log File         /data1/u01/app/oracle/diag/tnslsnr/Oracle-02/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=Oracle-02)(PORT=1521)))
The listener supports no services
The command completed successfully

lsnrctl status:

lsnrctl status

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 14-NOV-2019 14:48:53
Copyright (c) 1991, 2016, Oracle.  All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date                14-NOV-2019 14:46:48
Uptime                    0 days 0 hr. 2 min. 6 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Log File         /data1/u01/app/oracle/diag/tnslsnr/Oracle-02/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=Oracle-02)(PORT=1521)))
Services Summary...
Service "973d59cd17000978e05326847a0a1556" has 1 instance(s).
  Instance "cdb1", status READY, has 1 handler(s) for this service...
Service "cdb1" has 1 instance(s).
  Instance "cdb1", status READY, has 1 handler(s) for this service...
Service "cdb1XDB" has 1 instance(s).
  Instance "cdb1", status READY, has 1 handler(s) for this service...
Service "pdb1" has 1 instance(s).
  Instance "cdb1", status READY, has 1 handler(s) for this service...
The command completed successfully

7.2 OMF建庫

OMF全稱“Oracle managed file”趣兄。

7.3 web方式建庫

8.問題處理

8.1 問題1 : Users With Same UID:.

現(xiàn)象:Users With Same UID: 0: This test checks that multiple users do not exist with user id as "0".

$./runInstaller -force -silent -noconfig -responseFile /home/oracle/oracle12g/database/db_install.rsp

$tail -f xx.log
INFO: Using default Validator configured in the Action class oracle.install.ivw.db.action.PrereqAction
INFO: ------------------List of failed Tasks------------------
INFO: *********************************************
INFO: Swap Size: This is a prerequisite condition to test whether sufficient total swap space is available on the system.
INFO: Severity:IGNORABLE
INFO: OverallStatus:VERIFICATION_FAILED
INFO: *********************************************
INFO: Users With Same UID: 0: This test checks that multiple users do not exist with user id as "0".
INFO: Severity:CRITICAL
INFO: OverallStatus:VERIFICATION_FAILED
INFO: -----------------End of failed Tasks List----------------
INFO: Adding ExitStatus PREREQUISITES_NOT_MET to the exit status set
SEVERE: [FATAL] [INS-13013] Target environment does not meet some mandatory requirements.

原因:
有相同的UID 0。0:超級用戶 UID悼嫉,1-500為系統(tǒng)用戶,>500為普通用戶艇潭。
解決:
修改沖突的UID。發(fā)現(xiàn)果然有沖突如下戏蔑,把沖突的leadmin uid,gid改為非0蹋凝。

cat /etc/passwd|grep 'x:0:0:'   
root:x:0:0:root:/root:/bin/bash
leadmin:x:0:0:lele:/home/lele:/bin/bash

8.2 問題2 oraInventory/ is being used as a source by another session

https://blog.dbi-services.com/severeoui-10020the-target-area-u01apporacleorainventory-is-being-used-as-a-source-by-another-session/
http://blog.itpub.net/17252115/viewspace-1378059/

現(xiàn)象:

出錯信息:
oraInventory/ is being used as a source by another session

原因:
原因較多種各不同如下。作者遇到的是因為目錄為/data1/u01/app并ln 到/u01总棵。就以為可以直接寫軟鏈路徑/u01/app/oraInventory做為INVENTORY_LOCATION鳍寂,結(jié)果出錯如提示(正確該寫INVENTORY_LOCATION=/data1/u01/app/oraInventory)。

  • INVENTORY_LOCATION=/u01/app/oracle/oraInventory 寫成/u01/app/oracle/oraInventory/ 多寫'/'號彻舰。
  • Specific software is holding a lock on the OraInventory file.
  • Someone else is running an Oracle installation at the same time from the same Oracle_home
  • INVENTORY_LOCATION使用軟鏈目錄地址伐割,不是絕對路徑。

解決:
依出錯可能分別相應(yīng)解決刃唤。

8.3 ORA-00821: Specified value of sga_target xx M is too small

現(xiàn)象:
dbca -silent -createDatabase時提示sga_target is too small。出錯ORA-00821: Specified value of sga_target 1152M is too small, needs to be at least 1936M

$dbca -silent -createDatabase xxx
 -automaticMemoryManagement false \
 -totalMemory 1536 \
...
Copying database files
1% complete
2% complete
DBCA Operation failed.
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/cdb1/cdb1.log" for further details.

原因:
查看日志可以看到是內(nèi)存分配太小的原因白群。

#查看日志
tail /u01/app/oracle/cfgtoollogs/dbca/cdb1/cdb1.log
[ 2019-11-13 18:40:51.621 CST ] Copying database files
DBCA_PROGRESS : 1%
[ 2019-11-13 18:40:52.812 CST ] ORA-00821: Specified value of sga_target 1152M is too small, needs to be at least 1936M

解決:
在dbca時直接指定較大的totalMemory,或者修改$ORACLE_HOME/dbs/init.ora中memory_target=1G配置尚胞。

#ORACLE_HOME/dbs/init.ora 
cp $ORACLE_HOME/dbs/init.ora $ORACLE_HOME/dbs//init.ora.org 
vim $ORACLE_HOME/dbs/init.ora

參考:


陶老師運維筆記
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市帜慢,隨后出現(xiàn)的幾起案子笼裳,更是在濱河造成了極大的恐慌唯卖,老刑警劉巖,帶你破解...
    沈念sama閱讀 219,366評論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件躬柬,死亡現(xiàn)場離奇詭異拜轨,居然都是意外死亡,警方通過查閱死者的電腦和手機允青,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,521評論 3 395
  • 文/潘曉璐 我一進店門橄碾,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人颠锉,你說我怎么就攤上這事法牲。” “怎么了琼掠?”我有些...
    開封第一講書人閱讀 165,689評論 0 356
  • 文/不壞的土叔 我叫張陵拒垃,是天一觀的道長。 經(jīng)常有香客問我瓷蛙,道長悼瓮,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,925評論 1 295
  • 正文 為了忘掉前任艰猬,我火速辦了婚禮谤牡,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘姥宝。我一直安慰自己翅萤,他們只是感情好,可當我...
    茶點故事閱讀 67,942評論 6 392
  • 文/花漫 我一把揭開白布腊满。 她就那樣靜靜地躺著套么,像睡著了一般。 火紅的嫁衣襯著肌膚如雪碳蛋。 梳的紋絲不亂的頭發(fā)上胚泌,一...
    開封第一講書人閱讀 51,727評論 1 305
  • 那天,我揣著相機與錄音肃弟,去河邊找鬼玷室。 笑死,一個胖子當著我的面吹牛笤受,可吹牛的內(nèi)容都是我干的穷缤。 我是一名探鬼主播,決...
    沈念sama閱讀 40,447評論 3 420
  • 文/蒼蘭香墨 我猛地睜開眼箩兽,長吁一口氣:“原來是場噩夢啊……” “哼津肛!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起汗贫,我...
    開封第一講書人閱讀 39,349評論 0 276
  • 序言:老撾萬榮一對情侶失蹤身坐,失蹤者是張志新(化名)和其女友劉穎秸脱,沒想到半個月后,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體部蛇,經(jīng)...
    沈念sama閱讀 45,820評論 1 317
  • 正文 獨居荒郊野嶺守林人離奇死亡摊唇,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,990評論 3 337
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了涯鲁。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片巷查。...
    茶點故事閱讀 40,127評論 1 351
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖撮竿,靈堂內(nèi)的尸體忽然破棺而出吮便,到底是詐尸還是另有隱情,我是刑警寧澤幢踏,帶...
    沈念sama閱讀 35,812評論 5 346
  • 正文 年R本政府宣布髓需,位于F島的核電站,受9級特大地震影響房蝉,放射性物質(zhì)發(fā)生泄漏僚匆。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 41,471評論 3 331
  • 文/蒙蒙 一搭幻、第九天 我趴在偏房一處隱蔽的房頂上張望咧擂。 院中可真熱鬧,春花似錦檀蹋、人聲如沸松申。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,017評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽贸桶。三九已至,卻和暖如春桌肴,著一層夾襖步出監(jiān)牢的瞬間皇筛,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,142評論 1 272
  • 我被黑心中介騙來泰國打工坠七, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留水醋,地道東北人。 一個月前我還...
    沈念sama閱讀 48,388評論 3 373
  • 正文 我出身青樓彪置,卻偏偏與公主長得像拄踪,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子悉稠,可洞房花燭夜當晚...
    茶點故事閱讀 45,066評論 2 355

推薦閱讀更多精彩內(nèi)容