oracle nid修改dbname

修改name的目的只是为了日后管理清晰点,不重复。我比较懒、记性又差,所以就整理记下
1、检查当前name
SQL> show parameter name
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert string
db_name string test141
db_unique_name string test141
global_names boolean FALSE
instance_name string test141
lock_name_space string
log_file_name_convert string
processor_group_name string
service_names string test141

SQL> select dbid,name from v$database;

DBID NAME
---------- ---------
4003894062 TEST141

2、检查监听
[[email protected] ~]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 04-9月 -2017 19:23:58

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.5.233)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date 01-9月 -2017 23:46:38
Uptime 2 days 19 hr. 37 min. 20 sec
Trace Level off
Security ON: Password or Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/db/network/admin/listener.ora
Listener Log File /u01/app/oracle/product/11.2.0/db/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.5.233)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "test141" has 1 instance(s).
Instance "test141", status READY, has 1 handler(s) for this service...
The command completed successfully
--上面的检查其实都可以省略

--开始nid修改name
大致步骤:关闭DB、mount DB、nid dbname、修改init*.ora、修改环境变量并open DB、重建(s)pfile、修改tnsname.ora和listener.ora中对应名字并启动
关闭DB之前必须要知道sys密码,不知道的话就改下
SQL> alter user sys identified by qwer1234;
User altered.

1、关闭数据库,启动至mount模式
SQL> shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> STARTUP MOUNT
ORACLE instance started.

Total System Global Area 2087780352 bytes
Fixed Size 2229944 bytes
Variable Size 687868232 bytes
Database Buffers 1392508928 bytes
Redo Buffers 5173248 bytes
Database mounted.

2、NI修改DB_NAME
[[email protected] admin]$ nid target=sys/qwer1234 dbname=test233

DBNEWID: Release 11.2.0.3.0 - Production on 星期一 9月 4 19:26:25 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Connected to database TEST141 (DBID=4003894062)
Connected to server version 11.2.0

Control Files in database:
/u01/app/oracle/oradata/dbdata/control01.ctl
/u01/app/oracle/fast_recovery_area/dbdata/control02.ctl

Change database ID and database name TEST141 to TEST233? (Y/[N]) => Y

Proceeding with operation
Changing database ID from 4003894062 to 3120964513
Changing database name from TEST141 to TEST233
Control File /u01/app/oracle/oradata/dbdata/control01.ctl - modified
Control File /u01/app/oracle/fast_recovery_area/dbdata/control02.ctl - modified
Datafile /u01/app/oracle/oradata/dbdata/system01.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/dbdata/sysaux01.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/dbdata/undotbs01.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/dbdata/users01.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/dbdata/dat_member.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/dbdata/idx_member.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/dbdata/dat_account.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/dbdata/idx_account.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/dbdata/dat_sysdb.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/dbdata/idx_sysdb.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/dbdata/dat_risk.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/dbdata/idx_risk.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/dbdata/dat_tppaml.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/dbdata/idx_tppaml.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/dbdata/dat_test.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/dbdata/DAT_MS_ORDERS.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/dbdata/pftp01.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/dbdata/dat_cashreserve_01.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/dbdata/dat_orders.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/dbdata/idx_orders.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/dbdata/DAT_SSCARD.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/dbdata/IDX_SSCARD.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/dbdata/DAT_GDXT.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/dbdata/IDX_GDXT.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/dbdata/DAT_DINPAYPOS.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/dbdata/IDX_DINPAYPOS.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/dbdata/DAT_ERCON.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/dbdata/IDX_ERCON.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/dbdata/dat_bill01.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/dbdata/idx_bill01.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/dbdata/temp01.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/dbdata/TEMP_PFPT.db - dbid changed, wrote new name
Control File /u01/app/oracle/oradata/dbdata/control01.ctl - dbid changed, wrote new name
Control File /u01/app/oracle/fast_recovery_area/dbdata/control02.ctl - dbid changed, wrote new name
Instance shut down

Database name changed to TEST233.
Modify parameter file and generate a new password file before restarting.
Database ID for database TEST233 changed to 3120964513.
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.

3、修改参数文件
cd $ORACLE_HOME/dbs/init***.ora

vi /u01/app/oracle/product/11.2.0/db/dbs/inittest141.ora
#*.db_name=‘test141‘ 注释了
*.db_name=‘test233‘ 新增为想要修改的名字

vi .bash_profile

#export ORACLE_HOSTNAME=test141
export ORACLE_HOSTNAME=test233
#export ORACLE_SID=test141
export ORACLE_SID=test233

#export ORACLE_UNQNAME=test141
export ORACLE_UNQNAME=test233

4、重新生效环境变量,并启动数据库
[[email protected] ~]$ source .bash_profile
[[email protected] ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on 星期一 9月 4 19:33:40 2017

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

Connected to an idle instance.

SQL> startup pfile =‘/u01/app/oracle/product/11.2.0/db/dbs/inittest141.ora‘;
ORACLE instance started.

Total System Global Area 2087780352 bytes
Fixed Size 2229944 bytes
Variable Size 486541640 bytes
Database Buffers 1593835520 bytes
Redo Buffers 5173248 bytes
Database mounted.
ORA-01589: 要打开数据库则必须使用 RESETLOGS 或 NORESETLOGS 选项

SQL> alter database open resetlogs;

Database altered.

5、重新生成pfile文件
SQL> create spfile from pfile=‘/u01/app/oracle/product/11.2.0/db/dbs/inittest141.ora‘;

File created.

Elapsed: 00:00:00.06
SQL> create pfile from spfile;

File created.

6、修改监听配置
cd $ORACLE_HOME/network/admin
vi tnsname.ora

test233 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.5.233)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
#(SERVICE_NAME = test141)
(SERVICE_NAME = test233)
)
)

vi listener.ora
有SERVICE_NAME的话也修改为test233

重新加载或启动
[[email protected] admin]$ lsnrctl reload/start

原文地址:https://www.cnblogs.com/ritchy/p/8949661.html

时间: 2024-10-11 15:23:24

oracle nid修改dbname的相关文章

在Oracle12.1中使用NID 修改数据库的DBID和DBName【实战】

在异机恢复完成后,使用NID 修改数据库的DBID和DBName,重新启动数据库. 主要步骤如下: 1. 开启数据库:  SQL> startup ORA-32004: obsolete or deprecated parameter(s) specified for RDBMS instance ORACLE instance started. Total System Global Area 4.2950E+10 bytes Fixed Size                  45085

Oracle/SQL 修改字段类型和长度

标准SQL修改字段类型和长度语句:ALTER TABLE tableName modify column columnName 类型;例如Mysql的修改字段类型语句:alter table test modify column name varchar(255); Oracle修改字段类型和长度语句:ALTER TABLE tableName modify(columnName 类型);例如alter table test modify(name varchar(255)); Oracle/S

Oracle 11g 修改字符集 为 ZHS16GBK

方法一:sqlplus “用户/密码 as sysdba” sqlplus “sys/sys as sysdba”  方法二:sqlplus/nolog SQL> conn /as sysdba SQL> shutdown immediate; SQL> startup mount SQL> ALTER SYSTEM ENABLE RESTRICTED SESSION; SQL> ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0; SQL>

oracle如何修改字段类型(2)

在一次做开发的时候,遇到需要将数据表的字段类型由number改成varchar,可是该字段又有值, 用  alter table t-name modify cname newType;会报错. 话说,当时在网上没找到合适的解决办法,很苦恼! 今天在博客园看到解决这个问题的办法,很nice,分享! 当要修改的字段有值的时候,不能更改字段类型: 两种解决办法: 1.   > 新增一列,列类型与要修改的新类型一致: >将旧列的值赋给新列(需强制类型转换): > update tname se

oracle如何修改单个用户密码永不过期

Oracle的密码过期规则是用Profile来管理的,系统默认只有一个Profile(DEFAULT),该profile的密码过期规则为180天:而所有的用户都使用该DEFAULT的profile,所以如果修改DEFAULT的过期规则会影响所有的用户.如果你想修改某个用户的密码让其永不过期,则需要新建一个profile,修改该profile的过期规则为无限期,这样该用户的过期规则会改变,并且不会影响到其他用户. 首先查看用户的proifle是哪个,一般是default: sql>SELECT u

oracle数据库修改连接数

最近在用weblogic部署项目,同时用的是oracle数据库,然后今天遇到一个问题:多个用户连接数据库连接不成功,有时提示被锁住,经检查发现一方面weblogic控制台中数据源的连接池配置没有配置足够的容量,另一方面是oracle数据库没有配足够的连接数 1.weblogic控制台修改如下 2.通过cmd命令修改数据库连接数并重启数据库 C:\Users\Administrator>sqlplus sys/sys@192.168.13.211/oanet as sysdba SQL*Plus:

oracle通过修改控制文件scn推进数据库scn

数据库当前scn 代码如下 复制代码 idle> select checkpoint_change# from v$database; CHECKPOINT_CHANGE#------------------ 271743118 idle> shutdown abort ORACLE 例程已经关闭.分析控制文件中scn 这里我们可以看到加粗部分为数据库scn 代码如下 复制代码 SQL>select to_number('10327a59','xxxxxxxxx') from dual;

Oracle 手动修改spfile后的现象记录

Oracle 11G 引入Memory_max_target和Memory_target参数用于数据库的内存自动管理(AMM),本意是修改该两个参数超过物理内存的大小,视图看看数据库报什么错误. 备份spfile文件 $cp spfileorcl.ora spfileorcl.ora.bak 直接手动修改spfile中的两个参数值: 两个值得大小分别修改为6,815,744,000,000≈6.7T 实际物理内存为16G左右 $ free -g 启动数据库出现如下报错: SQL> startup

ORACLE数据库修改sga_max_size和sga_target后重启报ORA-00821错

故障背景: 为服务器进行操作系统重启,因硬件问题,服务器重启后128GB内存丢失一半,导致应用进程处理数据缓慢.Oracle软件版本为10.2.0.5.特别之处在于,数据库数据文件使用共享卷组裸设备,spfile是共享卷组上裸设备. 紧急决定,将此服务器上历史数据库SGA内存配置减少一般. 突发问题: 修改sga_max_size和sga_target后,重启数据库实例,报错提示ORA-00821. 应急处置: 在shutdown状态下,由spfile生产pfile.编辑pfile文件,调小sg