设为首页 收藏本站
查看: 1288|回复: 1

[经验分享] oracle口令文件研究以及db_name 研究

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2013-11-25 09:21:02 | 显示全部楼层 |阅读模式

今天是2013-11-24日,本来打算休息,但是在枕边烦了一下oracle的书籍,发现几个学习点,再次记录一下笔记内容。

第一:oracle口令文件研究:

先看一下官网介绍:

ORAPWD FILE=filename [ENTRIES=numusers] [FORCE={Y|N}] [IGNORECASE={Y|N}]

Command arguments are summarized in the following table.

Argument
Description

FILE
Name to assign to the password file. You must supply a complete path. If you supply only a file name, the file is written to the current directory.

ENTRIES
(Optional) Maximum number of entries (user accounts) to permit in the file.

FORCE
(Optional) If y, permits overwriting an existing password file.

IGNORECASE
(Optional) If y, passwords are treated as case-insensitive.

问题一:entries设置为3是否就是只有3个用户可以连接数据库, REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE。

验证:

[oracle@oracle-one dbs]$ orapwd
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@oracle-one dbs]$

[oracle@oracle-one dbs]$ find /opt/app/oracle -name orapw
[oracle@oracle-one dbs]$ find /opt/app/oracle -name orapwRHYS
/opt/app/oracle/product/11.2.0/dbhome_1/dbs/orapwRHYS
[oracle@oracle-one dbs]$ rm orapwRHYS
[oracle@oracle-one dbs]$ orapwd file=/opt/app/oracle/product/11.2.0/dbhome_1/dbs/orapwRHYS password=Amy entries=3
[oracle@oracle-one dbs]$sqlplus / as sysdba

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> show parameter remote_login_

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
remote_login_passwordfile string EXCLUSIVE
SQL>

在客户端登录发现,在11G已经启动了区分密码大小写。如下:

Center.jpg

Center.jpg

可以看出在远端可以通过密码文件进行数据库的启停操作,本次试验由于数据库关闭监听为动态监听因此无法启动数据库。

验证刚刚我的问题:

Center.jpg

可以看到密码文件设置的entries并没有起到限制作用。


SQL> grant sysdba to rhys;

Grant succeeded.

SQL> select * from v$pwfile_users;

USERNAME SYSDB SYSOP SYSAS
------------------------------ ----- ----- -----
SYS TRUE TRUE FALSE
RHYS TRUE FALSE FALSE

SQL>


官网这样写:

This argument specifies the number of entries that you require the password file to accept. This number corresponds to the number of distinct users allowed to connect to the database as SYSDBA or SYSOPER. The actual number of allowable entries can be higher than the number of users, because theORAPWD utility continues to assign password entries until an operating system block is filled. For example, if your operating system block size is 512 bytes, it holds four password entries. The number of password entries allocated is always a multiple of four.

Entries can be reused as users are added to and removed from the password file. If you intend to specify REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE, and to allow the granting ofSYSDBA and SYSOPER privileges to users, this argument is required.

通过如上也验证了remote_login_passwordfile=exclusive的可以 运行远程用户进行数据库密码文件验证,并且可以添加用户信息。

当数据库该参数为remote_login_passwordfile=none,拒绝远程客户端使用密码文件验证,只能通过操作系统验证进入 实例进而启动数据库。

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> show parameter remote_login

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
remote_login_passwordfile string EXCLUSIVE
SQL> alter system set remote_login_passwordfile=none scope=spfile;

System altered.

SQL> startup
ORA-01081: cannot start already-running ORACLE - shut it down first
SQL> startup force
ORACLE instance started.

Total System Global Area 471830528 bytes
Fixed Size 2254344 bytes
Variable Size 197134840 bytes
Database Buffers 268435456 bytes
Redo Buffers 4005888 bytes
Database mounted.
Database opened.
SQL>

Center.jpg

注意:remote_login_passwordfile为 静态参数,并且为shared共享orapw口令文件,不能添加其他用户,只用为 exclusive才可添加其他用户。另外这里的ignorecase

已经被忽略,必须去匹配密码大小写了。

eg:

[oracle@oracle-one dbs]$ orapwd file=/opt/app/oracle/product/11.2.0/dbhome_1/dbs/orapwRHYS password=Amy entries=3 ignorecase=n
[oracle@oracle-one dbs]$

Center.jpg


第二:db_name

db_name代表数据库的名字,官方介绍如下:

DB_NAME specifies a database identifier of up to 8 characters. This parameter must be specified and must correspond to the name specified in the CREATE DATABASEstatement.

If you have multiple databases, the value of this parameter should match the Oracle instance identifier of each one to avoid confusion with other databases running on the system. The value of DB_NAME should be the same in both the standby and production initialization parameter files.

The database name specified in either the STARTUP command or the ALTER DATABASE ... MOUNT statement for each instance of the cluster database must correspond to theDB_NAME initialization parameter setting.

The following characters are valid in a database name: alphanumeric characters, underscore (_), number sign (#), and dollar sign ($). No other characters are valid. Oracle removes double quotation marks before processing the database name. Therefore you cannot use double quotation marks to embed other characters in the name. The database name is case insensitive.

查看数据文件中的db_name,使用bbed工具。

我们知道数据块真正使用是从第9个块开始,1-2为数据文件头块,3-8为区位图块,9-10为assm位图块。下面使用bbed查看db_name信息。

eg:

对于10g直接编译:

[oracle@tf ~]$ cd $ORACLE_HOME/rdbms/lib
[oracle@tf lib]$ make -f ins_rdbms.mk BBED=$ORACLE_HOME/bin/bbed
rm -f /u01/oracle/product/10.2.0/rdbms/lib/skgaioi.o
chmod 755 /u01/oracle/product/10.2.0/bin

[oracle@tf lib]$ make -f ins_rdbms.mk BBED=$ORACLE_HOME/bin/bbed $ORACLE_HOME/bin/bbed

11g的话需要获得如下文件在进行编译:

Copy $ORA10g_HOME/rdbms/lib/ssbbded.o to$ORA11g_HOME/rdbms/lib
Copy $ORA10g_HOME/rdbms/lib/sbbdpt.o to $ORA11g_HOME/rdbms/lib

Copy $ORA10g_HOME/rdbms/mesg/bbedus.msb to $ORA11g_HOME/rdbms/mesg
Copy $ORA10g_HOME/rdbms/mesg/bbedus.msg to $ORA11g_HOME/rdbms/mesg
Copy $ORA10g_HOME/rdbms/mesg/bbedar.msb to $ORA11g_HOME/rdbms/mesg

make -f $ORA11g_HOME/rdbms/lib/ins_rdbms.mkBBED=$ORACLE_HOME/bin/bbed $ORACLE_HOME/bin/bbed

开始使用bbed工具:

SQL> select file_id||' '||file_name||' '||bytes parbbed from dba_data_files
2 ;

PARBBED
--------------------------------------------------------------------------------
4 /u01/oracle/oradata/tf1/users01.dbf 5242880
3 /u01/oracle/oradata/tf1/sysaux01.dbf 241172480
2 /u01/oracle/oradata/tf1/undotbs01.dbf 26214400
1 /u01/oracle/oradata/tf1/system01.dbf 503316480

SQL>

[oracle@tf bbed]$ more file.txt
4 /u01/oracle/oradata/tf1/users01.dbf 5242880
3 /u01/oracle/oradata/tf1/sysaux01.dbf 241172480
2 /u01/oracle/oradata/tf1/undotbs01.dbf 26214400
1 /u01/oracle/oradata/tf1/system01.dbf 503316480
[oracle@tf bbed]$ more parbbed.par
blocksize=8192
listfile=/home/oracle/bbed/file.txt
mode=edit
[oracle@tf bbed]$

[oracle@tf bbed]$ bbed -help
LRM-00118: syntax error at '-' at the end of input
PASSWORD - Required parameter
FILENAME - Database file name
BLOCKSIZE - Database block size
LISTFILE - List file name
MODE - [browse/edit]
SPOOL - Spool to logfile [no/yes]
CMDFILE - BBED command file name
LOGFILE - BBED log file name
PARFILE - Parameter file name
BIFILE - BBED before-image file name
REVERT - Rollback changes from BIFILE [no/yes]
SILENT - Hide banner [no/yes]
HELP - Show all valid parameters [no/yes]
BBED-00105: LRM error 110 occurred during command line parsing

[oracle@tf bbed]$


[oracle@tf bbed]$ bbed parfile=parbbed.par
Password:

BBED: Release 2.0.0.0.0 - Limited Production on Sat Nov 23 09:20:46 2013

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

************* !!! For Oracle Internal Use only !!! ***************

BBED> set file 1
FILE# 1

BBED> set block 1
BLOCK# 1

BBED> map
File: /u01/oracle/oradata/tf1/system01.dbf (1)
Block: 1 Dba:0x00400001
------------------------------------------------------------
Data File Header

struct kcvfh, 676 bytes @0

ub4 tailchk @8188


BBED> p kcvfh
struct kcvfh, 676 bytes @0
struct kcvfhbfh, 20 bytes @0
ub1 type_kcbh @0 0x0b
ub1 frmt_kcbh @1 0xa2
ub1 spare1_kcbh @2 0x00
ub1 spare2_kcbh @3 0x00
ub4 rdba_kcbh @4 0x00400001
ub4 bas_kcbh @8 0x00000000
ub2 wrp_kcbh @12 0x0000
ub1 seq_kcbh @14 0x01
ub1 flg_kcbh @15 0x04 (KCBHFCKV)
ub2 chkval_kcbh @16 0x6504
ub2 spare3_kcbh @18 0x0000
struct kcvfhhdr, 76 bytes @20
ub4 kccfhswv @20 0x00000000
ub4 kccfhcvn @24 0x0a200100
ub4 kccfhdbi @28 0xfb13c8d9
text kccfhdbn[0] @32 T
text kccfhdbn[1] @33 F
text kccfhdbn[2] @34 1
text kccfhdbn[3] @35
text kccfhdbn[4] @36
text kccfhdbn[5] @37
text kccfhdbn[6] @38
text kccfhdbn[7] @39
ub4 kccfhcsq @40 0x00000234
ub4 kccfhfsz @44 0x0000f000
s_blkz kccfhbsz @48 0x00
ub2 kccfhfno @52 0x0001
ub2 kccfhtyp @54 0x0003
ub4 kccfhacid @56 0x00000000
ub4 kccfhcks @60 0x00000000
text kccfhtag[0] @64
text kccfhtag[1] @65
text kccfhtag[2] @66
text kccfhtag[3] @67
text kccfhtag[4] @68
text kccfhtag[5] @69
text kccfhtag[6] @70
text kccfhtag[7] @71
text kccfhtag[8] @72
text kccfhtag[9] @73
text kccfhtag[10] @74
text kccfhtag[11] @75
text kccfhtag[12] @76
text kccfhtag[13] @77
text kccfhtag[14] @78
text kccfhtag[15] @79
text kccfhtag[16] @80
text kccfhtag[17] @81
text kccfhtag[18] @82
text kccfhtag[19] @83
text kccfhtag[20] @84
text kccfhtag[21] @85
text kccfhtag[22] @86
text kccfhtag[23] @87
text kccfhtag[24] @88
text kccfhtag[25] @89
text kccfhtag[26] @90
text kccfhtag[27] @91
text kccfhtag[28] @92
text kccfhtag[29] @93
text kccfhtag[30] @94
text kccfhtag[31] @95
ub4 kcvfhrdb @96 0x00400179
struct kcvfhcrs, 8 bytes @100
ub4 kscnbas @100 0x00000009
ub2 kscnwrp @104 0x0000
ub4 kcvfhcrt @108 0x2184ef93
ub4 kcvfhrlc @112 0x3161af1c
struct kcvfhrls, 8 bytes @116
ub4 kscnbas @116 0x0006ce7b
ub2 kscnwrp @120 0x0000
ub4 kcvfhbti @124 0x00000000
struct kcvfhbsc, 8 bytes @128
ub4 kscnbas @128 0x00000000
ub2 kscnwrp @132 0x0000
ub2 kcvfhbth @136 0x0000
ub2 kcvfhsta @138 0x2004 (KCVFHOFZ)
struct kcvfhckp, 36 bytes @484
struct kcvcpscn, 8 bytes @484
ub4 kscnbas @484 0x000ae617
ub2 kscnwrp @488 0x0000
ub4 kcvcptim @492 0x319af16b
ub2 kcvcpthr @496 0x0001
union u, 12 bytes @500
struct kcvcprba, 12 bytes @500
ub4 kcrbaseq @500 0x0000000d
ub4 kcrbabno @504 0x00000002
ub2 kcrbabof @508 0x0010
ub1 kcvcpetb[0] @512 0x02
ub1 kcvcpetb[1] @513 0x00
ub1 kcvcpetb[2] @514 0x00
ub1 kcvcpetb[3] @515 0x00
ub1 kcvcpetb[4] @516 0x00
ub1 kcvcpetb[5] @517 0x00
ub1 kcvcpetb[6] @518 0x00
ub1 kcvcpetb[7] @519 0x00
ub4 kcvfhcpc @140 0x00000056
ub4 kcvfhrts @144 0x319af169
ub4 kcvfhccc @148 0x00000055
struct kcvfhbcp, 36 bytes @152
struct kcvcpscn, 8 bytes @152
ub4 kscnbas @152 0x00000000
ub2 kscnwrp @156 0x0000
ub4 kcvcptim @160 0x00000000
ub2 kcvcpthr @164 0x0000
union u, 12 bytes @168
struct kcvcprba, 12 bytes @168
ub4 kcrbaseq @168 0x00000000
ub4 kcrbabno @172 0x00000000
ub2 kcrbabof @176 0x0000
ub1 kcvcpetb[0] @180 0x00
ub1 kcvcpetb[1] @181 0x00
ub1 kcvcpetb[2] @182 0x00
ub1 kcvcpetb[3] @183 0x00
ub1 kcvcpetb[4] @184 0x00
ub1 kcvcpetb[5] @185 0x00
ub1 kcvcpetb[6] @186 0x00
ub1 kcvcpetb[7] @187 0x00
ub4 kcvfhbhz @312 0x00000000
struct kcvfhxcd, 16 bytes @316
ub4 space_kcvmxcd[0] @316 0x00000000
ub4 space_kcvmxcd[1] @320 0x00000000
ub4 space_kcvmxcd[2] @324 0x00000000
ub4 space_kcvmxcd[3] @328 0x00000000
word kcvfhtsn @332 0
ub2 kcvfhtln @336 0x0006
text kcvfhtnm[0] @338 S
text kcvfhtnm[1] @339 Y
text kcvfhtnm[2] @340 S
text kcvfhtnm[3] @341 T
text kcvfhtnm[4] @342 E
text kcvfhtnm[5] @343 M

BBED> set dba 2,1
DBA 0x00800001 (8388609 2,1)

BBED> map
File: /u01/oracle/oradata/tf1/undotbs01.dbf (2)
Block: 1 Dba:0x00800001
------------------------------------------------------------
Data File Header

struct kcvfh, 676 bytes @0

ub4 tailchk @8188


BBED> p kcvfh
struct kcvfh, 676 bytes @0
struct kcvfhbfh, 20 bytes @0
ub1 type_kcbh @0 0x0b
ub1 frmt_kcbh @1 0xa2
ub1 spare1_kcbh @2 0x00
ub1 spare2_kcbh @3 0x00
ub4 rdba_kcbh @4 0x00800001
ub4 bas_kcbh @8 0x00000000
ub2 wrp_kcbh @12 0x0000
ub1 seq_kcbh @14 0x01
ub1 flg_kcbh @15 0x04 (KCBHFCKV)
ub2 chkval_kcbh @16 0x59c5
ub2 spare3_kcbh @18 0x0000
struct kcvfhhdr, 76 bytes @20
ub4 kccfhswv @20 0x00000000
ub4 kccfhcvn @24 0x0a200100
ub4 kccfhdbi @28 0xfb13c8d9
text kccfhdbn[0] @32 T
text kccfhdbn[1] @33 F
text kccfhdbn[2] @34 1
text kccfhdbn[3] @35
text kccfhdbn[4] @36
text kccfhdbn[5] @37
text kccfhdbn[6] @38
text kccfhdbn[7] @39
ub4 kccfhcsq @40 0x00000234
ub4 kccfhfsz @44 0x00000c80
s_blkz kccfhbsz @48 0x00
ub2 kccfhfno @52 0x0002
ub2 kccfhtyp @54 0x0003
ub4 kccfhacid @56 0x00000000
ub4 kccfhcks @60 0x00000000
text kccfhtag[0] @64
text kccfhtag[1] @65
text kccfhtag[2] @66
text kccfhtag[3] @67
text kccfhtag[4] @68
text kccfhtag[5] @69
text kccfhtag[6] @70
text kccfhtag[7] @71
text kccfhtag[8] @72
text kccfhtag[9] @73
text kccfhtag[10] @74
text kccfhtag[11] @75
text kccfhtag[12] @76
text kccfhtag[13] @77
text kccfhtag[14] @78
text kccfhtag[15] @79
text kccfhtag[16] @80
text kccfhtag[17] @81
text kccfhtag[18] @82
text kccfhtag[19] @83
text kccfhtag[20] @84
text kccfhtag[21] @85
text kccfhtag[22] @86
text kccfhtag[23] @87
text kccfhtag[24] @88
text kccfhtag[25] @89
text kccfhtag[26] @90
text kccfhtag[27] @91
text kccfhtag[28] @92
text kccfhtag[29] @93
text kccfhtag[30] @94
text kccfhtag[31] @95
ub4 kcvfhrdb @96 0x00000000
struct kcvfhcrs, 8 bytes @100
ub4 kscnbas @100 0x0006c6af
ub2 kscnwrp @104 0x0000
ub4 kcvfhcrt @108 0x2184fa15
ub4 kcvfhrlc @112 0x3161af1c
struct kcvfhrls, 8 bytes @116
ub4 kscnbas @116 0x0006ce7b
ub2 kscnwrp @120 0x0000
ub4 kcvfhbti @124 0x00000000
struct kcvfhbsc, 8 bytes @128
ub4 kscnbas @128 0x00000000
ub2 kscnwrp @132 0x0000
ub2 kcvfhbth @136 0x0000
ub2 kcvfhsta @138 0x0004 (KCVFHOFZ)
struct kcvfhckp, 36 bytes @484
struct kcvcpscn, 8 bytes @484
ub4 kscnbas @484 0x000ae617
ub2 kscnwrp @488 0x0000
ub4 kcvcptim @492 0x319af16b
ub2 kcvcpthr @496 0x0001
union u, 12 bytes @500
struct kcvcprba, 12 bytes @500
ub4 kcrbaseq @500 0x0000000d
ub4 kcrbabno @504 0x00000002
ub2 kcrbabof @508 0x0010
ub1 kcvcpetb[0] @512 0x02
ub1 kcvcpetb[1] @513 0x00
ub1 kcvcpetb[2] @514 0x00
ub1 kcvcpetb[3] @515 0x00
ub1 kcvcpetb[4] @516 0x00
ub1 kcvcpetb[5] @517 0x00
ub1 kcvcpetb[6] @518 0x00
ub1 kcvcpetb[7] @519 0x00
ub4 kcvfhcpc @140 0x00000031
ub4 kcvfhrts @144 0x319af169
ub4 kcvfhccc @148 0x00000030
struct kcvfhbcp, 36 bytes @152
struct kcvcpscn, 8 bytes @152
ub4 kscnbas @152 0x00000000
ub2 kscnwrp @156 0x0000
ub4 kcvcptim @160 0x00000000
ub2 kcvcpthr @164 0x0000
union u, 12 bytes @168
struct kcvcprba, 12 bytes @168
ub4 kcrbaseq @168 0x00000000
ub4 kcrbabno @172 0x00000000
ub2 kcrbabof @176 0x0000
ub1 kcvcpetb[0] @180 0x00
ub1 kcvcpetb[1] @181 0x00
ub1 kcvcpetb[2] @182 0x00
ub1 kcvcpetb[3] @183 0x00
ub1 kcvcpetb[4] @184 0x00
ub1 kcvcpetb[5] @185 0x00
ub1 kcvcpetb[6] @186 0x00
ub1 kcvcpetb[7] @187 0x00
ub4 kcvfhbhz @312 0x00000000
struct kcvfhxcd, 16 bytes @316
ub4 space_kcvmxcd[0] @316 0x00000000
ub4 space_kcvmxcd[1] @320 0x00000000
ub4 space_kcvmxcd[2] @324 0x00000000
ub4 space_kcvmxcd[3] @328 0x00000000
word kcvfhtsn @332 1
ub2 kcvfhtln @336 0x0008
text kcvfhtnm[0] @338 U
text kcvfhtnm[1] @339 N
text kcvfhtnm[2] @340 D
text kcvfhtnm[3] @341 O
text kcvfhtnm[4] @342 T
text kcvfhtnm[5] @343 B
text kcvfhtnm[6] @344 S
text kcvfhtnm[7] @345 1

可以看到在每个数据文件头都会存有db_name另外还有控制文件也存在db_name信息,并且在数据库mount过程中会验证控制文件中的db_name是否和参数文件中的db_name是否一致,如果不一致则数据库无法mount。

eg:

SQL> show parameter db_name

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_name string tf1
SQL> alter system set db_name=rhys scope=spfile;
alter system set db_name=rhys scope=spfile
*
ERROR at line 1:
ORA-32017: failure in updating SPFILE
ORA-32016: parameter "db_name" cannot be updated in SPFILE


SQL> show parameter spfile

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string /u01/oracle/product/10.2.0/dbs
/spfiletf1.ora
SQL> create pfile=/home/oracle/pfile.ora from spfile;


SQL> create pfile='/home/oracle/pfile.ora' from spfile;

File created.

SQL>

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> !vi /home/oracle/pfile.ora

tf1.__db_cache_size=197132288
tf1.__java_pool_size=4194304
tf1.__large_pool_size=4194304
tf1.__shared_pool_size=62914560
tf1.__streams_pool_size=8388608
*.audit_file_dest='/u01/oracle/admin/tf1/adump'
*.background_dump_dest='/u01/oracle/admin/tf1/bdump'
*.compatible='10.2.0.1.0'
*.control_files='/u01/oracle/oradata/tf1/control01.ctl','/u01/oracle/oradata/tf1/control02.ctl','/u01/oracle/oradata/tf1/control03.ctl'
*.core_dump_dest='/u01/oracle/admin/tf1/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='rhys'
*.db_recovery_file_dest='/u01/oracle/flash_recovery_area'
*.db_recovery_file_dest_size=2147483648
*.dispatchers='(PROTOCOL=TCP) (SERVICE=tf1XDB)'
*.job_queue_processes=10
*.open_cursors=300

SQL>
SQL> create spfile from pfile='/home/oracle/pfile.ora';

File created.

SQL> startup mount
ORACLE instance started.

Total System Global Area 285212672 bytes
Fixed Size 1219016 bytes
Variable Size 79693368 bytes
Database Buffers 197132288 bytes
Redo Buffers 7168000 bytes
ORA-01103: database name 'TF1' in control file is not 'RHYS'


SQL>

修改db_name,可以使用oracle自带的工具nit,在修改后数据库的db_name和dbid会变动,且数据库需要在mount状态下:

eg:

SQL> show parameter service

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
service_names string tf1
SQL> show parameter db_name

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_name string tf1
SQL> select dbid from v$database;

DBID
----------
4212377817

SQL> shutdown immediate

SQL> startup mount
ORACLE instance started.

Total System Global Area 285212672 bytes
Fixed Size 1219016 bytes
Variable Size 79693368 bytes
Database Buffers 197132288 bytes
Redo Buffers 7168000 bytes
Database mounted.
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@tf bbed]$ nid

DBNEWID: Release 10.2.0.1.0 - Production on Sat Nov 23 09:48:45 2013

Copyright (c) 1982, 2005, Oracle. 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

[oracle@tf bbed]$ nid target=sys/root dbname=rhys

DBNEWID: Release 10.2.0.1.0 - Production on Sat Nov 23 09:48:54 2013

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

Connected to database TF1 (DBID=4212377817)

Connected to server version 10.2.0

Control Files in database:
/u01/oracle/oradata/tf1/control01.ctl
/u01/oracle/oradata/tf1/control02.ctl
/u01/oracle/oradata/tf1/control03.ctl

Change database ID and database name TF1 to RHYS? (Y/[N]) => y

Proceeding with operation
Changing database ID from 4212377817 to 2744604102
Changing database name from TF1 to RHYS
Control File /u01/oracle/oradata/tf1/control01.ctl - modified
Control File /u01/oracle/oradata/tf1/control02.ctl - modified
Control File /u01/oracle/oradata/tf1/control03.ctl - modified
Datafile /u01/oracle/oradata/tf1/system01.dbf - dbid changed, wrote new name
Datafile /u01/oracle/oradata/tf1/undotbs01.dbf - dbid changed, wrote new name
Datafile /u01/oracle/oradata/tf1/sysaux01.dbf - dbid changed, wrote new name
Datafile /u01/oracle/oradata/tf1/users01.dbf - dbid changed, wrote new name
Datafile /u01/oracle/oradata/tf1/temp01.dbf - dbid changed, wrote new name
Control File /u01/oracle/oradata/tf1/control01.ctl - dbid changed, wrote new name
Control File /u01/oracle/oradata/tf1/control02.ctl - dbid changed, wrote new name
Control File /u01/oracle/oradata/tf1/control03.ctl - dbid changed, wrote new name
Instance shut down

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

[oracle@tf bbed]$

SQL> startup
ORACLE instance started.

Total System Global Area 285212672 bytes
Fixed Size 1219016 bytes
Variable Size 79693368 bytes
Database Buffers 197132288 bytes
Redo Buffers 7168000 bytes
ORA-01103: database name 'RHYS' in control file is not 'TF1'


SQL>

改完后还需要修改参数文件,参数修改完后,数据库相当于进入了一个新的生命期,需要使用resetlogs打开数据库。

eg:

SQL> startup
ORACLE instance started.

Total System Global Area 285212672 bytes
Fixed Size 1219016 bytes
Variable Size 79693368 bytes
Database Buffers 197132288 bytes
Redo Buffers 7168000 bytes
Database mounted.
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open


SQL> alter database open noresetlogs
2 ;
alter database open noresetlogs
*
ERROR at line 1:
ORA-01588: must use RESETLOGS option for database open


SQL> alter database open resetlogs;

Database altered.

SQL> select dbid from v$database;

DBID
----------
2744604102

SQL> show parameter db_name

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_name string rhys
SQL> show parameter service_

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
service_names string rhys
SQL>

SQL> select * from v$log;

GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
1 1 0 52428800 1 YES UNUSED 0
2 1 0 52428800 1 YES UNUSED 0
3 1 1 52428800 1 NO CURRENT 720302 23-NOV-13


That's all!



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.iyunv.com/thread-10664-1-1.html 上篇帖子: oracle Linux 6.3 安装oracle11g安装过程详解 下篇帖子: oracle如何通过同义词定位对象 oracle

尚未签到

发表于 2013-12-28 23:13:16 | 显示全部楼层
伤感个性签名:习惯一个人在那街角徘徊然后慢慢回忆你是如何远去。

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表