Mudar SID do banco

DBA Geral (instalação, configuração do banco, scripts do Sql*Plus, shell scripts, batch scripts, etc...)
Responder
diegolenhardt
Moderador
Moderador
Mensagens: 1177
Registrado em: Qui, 15 Out 2009 10:28 am
Localização: Recife

Informações do Ambiente:
* Versão do Oracle: 10
* Sistema Operacional: OEL5

aí pessoal, alguém tem algum how-to para mudar o SID de um banco
tava vendo um utilitario nid, não sei se fiz errado ou não mas, não deu muito certo,

quero clonar o ambiente de producao para criar um ambiente de desenvolvimento, com o rman,

o duplicate vai criar na mesma maquina, quero criar em maquinas diferentes,

como seria?
victorhugomuniz
Moderador
Moderador
Mensagens: 1396
Registrado em: Sex, 01 Fev 2008 2:06 pm
Localização: Rio de Janeiro - RJ
Contato:
:D

NID
DBNEWID is a database utility that can change the internal database identifier (DBID) and the database name (DBNAME) for an operational database.

Prior to the introduction of the DBNEWID utility, you could manually create a copy of a database and give it a new database name (DBNAME) by re-creating the control file. However, you could not give the database a new identifier (DBID). The DBID is an internal, unique identifier for a database. Because Recovery Manager (RMAN) distinguishes databases by DBID, you could not register a seed database and a manually copied database together in the same RMAN repository. The DBNEWID utility solves this problem by allowing you to change any of the following:

* Only the DBID of a database
* Only the DBNAME of a database
* Both the DBNAME and DBID of a database

Changing the DBID of a database is a serious procedure. When the DBID of a database is changed, all previous backups and archived logs of the database become unusable. After you change the DBID, you must open the database with the RESETLOGS option, which re-creates the online redo logs and resets their sequence to 1 (see the Oracle9i Database Administrator's Guide). Consequently, you should make a backup of the whole database immediately after changing the DBID.

Changing the DBNAME without changing the DBID does not require you to open with the RESETLOGS option, so database backups and archived logs are not invalidated. However, changing the DBNAME does have consequences. You must change the DB_NAME initialization parameter after a database name change to reflect the new name. Also, you may have to re-create the Oracle password file. If you restore an old backup of the control file (before the name change), then you should use the initialization parameter file and password file from before the database name change.

Syntax:
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 help messages NO
/*
Ensure that you have a recoverable whole database backup and ensure that the target database is mounted but not open, and that it was shut down consistently prior to mounting.
*/

Selecionar tudo

SHUTDOWN IMMEDIATE
STARTUP MOUNT
/* Invoke the DBNEWID utility on the command line, specifying a valid user with the SYSDBA privilege.
*/

Selecionar tudo

% nid TARGET=sys/oracle@test_db
/*
To change the database name in addition to the DBID, specify the DBNAME parameter.
This example changes the name to orabase:
*/

Selecionar tudo

% nid TARGET=sys/oracle@test DBNAME=orabase
/*
The DBNEWID utility performs validations in the headers of the datafiles and control files before attempting I/O to the files. If validation is successful, then DBNEWID prompts you to confirm the operation (unless you specify a log file, in which case it does not prompt), changes the DBID for each datafile (including offline normal and read-only datafiles), and then exits. The database is left mounted but is not yet usable.
*/

Selecionar tudo

DBNEWID: Release 10.2.0.1.0

(c) Copyright 2005 Oracle Corporation. All rights reserved.

Connected to database TEST_DB (DBID=3942195360)
Control Files in database:
/oracle/dbs/cf1.f
/oracle/dbs/cf2.f

Change database id of database SOLARIS? (Y/[N]) => y

Proceeding with operation
Datafile /oracle/dbs/tbs_01.f - changed
Datafile /oracle/dbs/tbs_02.f - changed
Datafile /oracle/dbs/tbs_11.f - changed
Datafile /oracle/dbs/tbs_12.f - changed
Datafile /oracle/dbs/tbs_21.f - changed[/code]

/*
New DBID for database TEST_DB is 3942196782.
All previous backups and archived redo logs for this database are unusable
Proceed to shutdown database and open with RESETLOGS option.
DBNEWID - Database changed.

If validation is not successful, then DBNEWID terminates and leaves the target database intact. You can open the database, fix the error, and then either resume the DBNEWID operation or continue using the database without changing its DBID.
After DBNEWID successfully changes the DBID, shut down the database
*/

Selecionar tudo

SHUTDOWN IMMEDIATE
-- Mount the database

Selecionar tudo

STARTUP MOUNT
-- Open the database in RESETLOGS mode and resume normal use

Selecionar tudo

ALTER DATABASE OPEN RESETLOGS;
/*
Make a new database backup. Because you reset the online redo logs, the old backups and archived logs are no longer usable in the current incarnation of the database.
*/
/*
The following steps describe how to change the database name without changing the DBID.

1. Ensure that you have a recoverable whole database backup.
2. Ensure that the target database is mounted but not open, and that it was shut down consistently prior to mounting.
*/

Selecionar tudo

SHUTDOWN IMMEDIATE
STARTUP MOUNT
/*
3. Invoke the utility on the command line, specifying a valid user with the SYSDBA privilege. You must specify both the DBNAME and SETNAME parameters. This example changes the name to orabase:
*/

Selecionar tudo

% nid TARGET=SYS/oracle@test_db DBNAME=orabase SETNAME=YES
/*
DBNEWID performs validations in the headers of the control files (not the datafiles) before attempting I/O to the files. If validation is successful, then DBNEWID prompts for confirmation, changes the database name in the control files, and exits. After DBNEWID completes successfully, the database is left mounted but is not yet usable.
*/

Selecionar tudo

DBNEWID: Release 10.2.0.1.0

(c) Copyright 2005 Oracle Corporation. All rights reserved.

Connected to database TEST_DB (DBID=3942196782)

Control Files in database:
/oracle/dbs/cf1.f
/oracle/dbs/cf2.f

Change database name of database TEST_DB to ORABASE? (Y/[N]) => Y

Proceeding with operation

Database name changed from TEST_DB to ORABASE - database needs to be
shutdown.
Modify parameter file and generate a new password file before restarting.

DBNEWID - Successfully changed database name
/*
If validation is not successful, then DBNEWID terminates and leaves the target database intact. You can open the database, fix the error, and then either resume the DBNEWID operation or continue using the database without changing the database name.
4. Shut down the database.
*/

Selecionar tudo

SHUTDOWN IMMEDIATE
/*
5. Set the DB_NAME initialization parameter in the initialization parameter file to the new database name.
6. Create a new password file.
7. Start up the database and resume normal use.
*/


http://glufke.net/oracle/viewtopic.php?t=2889
pedroedu
Rank: Programador Sênior
Rank: Programador Sênior
Mensagens: 50
Registrado em: Qua, 10 Fev 2010 3:04 pm
Localização: são Luis
Oracle Database 10g/12c Administrator Certified Professional
Oracle Database 11g Security
ISFS Information Security Foundation based on ISO IEC 27001
ITIL® Foundation V3 in IT Service Management

simples e facil, depois de restaurar o banco com o mesmo nome, você altera a sid no init, na variavel ORACLE_SID e recria o controlfile com o trace, você deve saber do q tou falando, la dentro do trace (gerado pelo comando alter database backup controlfile to trace as '/tmp/coltrolfile.txt' ) altera a sid:

Selecionar tudo

CREATE CONTROLFILE REUSE SET DATABASE [b]SID_NOVA[/b] NORESETLOGS ARCHIVELOG 
apos recriar o controlfile você vai executar o alter database open e proooonto. :wink:
annubiss
Rank: Programador Júnior
Rank: Programador Júnior
Mensagens: 26
Registrado em: Sex, 05 Fev 2010 12:43 pm
Localização: RS

O que seria SID do banco exatamente?

Tipo um nome no qual vai usar pra se conectar?
victorhugomuniz
Moderador
Moderador
Mensagens: 1396
Registrado em: Sex, 01 Fev 2008 2:06 pm
Localização: Rio de Janeiro - RJ
Contato:
:D

The Oracle System ID (SID) is used to uniquely identify a particular database on a system. For this reason, one cannot have more than one database with the same SID on a computer system.

When using RAC, all instances belonging to the same database must have unique SID's.
annubiss
Rank: Programador Júnior
Rank: Programador Júnior
Mensagens: 26
Registrado em: Sex, 05 Fev 2010 12:43 pm
Localização: RS

Entendi... vlw cara!
Responder
  • Informação
  • Quem está online

    Usuários navegando neste fórum: Nenhum usuário registrado e 1 visitante