时间:2021-07-01 10:21:17 帮助过:10人阅读
ALTER DATABASE RENAME GLOBAL_NAME TO sales.us.example.com
[oracle@oracle1 ~]$ nid help=y
?
DBNEWID: Release 11.2.0.4.0 - Production on Sun Feb 11 13:42:34 2018
?
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
?
Keyword Description (Default)
----------------------------------------------------
TARGET Username/Password (NONE)
DBNAME New database name (NONE)
LOGFILE Output Log (NONE)
REVERT Revert failed change NO
SETNAME Set a new database name only NO
APPEND Append to output log NO
HELP Displays these messages NO
在执行nid命令时,该程序会校验当前数据库所有数据文件以及控制文件的头部信息,校验成功后提示是否要修改。nid target=sys/password # 此方式是仅仅修改dbid
nid target=/ dbname=new_dbname [setname=yes] # / 表明连接到当前环境的sid,且使用操作系统认证
nid target=sys/password dbname=new_dbname [setname=yes] # setname=yes 仅仅修改数据库名字,如果省略,则两者同时修改
nid target=sys/pwdd@conn_string dbname=new_dbname [setname=yes] # 使用连接串连接到远程主机并修改</span>
f、修改Oracle 参数文件 pfile(使用先前从spfile备份的)中的参数db_name,如果仅仅修改dbid,跳过此步骤--查看当前数据库名
SQL> show parameter name
?
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
cell_offloadgroup_name string
db_file_name_convert string
db_name string oracle1
db_unique_name string oracle1
global_names boolean FALSE
instance_name string oracle1
lock_name_space string
log_file_name_convert string
processor_group_name string
service_names string oracle1
?
--启动数据库到mount 状态
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
?
Total System Global Area 409194496 bytes
Fixed Size 2253744 bytes
Variable Size 314575952 bytes
Database Buffers 88080384 bytes
Redo Buffers 4284416 bytes
Database mounted.
SQL> select dbid,name,open_mode from v$database;
?
DBID NAME OPEN_MODE
---------- --------- --------------------
617378827 ORACLE1 MOUNTED
b. nid 修改 DBNAME
[oracle@oracle1 ~]$ nid target=/ dbname=orcl
?
DBNEWID: Release 11.2.0.4.0 - Production on Sun Feb 11 13:33:43 2018
?
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
?
Connected to database ORACLE1 (DBID=617378827)
?
Connected to server version 11.2.0
?
Control Files in database:
/u01/app/oracle/oradata/oracle1/control01.ctl
/u01/app/oracle/fast_recovery_area/oracle1/control02.ctl
?
Change database ID and database name ORACLE1 to ORCL? (Y/[N]) => y
?
Proceeding with operation
Changing database ID from 617378827 to 1495594423 #DBID 变化
Changing database name from ORACLE1 to ORCL #DBNAME 变化
Control File /u01/app/oracle/oradata/oracle1/control01.ctl - modified #修改控制文件
Control File /u01/app/oracle/fast_recovery_area/oracle1/control02.ctl - modified
Datafile /u01/app/oracle/oradata/oracle1/system01.db - dbid changed, wrote new name #修改数据文件DBID/DBNAME
Datafile /u01/app/oracle/oradata/oracle1/sysaux01.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/oracle1/undotbs01.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/oracle1/users01.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/oracle1/example01.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/oracle1/t01.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/oracle1/t16.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/oracle1/temp01.db - dbid changed, wrote new name
Control File /u01/app/oracle/oradata/oracle1/control01.ctl - dbid changed, wrote new name #修改控制文件DBID/DBNAME
Control File /u01/app/oracle/fast_recovery_area/oracle1/control02.ctl - dbid changed, wrote new name
Instance shut down #关闭实例
?
Database name changed to ORCL. #数据库名已变更为orcl
Modify parameter file and generate a new password file before restarting. #重启前请 修改参数文件,创建新密码文件
Database ID for database ORCL changed to 1495594423. #DBID 已变更为 1495594423
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. #数据库已关闭,请以Resetlogs方式打开
Succesfully changed database name and ID. #变更完成
DBNEWID - Completed succesfully.
c. 创建密码文件,修改参数文件 并启动数据库
[oracle@oracle1 ~]$ cd $ORACLE_HOME/dbs
[oracle@oracle1 dbs]$ orapwd help=y
Usage: orapwd file=<fname> entries=<users> force=<y/n> ignorecase=<y/n> nosysdba=<y/n>
?
where
file - name of password file (required),
password - password for SYS will be prompted if not specified at command line,
entries - maximum number of distinct DBA (optional),
force - whether to overwrite existing file (optional),
ignorecase - passwords are case-insensitive (optional),
nosysdba - whether to shut out the SYSDBA logon (optional Database Vault only).
There must be no spaces around the equal-to (=) character.
[oracle@oracle1 dbs]$ orapwd file=orapworcl password=oracle
[oracle@oracle1 dbs]$ sqlplus / as sysdba
?
SQL*Plus: Release 11.2.0.4.0 Production on Sun Feb 11 13:55:27 2018
?
Copyright (c) 1982, 2013, Oracle. All rights reserved.
?
Connected to an idle instance.
?
SQL> create pfile from spfile;
?
File created.
?
SQL> quit
Disconnected
[oracle@oracle1 dbs]$ ls initoracle1.ora
initoracle1.ora
[oracle@oracle1 dbs]$ mv initoracle1.ora initorcl.ora
[oracle@oracle1 dbs]$ vi initorcl.ora #修改 pfile 中的db_name
*.db_name=‘orcl‘ # 修该 Pfile 文件中的db_name
[oracle@oracle1 dbs]$ sqlplus / as sysdba
?
SQL*Plus: Release 11.2.0.4.0 Production on Sun Feb 11 14:07:25 2018
?
Copyright (c) 1982, 2013, Oracle. All rights reserved.
?
Connected to an idle instance.
?
SQL> create spfile from pfile; # 通过pfile 创建 spfile,然后通过spfile 启动
?
File created.
SQL> startup
ORACLE instance started.
?
Total System Global Area 409194496 bytes
Fixed Size 2253744 bytes
Variable Size 314575952 bytes
Database Buffers 88080384 bytes
Redo Buffers 4284416 bytes
Database mounted.
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
?
SQL> alter database open RESETLOGS; #以 RestLogs 方式打开数据库
?
Database altered.
SQL> show parameter name #数据库名已变更
?
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
cell_offloadgroup_name string
db_file_name_convert string
db_name string orcl
db_unique_name string orcl
global_names boolean FALSE
instance_name string orcl
lock_name_space string
log_file_name_convert string
processor_group_name string
service_names string orcl
?
SQL> select dbid,name,open_mode from v$database;
?
DBID NAME OPEN_MODE
---------- --------- --------------------
1495594423 ORCL READ WRITE
SQL> set line 200 pages 200
SQL> col value for a80
SQL> col name for a30
SQL> select * from v$diag_info;
?
INST_ID NAME VALUE
---------- ------------------------------ --------------------------------------------------------------------------------
1 Diag Enabled TRUE
1 ADR Base /u01/app/oracle
1 ADR Home /u01/app/oracle/diag/rdbms/orcl/orcl
1 Diag Trace /u01/app/oracle/diag/rdbms/orcl/orcl/trace
1 Diag Alert /u01/app/oracle/diag/rdbms/orcl/orcl/alert
1 Diag Incident /u01/app/oracle/diag/rdbms/orcl/orcl/incident
1 Diag Cdump /u01/app/oracle/diag/rdbms/orcl/orcl/cdump
1 Health Monitor /u01/app/oracle/diag/rdbms/orcl/orcl/hm
1 Default Trace File /u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_102730.trc
1 Active Problem Count 0
1 Active Incident Count 0
?
11 rows selected.
# ADR 在新的位置,其他的数据文件等位置都不变,之前的ADR,参数文件,密码文件 不会自动删除,需手工删除。
# 如果配置了静态监听,则需要修改监听文件指向新的数据库
# 如果配置了TNS 文件,同样需要修改
# 如果需要使用dbconsole,需重建
?
SQL> SELECT GROUP#,SEQUENCE#,ARCHIVED,STATUS FROM V$LOG;
?
GROUP# SEQUENCE# ARC STATUS
---------- ---------- --- ----------------
1 1 NO CURRENT # Sequence 重置为1
2 0 YES UNUSED # 在线重做日志重建,置于UNUSED状态。
3 0 YES UNUSED
8. DBNEWID 工具(使用nid命令修改db name及dbid)
标签:mount 识别 文件中 where cee restart passwords fas oracle