【Oracle学习02】CentOS6静默安装Oracle12c
文章来源: 陶老师运维笔记- 微信公众号
Oracle Database,又名Oracle RDBMS,或简称Oracle。是甲骨文公司的一款关系型数据库管理系统。
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, 内存>2G,若安装 Oracle Grid>8G。操作系统: 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. 安装环境
1.1 系统环境
OS | Hostname | IP | 硬件 |
---|---|---|---|
CentOS6.6 | Oracle-01 | 192.122.132.37 | 空闲磁盘>8G,内存>2G,SWap分区>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
检查下载文件:
$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):
- Interactive Mode
- Suppressed-Interactive Mode
- Silent Mode
1) OUI图形化安装
Oracle Universal Installer (OUI)图形化安装。Interactive Mode。
2)静默安装
静默安装 Silent Mode 。在无图形界面或命令行批量部署时可静默(Silent Mode)安装 oracle ,用命令行创建db,配置netca等,快速完成oracle部署。
$ORACLE_HOME/runInstaller -h
./runInstaller [-silent] [-noconfig] -responseFile responsefilename
3)克隆安装
若是有配置相同的机器需要安装,这时可以进行clone安装。
2.2 安装目录
OFA 中有几个关键目录需要知道。介绍: 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的产品目录,类似 /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环境变量
grid、Oracle 两个用户各自的设置是不同的:
#grid、Oracle 两个用户各自的设置是不同的:
$env |grep ORA -i
GRID用户的环境变量设置:
export ORACLE_BASE=/u01/app/grid
export ORACLE_HOME=/u01/app/12.2.0.1/grid
path=$ORACLE_HOME/bin:$PATH:$HOME/bin
oracle 用户的环境变量设置:
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-*
或写在一起。
检查软件包安装情况:
$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 }'
#结果,缺少的软件包就会列出来,如下。
...
yum install -y glibc-2.5
yum install -y gcc*
3.2 修改OS参数
3.2.1 修改内核参数
修改/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 '^$'
修改后使之生效执行如下代码。
$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 关闭SELINUX
$vi /etc/selinux/config
# 将`SELINUX`修改为disabled
SELINUX=disabled
SELINUXTYPE=targeted
#临时关闭
$setenforce 0
3.2.5 禁用防火墙
为了避免不必要的问题,可以关闭防火墙。
iptables -L
cat /etc/sysconfig/iptables
iptables-save > /etc/sysconfig/iptables
#永久关闭防火墙
service iptables stop
chkconfig iptables off
service ip6tables stop
chkconfig ip6tables off
##centos7
systemctl stop firewalld
systemctl disable firewalld
4. 创建用户及组
4.1 创建用户及安装目录
创建用户:
#添加用户组:(组id最好在500以后的值, 500前为系统用户。)
$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
创建oracle安装目录:
官方是类似/u01/app/oracle目录,但是作者是data1磁盘最大,安装在data1盘中。如下:
#mkdir -p /u01/app/oracle
#环境是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组用于安装数据库 , dba组用于管理数据库。-g表示这个用户的主组 , -G标识这个用户的其它组。一个用户可以属于多个用户组,但是一个用户只能指定一个组作为其主组。
5. Oracle环境变量
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系统/home/oracle目录下解压,解压后目录为database。
cd /home/oracle
wget 'xxx'
unzip linuxx64_12201_database.zip
6.2 修改静默响应文件
6.2.1 配置说明
静默响应文件位于database/response/db_install.rsp 。数据库安装响应文件db_install.rsp修改的地方,参见Oracle Universal Installer (OUI) Silent Installations中12cR2进行设置。
静默安装的参数含义:
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 软件静默安装的参数含义如下:
-silent 表示以静默方式安装,不会有任何提示
-force 表示允许安装到一个非空目录
-noconfig 表示不运行配置助手netca
-responseFile 表示使用哪个响应文件,必需使用绝对路径
oracle.install.responseFileVersion 响应文件模板的版本,该参数不要更改
oracle.install.option 安装模式选项,本例只安装oracle软件,该参数不要更改
DECLINE_SECURITY_UPDATES 是否需要在线安全更新,设置为false,该参数不要更改
UNIX_GROUP_NAME oracle 用户用于安装软件的组名
INVENTORY_LOCATION oracle 产品清单目录
SELECTED_LANGUAGES oracle 运行语言环境,一般包括引文和简繁体中文
ORACLE_HOME oracle安装目录
ORACLE_BASE oracle基础目录
oracle.install.db.InstallEdition 安装版本类型,一般是企业版
oracle.install.db.isCustomInstall 是否定制安装,默认Partitioning,OLAP,RAT都选上。根据自己的需要选择组件。
oracle.install.db.customComponents 定制安装组件列表:除了以上默认的,可加上Label Security和Database Vault
oracle.install.db.DBA_GROUP oracle 用户用于授予osdba权限的组名
oracle.install.db.OPER_GROUP oracle 用户用于授予osoper权限的组名
6.2.2 修改响应文件
可以使用软件带的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文件如下。
$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 执行静默安装
6.3.1检查响应文件
检查12cR2_u01.rsp及.bash_profile 文件中路径设置是否一致。
$cat /home/oracle/.bash_profile
$cat 12cR2_u01.rsp |grep -v '#' |grep -v '^$' |grep -v '=$'
6.3.2执行安装
示例: 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
执行安装:
把示例中的变量进行更换即可。 命令行的设置优先级高于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
执行脚本:
$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 测试结果
目录结构:
$cd /data1/u01/app
$tree -L 2
.
├── oracle
│ ├── checkpoints
│ ├── diag
│ └── product
└── oraInventory
├── ContentsXML
├── logs
├── oraInst.loc
├── orainstRoot.sh
└── oui
sqlplus登录:
执行命令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.创建数据库
可以使用DBCA或OMF等方式建数据库。
7.1 DBCA 静默建库
https://docs.oracle.com/database/121/ADMIN/create.htm#ADMIN11124
数据库配置助手DBCA静默模式下创建数据库:
$dbca -help
$cat $ORACLE_HOME/dbs/init.ora #查看参数。
#totalMemory设置为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,否则会失败。
结果:
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:.
现象: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为系统用户,>500为普通用户。
解决:
修改冲突的UID。发现果然有冲突如下,把冲突的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/
现象:
出错信息:
oraInventory/ is being used as a source by another session
原因:
原因较多种各不同如下。作者遇到的是因为目录为/data1/u01/app并ln 到/u01。就以为可以直接写软链路径/u01/app/oraInventory做为INVENTORY_LOCATION,结果出错如提示(正确该写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使用软链目录地址,不是绝对路径。
解决:
依出错可能分别相应解决。
8.3 ORA-00821: Specified value of sga_target xx M is too small
现象:
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.
原因:
查看日志可以看到是内存分配太小的原因。
#查看日志
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
参考:
- https://docs.oracle.com/en/database/oracle/oracle-database/12.2/install-and-upgrade.html
- https://oracle-base.com/articles/misc/oui-silent-installations
- https://docs.oracle.com/cd/E26854_01/em.121/e37799/ch1_introduction.htm#OUICG107
- https://www.oracle.com/webfolder/technetwork/tutorials/obe/db/12c/r1/odb_quickstart/odb_quick_start.html
- Linux命令行安装Oracle12c https://blog.csdn.net/sl1992/article/details/80457935
- 静默安装 oracle 11gr2 杨奇龙 http://blog.itpub.net/22664653/viewspace-1062585/
- oracle dir 说明: https://blog.csdn.net/m0_37814112/article/details/77373863