centos使用docker安装oracle实例名修改

  1. 进入oracle容器

docker exec -it oracle11g bash
  1. 连接oracle

[oracle@d18f5ad185d7 /]$ source ~/.bash_profile
[oracle@d18f5ad185d7 /]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.1.0 Production on Sun Mar 29 08:22:08 2020

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

SQL> conn /as sysdba;
Connected.
  1. 查看实例名

SQL> select instance from v$thread;

INSTANCE
--------------------------------------------------------------------------------
helowin
  1. 关闭数据库

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

# 退出oracle,sql模式
SQL> exit
  1. 修改/etc/oratab文件

[oracle@d18f5ad185d7 /]$ vi /etc/oratab 
# /etc/oratab  内容, 将 helowin 修改为 lckj
helowin:/home/oracle/app/oracle/product/11.2.0/dbhome_2:Y

# 修改后的内容为
lckj:/home/oracle/app/oracle/product/11.2.0/dbhome_2:Y
  1. 修改.bash_profile文件,将修改ORACLE_SID的修改为lckj

[oracle@d18f5ad185d7 /]$ vi ~/.bash_profile
# .bash_profile 内容

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH
ORACLE_BASE=/home/oracle/app/oracle;export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_2;export ORACLE_HOME
ORACLE_SID=helowin;export ORACLE_SID
ORACLE_TERM=xterm;export ORACLE_TERM
PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib;
export CLASSPATH
# 使配置文件生效
[oracle@d18f5ad185d7 /]$ source ~/.bash_profile

# 查看环境变量进行确认
[oracle@d18f5ad185d7 /]$ env|grep ORACLE
ORACLE_SID=lckj
ORACLE_BASE=/home/oracle/app/oracle
ORACLE_TERM=xterm
ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_2
  1. 修改dbs目录下的文件名

dbs目录是用于存放数据库服务器端的参数文件Spfile、初始化文件init、还有密码文件orapworaclesid 在 ORACLE_SID 在ORACLE_HOME目录下

# 进入到 $ORACLE_HOME/dbs并对hc_helowin.dat, lkHELOWIN spfilehelowin.ora 进行重名名
[oracle@d18f5ad185d7 /]$ cd $ORACLE_HOME/dbs
[oracle@d18f5ad185d7 dbs]$ ll
total 32
-rw-r-----. 1 oracle oinstall 3584 Jan  4  2016 123.sp
-rw-rw----. 1 oracle oinstall 1544 Mar 29 08:25 hc_helowin.dat
-rw-r--r--. 1 oracle oinstall 2851 May 16  2009 init.ora
-rw-r--r--. 1 oracle oinstall 1067 Jan  4  2016 inithelowin.ora
-rw-r-----. 1 oracle oinstall   24 Aug 23  2014 lkHELOWIN
-rw-r-----. 1 oracle oinstall   24 Dec 29  2015 lkORCL
-rw-r-----. 1 oracle oinstall 2048 Mar 28 21:01 orapwhelowin
-rw-r-----. 1 oracle oinstall 3584 Mar 28 20:31 spfilehelowin.ora
[oracle@d18f5ad185d7 dbs]$ mv hc_helowin.dat  hc_lckj.dat
[oracle@d18f5ad185d7 dbs]$ mv lkHELOWIN lkLCKJ
[oracle@d18f5ad185d7 dbs]$ mv spfilehelowin.ora  spfilelckj.ora 
[oracle@d18f5ad185d7 dbs]$ ll
total 28
-rw-r-----. 1 oracle oinstall 3584 Jan  4  2016 123.sp
-rw-rw----. 1 oracle oinstall 1544 Mar 29 08:25 hc_lckj.dat
-rw-r--r--. 1 oracle oinstall 2851 May 16  2009 init.ora
-rw-r--r--. 1 oracle oinstall 1067 Jan  4  2016 inithelowin.ora
-rw-r-----. 1 oracle oinstall   24 Aug 23  2014 lkLCKJ
-rw-r-----. 1 oracle oinstall 2048 Mar 28 21:01 orapwhelowin
-rw-r-----. 1 oracle oinstall 3584 Mar 28 20:31 spfilelckj.ora

# 重新生成密码文件,并将旧的密码文件删除
[oracle@d18f5ad185d7 dbs]$ orapwd file=$ORACLE_HOME/dbs/oraw$ORACLE_SID password=lckj123456 entries=5 force=y
[oracle@d18f5ad185d7 dbs]$ ll
total 32
-rw-r-----. 1 oracle oinstall 3584 Jan  4  2016 123.sp
-rw-rw----. 1 oracle oinstall 1544 Mar 29 08:25 hc_lckj.dat
-rw-r--r--. 1 oracle oinstall 2851 May 16  2009 init.ora
-rw-r--r--. 1 oracle oinstall 1067 Jan  4  2016 inithelowin.ora
-rw-r-----. 1 oracle oinstall   24 Aug 23  2014 lkLCKJ
-rw-r-----. 1 oracle oinstall 2048 Mar 28 21:01 orapwhelowin
-rw-r-----. 1 oracle oinstall 2048 Mar 29 08:50 oraworcl
-rw-r-----. 1 oracle oinstall 3584 Mar 28 20:31 spfilelckj.ora

[oracle@d18f5ad185d7 dbs]$ rm -rf orapwhelowin 
[oracle@d18f5ad185d7 dbs]$ ll
total 28
-rw-r-----. 1 oracle oinstall 3584 Jan  4  2016 123.sp
-rw-rw----. 1 oracle oinstall 1544 Mar 29 08:25 hc_lckj.dat
-rw-r--r--. 1 oracle oinstall 2851 May 16  2009 init.ora
-rw-r--r--. 1 oracle oinstall 1067 Jan  4  2016 inithelowin.ora
-rw-r-----. 1 oracle oinstall   24 Aug 23  2014 lkLCKJ
-rw-r-----. 1 oracle oinstall 2048 Mar 29 08:50 oraworcl
-rw-r-----. 1 oracle oinstall 3584 Mar 28 20:31 spfilelckj.ora
  1. 登录启动数据库,查看实例名字

[oracle@d18f5ad185d7 dbs]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Sun Mar 29 08:55:20 2020

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area 1603411968 bytes
Fixed Size            2213776 bytes
Variable Size          402655344 bytes
Database Buffers     1191182336 bytes
Redo Buffers            7360512 bytes
Database mounted.
Database opened.
SQL> select instance from v$thread;

INSTANCE
--------------------------------------------------------------------------------
lckj
  1. 备份控制文件,并关闭退出数据库

SQL> alter database backup controlfile to trace resetlogs;

Database altered.

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
  1. 根据旧的控制文件生成修改更新控制文件

进入控制文件的备份目录,根据alter_orcl.log日志文件($ORACLE_BASE/diag/rdbms/原实例名/新实例名/trace)找到控制备份文件oracle的备份文件复制一份进行修改

[oracle@d18f5ad185d7 dbs]$ cd $ORACLE_BASE/diag/rdbms/helowin/lckj/trace
[oracle@d18f5ad185d7 trace]$ pwd
/home/oracle/app/oracle/diag/rdbms/helowin/lckj/trace

[oracle@d18f5ad185d7 trace]$ ls
alert_lckj.log      lckj_j000_1142.trm  lckj_mman_86.trm    lckj_ora_1110.trm  lckj_p001_115.trm   orcl_vktm_1072.trm
lckj_ckpt_92.trc    lckj_j000_205.trc   lckj_mmon_1098.trc  lckj_ora_258.trc   lckj_p002_117.trc   orcl_vktm_72.trc
lckj_ckpt_92.trm    lckj_j000_205.trm   lckj_mmon_1098.trm  lckj_ora_258.trm   lckj_p002_117.trm   orcl_vktm_72.trm
lckj_dbrm_1080.trc  lckj_j004_166.trc   lckj_ora_1067.trc   lckj_ora_53.trc    lckj_p003_119.trc
lckj_dbrm_1080.trm  lckj_j004_166.trm   lckj_ora_1067.trm   lckj_ora_53.trm    lckj_p003_119.trm
lckj_dbrm_80.trc    lckj_mman_1086.trc  lckj_ora_111.trc    lckj_p000_113.trc  lckj_p004_121.trc
lckj_dbrm_80.trm    lckj_mman_1086.trm  lckj_ora_111.trm    lckj_p000_113.trm  lckj_p004_121.trm
lckj_j000_1142.trc  lckj_mman_86.trc    lckj_ora_1110.trc   lckj_p001_115.trc  lckj_vktm_1072.trc

# 进入alert_lckj.log 查找备份文件目录,
[oracle@d18f5ad185d7 trace]$ vi alert_lckj.log 

# 在日志文件中找到如下记录
alter database backup controlfile to trace resetlogs
Backup controlfile written to trace file /home/oracle/app/oracle/diag/rdbms/helowin/lckj/trace/orcl_ora_1110.trc

# 复制并修改
[oracle@d18f5ad185d7 trace]$ cp /home/oracle/app/oracle/diag/rdbms/helowin/lckj/trace/orcl_ora_1110.trc lckj.sql
[oracle@d18f5ad185d7 trace]$ vi lckj.sql 

打开lckj.sql文件,并执行如下命令

#  :set number 或者 :set nu   是打开行数显示   :set nu!  关闭行数
# 1、删除 STARTUP NOMOUNT 之前的内容  /STARTUP NOMOUNT  查出位置    60dd 删除内容
# 2、删除 -- End of tempfile additions. 之后的内容  /End of tempfile 查出位置后删除
# 3、替换所有的helowin为orcl   命令   :%s/helowin/orcl/g
# 4、替换所有的HELOWIN为ORCL   命令   :%s/HELOWIN/ORCL/g
# 5、删掉以  -- 的行
# 6、将CREATE CONTROLFILE REUSE DATABASE "ORCL" RESETLOGS  NOARCHIVELOG 中的 REUSE 改为 SET 变为了 CREATE CONTROLFILE SET DATABASE "ORCL" RESETLOGS  NOARCHIVELOG
# 7、将 RECOVER DATABASE USING BACKUP CONTROLFILE 注释掉改为 -- RECOVER DATABASE USING BACKUP CONTROLFILE
# 生成配置文件
[oracle@d18f5ad185d7 trace]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Sun Mar 29 09:52:23 2020
Copyright (c) 1982, 2009, Oracle.  All rights reserved.
Connected to an idle instance.

SQL> create pfile from spfile;
File created.

SQL> exit
Disconnected

# 最终生成的文件在$ORACLE_HOME/dbs目录下文件名为init$ORACLE_SID.ora
# 本实例名称为  initlckj.ora
[oracle@d18f5ad185d7 trace]$ ll $ORACLE_HOME/dbs
total 36
-rw-r-----. 1 oracle oinstall 3584 Jan  4  2016 123.sp
-rw-rw----. 1 oracle oinstall 1544 Mar 29 08:25 hc_lckj.dat
-rw-r--r--. 1 oracle oinstall 2851 May 16  2009 init.ora
-rw-r--r--. 1 oracle oinstall 1067 Jan  4  2016 inithelowin.ora
-rw-r--r--. 1 oracle oinstall 1398 Mar 29 09:52 initlckj.ora
-rw-r-----. 1 oracle oinstall   24 Aug 23  2014 lkLCKJ
-rw-r-----. 1 oracle oinstall 2048 Mar 28 21:01 orapwhelowin
-rw-r-----. 1 oracle oinstall 2048 Mar 29 08:50 oraworcl
-rw-r-----. 1 oracle oinstall 3584 Mar 28 20:31 spfilelckj.ora

initlckj.ora文件修改

# initlckj.ora文件修改
#  1、 删除helowin. 开头的文件
#  2、 替换所有的helowin为lckj   命令   :%s/helowin/lckj/g
#  3、 替换所有的HELOWIN为LCKJ   命令   :%s/HELOWIN/LCKJ/g
[oracle@d18f5ad185d7 dbs]$ cd $ORACLE_HOME/dbs

init.ora文件修改

# 修改init.ora 文件
#  1、 替换所有的helowin为lckj   命令   :%s/helowin/lckj/g
#  2、 替换所有的HELOWIN为LCKJ   命令   :%s/HELOWIN/LCKJ/g

spfileisdms.ora文件修改

# 修改spfileisdms.ora 文件
#  1、 删除helowin. 开头的文件
#  2、 替换所有的helowin为lckj   命令   :%s/helowin/lckj/g
#  3、 替换所有的HELOWIN为LCKJ   命令   :%s/HELOWIN/LCKJ/g

删除lkHELOWIN 文件

[oracle@d18f5ad185d7 dbs]$ rm -rf lkHELOWIN
  1. 修改$ORACLE_BASE/admin目录下的目录和文件内容

[oracle@d18f5ad185d7 dbs]$ cd $ORACLE_BASE/admin
[oracle@d18f5ad185d7 admin]$ ll
total 0
drwxr-x---. 1 oracle oinstall 19 Aug 23  2014 helowin

# 修改目录名
[oracle@d18f5ad185d7 admin]$ mv helowin lckj

# 修改$ORACLE_BASE/admin/orcl/pfile目录下文件
#  1、 替换所有的helowin为lckj   命令   :%s/helowin/lckj/g
#  2、 替换所有的HELOWIN为LCKJ   命令   :%s/HELOWIN/LCKJ/g
[oracle@d18f5ad185d7 admin]$ cd lckj/pfile/
[oracle@d18f5ad185d7 pfile]$ ll
total 4
-rw-r-----. 1 oracle oinstall 2223 Aug 23  2014 init.ora.72320146402
[oracle@d18f5ad185d7 pfile]$ vi init.ora.72320146402 
  1. 修改$ORACLE_BASE/diag目录下的目录和文件内容

[oracle@d18f5ad185d7 pfile]$ cd $ORACLE_BASE/diag
[oracle@d18f5ad185d7 diag]$ ll
total 0
drwxr-x---. 1 oracle oinstall 21 Jan  4  2016 rdbms
drwxr-xr-x. 1 oracle oinstall 26 Mar 28 20:31 tnslsnr
[oracle@d18f5ad185d7 diag]$ cd rdbms/
[oracle@d18f5ad185d7 rdbms]$ ll
total 0
drwxr-x---. 1 oracle oinstall 48 Dec 29  2015 helowin

# 修改名称
[oracle@d18f5ad185d7 rdbms]$ mv helowin lckj
[oracle@d18f5ad185d7 rdbms]$ cd lckj/
[oracle@d18f5ad185d7 lckj]$ ll
total 0
drwxr-xr-x. 13 oracle oinstall 148 Dec 29  2015 helowin
-rw-r-----.  1 oracle oinstall   0 Dec 29  2015 i_1.mif
drwxr-x---. 13 oracle oinstall 148 Aug 23  2014 orcl

# 删除helowin
[oracle@d18f5ad185d7 lckj]$ rm -rf helowin 
[oracle@d18f5ad185d7 lckj]$ ll
total 0
-rw-r-----.  1 oracle oinstall   0 Dec 29  2015 i_1.mif
drwxr-x---. 13 oracle oinstall 148 Aug 23  2014 orcl
  1. 修改$ORACLE_BASE/flash_recovery_area目录下的目录和文件内容‘’

[oracle@d18f5ad185d7 lckj]$ cd $ORACLE_BASE/flash_recovery_area
[oracle@d18f5ad185d7 flash_recovery_area]$ ll
total 0
drwxr-x---. 1 oracle oinstall 24 Jan  4  2016 HELOWIN
drwxr-x---. 1 oracle oinstall 27 Jan  4  2016 helowin

# 重命名
[oracle@d18f5ad185d7 flash_recovery_area]$ mv helowin lckj
[oracle@d18f5ad185d7 flash_recovery_area]$ mv HELOWIN LCKJ
[oracle@d18f5ad185d7 flash_recovery_area]$ ll
total 0
drwxr-x---. 4 oracle oinstall 41 Jan  4  2016 LCKJ
drwxr-x---. 2 oracle oinstall 52 Jan  4  2016 lckj
[oracle@d18f5ad185d7 flash_recovery_area]$ cd lckj/
[oracle@d18f5ad185d7 lckj]$ ll
total 19364
-rw-r-----. 1 oracle oinstall 10076160 Mar 29 08:56 control02.ctl
-rw-r-----. 1 oracle oinstall  9748480 Jan  4  2016 control02.ctl.bak

# 删除控制文件
[oracle@d18f5ad185d7 lckj]$ rm -rf control02.ctl
[oracle@d18f5ad185d7 lckj]$ ll
total 9520
-rw-r-----. 1 oracle oinstall 9748480 Jan  4  2016 control02.ctl.bak
  1. 修改$ORACLE_BASE/oradata目录下的目录和文件

[oracle@d18f5ad185d7 lckj]$ cd $ORACLE_BASE/oradata
[oracle@d18f5ad185d7 oradata]$ ll
total 0
drwxr-x---. 2 oracle oinstall 225 Mar 28 20:31 helowin
[oracle@d18f5ad185d7 oradata]$ mv helowin lckj
[oracle@d18f5ad185d7 oradata]$ ll
total 0
drwxr-x---. 2 oracle oinstall 225 Mar 28 20:31 lckj
[oracle@d18f5ad185d7 oradata]$ cd lckj/
[oracle@d18f5ad185d7 lckj]$ ll
total 1626076
-rw-r-----. 1 oracle oinstall  10076160 Mar 29 08:56 control01.ctl
-rw-r-----. 1 oracle oinstall   9748480 Jan  4  2016 control01.ctl.bak
-rw-r-----. 1 oracle oinstall 104865792 Mar 29 08:56 example01.dbf
-rw-r-----. 1 oracle oinstall  52429312 Mar 29 08:55 redo01.log
-rw-r-----. 1 oracle oinstall  52429312 Mar 29 08:56 redo02.log
-rw-r-----. 1 oracle oinstall  52429312 Mar 29 08:55 redo03.log
-rw-r-----. 1 oracle oinstall 534781952 Mar 29 08:56 sysaux01.dbf
-rw-r-----. 1 oracle oinstall 713039872 Mar 29 08:56 system01.dbf
-rw-r-----. 1 oracle oinstall  30416896 Mar 28 21:31 temp01.dbf
-rw-r-----. 1 oracle oinstall  99622912 Mar 29 08:56 undotbs01.dbf
-rw-r-----. 1 oracle oinstall   5251072 Mar 29 08:56 users01.dbf
[oracle@d18f5ad185d7 lckj]$ rm -rf control01.ctl
[oracle@d18f5ad185d7 lckj]$ ll
total 1616236
-rw-r-----. 1 oracle oinstall   9748480 Jan  4  2016 control01.ctl.bak
-rw-r-----. 1 oracle oinstall 104865792 Mar 29 08:56 example01.dbf
-rw-r-----. 1 oracle oinstall  52429312 Mar 29 08:55 redo01.log
-rw-r-----. 1 oracle oinstall  52429312 Mar 29 08:56 redo02.log
-rw-r-----. 1 oracle oinstall  52429312 Mar 29 08:55 redo03.log
-rw-r-----. 1 oracle oinstall 534781952 Mar 29 08:56 sysaux01.dbf
-rw-r-----. 1 oracle oinstall 713039872 Mar 29 08:56 system01.dbf
-rw-r-----. 1 oracle oinstall  30416896 Mar 28 21:31 temp01.dbf
-rw-r-----. 1 oracle oinstall  99622912 Mar 29 08:56 undotbs01.dbf
-rw-r-----. 1 oracle oinstall   5251072 Mar 29 08:56 users01.dbf
  1. 修改监听的配置文件tnsnames.ora

[oracle@d18f5ad185d7 admin]$ cd $ORACLE_HOME/network/admin
[oracle@d18f5ad185d7 admin]$ ll
total 16
-rw-r--r--. 1 oracle oinstall 381 Dec 29  2015 listener.ora
drwxr-xr-x. 2 oracle oinstall  64 Aug 23  2014 samples
-rw-r--r--. 1 oracle oinstall 187 May  8  2007 shrept.lst
-rw-r--r--. 1 oracle oinstall 239 Aug 23  2014 sqlnet.ora
-rw-r-----. 1 oracle oinstall 425 Jan  4  2016 tnsnames.ora
[oracle@d18f5ad185d7 admin]$ vi tnsnames.ora 

# 修改后的内容
LISTENER_LCKJ =
  (ADDRESS = (PROTOCOL = TCP)(HOST = d18f5ad185d7)(PORT = 8200))
LCKJ  =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = d18f5ad185d7)(PORT = 8200))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = lckj)
    )
  )
  1. 调用前面步骤修改好的orcl.sql,目的是生成链接控制文件等

# 进入到 lckj.sql的目录中
[oracle@d18f5ad185d7 trace]$ cd $ORACLE_BASE/diag/rdbms/lckj/lckj/trace
[oracle@d18f5ad185d7 trace]$ ls
alert_lckj.log      lckj_j000_1142.trc  lckj_mman_86.trc    lckj_ora_1110.trc  lckj_p001_115.trc  orcl_vktm_1072.trc
lckj.sql            lckj_j000_1142.trm  lckj_mman_86.trm    lckj_ora_1110.trm  lckj_p001_115.trm  orcl_vktm_1072.trm
lckj_ckpt_92.trc    lckj_j000_205.trc   lckj_mmon_1098.trc  lckj_ora_258.trc   lckj_p002_117.trc  orcl_vktm_72.trc
lckj_ckpt_92.trm    lckj_j000_205.trm   lckj_mmon_1098.trm  lckj_ora_258.trm   lckj_p002_117.trm  orcl_vktm_72.trm
lckj_dbrm_1080.trc  lckj_j004_166.trc   lckj_ora_1067.trc   lckj_ora_53.trc    lckj_p003_119.trc
lckj_dbrm_1080.trm  lckj_j004_166.trm   lckj_ora_1067.trm   lckj_ora_53.trm    lckj_p003_119.trm
lckj_dbrm_80.trc    lckj_mman_1086.trc  lckj_ora_111.trc    lckj_p000_113.trc  lckj_p004_121.trc
lckj_dbrm_80.trm    lckj_mman_1086.trm  lckj_ora_111.trm    lckj_p000_113.trm  lckj_p004_121.trm

# 查看文件的绝对路径,为执行sql做准备
[oracle@d18f5ad185d7 trace]$ pwd
/home/oracle/app/oracle/diag/rdbms/lckj/lckj/trace


[oracle@d18f5ad185d7 trace]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Sun Mar 29 10:52:14 2020

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

Connected to an idle instance.
# 执行修改好的sql,生成连接控制文件
SQL> @/home/oracle/app/oracle/diag/rdbms/lckj/lckj/trace/lckj.sql

ORACLE instance started.

Total System Global Area 1603411968 bytes
Fixed Size            2213776 bytes
Variable Size          402655344 bytes
Database Buffers     1191182336 bytes
Redo Buffers            7360512 bytes

Control file created.


Database altered.


Tablespace altered.
# 查看数据库运行状态 read_write为可读写模式
SQL> select open_mode from v$database;

OPEN_MODE
--------------------
READ WRITE

# 查看name 参数
SQL> show parameter name ;
NAME                     TYPE     VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert             string
db_name                  string     lckj
db_unique_name                 string     lckj
global_names                 boolean     FALSE
instance_name                 string     lckj
lock_name_space              string
log_file_name_convert             string
service_names                 string     lckj

# 查看实例名
SQL> select name from v$database;  
NAME
---------
LCKJ

#  关闭
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

# 启动
SQL> startup
ORACLE instance started.

Total System Global Area 1603411968 bytes
Fixed Size            2213776 bytes
Variable Size          402655344 bytes
Database Buffers     1191182336 bytes
Redo Buffers            7360512 bytes
Database mounted.
Database opened.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

# 启动监听器
[oracle@7ac184622d55 trace]$ lsnrctl start
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 29-MAR-2020 13:49:01
Copyright (c) 1991, 2009, Oracle.  All rights reserved.
TNS-01106: Listener using listener name LISTENER has already been started
#  TNS-01106:  表示监听已启动
  1. 每次更改oracle的监听配置文件后都需要重新刷新配置90%的连接异常都是来源于监听配置问题

exit#退出容器
systemctl restart docker.service#重启服务
docker start oracle11g#重启容器
docker exec -it -u root oracle11g bash#重新进入容器
su - oracle#切换oracle账户
sqlplus / as sysdba #登入数据库
SQL>alter system register;#强制重新注册实例
SQL>quit#退出数据库
lsnrctl reload#在容器内重启监听
lsnrctl status#查看监听服务状态

文章引用自https://blog.csdn.net/Liveor_Die/article/details/105177966

你可能感兴趣的:(docker,oracle,linux,centos,docker,oracle,实例名,linux)