oracle12c12.2.0静默安装及简单使用

database

oracle12c 12.2.0静默安装及简单使用
m0_37975257 2019-09-17 10:25:31 1302 收藏 2
分类专栏: 数据库 #oracle
版权

oracle12c 静默安装及简单使用

    oracle12c安装
        安装centos7.5
            修改配置文件
                修改主机名: vi /etc/hostname
                修改网络等:vi ifcfg-ens33
                VMware:
                配置yum源
                安装命令
                关闭selinux
                关闭防火墙
        oracle相关配置
            安装oracle依赖包关系
            修改内核参数
            修改用户限制
            创建oracle帐号和组
            创建相关数据库目录
            修改oracle环境变量
            下载并解压安装包
            复制响应文件模板
            修改创建数据库配置文件
            安装数据库
            执行脚本
            静默配置监听
            静默建立新库
            检查oracle进程状态
            登录数据库
        oracle12c数据库普通用户创建及登录
            登陆数据库
            连接数据库
            查看数据库
            查看当前实例
            查看所有容器
            修改当前环境为你需要的数据库
            查看当前实例
            创建用户
            配置服务器监听
            重启数据库
        设置数据库开机启动

oracle12c安装
安装centos7.5

我使用的是虚拟机
内存不少于1G, 1.5G没用那么容易卡
磁盘不少于40G 建议50G以上
修改配置文件
修改主机名: vi /etc/hostname

                      我设置为orcl

    1

修改网络等:vi ifcfg-ens33

    TYPE=Ethernet
    BOOTPROTO=static
    DEFROUTE=yes
    PEERNDS=yes
    IPV4_FAILURE_FATAL=no
    IPV6INIT=yes
    IPV6_AUTOCONF=yes
    IPV6_DEFROUTE=yes
    IPV6_PEEROUTES=yes
    IPV6_PEEROUTES=yes
    IPV6_FAILURE_FATAL=no
    NAME=ens33
    UUID=43d6070e-ee02-46e4-a6cb-fe2ce2013d5a
    DEVICE=ens33
    ONBOOT=yes
    IPADDR0=192.168.42.132
    GATEWAY0=192.168.42.2
    DNS1=8.8.8.8
    DNS2=114.114.114.114

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19

VMware:

      ip地址必须和ifcfg-ens33 中的GATEWAY0相同

    1

在这里插入图片描述
配置yum源

使用默认yum源即可, 163的也可以

yum clean all && yum makecache
安装命令

wget ifconfig vim 等你需要的
关闭selinux

    vim /etc/selinux/config
    SELINUX=disabled

    1
    2

关闭防火墙

查看防火墙状态
firewall-cmd --state
停止firewall
systemctl stop firewalld.service
禁止firewall开机启动
systemctl disable firewalld.service
oracle相关配置
安装oracle依赖包关系

yum install -y binutils compat-libcap1 compat-libstdc+±33 compat-libstdc+±33.i686 glibc glibc.i686 glibc-devel glibc-devel.i686 ksh libaio libaio.i686 libaio-devel libaio-devel.i686 libX11 libX11.i686 libXau libXau.i686 libXi libXi.i686 libXtst libXtst.i686 libgcc libgcc.i686 libstdc++ libstdc++.i686 libstdc+±devel libstdc+±devel.i686 libxcb libxcb.i686 make nfs-utils net-tools smartmontools sysstat unixODBC unixODBC-devel gcc gcc-c++ libXext libXext.i686 zlib-devel zlib-devel.i686
修改内核参数

vim /etc/sysctl.conf 请根据自己实际情况修改,内核参数如下

fs.file-max = 6815744
kernel.sem = 250 32000 100 128
kernel.shmmni = 4096
kernel.shmall = 1073741824
kernel.shmmax = 4398046511104
kernel.panic_on_oops = 1
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
net.ipv4.conf.all.rp_filter = 2
net.ipv4.conf.default.rp_filter = 2
fs.aio-max-nr = 1048576
net.ipv4.ip_local_port_range = 9000 65500

/sbin/sysctl -p 刷新内核参数表
修改用户限制

vim /etc/security/limits.conf
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240

vim /etc/pam.d/login

session required pam_limits.so

vim /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
创建oracle帐号和组

groupadd oinstall
groupadd dba
groupadd asmadmin
groupadd asmdba
useradd -g oinstall -G dba,asmdba oracle -d /home/oracle
passwd oracle
创建相关数据库目录

mkdir /u01
mkdir /u01/app
mkdir -p /u01/app/oracle/oradata //存放数据库的数据目录
mkdir -p /u01/app/oracle/oradata_back //存放数据库备份文件
chmod -R 775 /u01/app //权限
chown -R oracle:oinstall /u01 //属主属组
修改oracle环境变量

vim /etc/proile

PATH=PATH:
PATH:HOME/.local/bin:KaTeX parse error: Expected "EOF", got "#" at position 73: … #̲日志存放位置 export T…TMP
export ORACLE_HOSTNAME=Oracle #主机名
export ORACLE_UNQNAME=orcl #库名称
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=KaTeX parse error: Expected "EOF", got "#" at position 78: … #̲库名称 export PATH…PATH
export PATH=ORACLEHOME/bin:ORACLEH​OME/bin:PATH
export LD_LIBRARY_PATH=ORACLEHOME/lib:/lib:/usr/libexportCLASSPATH=ORACLEH​OME/lib:/lib:/usr/libexportCLASSPATH=ORACLE_HOME/jlib:ORACLEHOME/rdbms/jlibexportPATH=/usr/sbin:ORACLEH​OME/rdbms/jlibexportPATH=/usr/sbin:PATH
export PATH=ORACLEHOME/bin:ORACLEH​OME/bin:PATH
export LD_LIBRARY_PATH=ORACLEHOME/lib:/lib:/usr/libexportCLASSPATH=

ORACLEH​OME/lib:/lib:/usr/libexportCLASSPATH=ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
下载并解压安装包

下载安装包到/home/oracle/ 下面 linuxx64_12201_database.zip
unzip linuxx64_12201_database.zip /home/oracle/
复制响应文件模板

su – root
cd /home/oracle/
mkdir etc
cp /home/oracle/database/response/* /home/oracle/etc/
chmod 777 /home/oracle/etc/*.rsp
修改创建数据库配置文件

/home/oracle/etc/db_install.rsp
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v12.2.0
oracle.install.option=INSTALL_DB_SWONLY //30行安装类型,只装数据库软件
UNIX_GROUP_NAME=oinstall //35行主机名称(hostname查询)
INVENTORY_LOCATION=/u01/app/oracle/oraInventory //42行INVENTORY目录(不填就是默认值)
ORACLE_HOME=/u01/app/oracle/product/12.2.0.1/db_1 //46行oracle目录
ORACLE_BASE=/u01/app/oracle //51行
oracle.install.db.InstallEdition=EE //63行oracle版本
oracle.install.db.OSDBA_GROUP=dba //80行
oracle.install.db.OSOPER_GROUP=oinstall //86行 自定义安装,否,使用默认组件
oracle.install.db.OSBACKUPDBA_GROUP=dba //91行
oracle.install.db.OSDGDBA_GROUP=dba //96行
oracle.install.db.OSKMDBA_GROUP=dba //101行
oracle.install.db.OSRACDBA_GROUP=dba //106行
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE //180行数据库类型
oracle.install.db.config.starterdb.globalDBName=orcl //185行
oracle.install.db.config.starterdb.SID=orcl //190行
oracle.install.db.config.starterdb.characterSet=AL32UTF8 //216行
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false //384行
DECLINE_SECURITY_UPDATES=true //398行//设置安全更新(貌似是有bug,这个一定要选true,否则会无限提醒邮件地址有问题,终止安装。PS:不管地址对不对)
安装数据库

su - oracle
cd /home/oracle/database
./runInstaller -force -silent -noconfig -responseFile /home/oracle/etc/db_install.rsp

可以边装边查看日志
tail –f /u01/app/oracle/oraInventory/logs/installActions2019-09-15_08-36-48PM.log

如果报错: 看看是否未授权 /home/oracle/etc/*.rsp
执行脚本

su - root
/u01/app/oracle/oraInventory/orainstRoot.sh
/u01/app/oracle/product/12.2.0.1/db_1/root.sh
部分只需要执行第二条脚本
静默配置监听

su - oracle
netca -silent -responsefile /home/oracle/etc/netca.rsp
查看监听: netstat status
启动监听: netstat start
netstat -tlnp
静默建立新库

vim /home/oracle/etc/dbca.rsp

responseFileVersion=/oracle/assistants/rspfmt_dbca_response_schema_v12.2.0//21行不可更改
gdbName=orcl //32
sid=orcl //42
databaseConfigType=SI //52
policyManaged=false //74
createServerPool=false //88
force=false //127
createAsContainerDatabase=true //163
numberOfPDBs=1 //172
pdbName=orclpdb //182
useLocalUndoForPDBs=true //192
templateName=/u01/app/oracle/product/12.2.0.1/db_1/assistants/dbca/templates/General_Purpose.dbc //223
emExpressPort=5500 //273
runCVUChecks=false //284
omsPort=0 //313
dvConfiguration=false //341
olsConfiguration=false //391
datafileJarLocation={ORACLE_HOME}/assistants/dbca/templates/ //401
datafileDestination={ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/ //411
recoveryAreaDestination={ORACLE_BASE}/fast_recovery_area/{DB_UNIQUE_NAME} //421
storageType=FS //431
characterSet=AL32UTF8 //468字符集创建库之后不可更改
nationalCharacterSet=AL16UTF16 //478
registerWithDirService=false //488
listeners=LISTENER //526
variables=DB_UNIQUE_NAME=cdb1,ORACLE_BASE=/u01/app/oracle,PDB_NAME=,DB_NAME=orcl,ORACLE_HOME=/u01/app/oracle/product/12.2.0.1/db_1,SID=orcl //546

initParams=undo_tablespace=UNDOTBS1,memory_target=796MB,processes=300,db_recovery_file_dest_size=2780MB,nls_language=AMERICAN //555
sampleSchema=false //565
memoryPercentage=40 //574
databaseType=MULTIPURPOSE //584
automaticMemoryManagement=true //594
totalMemory=0 //604

cd /u01/database
dbca -silent -createDatabase -responseFile /home/oracle/etc//dbca.rsp

提示信息:
*[WARNING] [DBT-06801] Specified Fast Recovery Area size (2,780 MB) is less than the recommended value.
CAUSE: Fast Recovery Area size should at least be three times the database size (2,730 MB).
ACTION: Specify Fast Recovery Area Size to be at least three times the database size.
[WARNING] [DBT-11209] Current available physical memory is less than the required physical memory (796MB) for creating the database.
Enter SYS user password: #超级管理员密码

Enter SYSTEM user password: #管理员密码

Enter PDBADMIN User Password: #库密码

[WARNING] [DBT-06208] The ‘SYS’ password entered does not conform to the Oracle recommended standards.
CAUSE:
a. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9].
b.The password entered is a keyword that Oracle does not recommend to be used as password
ACTION: Specify a span password. If required refer Oracle documentation for guidelines.
[WARNING] [DBT-06208] The ‘SYSTEM’ password entered does not conform to the Oracle recommended standards.
CAUSE:
a. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9].
b.The password entered is a keyword that Oracle does not recommend to be used as password
ACTION: Specify a span password. If required refer Oracle documentation for guidelines.
[WARNING] [DBT-06208] The ‘PDBADMIN’ password entered does not conform to the Oracle recommended standards.
CAUSE:
a. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9].
b.The password entered is a keyword that Oracle does not recommend to be used as password
ACTION: Specify a span password. If required refer Oracle documentation for guidelines.
[WARNING] [DBT-06801] Specified Fast Recovery Area size (2,780 MB) is less than the recommended value.
CAUSE: Fast Recovery Area size should at least be three times the database size (3,571 MB).
ACTION: Specify Fast Recovery Area Size to be at least three times the database size.
Copying database files
1% complete
13% complete
25% complete
Creating and starting Oracle instance
26% complete
30% complete
31% complete
35% complete
38% complete
39% complete
41% complete
Completing Database Creation
42% complete
43% complete
44% complete
46% complete
49% complete
50% complete
Creating Pluggable Databases
55% complete
75% complete
Executing Post Configuration Actions
100% complete
Look at the log file “/u01/app/oracle/cfgtoollogs/dbca/cdb1/cdb1.log” for further details.*

安装时间特别长, 注意别win10自动待机,导致安装到一半未完成
检查oracle进程状态

ps -ef | grep ora_ | grep -v grep
lsnrctl status (lsnrctl是oracle命令)
登录数据库

sqlplus / as sysdba
oracle12c数据库普通用户创建及登录
登陆数据库

sqlplus sys/oracle as sysdba;
连接数据库

conn sys/oracle as sysdba;
查看数据库

select name,cdb from v$database;
查看当前实例

select sys_context (‘USERENV’, ‘CON_NAME’) from dual;
在这里插入图片描述
查看所有容器

select pdb_id,pdb_name,dbid,status,creation_scn from dba_pdbs;
在这里插入图片描述
修改当前环境为你需要的数据库

alter session set container=ORCLPDB;
查看当前实例

select sys_context (‘USERENV’, ‘CON_NAME’) from dual;
在这里插入图片描述
创建用户

create user test identified by oracle default tablespace users temporary tablespace temp;
alter user test account unlock;
grant create session, create any view, create any procedure, execute any procedure to test ;
grant connect, resource to test ;
配置服务器监听

vim /u01/app/oracle/product/12.2.0.1/db_1/network/admin/tnsnames.ora

ORCLPDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = orcl)(PORT = 1539))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orclpdb)
)
)
重启数据库

dbstop
su - oracle
lsnrctl start
dbstart
设置数据库开机启动

    1、root用户修改

vi /etc/oratab

orcl:/u01/app/oracle/product/12.2.0.1/db_1:N
将上面的N改为Y

    2、oracle用户修改

su - oracle

cd $ORACLE_HOME/bin

vi dbstart

修改 #ORACLE_HOME_LISTNER=1为ORACLEHOMELISTNER=

1为ORACLEH​OMEL​ISTNER=ORACLE_HOME

vi dbshut

修改 #ORACLE_HOME_LISTNER=1为ORACLEHOMELISTNER=

1为ORACLEH​OMEL​ISTNER=ORACLE_HOME

    3、root用户修改

chmod 777 /etc/rc.d/rc.local

vi /etc/rc.d/rc.local

添加 su - oracle -lc dbstart

        重启应用测试
        reboot
————————————————
版权声明:本文为CSDN博主「m0_37975257」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/m0_37975257/java/article/details/100915595

以上是 oracle12c12.2.0静默安装及简单使用 的全部内容, 来源链接: utcz.com/z/534801.html

回到顶部