单实例更新实例名
1.Oracle用户执行
1.创建pfile 文件
sqlplus / as sysdba
show parameter name
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert string
db_name string tyzfdb
db_unique_name string tyzfdb
global_names boolean FALSE
instance_name string tyzfdb
lock_name_space string
log_file_name_convert string
processor_group_name string
service_names string tyzfdb
SQL>
File created.
create pfile='/home/oracle/pfile.ora' from spfile;
shutdown immediate
startup mount
1.2 备份控制文件,并关闭退出数据库(如果路径没有变化,放置位置一致可不用修改)
alter database backup controlfile to trace resetlogs;
2. 修改相关名称实施步骤(本套数据库修改名称定为 fqzdb)
2.1 Oracle用户使用nid命令执行
nid target=/ dbname=fqzdb
[oracle@VM_128_177_centos ~]$ nid target=/ dbname=fqzdb
DBNEWID: Release 11.2.0.3.0 - Production on Sat Oct 3 17:37:22 2020
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Connected to database TYZFDB (DBID=2806943307)
Connected to server version 11.2.0
Control Files in database:
/data/tyzfdb/control01.ctl
/oracle/app/oracle/fast_recovery_area/tyzfdb/control02.ctl
Change database ID and database name TYZFDB to FQZDB? (Y/[N]) => y
Proceeding with operation
Changing database ID from 2806943307 to 3789126098
Changing database name from TYZFDB to FQZDB
Control File /data/tyzfdb/control01.ctl - modified
Control File /oracle/app/oracle/fast_recovery_area/tyzfdb/control02.ctl - modified
Datafile /data/tyzfdb/system01.db - dbid changed, wrote new name
Datafile /data/tyzfdb/sysaux01.db - dbid changed, wrote new name
Datafile /data/tyzfdb/undotbs01.db - dbid changed, wrote new name
Datafile /data/tyzfdb/users01.db - dbid changed, wrote new name
Datafile /data/tyzfdb/example01.db - dbid changed, wrote new name
Datafile /data/tyzfdb/temp01.db - dbid changed, wrote new name
Control File /data/tyzfdb/control01.ctl - dbid changed, wrote new name
Control File /oracle/app/oracle/fast_recovery_area/tyzfdb/control02.ctl - dbid changed, wrote new name
Instance shut down
Database name changed to FQZDB.
Modify parameter file and generate a new password file before restarting.
Database ID for database FQZDB changed to 3789126098.
All previous backups and archived redo logs for this database are unusable.
Database is not aware of previous backups and archived logs in Recovery Area.
Database has been shutdown, open database with RESETLOGS option.
Succesfully changed database name and ID.
DBNEWID - Completed succesfully.
2.3. 修改实例名
sed -i "s/ORACLE_SID=tyzfdb/ORACLE_SID=fqzdb/" /home/oracle/.bash_profile
source ~/.bash_profile
env|grep ORACLE
2.4. 建dump 文件夹
mkdir -p /oracle/app/oracle/admin/fqzdb/adump
2.5.把相关的数据文件,redo文件移动到新的路径下
cp /u01/app/oracle/oradata/FQZDB/ * -r /u01/app/data/
2.6修改pfile.ora的参数
fqzdb.__data_transfer_cache_size=0
fqzdb.__db_cache_size=264241152
fqzdb.__inmemory_ext_roarea=0
fqzdb.__inmemory_ext_rwarea=0
fqzdb.__java_pool_size=4194304
fqzdb.__large_pool_size=8388608
fqzdb.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
fqzdb.__pga_aggregate_target=335544320
fqzdb.__sga_target=503316480
fqzdb.__shared_io_pool_size=20971520
fqzdb.__shared_pool_size=188743680
fqzdb.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/fqzdb/adump'
*.audit_trail='db'
*.compatible='12.2.0'
*.control_files='/u01/app/data/control01.ctl','/u01/app/data/control02.ctl'
*.db_block_size=8192
*.db_domain='fqzdb.com'
*.db_name='fqzdb'
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=fqzdbXDB)'
*.local_listener='LISTENER_fqzdb'
*.memory_target=800m
*.nls_language='AMERICAN'
*.nls_territory='AMERICA'
*.open_cursors=300
*.processes=300
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'
2.6.根据旧的控制文件生成修改更新控制文件的sql语句
startup nomount pfile='/home/oracle/pfile.ora'
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "SMSS" NORESETLOGS NOARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/u01/app/oracle/oradata/FQZDB/redo01.log' SIZE 200M BLOCKSIZE 512,
GROUP 2 '/u01/app/oracle/oradata/FQZDB/redo02.log' SIZE 200M BLOCKSIZE 512,
GROUP 3 '/u01/app/oracle/oradata/FQZDB/redo03.log' SIZE 200M BLOCKSIZE 512
-- STANDBY LOGFILE
DATAFILE
'/u01/app/oracle/oradata/FQZDB/system01.dbf',
'/u01/app/oracle/oradata/FQZDB/sysaux01.dbf',
'/u01/app/oracle/oradata/FQZDB/undotbs01.dbf',
'/u01/app/oracle/oradata/FQZDB/users01.dbf'
CHARACTER SET AL32UTF8
;
有归档的------
ALTER DATABASE REGISTER LOGFILE '/u01/app/oracle/product/12.2.0/dbhome_1/dbs/arch1_1_934293149.dbf';
ALTER DATABASE REGISTER LOGFILE '/u01/app/oracle/product/12.2.0/dbhome_1/dbs/arch1_1_946660796.dbf';
ALTER DATABASE REGISTER LOGFILE '/u01/app/oracle/product/12.2.0/dbhome_1/dbs/arch1_1_1052835808.dbf';
2.7 起库
select status from v$instance;
STATUS
------------
MOUNTED
alter database open resetlogs;
Database altered.
create spfile from pfile='/home/oracle/pfile.ora';
3. 验证
3.1 看实例的相关信息
show parameter name
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert string
db_name string fqzdb
db_unique_name string fqzdb
global_names boolean FALSE
instance_name string fqzdb
lock_name_space string
log_file_name_convert string
processor_group_name string
service_names string fqzdb
3.2 创建spfile
create spfile from pfile='/home/oracle/pfile.ora';
3.3 关库使用spfile起库
SQL> shutdown immediate
Database closed.
Database dismounted.
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.
3.5 开监听
lsnrctl start
LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 03-OCT-2020 17:39:55
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Starting /oracle/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Log messages written to /oracle/app/oracle/diag/tnslsnr/VM_128_177_centos/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=VM_128_177_centos)(PORT=1521)))
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date 03-OCT-2020 17:39:55
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Log File /oracle/app/oracle/diag/tnslsnr/VM_128_177_centos/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=VM_128_177_centos)(PORT=1521)))
The listener supports no services
The command completed successfully