Oracle静默安装搭建

oracle数据库静默安装

环境配置

系统:CentOS7.6

cpu:2*4=8核

硬盘:120G

内存:8G

一,配置

1,关闭防火墙及selinux

 [root@localhost ~]# iptables -F
 [root@localhost ~]# systemctl stop firewalld
 [root@localhost ~]# systemctl disable firewalld
 [root@localhost ~]# systemctl status firewalld
 [root@localhost ~]# setenforce 0
 [root@localhost ~]# sed -i "s/^SELINUX=.*/SELINUX=disabled/g" /etc/selinux/config

2,配置yum源

在下载163源的时候如果有报错可能是因为没有配置dns按照下面方法配置一下即可

[root@localhost yum.repos.d]# vi /etc/resolv.conf
[root@localhost yum.repos.d]# cat /etc/resolv.conf
nameserver 8.8.8.8

配置yum源

 
 [root@localhost ~]# cp /etc/yum.conf /etc/yum.confbak`date +%F_%T`
 [root@localhost ~]# echo 'exclude=kernel*
 exclude=centos-release*' >> /etc/yum.conf && grep exclude /etc/yum.conf  && mkdir -p /tmp/repobak && rm -rf /tmp/repobak/* && cd /etc/yum.repos.d/ && mv -f * /tmp/repobak/ > /dev/null 2>&1
 [root@localhost ~]# curl -o /etc/yum.repos.d/CentOS6-Base-163.repo http://mirrors.163.com/.help/CentOS6-Base-163.repo
 [root@localhost ~]# mv -f /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup > /dev/null 2>&1
 [root@localhost ~]# mv -f /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel-testing.repo.backup > /dev/null 2>&1
 [root@localhost ~]#  curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
 [root@localhost ~]# rpm --import /etc/pki/rpm-gpg/RPM* &&  yum clean all &&  yum makecache &&  yum groupinfo 'Development tools' &&  yum groupinstall -y 'Development tools' &&  yum install wget vim man rsync openssh-clients openssl -y && ls -l && cd ~

3,配置主机名

[root@localhost ~]# vim /etc/hosts
[root@localhost ~]# cat /etc/hosts
 127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
 ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
 192.168.66.61 db
[root@localhost ~]# reboot

4,安装依赖包

[root@db ~]# yum install binutils  compat-libstdc* elfutils-libelf elfutils-libelf-devel  gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers libaio libaio-devel  libgcc  libstdc++ libstdc++-devel  libgomp make numactl numactl-devel sysstat -y
[root@db ~]# yum install unixODBC unixODBC-devel -y

pdksh需要使用rpm安装,先把包放到/tmp目录下

[root@db tmp]# ll
 total 172
 -rw-r--r--  1 root root 173189 Jun 24  2013 pdksh-5.2.14-1.i386.rpm
 [root@db tmp]#  rpm -ivh pdksh-5.2.14-1.i386.rpm --nodeps
 Preparing...                          ################################# [100%]
     file /usr/bin/ksh conflicts between attempted installs of pdksh-5.2.14-1.i386 and pdksh-5.2.14-1.i386

5,配置内核参数

[root@db ~]# cp /etc/sysctl.conf /etc/sysctl.conf.bak
[root@db ~]# echo 'net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-arptables = 0
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmmax = 8589934591
kernel.shmall = 2097152
fs.aio-max-nr = 1048576
fs.file-max = 6815744
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' > /etc/sysctl.conf
 ​
 执行/sbin/sysctl -p使之生效
 如果有下面的报错
 sysctl: cannot stat /proc/sys/net/bridge/bridge-nf-call-ip6tables: No such file or directory
 sysctl: cannot stat /proc/sys/net/bridge/bridge-nf-call-iptables: No such file or directory
 sysctl: cannot stat /proc/sys/net/bridge/bridge-nf-call-arptables: No such file or directory
 执行下面命令,没有报错忽略
 [root@db ~]# modprobe br_netfilter
 然后执行
 [root@db ~]# /sbin/sysctl -p
 net.ipv4.ip_forward = 0
 net.ipv4.conf.default.rp_filter = 1
 net.ipv4.conf.default.accept_source_route = 0
 kernel.sysrq = 0
 kernel.core_uses_pid = 1
 net.ipv4.tcp_syncookies = 1
 net.bridge.bridge-nf-call-ip6tables = 0
 net.bridge.bridge-nf-call-iptables = 0
 net.bridge.bridge-nf-call-arptables = 0
 kernel.msgmnb = 65536
 kernel.msgmax = 65536
 kernel.shmmax = 8589934591
 kernel.shmall = 2097152
 fs.aio-max-nr = 1048576
 fs.file-max = 6815744
 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

参数说明:

 
 1 kernel.shmmax:
 2  64位linux系统:可取的最大值为物理内存值-1byte,建议值为多于物理内存的一半,一般取值大于SGA_MAX_SIZE即可,可以取物理内存-1byte。例如,如果为12GB物理内存,可取128*1024*1024*1024-1=12884901887,SGA肯定会包含在单个共享内存段中。128GB对应的是137438953471。
 3  kernel.shmall:
 4  该参数控制可以使用的共享内存的总页数。Linux共享内存页大小为4KB,共享内存段的大小都是共享内存页大小的整数倍。一个共享内存段的最大大小是16G,那么需要共享内存页数是16GB/4KB=16777216KB /4KB=4194304(页)。
 5  即16GB对应4194304,8GB对应2097152,128GB对应33554432
 6  net.ipv4.ip_forward = 0 #不变 
 7  net.ipv4.conf.default.rp_filter = 1 #不变
 8  net.ipv4.conf.default.accept_source_route = 0   #不变
 9  kernel.sysrq = 0    #不变
10  kernel.core_uses_pid = 1    #不变
11  net.ipv4.tcp_syncookies = 1 #不变
12  net.bridge.bridge-nf-call-ip6tables = 0  #不变
13  net.bridge.bridge-nf-call-iptables = 0   #不变
14  net.bridge.bridge-nf-call-arptables = 0  #不变
15  kernel.msgmnb = 65536   #不变
16  kernel.msgmax = 65536   #不变
17  kernel.shmmax = 4294967295  #变 note:4*1024*1024*1024-1=4294967295 共享内存段的最大尺寸,需要小于SGA MAX SIZE,大小为shmall*页大小(4K);
18  kernel.shmall = 2097152     #变note:4*1024*1024/4K*2=2097152,两倍, 1倍实际不够,控制共享内存页数
19  fs.aio-max-nr = 1048576 #新增 异步I/O请求数目
20  fs.file-max = 6815744   #新增 一个进程可以打开的文件句柄的最大数量
21  kernel.shmmni = 4096    #新增 共享内存段的最大数量,ipcs -sa
22  kernel.sem = 250 32000 100 128  #新增 设置的信号量
23  net.ipv4.ip_local_port_range = 9000 65500   #新增 专用服务器模式下与用户进程通信时分配给用户的端口区间
24  net.core.rmem_default = 262144  #新增 默认接收缓冲区大小
25  net.core.rmem_max = 4194304 #新增 接收缓冲区最大值
26  net.core.wmem_default = 262144  #新增 默认发送缓冲区大小
27  net.core.wmem_max = 1048586 #新增 默认发送缓冲区大小

6,配置资源限制

 [root@db ~]# cp /etc/security/limits.conf /etc/security/limits.conf.bak
 [root@db ~]# sed -i.bak 's/1024/102400/' /etc/security/limits.d/20-nproc.conf 
 [root@db ~]# ulimit -u 102400
 [root@db ~]# echo 'session    required     pam_limits.so' >> /etc/pam.d/login
 [root@db ~]# echo '
 oracle  soft    nproc   16000
 oracle  hard    nproc   16384
 oracle  soft    nofile  60000
 oracle  hard    nofile  65536
 oracle  soft    stack   20480
 oracle  hard    stack   20480
 anaconda-ks.cfg soft    memlock unlimited
 anaconda-ks.cfg hard    memlock unlimited' >> /etc/security/limits.conf

参数说明:

1  oracle              soft    nproc   16000   #oracle要求最小为2047
2  oracle              hard    nproc   16384       #--进程的最大数目,对oracle用户生效
3  oracle              soft    nofile  60000       #oracle要求最小为1024
4  oracle              hard    nofile  65536       #--打开文件的最大数目,对oracle用户生效
5  oracle              soft    stack   10240
6  oracle              hard    stack   10240
7  * soft  memlock     unlimited
8  * hard  memlock     unlimited               #--最大锁定内存地址空间,对所有用户生效

7,创建oracle用户和组,并赋予密码

 [root@db ~]# groupadd oinstall
 [root@db ~]# groupadd dba
 [root@db ~]# useradd -g oinstall -G dba oracle
 [root@db ~]# id oracle
 uid=1000(oracle) gid=1000(oinstall) groups=1000(oinstall),1001(dba)
 [root@db ~]# echo "oracle" | passwd --stdin oracle
 Changing password for user oracle.
 passwd: all authentication tokens updated successfully.

8,创建安装oracle数据库所需要的目录并赋予权限

 [root@db ~]# mkdir -p /data/app/oracle
 [root@db ~]# mkdir -p /data/app/oraInventory
 [root@db ~]# chown -R oracle:oinstall /data/
 [root@db ~]# chmod -R 775 /data/

9,配置root和oracle用户的环境变量

root用户:

[root@db ~]# cat >> /root/.bash_profile  << EOF
export ORACLE_BASE=/data/app/oracle
export ORACLE_HOME=\$ORACLE_BASE/product/11.2.0.4/db_1
export LD_LIBRARY_PATH=\$ORACLE_HOME/lib:/lib:/usr/lib:$GGS_HOME
export TNS_ADMIN=\$ORACLE_HOME/network/admin/
EOF
[root@db ~]# source /root/.bash_profile && 
echo $ORACLE_HOME
/data/app/oracle/product/11.2.0.4/db_1
 ​

oracle用户:

[root@db ~]# su - oracle
[oracle@db ~]$ cat >> /home/oracle/.bash_profile << EOF
export ORACLE_BASE=/data/app/oracle
export ORACLE_HOME=\$ORACLE_BASE/product/11.2.0.4/db_1
export ORACLE_SID=orcl
export ORALCE_OWNER=oracle
PATH=\$PATH:\$HOME/bin:\$ORACLE_HOME/bin:\$ORACLE_HOME/OPatch:\$ORACLE_HOME/jdk/bin:/usr/bin:/usr/sbin:/sbin:/bin:/usr/local/bin:/usr/local/sbin
export PATH
export LANG="en_US.UTF-8"
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"
export LD_LIBRARY_PATH=\$ORACLE_HOME/lib:/lib:/usr/lib:$GGS_HOME
alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'
alias scp='scp -o StrictHostKeyChecking=no'
alias ssh='ssh -o StrictHostKeyChecking=no'
EOF
[oracle@db ~]$ source /home/oracle/.bash_profile &&
echo $ORACLE_HOME &&
echo $ORACLE_BASE &&
env | grep ORA
/data/app/oracle/product/11.2.0.4/db_1 /data/app/oracle ORALCE_OWNER=oracle ORACLE_SID=orcl ORACLE_BASE=/data/app/oracle ORACLE_HOME=/data/app/oracle/product/11.2.0.4/db_1

10,上传oracle数据库安装包和rlwrap软件包并解压

oracle用户上传,上传到/tmp下

[oracle@db tmp]$ unzip p13390677_112040_Linux-x86-64_1of7.zip && \
unzip p13390677_112040_Linux-x86-64_2of7.zip && \
chown -R oracle:oinstall /tmp/database/ && \
chmod -R 775 /tmp/database/ && \
cd /tmp/database && \
ll
 。。。。。。。。。。。。。。。。。。。。。
 。。。。。。。。。。。。。。。。。。。。。
 。。。。。。。。。。。。。。。。。。。。。
 total 44
 drwxrwxr-x  4 oracle oinstall   248 Aug 27  2013 install
 -rwxrwxr-x  1 oracle oinstall 30016 Aug 27  2013 readme.html
 drwxrwxr-x  2 oracle oinstall    61 Aug 27  2013 response
 drwxrwxr-x  2 oracle oinstall    34 Aug 27  2013 rpm
 -rwxrwxr-x  1 oracle oinstall  3267 Aug 27  2013 runInstaller
 drwxrwxr-x  2 oracle oinstall    29 Aug 27  2013 sshsetup
 drwxrwxr-x 14 oracle oinstall  4096 Aug 27  2013 stage
 -rwxrwxr-x  1 oracle oinstall   500 Aug 27  2013 welcome.html

root用户安装rlwrap

[root@db tmp]# yum -y install readline* && \
tar -zxvf rlwrap-0.42.tar.gz && \
cd rlwrap-0.42 && \
./configure && \
make && make install

11,配置配置db_install.rsp文件

安装包解压后在/database/response目录下有三个rsp文件,用来作为静默安装时的应答文件

 [root@db ~]# su - oracle
 Last login: Mon Jun 15 03:06:50 EDT 2020 on pts/0
 [oracle@db ~]$ cd /tmp/database/response/
 [oracle@db response]$ ls
 dbca.rsp  db_install.rsp  netca.rsp
 [oracle@db response]$ cp db_install.rsp db_install.rsp.bak
 [oracle@db response]$ ls
 dbca.rsp  db_install.rsp  db_install.rsp.bak  netca.rsp

SID为orcl,ORACLE_HOSTNAME=db(主机名)

[oracle@db response]$ cat > /tmp/database/response/db_install.rsp << EOF
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=db
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/data/app/oraInventory
SELECTED_LANGUAGES=en,zh_CN,th,zh_TW
ORACLE_HOME=/data/app/oracle/product/11.2.0.4/db_1
ORACLE_BASE=/data/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.EEOptionsSelection=true
oracle.install.db.optionalComponents=oracle.rdbms.partitioning:11.2.0.4.0,oracle.oraolap:11.2.0.4.0,oracle.rdbms.dm:11.2.0.4.0,oracle.rdbms.dv:11.2.0.4.0,oracle.rdbms.lbac:11.2.0.4.0,oracle.rdbms.rat:11.2.0.4.0
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oinstall
oracle.install.db.CLUSTER_NODES=
oracle.install.db.isRACOneInstall=
oracle.install.db.racOneServiceName=
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
oracle.install.db.config.starterdb.globalDBName=orcl
oracle.install.db.config.starterdb.SID=orcl
oracle.install.db.config.starterdb.characterSet=AL32UTF8
oracle.install.db.config.starterdb.memoryOption=true
oracle.install.db.config.starterdb.memoryLimit=
oracle.install.db.config.starterdb.installExampleSchemas=false
oracle.install.db.config.starterdb.enableSecuritySettings=true
oracle.install.db.config.starterdb.password.ALL=oracle
oracle.install.db.config.starterdb.password.SYS=oracle
oracle.install.db.config.starterdb.password.SYSTEM=oracle
oracle.install.db.config.starterdb.password.SYSMAN=oracle
oracle.install.db.config.starterdb.password.DBSNMP=
oracle.install.db.config.starterdb.control=DB_CONTROL
oracle.install.db.config.starterdb.gridcontrol.gridControlServiceURL=
oracle.install.db.config.starterdb.automatedBackup.enable=false
oracle.install.db.config.starterdb.automatedBackup.osuid=
oracle.install.db.config.starterdb.automatedBackup.ospwd=
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=
DECLINE_SECURITY_UPDATES=true
PROXY_HOST=
PROXY_PORT=
PROXY_USER=
PROXY_PWD=
PROXY_REALM=
COLLECTOR_SUPPORTHUB_URL=
oracle.installer.autoupdates.option=SKIP_UPDATES
oracle.installer.autoupdates.downloadUpdatesLoc=
AUTOUPDATES_MYORACLESUPPORT_USERNAME=
AUTOUPDATES_MYORACLESUPPORT_PASSWORD=
EOF
 ​

参数说明:

 
 1 oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0//标注响应文件版本
 2  oracle.install.option=INSTALL_DB_SWONLY//.只装数据库软件
 3  ORACLE_HOSTNAME=主机名
 4  UNIX_GROUP_NAME=oinstall//指定oracle inventory目录的所有者
 5  INVENTORY_LOCATION=/u01/app/oraInventory指定产品清单oracle inventory目录的路径
 6  SELECTED_LANGUAGES=en,zh_CN//指定语言
 7  ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_home1//设置ORALCE_HOME的路径
 8  ORACLE_BASE=/u01/app/oracle//指定ORALCE_BASE的路径
 9  oracle.install.db.InstallEdition=EE//安装数据库软件的版本,企业版
10  oracle.install.db.EEOptionsSelection=true//手动指定企业安装组件 选true对安装大小影响不大所以选true
11  oracle.install.db.optionalComponents=oracle.rdbms.partitioning:11.2.0.4.0,oracle.oraolap:11.2.0.4.0,oracle.rdbms.dm:11.2.0.4.0,oracle.rdbms.dv:11.2.0.4.0,oracle.rdbms.lbac:11.2.0.4.0,oracle.rdbms.rat:11.2.0.4.0//如果上面选true,这些就是手动指定的组件
12  oracle.install.db.DBA_GROUP=dba//指定拥有DBA用户组,通常会是dba组
13  oracle.install.db.OPER_GROUP=oper//指定oper用户组
14  oracle.install.db.CLUSTER_NODES=//指定所有的节点
15  oracle.install.db.isRACOneInstall=false//是否是RACO方式安装
16  oracle.install.db.racOneServiceName=
17  oracle.install.db.config.starterdb.type=//选择数据库的用途,一般用途/事物处理,数据仓库
18  oracle.install.db.config.starterdb.globalDBName=指定GlobalName
19  oracle.install.db.config.starterdb.SID=//你指定的SID
20  oracle.install.db.config.starterdb.characterSet=AL32UTF8//设置数据库编码
21  oracle.install.db.config.starterdb.memoryOption=true//11g的新特性自动内存管理,也就是SGA_TARGET和PAG_AGGREGATE_TARGET都,不用设置了,Oracle会自动调配两部分大小,这个要选true
22  oracle.install.db.config.starterdb.memoryLimit=上面是true的情况下,指定Oracle自动管理内存的大小,这里不用填或者填写物理内存的40%左右等等自定义;
23  oracle.install.db.config.starterdb.installExampleSchemas=false是否载入模板示例
24  oracle.install.db.config.starterdb.enableSecuritySettings=true  是否启用安全设置
25  oracle.install.db.config.starterdb.password.ALL=123456所有用户名的密码
26  oracle.install.db.config.starterdb.password.SYS=
27  oracle.install.db.config.starterdb.password.SYSTEM=
28  oracle.install.db.config.starterdb.password.SYSMAN=
29  oracle.install.db.config.starterdb.password.DBSNMP=
30  oracle.install.db.config.starterdb.control=DB_CONTROL数据库本地管理工具DB_CONTROL,远程集中管理工具GRID_CONTROL
31  oracle.install.db.config.starterdb.gridcontrol.gridControlServiceURL=GRID_CONTROL需要设定grid control的远程路径URL
32  oracle.install.db.config.starterdb.automatedBackup.enable=false设置自动备份
33  oracle.install.db.config.starterdb.automatedBackup.osuid=.自动备份会启动一个job,指定启动JOB的系统用户ID
34  oracle.install.db.config.starterdb.automatedBackup.ospwd=自动备份会开启一个job,需要指定OSUser的密码
35  oracle.install.db.config.starterdb.storageType=要求指定使用的文件系统存放数据库文件还是ASM
36  oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=使用文件系统存放数据库文件才需要指定数据文件、控制文件、Redo log的存放目录
37  oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=使用文件系统存放数据库文件才需要指定备份恢复目录
38  oracle.install.db.config.asm.diskGroup=使用ASM存放数据库文件才需要指定存放的磁盘组
39  oracle.install.db.config.asm.ASMSNMPPassword=使用ASM存放数据库文件才需要指定ASM实例密码
40  MYORACLESUPPORT_USERNAME=指定metalink账户用户名
41  MYORACLESUPPORT_PASSWORD=指定metalink账户密码
42  SECURITY_UPDATES_VIA_MYORACLESUPPORT=用户是否可以设置metalink密码
43  DECLINE_SECURITY_UPDATES=true是否设置安全更新,
44  PROXY_HOST=代理服务器名
45  PROXY_PORT=代理服务器端口
46  PROXY_USER=代理服务器用户名
47  PROXY_PWD=代理服务器密码
48  PROXY_REALM=
49  COLLECTOR_SUPPORTHUB_URL=
50  oracle.installer.autoupdates.option=SKIP_UPDATES 自动更新
51  oracle.installer.autoupdates.downloadUpdatesLoc=自动更新下载目录
52  AUTOUPDATES_MYORACLESUPPORT_USERNAME=自动更新的用户名
53  AUTOUPDATES_MYORACLESUPPORT_PASSWORD=自动更新的密码

12,使用静默方式安装oracle,执行db_install.rsp

 [oracle@db response]$ unset LANG LANGUAGE;unset DISPLAY;
 [oracle@db response]$ /tmp/database/runInstaller -silent -force -ignoreSysPrereqs -ignorePrereq -showprogress -responseFile /tmp/database/response/db_install.rsp
 ..................................................   100% Done.
 ​
 Execute Root Scripts successful.
 Successfully Setup Software.

13,执行脚本

root用户:

[oracle@db response]$ su - root
 Password: 
 Last login: Mon Jun 15 02:50:24 EDT 2020 from 192.168.45.9 on pts/0
 [root@db ~]# sh /data/app/oraInventory/orainstRoot.sh 
 Changing permissions of /data/app/oraInventory.
 Adding read,write permissions for group.
 Removing read,write,execute permissions for world.
 ​
 Changing groupname of /data/app/oraInventory to oinstall.
 The execution of the script is complete.
 [root@db ~]# 
 [root@db ~]# sh /data/app/oracle/product/11.2.0.4/db_1/root.sh 
 Check /data/app/oracle/product/11.2.0.4/db_1/install/root_db_2020-06-15_03-44-09.log for the output of root script

14, 配置静态监听

oracle用户:

[root@db ~]# su - oracle
 Last login: Mon Jun 15 03:31:45 EDT 2020 on pts/0
 [oracle@db ~]$ cd $ORACLE_HOME/network/admin
 [oracle@db admin]$ ls
 samples  shrept.lst
 [oracle@db admin]$ echo '
  SID_LIST_LISTENER =
  (SID_LIST =
   (SID_DESC =
     (GLOBAL_DBNAME = orcl)
     (ORACLE_HOME = /data/app/oracle/product/11.2.0.4/db_1)
     (SID_NAME = orcl)
   )
  )
  
  LISTENER =
  (DESCRIPTION_LIST =
   (DESCRIPTION =
     (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
   )
   (DESCRIPTION =
     (ADDRESS = (PROTOCOL = TCP)(HOST = db)(PORT = 1521))
   )
  )
  ADR_BASE_LISTENER = /data/app/oracle' > listener.ora

15,配置网络服务名文件

[oracle@db admin]$ echo '
  ORCL =
  (DESCRIPTION =
   (ADDRESS_LIST =
     (ADDRESS = (PROTOCOL = TCP)(HOST = db)(PORT = 1521))
   )
   (CONNECT_DATA =
     (SERVICE_NAME = orcl)
     (SERVER = DEDICATED)
   )
  )
  ' > tnsnames.ora

启动监听程序

 [oracle@db admin]$ lsnrctl start 
 [oracle@db admin]$ tnsping orcl
 。。。。。。。。。。。。。。。。。。。
 Used TNSNAMES adapter to resolve the alias
 Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = db)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = orcl) (SERVER = DEDICATED)))
 OK (0 msec)

查看监听程序是否启动

[oracle@db admin]$ ps -ef | grep tnslsnr
 oracle   20763     1  0 03:49 ?        00:00:00 /data/app/oracle/product/11.2.0.4/db_1/bintnslsnr LISTENER -inherit
 oracle   20778 20739  0 03:50 pts/0    00:00:00 grep --color=auto tnslsnr

16,创建实例,配置响应文件dbca.rsp

[oracle@db ~]$ mkdir -p /data/app/oracle/oradata
[oracle@db ~]$ mkdir -p /data/app/oracle/flash_recovery_area
[oracle@db ~]$ cd /tmp/database/response/
[oracle@db response]$ cp dbca.rsp dbca.rsp.bak
[oracle@db response]$ cat > /tmp/database/response/dbca.rsp << EOF
[GENERAL]
  RESPONSEFILE_VERSION = "11.2.0"
  OPERATION_TYPE = "createDatabase"
  [CREATEDATABASE]
  GDBNAME = "orcl"
  SID = "orcl"
  TEMPLATENAME = "General_Purpose.dbc"
  SYSPASSWORD = "oracle"
  SYSTEMPASSWORD = "oracle"
  DATAFILEDESTINATION = /data/app/oracle/oradata
  RECOVERYAREADESTINATION=/data/app/oracle/flash_recovery_area
  CHARACTERSET = "AL32UTF8"
  [CONFIGUREDATABASE]
  SYSDBAUSERNAME = "sys"
EOF

参数说明:

 1 RESPONSEFILE_VERSION = "11.2.0"      #不能更改
 2  OPERATION_TYPE = "createDatabase"    #不变 默认即可
 3  GDBNAME = "orcl"        #数据库的名字,随便怎么改,不影响,自定义 比如"oracle11g.com"
 4  SID = "orcl"            #对应的实例名字instance_name,随便怎么改,不影响,自定义 比如"oracle11g.com"
 5  TEMPLATENAME = "General_Purpose.dbc" #不变 默认即可 建库用的模板文件 
 6  SYSPASSWORD = "oracle"   #SYS管理员密码 自定义
 7  SYSTEMPASSWORD = "oracle"  #SYSTEM管理员密码 自定义
 8  DATAFILEDESTINATION = /data/app/oracle/oradata   #数据文件存放目录 可自定义如/data目录但用户和组要是oracle:oinstall即mkdir /data ; chown -R oracle:oinstall /data ; chmod -R 775 /data; 当然此项默认是$ORACLE_BASE/oradata 此项本来是注释掉的,而$ORACLE_BASE/oradata就是/data/app/oracle/oradata,故此项可不用动,即保持注释掉即也可;
 9  RECOVERYAREADESTINATION=/data/app/oracle/flash_recovery_area #恢复数据存放目录 闪回区 可自定义
10  CHARACTERSET = "AL32UTF8"   #字符集,重要!!! 建库后一般不能更改,所以建库前要确定清楚,选AL32UTF8比较合适;
11  NATIONALCHARACTERSET= "AL16UTF16" #最好还是保持默认的"AL16UTF16",这里我选的UTF8可能出现了后面的PLSQL中文乱码;
12  #MEMORYPERCENTAGE = "40"       #服务器物理内存分配给oracle的内存比例,这里先不选
13  #TOTALMEMORY = "3500"    # //物理内存的60%左右,分配给oracle的总内存3500MB,可自行设定 或者注释不选因为oracle会自行管理;
14  #-----------------------*** End of CREATEDATABASE section ***------------------------
15  SOURCEDB = "myhost:1521:orcl"     #End of CREATEDATABASE sectio后面的很多没有注释掉的选项不用管。

17,执行响应文件

oracle用户执行,使用-responseFile参数后面必须跟绝对路径

[oracle@db response]$ dbca -silent -responseFile /tmp/database/response/dbca.rsp
 。。。。。。。。。。。。。。。。。。。
 96% complete
 100% complete
 Look at the log file "/data/app/oracle/cfgtoollogs/dbca/orcl/orcl.log" for further details. ​

查看oracle进程

[oracle@db response]$ ps -ef | grep ora_| grep -v grep |wc -l
 21
[oracle@db response]$ ps -ef | grep ora_| grep -v grep 

把oracle配置文件最后一行改为yes,/etc/oratab

[oracle@db response]$ vim /etc/oratab 
 [oracle@db response]$ cat /etc/oratab 
 orcl:/data/app/oracle/product/11.2.0.4/db_1:Y

=====================================

oracle安装到此搭建完成

 

posted @ 2020-06-15 17:10  小渣渣呦!!!  阅读(491)  评论(0编辑  收藏  举报