Oracle 11gr2 rac nid change db_name and dbid practice

[BEGIN] 2016/12/23 19:24:09
1.主机版本信息:
[root@node1 ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.7 (Santiago)
[root@node1 ~]# arch
x86_64
[root@node1 ~]# uname -a
Linux node1 2.6.32-573.el6.x86_64 #1 SMP Wed Jul 1 18:23:37 EDT 2015 x86_64 x86_64 x86_64 GNU/Linux
[root@node1 ~]#
[root@node1 ~]#
[root@node1 ~]#
[root@node1 ~]#
2.drop dbconsole

未配置略

3.原有数据库dbid db_name:
[root@node1 ~]# su - orardbms
[orardbms@node1 ~]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.4.0 Production on Sat Dec 24 03:24:35 2016

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

SQL> connect /as sysDBA
Connected.



SQL> select open_mode,inst_id,dbid,name from gv$database;

OPEN_MODE                INST_ID       DBID NAME
-------------------- ---------- ---------- ---------
READ WRITE                      1  986006396 ORCC
READ WRITE                      2  986006396 ORCC

SQL>
SQL>
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options

原有环境集群信息:
[orardbms@node1 ~]$ crs_stat -t
-bash: crs_stat: command not found
[orardbms@node1 ~]$ exit
logout
[root@node1 ~]# su - oragrid
[oragrid@node1 ~]$ crs_stat -t
Name           Type           Target    State     Host        
------------------------------------------------------------
ora.ARCH.dg    ora....up.type ONLINE    ONLINE    node1      
ora.DATA.dg    ora....up.type ONLINE    ONLINE    node1      
ora....ER.lsnr ora....er.type ONLINE    ONLINE    node1      
ora....N1.lsnr ora....er.type ONLINE    ONLINE    node2      
ora.OCRVOTE.dg ora....up.type ONLINE    ONLINE    node1      
ora.asm        ora.asm.type   ONLINE    ONLINE    node1      
ora.cvu        ora.cvu.type   ONLINE    ONLINE    node2      
ora.gsd        ora.gsd.type   OFFLINE   OFFLINE               
ora....network ora....rk.type ONLINE    ONLINE    node1      
ora....SM1.asm application    ONLINE    ONLINE    node1      
ora....E1.lsnr application    ONLINE    ONLINE    node1      
ora.node1.gsd  application    OFFLINE   OFFLINE               
ora.node1.ons  application    ONLINE    ONLINE    node1      
ora.node1.vip  ora....t1.type ONLINE    ONLINE    node1      
ora....SM2.asm application    ONLINE    ONLINE    node2      
ora....E2.lsnr application    ONLINE    ONLINE    node2      
ora.node2.gsd  application    OFFLINE   OFFLINE               
ora.node2.ons  application    ONLINE    ONLINE    node2      
ora.node2.vip  ora....t1.type ONLINE    ONLINE    node2      
ora.oc4j       ora.oc4j.type  ONLINE    ONLINE    node2      
ora.ons        ora.ons.type   ONLINE    ONLINE    node1      
ora.orcc.db    ora....se.type ONLINE    ONLINE    node1      
ora....ry.acfs ora....fs.type ONLINE    ONLINE    node1      
ora.scan1.vip  ora....ip.type ONLINE    ONLINE    node2      
[oragrid@node1 ~]$ exit
logout

cluster 参数信息:
[root@node1 ~]# su - orardbms
[orardbms@node1 ~]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.4.0 Production on Sat Dec 24 03:26:14 2016

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

SQL> connect /as sysdba
Connected.
SQL> show parameter cluster

NAME                                     TYPE         VALUE
------------------------------------ ----------- ------------------------------
cluster_database                     boolean         TRUE
cluster_database_instances             integer         2
cluster_interconnects                     string
SQL>
SQL>
SQL>
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options

[orardbms@node1 admin]$


4.备份数据库(略)

5.修改cluster_database参数:
[orardbms@node1 admin]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.4.0 Production on Sat Dec 24 03:34:04 2016

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

SQL> connect /as sysdba
Connected.
SQL> show parameter cluster;

NAME                                     TYPE         VALUE
------------------------------------ ----------- ------------------------------
cluster_database                     boolean         TRUE
cluster_database_instances             integer         2
cluster_interconnects                     string

SQL> ALTER SYSTEM SET CLUSTER_DATABASE=FALSE SCOPE=SPFILE;

System altered.

SQL> EXIT
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options

6.关闭数据库:
[orardbms@node1 admin]$ srvctl stop database -d orcc -o immediate;

[root@node1 ~]# su - oragrid
[oragrid@node1 ~]$ crs_stat -t
Name           Type           Target    State     Host        
------------------------------------------------------------
ora.ARCH.dg    ora....up.type ONLINE    ONLINE    node1      
ora.DATA.dg    ora....up.type ONLINE    ONLINE    node1      
ora....ER.lsnr ora....er.type ONLINE    ONLINE    node1      
ora....N1.lsnr ora....er.type ONLINE    ONLINE    node2      
ora.OCRVOTE.dg ora....up.type ONLINE    ONLINE    node1      
ora.asm        ora.asm.type   ONLINE    ONLINE    node1      
ora.cvu        ora.cvu.type   ONLINE    ONLINE    node2      
ora.gsd        ora.gsd.type   OFFLINE   OFFLINE               
ora....network ora....rk.type ONLINE    ONLINE    node1      
ora....SM1.asm application    ONLINE    ONLINE    node1      
ora....E1.lsnr application    ONLINE    ONLINE    node1      
ora.node1.gsd  application    OFFLINE   OFFLINE               
ora.node1.ons  application    ONLINE    ONLINE    node1      
ora.node1.vip  ora....t1.type ONLINE    ONLINE    node1      
ora....SM2.asm application    ONLINE    ONLINE    node2      
ora....E2.lsnr application    ONLINE    ONLINE    node2      
ora.node2.gsd  application    OFFLINE   OFFLINE               
ora.node2.ons  application    ONLINE    ONLINE    node2      
ora.node2.vip  ora....t1.type ONLINE    ONLINE    node2      
ora.oc4j       ora.oc4j.type  ONLINE    ONLINE    node2      
ora.ons        ora.ons.type   ONLINE    ONLINE    node1      
ora.orcc.db    ora....se.type OFFLINE   OFFLINE               
ora....ry.acfs ora....fs.type ONLINE    ONLINE    node1      
ora.scan1.vip  ora....ip.type ONLINE    ONLINE    node2  

7.仅启动数据库实例1至mount状态:     
[oragrid@node1 ~]$ srvctl start instance -d orcc -i orcc1 -o mount;
[oragrid@node1 ~]$ crs_stat -t
Name           Type           Target    State     Host        
------------------------------------------------------------
ora.ARCH.dg    ora....up.type ONLINE    ONLINE    node1      
ora.DATA.dg    ora....up.type ONLINE    ONLINE    node1      
ora....ER.lsnr ora....er.type ONLINE    ONLINE    node1      
ora....N1.lsnr ora....er.type ONLINE    ONLINE    node2      
ora.OCRVOTE.dg ora....up.type ONLINE    ONLINE    node1      
ora.asm        ora.asm.type   ONLINE    ONLINE    node1      
ora.cvu        ora.cvu.type   ONLINE    ONLINE    node2      
ora.gsd        ora.gsd.type   OFFLINE   OFFLINE               
ora....network ora....rk.type ONLINE    ONLINE    node1      
ora....SM1.asm application    ONLINE    ONLINE    node1      
ora....E1.lsnr application    ONLINE    ONLINE    node1      
ora.node1.gsd  application    OFFLINE   OFFLINE               
ora.node1.ons  application    ONLINE    ONLINE    node1      
ora.node1.vip  ora....t1.type ONLINE    ONLINE    node1      
ora....SM2.asm application    ONLINE    ONLINE    node2      
ora....E2.lsnr application    ONLINE    ONLINE    node2      
ora.node2.gsd  application    OFFLINE   OFFLINE               
ora.node2.ons  application    ONLINE    ONLINE    node2      
ora.node2.vip  ora....t1.type ONLINE    ONLINE    node2      
ora.oc4j       ora.oc4j.type  ONLINE    ONLINE    node2      
ora.ons        ora.ons.type   ONLINE    ONLINE    node1      
ora.orcc.db    ora....se.type ONLINE    ONLINE    node1      
ora....ry.acfs ora....fs.type ONLINE    ONLINE    node1      
ora.scan1.vip  ora....ip.type ONLINE    ONLINE    node2      
[oragrid@node1 ~]$ exit
logout


8.修改前备份参数文件,用于调整后修改:
[root@node1 ~]# su - orardbms
[orardbms@node1 ~]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.4.0 Production on Sat Dec 24 03:37:50 2016

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

SQL> connect /as sysdba
Connected.
SQL> create pfile='/tmp/a.ora' from spfile;

File created.

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
[orardbms@node1 ~]$
[orardbms@node1 ~]$
[orardbms@node1 ~]$
[orardbms@node1 ~]$
[orardbms@node1 ~]$


9.主机node1上mount状态下修改dbname:


[orardbms@node1 ~]$ nid TARGET=sys/oracle@orcc DBNAME=ORCL

DBNEWID: Release 11.2.0.4.0 - Production on Sat Dec 24 03:39:11 2016

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

Connected to database ORCC (DBID=986006396)

Connected to server version 11.2.0

Control Files in database:
    +DATA/orcc/controlfile/current.256.917398463
    +ARCH/orcc/controlfile/current.256.917398465

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

Proceeding with operation
Changing database ID from 986006396 to 1459221727
Changing database name from ORCC to ORCL
    Control File +DATA/orcc/controlfile/current.256.917398463 - modified
    Control File +ARCH/orcc/controlfile/current.256.917398465 - modified
    Datafile +DATA/orcc/datafile/system.259.91739846 - dbid changed, wrote new name
    Datafile +DATA/orcc/datafile/sysaux.260.91739847 - dbid changed, wrote new name
    Datafile +DATA/orcc/datafile/undotbs1.261.91739848 - dbid changed, wrote new name
    Datafile +DATA/orcc/datafile/undotbs2.263.91739848 - dbid changed, wrote new name
    Datafile +DATA/orcc/datafile/users.264.91739849 - dbid changed, wrote new name
    Datafile +DATA/orcc/tempfile/temp.262.91739848 - dbid changed, wrote new name
    Control File +DATA/orcc/controlfile/current.256.917398463 - dbid changed, wrote new name
    Control File +ARCH/orcc/controlfile/current.256.917398465 - dbid changed, wrote new name
    Instance shut down

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

[orardbms@node1 ~]$
[orardbms@node1 ~]$
[orardbms@node1 ~]$
[orardbms@node1 ~]$


10.修改参数文件
修改前参数文件:
[orardbms@node1 ~]$ cat /tmp/a.ora
orcc2.__db_cache_size=1828716544
orcc1.__db_cache_size=1828716544
orcc2.__java_pool_size=16777216
orcc1.__java_pool_size=16777216
orcc2.__large_pool_size=33554432
orcc1.__large_pool_size=100663296
orcc2.__pga_aggregate_target=838860800
orcc1.__pga_aggregate_target=838860800
orcc2.__sga_target=2483027968
orcc1.__sga_target=2483027968
orcc2.__shared_io_pool_size=0
orcc1.__shared_io_pool_size=0
orcc2.__shared_pool_size=570425344
orcc1.__shared_pool_size=503316480
orcc2.__streams_pool_size=0
orcc1.__streams_pool_size=0
*.audit_file_dest='/oracle/oracle_base/admin/orcc/adump'
*.audit_trail='db'
*.cluster_database=FALSE
*.compatible='11.2.0.4.0'
*.control_files='+DATA/orcc/controlfile/current.256.917398463','+ARCH/orcc/controlfile/current.256.917398465'
*.db_block_size=8192
*.db_create_file_dest='+DATA'
*.db_domain=''
*.db_name='orcc'
*.db_recovery_file_dest='+ARCH'
*.db_recovery_file_dest_size=6005194752
*.diagnostic_dest='/oracle/oracle_base'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orccXDB)'
orcc1.instance_number=1
orcc2.instance_number=2
*.log_archive_format='%t_%s_%r.dbf'
*.open_cursors=300
*.pga_aggregate_target=823132160
*.processes=150
*.remote_listener='node-scan:1521'
*.remote_login_passwordfile='exclusive'
*.sga_target=2470445056
orcc2.thread=2
orcc1.thread=1
orcc2.undo_tablespace='UNDOTBS2'
orcc1.undo_tablespace='UNDOTBS1'

调整后参数文件:
[orardbms@node1 ~]$ vi /tmp/a.ora
[orardbms@node1 ~]$ cat /tmp/a.ora
orcl2.__db_cache_size=1828716544
orcl1.__db_cache_size=1828716544
orcl2.__java_pool_size=16777216
orcl1.__java_pool_size=16777216
orcl2.__large_pool_size=33554432
orcl1.__large_pool_size=100663296
orcl2.__pga_aggregate_target=838860800
orcl1.__pga_aggregate_target=838860800
orcl2.__sga_target=2483027968
orcl1.__sga_target=2483027968
orcl2.__shared_io_pool_size=0
orcl1.__shared_io_pool_size=0
orcl2.__shared_pool_size=570425344
orcl1.__shared_pool_size=503316480
orcl2.__streams_pool_size=0
orcl1.__streams_pool_size=0
*.audit_file_dest='/oracle/oracle_base/admin/orcc/adump'
*.audit_trail='db'
*.cluster_database=FALSE
*.compatible='11.2.0.4.0'
*.control_files='+DATA/orcc/controlfile/current.256.917398463','+ARCH/orcc/controlfile/current.256.917398465'
*.db_block_size=8192
*.db_create_file_dest='+DATA'
*.db_domain=''
*.db_name='orcl'
*.db_recovery_file_dest='+ARCH'
*.db_recovery_file_dest_size=6005194752
*.diagnostic_dest='/oracle/oracle_base'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
orcl1.instance_number=1
orcl2.instance_number=2
*.log_archive_format='%t_%s_%r.dbf'
*.open_cursors=300
*.pga_aggregate_target=823132160
*.processes=150
*.remote_listener='node-scan:1521'
*.remote_login_passwordfile='exclusive'
*.sga_target=2470445056
orcl2.thread=2
orcl1.thread=1
orcl2.undo_tablespace='UNDOTBS2'
orcl1.undo_tablespace='UNDOTBS1'
[orardbms@node1 ~]$
[orardbms@node1 ~]$
[orardbms@node1 ~]$
[orardbms@node1 ~]$
[orardbms@node1 ~]$
[orardbms@node1 ~]$



11.nid命令执行成功后数据库数据库已经关闭:
Database name changed to ORCL.
Modify parameter file and generate a new password file before restarting.
Database ID for database ORCL changed to 1459221727.
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.

12.编辑后的静态参数文件创建spfile,此时数据库处于关闭状态:
export ORACLE_SID=orcl1
su - orardbms
sqlplus /nolog


SQL> create spfile='+DATA/orcc/spfileorcl.ora' from pfile='/tmp/a.ora';

File created.
13.启动数据库并open resetlogs 模式打开:
SQL> startup
ORACLE instance started.

Total System Global Area 2471931904 bytes
Fixed Size                    2255752 bytes
Variable Size                  620758136 bytes
Database Buffers         1828716544 bytes
Redo Buffers                   20201472 bytes
Database mounted.
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open


SQL> select open_mode from v$database;

OPEN_MODE
--------------------
MOUNTED

SQL> alter database open resetlogs;

Database altered.

SQL> select name,dbid,open_mode from v$database;

NAME                DBID OPEN_MODE
--------- ---------- --------------------
ORCL          1459221727 READ WRITE
14.调整参数cluster_database=TRUE,并重启数据库
SQL> show parameter cluster

NAME                                     TYPE         VALUE
------------------------------------ ----------- ------------------------------
cluster_database                     boolean         FALSE
cluster_database_instances             integer         1
cluster_interconnects                     string


SQL> alter system set cluster_database=TRUE scope=spfile;

System altered.

SQL> startup force;
ORA-29760: instance_number parameter not specified

此报错是应为为调整ORACLE_SID全局变量

下面声明全局变量后启动再次报另外一个错误
SQL> exit
Disconnected
[orardbms@node1 ~]$ echo $ORACLE_SID
orcc1
[orardbms@node1 ~]$ export ORACLE_SID=orcl1
[orardbms@node1 ~]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.4.0 Production on Sat Dec 24 03:51:24 2016

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

SQL> connect /as sysdba
Connected to an idle instance.
SQL> startup
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/oracle/oracle_home/dbs/initorcl1.ora'

此报错原因 node1 $ORACLE_HOME/dbs/initorcc1.ora 替换为initorcl1.ora
           node2 $ORACLE_HOME/dbs/initorcc2.ora 替换为initorcl2.ora
且文件中的链接调整为  SPFILE='+DATA/orcc/spfileorcl.ora',调整步骤如下:         


SQL> exit
Disconnected
[orardbms@node1 ~]$ cd $ORACLE_HOME/dbs
[orardbms@node1 dbs]$ ls
hc_orcc1.dat  init.ora  initorcc1.ora  orapworcc1
[orardbms@node1 dbs]$ more initorcc1.ora
SPFILE='+DATA/orcc/spfileorcc.ora'
[orardbms@node1 dbs]$ mv initorcc1.ora initorcl1.ora
[orardbms@node1 dbs]$ vi initorcl1.ora
[orardbms@node1 dbs]$ cat initorcl1.ora
SPFILE='+DATA/orcc/spfileorcl.ora'
[orardbms@node1 dbs]$
[orardbms@node1 dbs]$
[orardbms@node1 dbs]$ ssh node2
[orardbms@node2 ~]$ cd $ORACLE_HOME/dbs
[orardbms@node2 dbs]$ mv initorcc2.ora initorcl2.ora
[orardbms@node2 dbs]$ vi initorcl2.ora
[orardbms@node2 dbs]$ cat initorcl2.ora
SPFILE='+DATA/orcc/spfileorcl.ora'
[orardbms@node2 dbs]$
[orardbms@node2 dbs]$
[orardbms@node2 dbs]$ exit
logout
Connection to node2 closed.




14.上面报错处理后调整cluster_database=TRUE,重启数据库

[orardbms@node1 dbs]$
[orardbms@node1 dbs]$ echo $ORACLE_SID
orcl1
[orardbms@node1 dbs]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.4.0 Production on Sat Dec 24 03:55:24 2016

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

SQL> connect /as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started.

Total System Global Area 2471931904 bytes
Fixed Size                    2255752 bytes
Variable Size                  620758136 bytes
Database Buffers         1828716544 bytes
Redo Buffers                   20201472 bytes
Database mounted.
Database opened.
SQL> show parameter cluster

NAME                                     TYPE         VALUE
------------------------------------ ----------- ------------------------------
cluster_database                     boolean         FALSE
cluster_database_instances             integer         1
cluster_interconnects                     string
SQL> alter system set cluster_database=TRUE scope=spfile;

System altered.

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area 2471931904 bytes
Fixed Size                    2255752 bytes
Variable Size                  620758136 bytes
Database Buffers         1828716544 bytes
Redo Buffers                   20201472 bytes
Database mounted.
Database opened.
SQL> show parameter cluster

NAME                                     TYPE         VALUE
------------------------------------ ----------- ------------------------------
cluster_database                     boolean         TRUE
cluster_database_instances             integer         2
cluster_interconnects                     string
SQL> select dbid,open_mode,name from gv$database;

      DBID OPEN_MODE                NAME
---------- -------------------- ---------
1459221727 READ WRITE                ORCL

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
[orardbms@node1 dbs]$ ssh node2
Last login: Sat Dec 24 03:54:33 2016 from node1
登录node2,启动数据库实例orcl2
[orardbms@node2 ~]$ echo $ORACLE_SID
orcc2
[orardbms@node2 ~]$ export ORACLE_SID=orcl2
[orardbms@node2 ~]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.4.0 Production on Sat Dec 24 03:58:31 2016

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

SQL> connect /as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started.

Total System Global Area 2471931904 bytes
Fixed Size                    2255752 bytes
Variable Size                  687867000 bytes
Database Buffers         1761607680 bytes
Redo Buffers                   20201472 bytes
Database mounted.
Database opened.
SQL> select dbid,open_mode,name from gv$database;

      DBID OPEN_MODE                NAME
---------- -------------------- ---------
1459221727 READ WRITE                ORCL
1459221727 READ WRITE                ORCL

SQL> select inst_id,dbid,open_mode from gv$database;

   INST_ID         DBID OPEN_MODE
---------- ---------- --------------------
         2 1459221727 READ WRITE
         1 1459221727 READ WRITE

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
[orardbms@node2 ~]$ exit
logout
Connection to node2 closed.
[orardbms@node1 dbs]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.4.0 Production on Sat Dec 24 04:00:02 2016

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

SQL> connect /as sysdba
Connected.
SQL> select inst_id,dbid,open_mode from gv$database;

   INST_ID         DBID OPEN_MODE
---------- ---------- --------------------
         1 1459221727 READ WRITE
         2 1459221727 READ WRITE

SQL> exit


15.下面步骤为调整密码文件,listener.ora,tnsnames.ora,remove database ,add database ,add instance 步骤
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
[orardbms@node1 dbs]$ exit
logout
[root@node1 ~]# su - oragrid
[oragrid@node1 ~]$ crs_stat -t
Name           Type           Target    State     Host        
------------------------------------------------------------
ora.ARCH.dg    ora....up.type ONLINE    ONLINE    node1      
ora.DATA.dg    ora....up.type ONLINE    ONLINE    node1      
ora....ER.lsnr ora....er.type ONLINE    ONLINE    node1      
ora....N1.lsnr ora....er.type ONLINE    ONLINE    node2      
ora.OCRVOTE.dg ora....up.type ONLINE    ONLINE    node1      
ora.asm        ora.asm.type   ONLINE    ONLINE    node1      
ora.cvu        ora.cvu.type   ONLINE    ONLINE    node2      
ora.gsd        ora.gsd.type   OFFLINE   OFFLINE               
ora....network ora....rk.type ONLINE    ONLINE    node1      
ora....SM1.asm application    ONLINE    ONLINE    node1      
ora....E1.lsnr application    ONLINE    ONLINE    node1      
ora.node1.gsd  application    OFFLINE   OFFLINE               
ora.node1.ons  application    ONLINE    ONLINE    node1      
ora.node1.vip  ora....t1.type ONLINE    ONLINE    node1      
ora....SM2.asm application    ONLINE    ONLINE    node2      
ora....E2.lsnr application    ONLINE    ONLINE    node2      
ora.node2.gsd  application    OFFLINE   OFFLINE               
ora.node2.ons  application    ONLINE    ONLINE    node2      
ora.node2.vip  ora....t1.type ONLINE    ONLINE    node2      
ora.oc4j       ora.oc4j.type  ONLINE    ONLINE    node2      
ora.ons        ora.ons.type   ONLINE    ONLINE    node1      
ora.orcc.db    ora....se.type OFFLINE   OFFLINE               
ora....ry.acfs ora....fs.type ONLINE    ONLINE    node1      
ora.scan1.vip  ora....ip.type ONLINE    ONLINE    node2      
[oragrid@node1 ~]$
[oragrid@node1 ~]$
[oragrid@node1 ~]$
[oragrid@node1 ~]$ cd $ORACLE_HOME/dbs
[oragrid@node1 dbs]$ ls -l
总用量 16
-rw-rw---- 1 oragrid oinstall 1053 12月 24 03:05 ab_+ASM1.dat
-rw-rw---- 1 oragrid oinstall 1544 12月 24 03:05 hc_+ASM1.dat
-rw-r--r-- 1 oragrid oinstall 2851 5月  15 2009 init.ora
-rw-r----- 1 oragrid oinstall 1536 7月  17 00:17 orapw+ASM
[oragrid@node1 dbs]$ exit
logout
[root@node1 ~]# su - orardbms
[orardbms@node1 ~]$ cd $ORACLE_HOME/dbs
[orardbms@node1 dbs]$ ls -l
总用量 20
-rw-rw---- 1 orardbms asmadmin 1544 12月 24 03:47 hc_orcc1.dat
-rw-rw---- 1 orardbms asmadmin 1544 12月 24 03:58 hc_orcl1.dat
-rw-r--r-- 1 orardbms oinstall 2851 5月  15 2009 init.ora
-rw-r----- 1 orardbms oinstall   35 12月 24 03:54 initorcl1.ora
-rw-r----- 1 orardbms oinstall 1536 7月  17 00:54 orapworcc1
[orardbms@node1 dbs]$ mv orapworcc1 orapworcl1
[orardbms@node1 dbs]$ ssh node2
Last login: Sat Dec 24 03:58:01 2016 from node1
[orardbms@node2 ~]$ cd $ORACLE_HOME/dbs
[orardbms@node2 dbs]$ mv orapworcc2 orapworcl2
[orardbms@node2 dbs]$
[orardbms@node2 dbs]$
[orardbms@node2 dbs]$ cd
[orardbms@node2 ~]$ vi .bash_profile
[orardbms@node2 ~]$ cat .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATHHOME/bin

export PATH
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_HOSTNAME=node2
export ORACLE_UNQNAME=orcl
export ORACLE_BASE=/oracle/oracle_base
export ORACLE_HOME=/oracle/oracle_home
export ORACLE_SID=orcl2
export PATH=/usr/sbinPATH
export PATH=$ORACLE_HOME/binPATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/JREORACLE_HOME/jlibORACLE_HOME/rdbms/jlib
# ---------------------------------------------------
# UMASK
# ---------------------------------------------------
# Set the default file mode creation mask
# (umask) to 022 to ensure that the user performing
# the Oracle software installation creates files
# with 644 permissions.
# ---------------------------------------------------
umask 022
[orardbms@node2 ~]$ source .bash_profile
[orardbms@node2 ~]$ cd $ORACLE_HOME/network/admin
[orardbms@node2 admin]$ ls
samples  shrept.lst  tnsnames.ora
[orardbms@node2 admin]$ vi tnsnames.ora
[orardbms@node2 admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /oracle/oracle_home/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = node-scan)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )

[orardbms@node2 admin]$ su - oragrid
密码:
[oragrid@node2 ~]$ cd $ORACLE_HOME/network/admin
[oragrid@node2 admin]$ ls
endpoints_listener.ora  listener.ora  listener.ora.bak.node2  samples  shrept.lst  sqlnet.ora
[oragrid@node2 admin]$ vi listener.ora
[oragrid@node2 admin]$ cat listener.ora
LISTENER_SCAN1=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN1))))                # line added by Agent
LISTENER=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER))))                # line added by Agent
ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON                # line added by Agent
ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_SCAN1=ON                # line added by Agent
[oragrid@node2 admin]$
[oragrid@node2 admin]$
[oragrid@node2 admin]$ exit
logout
[orardbms@node2 admin]$ exit
logout
Connection to node2 closed.
[orardbms@node1 dbs]$ cd $ORACLE_HOME/network/admin
[orardbms@node1 admin]$ ls
samples  shrept.lst  tnsnames.ora
[orardbms@node1 admin]$ vi tnsnames.ora
[orardbms@node1 admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /oracle/oracle_home/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = node-scan)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )

[orardbms@node1 admin]$ vi .bash_profile
[orardbms@node1 admin]$ cd
[orardbms@node1 ~]$ vi .bash_profile
[orardbms@node1 ~]$ source .bash_profile
[orardbms@node1 ~]$ cat .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATHHOME/bin

export PATH
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_HOSTNAME=node1
export ORACLE_UNQNAME=orcl
export ORACLE_BASE=/oracle/oracle_base
export ORACLE_HOME=/oracle/oracle_home
export ORACLE_SID=orcl1
export PATH=/usr/sbinPATH
export PATH=$ORACLE_HOME/binPATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/JREORACLE_HOME/jlibORACLE_HOME/rdbms/jlib
# ---------------------------------------------------
# UMASK
# ---------------------------------------------------
# Set the default file mode creation mask
# (umask) to 022 to ensure that the user performing
# the Oracle software installation creates files
# with 644 permissions.
# ---------------------------------------------------
umask 022
[orardbms@node1 ~]$
[orardbms@node1 ~]$
[orardbms@node1 ~]$
[orardbms@node1 ~]$
[orardbms@node1 ~]$ exit
logout
[root@node1 ~]# su - oragrid
[oragrid@node1 ~]$ crs_stat -t
Name           Type           Target    State     Host        
------------------------------------------------------------
ora.ARCH.dg    ora....up.type ONLINE    ONLINE    node1      
ora.DATA.dg    ora....up.type ONLINE    ONLINE    node1      
ora....ER.lsnr ora....er.type ONLINE    ONLINE    node1      
ora....N1.lsnr ora....er.type ONLINE    ONLINE    node2      
ora.OCRVOTE.dg ora....up.type ONLINE    ONLINE    node1      
ora.asm        ora.asm.type   ONLINE    ONLINE    node1      
ora.cvu        ora.cvu.type   ONLINE    ONLINE    node2      
ora.gsd        ora.gsd.type   OFFLINE   OFFLINE               
ora....network ora....rk.type ONLINE    ONLINE    node1      
ora....SM1.asm application    ONLINE    ONLINE    node1      
ora....E1.lsnr application    ONLINE    ONLINE    node1      
ora.node1.gsd  application    OFFLINE   OFFLINE               
ora.node1.ons  application    ONLINE    ONLINE    node1      
ora.node1.vip  ora....t1.type ONLINE    ONLINE    node1      
ora....SM2.asm application    ONLINE    ONLINE    node2      
ora....E2.lsnr application    ONLINE    ONLINE    node2      
ora.node2.gsd  application    OFFLINE   OFFLINE               
ora.node2.ons  application    ONLINE    ONLINE    node2      
ora.node2.vip  ora....t1.type ONLINE    ONLINE    node2      
ora.oc4j       ora.oc4j.type  ONLINE    ONLINE    node2      
ora.ons        ora.ons.type   ONLINE    ONLINE    node1      
ora.orcc.db    ora....se.type OFFLINE   OFFLINE               
ora....ry.acfs ora....fs.type ONLINE    ONLINE    node1      
ora.scan1.vip  ora....ip.type ONLINE    ONLINE    node2      
[oragrid@node1 ~]$ exit
logout
[root@node1 ~]# su - orardbms
[orardbms@node1 ~]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.4.0 Production on Sat Dec 24 04:06:34 2016

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

SQL> connect /as sysdba
Connected.
SQL> show parameter db_domain

NAME                                     TYPE         VALUE
------------------------------------ ----------- ------------------------------
db_domain                             string
SQL>
SQL>
SQL>
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
[orardbms@node1 ~]$ exit
logout
[root@node1 ~]# su - oragrid
[oragrid@node1 ~]$ exit
logout
[root@node1 ~]# su - orardbms
[orardbms@node1 ~]$ echo $ORACLE_HOME
/oracle/oracle_home
[root@node1 ~]# su - orardbms
[orardbms@node1 ~]$ srvctl add database -d orcl -o $ORACLE_HOME
[orardbms@node1 ~]$ srvctl add instance -d orcl -i orcl1 -n node1
[orardbms@node1 ~]$ srvctl add instance -d orcl -i orcl2 -n node2
[orardbms@node1 ~]$ srvctl remove database -d orcc
是否删除数据库 orcc? (y/[n]) y
[orardbms@node1 ~]$ exit
logout
[root@node1 ~]# su - oragrid
[oragrid@node1 ~]$ crs_stat -t
Name           Type           Target    State     Host        
------------------------------------------------------------
ora.ARCH.dg    ora....up.type ONLINE    ONLINE    node1      
ora.DATA.dg    ora....up.type ONLINE    ONLINE    node1      
ora....ER.lsnr ora....er.type ONLINE    ONLINE    node1      
ora....N1.lsnr ora....er.type ONLINE    ONLINE    node2      
ora.OCRVOTE.dg ora....up.type ONLINE    ONLINE    node1      
ora.asm        ora.asm.type   ONLINE    ONLINE    node1      
ora.cvu        ora.cvu.type   ONLINE    ONLINE    node2      
ora.gsd        ora.gsd.type   OFFLINE   OFFLINE               
ora....network ora....rk.type ONLINE    ONLINE    node1      
ora....SM1.asm application    ONLINE    ONLINE    node1      
ora....E1.lsnr application    ONLINE    ONLINE    node1      
ora.node1.gsd  application    OFFLINE   OFFLINE               
ora.node1.ons  application    ONLINE    ONLINE    node1      
ora.node1.vip  ora....t1.type ONLINE    ONLINE    node1      
ora....SM2.asm application    ONLINE    ONLINE    node2      
ora....E2.lsnr application    ONLINE    ONLINE    node2      
ora.node2.gsd  application    OFFLINE   OFFLINE               
ora.node2.ons  application    ONLINE    ONLINE    node2      
ora.node2.vip  ora....t1.type ONLINE    ONLINE    node2      
ora.oc4j       ora.oc4j.type  ONLINE    ONLINE    node2      
ora.ons        ora.ons.type   ONLINE    ONLINE    node1      
ora.orcl.db    ora....se.type OFFLINE   OFFLINE               
ora....ry.acfs ora....fs.type ONLINE    ONLINE    node1      
ora.scan1.vip  ora....ip.type ONLINE    ONLINE    node2

数据库在集群中的状态为及时更新,重启更新一下      
[oragrid@node1 ~]$ srvctl stop database -d orcl -o immediate;
PRCC-1016 : orcl 已停止
[oragrid@node1 ~]$ srvctl start database -d orcl -o open
[oragrid@node1 ~]$ crs_stat -t
Name           Type           Target    State     Host        
------------------------------------------------------------
ora.ARCH.dg    ora....up.type ONLINE    ONLINE    node1      
ora.DATA.dg    ora....up.type ONLINE    ONLINE    node1      
ora....ER.lsnr ora....er.type ONLINE    ONLINE    node1      
ora....N1.lsnr ora....er.type ONLINE    ONLINE    node2      
ora.OCRVOTE.dg ora....up.type ONLINE    ONLINE    node1      
ora.asm        ora.asm.type   ONLINE    ONLINE    node1      
ora.cvu        ora.cvu.type   ONLINE    ONLINE    node2      
ora.gsd        ora.gsd.type   OFFLINE   OFFLINE               
ora....network ora....rk.type ONLINE    ONLINE    node1      
ora....SM1.asm application    ONLINE    ONLINE    node1      
ora....E1.lsnr application    ONLINE    ONLINE    node1      
ora.node1.gsd  application    OFFLINE   OFFLINE               
ora.node1.ons  application    ONLINE    ONLINE    node1      
ora.node1.vip  ora....t1.type ONLINE    ONLINE    node1      
ora....SM2.asm application    ONLINE    ONLINE    node2      
ora....E2.lsnr application    ONLINE    ONLINE    node2      
ora.node2.gsd  application    OFFLINE   OFFLINE               
ora.node2.ons  application    ONLINE    ONLINE    node2      
ora.node2.vip  ora....t1.type ONLINE    ONLINE    node2      
ora.oc4j       ora.oc4j.type  ONLINE    ONLINE    node2      
ora.ons        ora.ons.type   ONLINE    ONLINE    node1      
ora.orcl.db    ora....se.type ONLINE    ONLINE    node1      
ora....ry.acfs ora....fs.type ONLINE    ONLINE    node1      
ora.scan1.vip  ora....ip.type ONLINE    ONLINE    node2      
[oragrid@node1 ~]$
[oragrid@node1 ~]$
[oragrid@node1 ~]$
[oragrid@node1 ~]$
[oragrid@node1 ~]$
[oragrid@node1 ~]$

[root@node1 ~]# su - orardbms
[orardbms@node1 ~]$ tnsping orcl

TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 24-DEC-2016 04:11:57

Copyright (c) 1997, 2013, Oracle.  All rights reserved.

Used parameter files:


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = node-scan)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl)))
OK (10 msec)

[END] 2016/12/23 20:12:10
标签: 暂无标签
dongxujian

写了 86 篇文章,拥有财富 384,被 13 人关注

转播转播 分享分享 分享淘帖
回复

使用道具

P4 | 发表于 2016-12-24 01:00:58
Metalink -----How to Change the DBID, DBNAME Using NID Utility (Doc ID 863800.1),小测一下仅供参考
回复

使用道具

您需要登录后才可以回帖 登录 | 加入社区

本版积分规则

意见
反馈