暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Oracle 11g修改SID

wzf0072 2025-03-24
19

Oracle 11g修改SID

 #1 关闭数据库
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

# 2. ‌修改环境变量
[oracle@localhost admin]$ export ORACLE_SID=ecology
[oracle@localhost admin]$ source ~/.bash_profile
[oracle@localhost admin]$ echo $ORACLE_SID
oadb
[oracle@localhost admin]$ export ORACLE_SID=ecology
[oracle@localhost admin]$ source ~/.bash_profile
[oracle@localhost admin]$ echo $ORACLE_SID
oadb
[oracle@localhost admin]$ exi
-bash: exi: command not found
[oracle@localhost admin]$ exit
logout
[root@localhost ~]# su - oracle
[oracle@localhost ~]$ echo $ORACLE_SID
oadb
[oracle@localhost ~]$ vim .bash_profile
[oracle@localhost ~]$ source ~/.bash_profile
[oracle@localhost ~]$ echo $ORACLE_SID
ecology

# 3. ‌修改/etc/oratab文件
[oracle@localhost ~]$ vim /etc/oratab
[oracle@localhost ~]$ cat /etc/oratab
#



# This file is used by ORACLE utilities. It is created by root.sh
# and updated by either Database Configuration Assistant while creating
# a database or ASM Configuration Assistant while creating ASM instance.

# A colon, ':', is used as the field terminator. A new line terminates
# the entry. Lines beginning with a pound sign, '#', are comments.
#
# Entries are of the form:
# $ORACLE_SID:$ORACLE_HOME:<N|Y>:
#
# The first and second fields are the system identifier and home
# directory of the database respectively. The third filed indicates
# to the dbstart utility that the database should , "Y", or should not,
# "N", be brought up at system boot time.
#
# Multiple entries with the same $ORACLE_SID are not allowed.
#
#
#oadb:/u01/app/oracle/product/ora11g:Y
ecology:/u01/app/oracle/product/ora11g:Y
[oracle@localhost ~]$


# 4. ‌修改相关文件名
[oracle@localhost ~]$ cd $ORACLE_HOME/dbs
[oracle@localhost dbs]$ ll
total 167000
-rw-r--r-- 1 oracle oinstall 1514 Jun 25 2024 bak_initoadb.ora
-rw-r----- 1 oracle oinstall 4608 Mar 14 15:05 bak_spfileoadb.ora
-rw-r----- 1 oracle oinstall 31555584 Jul 2 2024 c-2630991496-20240702-00
-rw-r----- 1 oracle oinstall 46497792 Nov 23 10:22 c-2630991496-20241123-00
-rw-r----- 1 oracle oinstall 46497792 Nov 25 18:46 c-2630991496-20241125-00
-rw-rw---- 1 oracle oinstall 1544 Mar 24 16:51 hc_oadb.dat
-rw-r--r-- 1 oracle oinstall 1330 Mar 24 16:02 initoadb.ora
-rw-r----- 1 oracle oinstall 24 Jun 21 2024 lkOADB
-rw-r----- 1 oracle oinstall 24 Jun 25 2024 lkOADBSTY
-rw-r----- 1 oracle oinstall 1536 Nov 23 14:27 orapwoadb
-rw-r----- 1 oracle oinstall 46415872 Nov 25 18:46 snapcf_oadb.f
-rw-r----- 1 oracle oinstall 3584 Mar 24 16:38 spfileoadb.ora
[oracle@localhost dbs]$ mv hc_oadb.dat hc_ecology.dat
[oracle@localhost dbs]$ mv initoadb.ora initecology.ora
[oracle@localhost dbs]$ mv lkOADB lkECOLOGY
[oracle@localhost dbs]$ mv lkOADBSTY lkECOLOGYSTY
[oracle@localhost dbs]$ mv orapwoadb orapwecology
[oracle@localhost dbs]$ mv spfileoadb.ora spfileecology.ora

# 5. ‌重建口令文件
[oracle@localhost dbs]$ orapwd file=$ORACLE_HOME/dbs/orapw$ORACLE_SID password=********* entries=5 force=y
 


# 6. ‌启动数据库
[oracle@localhost dbs]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Mon Mar 24 16:58:16 2025

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

Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area 1.9241E+10 bytes
Fixed Size 2236488 bytes
Variable Size 2415923128 bytes
Database Buffers 1.6777E+10 bytes
Redo Buffers 45682688 bytes
Database mounted.
Database opened.
SQL> show parameter instance_name

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
instance_name string ecology
SQL>

# 7. ‌修改监听器配置
[oracle@localhost dbs]$ cd /u01/app/oracle/product/ora11g/network/admin/
[oracle@localhost admin]$ vim listener.ora
[oracle@localhost admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/ora11g/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(ORACLE_HOME = /u01/app/oracle/product/ora11g)
# (GLOBAL_DBNAME=oadbsty)
(SID_NAME = ecology)
)
)


LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
# (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.130.38)(PORT = 1521))
)
)

#ADR_BASE_LISTENER = /u01/app/oracle

[oracle@localhost admin]$ lsnrctl

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 24-MAR-2025 17:01:39

Copyright (c) 1991, 2011, Oracle. All rights reserved.

Welcome to LSNRCTL, type "help" for information.

LSNRCTL> stop
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=172.16.130.38)(PORT=1521)))
starThe command completed successfully
LSNRCTL> st^H
NL-00853: undefined command "stars". Try "help"
LSNRCTL> start
Starting /u01/app/oracle/product/ora11g/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.3.0 - Production
System parameter file is /u01/app/oracle/product/ora11g/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=172.16.130.38)(PORT=1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=172.16.130.38)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date 24-MAR-2025 17:01:49
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/ora11g/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=172.16.130.38)(PORT=1521)))
Services Summary...
Service "ecology" has 1 instance(s).
Instance "ecology", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
LSNRCTL> 

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论