zoukankan      html  css  js  c++  java
  • 利用冷备份实现ORACLE数据库迁移

    冷备份恢复到另外的服务器
    要求系统相同,数据库版本相同。为了加深理解实例和数据库的关系,我们这里的实例的名字和数据库的名字是不一致的。

    停用数据库的force_logging
    SQL> select force_logging from v$database;
    FOR
    ---
    YES
    SQL> alter database no force logging;
    Database altered.
    SQL> select force_logging from v$database;
    FOR
    ---
    NO

    =================================================

    ORACLE数据库从归档改成非归档状态

    把数据库打开到mount状态,生产库记住要先shutdown immediate,
    然后再startup mount,shutdown abort容易带来灾难性问题
    sys@HYJT> startup force mount
    ORACLE instance started.

    Total System Global Area 184549376 bytes
    Fixed Size 1218412 bytes
    Variable Size 67111060 bytes
    Database Buffers 113246208 bytes
    Redo Buffers 2973696 bytes
    Database mounted.

    在mount状态下修改数据库归档模式
    sys@HYJT> alter database noarchivelog;
    Database altered.

    =================================================

    备份出控制文件的信息,以防出问题手写控制文件解决问题。

    sys@HYJT> alter database open;
    sys@HYJT> alter database backup controlfile to trace as '/home/oracle/c1.sql' reuse; --自己定义存储到一个文件
    sys@HYJT> alter database backup controlfile to trace; --到udump下

    --把控制文件以文本的形式输出出来,只是结构。可以做模板手写控制文件,
    里面包含resetlogs方式和noresetlogs方式。需要保存下面部分,开头不能有空格:
    CREATE CONTROLFILE REUSE DATABASE "HYJT" NORESETLOGS NOARCHIVELOG
    MAXLOGFILES 16
    MAXLOGMEMBERS 3
    MAXDATAFILES 100
    MAXINSTANCES 8
    MAXLOGHISTORY 292
    LOGFILE
    GROUP 1 '/u01/app/oracle/oradata/orcl/redo01.log' SIZE 50M,
    GROUP 2 '/u01/app/oracle/oradata/orcl/redo02.log' SIZE 50M,
    GROUP 3 '/u01/app/oracle/oradata/orcl/redo03.log' SIZE 50M
    -- STANDBY LOGFILE

    DATAFILE
    '/u01/app/oracle/oradata/orcl/system01.dbf',
    '/u01/app/oracle/oradata/orcl/undotbs01.dbf',
    '/u01/app/oracle/oradata/orcl/sysaux01.dbf',
    '/u01/app/oracle/oradata/orcl/users01.dbf',
    '/u01/app/oracle/oradata/orcl/stone01.dbf',
    '/u01/app/oracle/oradata/orcl/ts1.1',
    '/u01/app/oracle/oradata/orcl/big01.dbf',
    '/u01/app/oracle/oradata/orcl/t4k.4',
    '/u01/app/oracle/oradata/orcl/tnolog.dbf',
    '/u01/app/oracle/oradata/orcl/ts3.dbf',
    '/u01/app/oracle/oradata/orcl/ts4.dbf',
    '/u01/app/oracle/oradata/orcl/undo2.dbf',
    '/u01/app/oracle/oradata/orcl/tm2.dbf'
    CHARACTER SET ZHS16GBK
    ;

    =================================================

    shutdown immediate
    做冷备份,包括数据文件、控制文件、重做日志文件、参数文件、密码文件


    在目标服务器上首先写环境变量/home/oracle/.bash_profile文件
    [oracle@rhel5 ~]$ vi .bash_profile

    # .bash_profile

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

    # User specific environment and startup programs

    PATH=$PATH:$HOME/bin

    export PATH

    export TMP=/tmp
    export TEMP=/tmp
    export ORACLE_BASE=/u01/app/oracle
    export ORACLE_HOME=$ORACLE_BASE/product/10.2
    export ORACLE_SID=jia
    export ORACLE_TERM=xterm
    export TNS_ADMIN=$ORACLE_HOME/network/admin
    export PATH=$ORACLE_HOME/bin:$PATH
    export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
    export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
    export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
    export NLS_DATE_FORMAT='yyyymmdd hh24:mi:ss'

    alias sqlplus='/usr/local/rlwrap/bin/rlwrap sqlplus'
    alias rman='/usr/local/rlwrap/bin/rlwrap rman'
    alias imp='/usr/local/rlwrap/bin/rlwrap imp'
    alias exp='/usr/local/rlwrap/bin/rlwrap exp'
    alias impdp='/usr/local/rlwrap/bin/rlwrap impdp'
    alias expdp='/usr/local/rlwrap/bin/rlwrap expdp'

    然后注销重新登录或执行
    source /home/oracle/.bash_profile

    拷贝冷备份文件到新服务器,生产环境要mount对应的存储,在此以创建目录为例进行说明。
    [root@rhel5 ~]# mkdir /jia
    [root@rhel5 ~]# cd /
    [root@rhel5 /]# chown oracle:oinstall jia
    [root@rhel5 /]# chmod 775 jia
    [root@rhel5 /]# ll -d /jia
    drwxrwxr-x 2 oracle oinstall 4096 Dec 6 12:35 /jia

    [oracle@rhel5 /]$ cp /u01/app/oracle/oradata/orcl/* /jia/

    注意一定要检查权限和所有者
    [oracle@rhel5 /]$ ls -l /jia/
    total 1255172
    -rw-r----- 1 oracle oinstall 2105344 Dec 6 12:20 big01.dbf
    -rw-r----- 1 oracle oinstall 7061504 Dec 6 12:20 control01.ctl
    -rw-r----- 1 oracle oinstall 7061504 Dec 6 12:20 control02.ctl
    -rw-r----- 1 oracle oinstall 7061504 Dec 6 12:20 control03.ctl
    -rw-r----- 1 oracle oinstall 52429312 Dec 6 10:44 redo01.log
    -rw-r----- 1 oracle oinstall 52429312 Dec 6 10:44 redo02.log
    -rw-r----- 1 oracle oinstall 52429312 Dec 6 12:20 redo03.log
    -rw-r----- 1 oracle oinstall 3153920 Dec 6 12:20 stone01.dbf
    -rw-r----- 1 oracle oinstall 314580992 Dec 6 12:20 sysaux01.dbf
    -rw-r----- 1 oracle oinstall 524296192 Dec 6 12:20 system01.dbf
    -rw-r----- 1 oracle oinstall 2101248 Dec 6 12:20 t4k.4
    -rw-r----- 1 oracle oinstall 27271168 Dec 5 21:18 temp01.dbf
    -rw-r----- 1 oracle oinstall 5251072 Dec 6 12:20 tm2.dbf
    -rw-r----- 1 oracle oinstall 2105344 Dec 6 12:20 tnolog.dbf
    -rw-r----- 1 oracle oinstall 5251072 Dec 6 12:20 ts1.1
    -rw-r----- 1 oracle oinstall 2105344 Dec 6 12:20 ts3.dbf
    -rw-r----- 1 oracle oinstall 3153920 Dec 6 12:20 ts4.dbf
    -rw-r----- 1 oracle oinstall 5251072 Dec 6 12:20 undo2.dbf
    -rw-r----- 1 oracle oinstall 209723392 Dec 6 12:20 undotbs01.dbf
    -rw-r----- 1 oracle oinstall 5251072 Dec 6 12:20 users01.dbf

    将密码文件拷贝到$ORACLE_HOME/dbs目录下改名为orapwjia
    将参数文件拷贝到$ORACLE_HOME/dbs目录下改名为initjia.ora
    修改initjia.ora文件内容,特别注意控制文件和dump文件路径的改写
    [oracle@rhel5 dbs]$ cat initjia.ora
    orcl.__db_cache_size=104857600
    orcl.__java_pool_size=4194304
    orcl.__large_pool_size=4194304
    orcl.__shared_pool_size=67108864
    orcl.__streams_pool_size=0
    *.audit_file_dest='/u01/app/oracle/admin/jia/adump'
    *.background_dump_dest='/u01/app/oracle/admin/jia/bdump'
    *.compatible='10.2.0.1.0'
    *.control_files='/jia/control01.ctl','/jia/control02.ctl','/jia/control03.ctl'
    *.core_dump_dest='/u01/app/oracle/admin/jia/cdump'
    *.db_block_size=8192
    *.db_domain=''
    *.db_file_multiblock_read_count=16
    *.db_name='hyjt'
    *.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'
    *.db_recovery_file_dest_size=2147483648
    *.dispatchers='(PROTOCOL=TCP) (SERVICE=hyjtXDB)'
    *.job_queue_processes=10
    *.log_archive_format='%t_%s_%r.arc'
    *.log_archive_max_processes=3
    *.open_cursors=300
    *.pga_aggregate_target=60817408
    *.processes=150
    *.remote_login_passwordfile='EXCLUSIVE'
    *.sga_target=184549376
    *.undo_management='AUTO'
    *.undo_tablespace='UNDOTBS1'
    *.user_dump_dest='/u01/app/oracle/admin/jia/udump'

    根据initjia.ora文件创建对应的目录
    [oracle@rhel5 oracle]$ cd $ORACLE_BASE/admin
    [oracle@rhel5 admin]$ ls
    orcl
    [oracle@rhel5 admin]$ mkdir jia
    [oracle@rhel5 admin]$ cd jia
    [oracle@rhel5 jia]$ mkdir adump bdump cdump dpdump udump [pfile scripts]
    [oracle@rhel5 jia]$ ll
    total 28
    drwxr-xr-x 2 oracle oinstall 4096 Dec 6 12:54 adump
    drwxr-xr-x 2 oracle oinstall 4096 Dec 6 12:54 bdump
    drwxr-xr-x 2 oracle oinstall 4096 Dec 6 12:54 cdump
    drwxr-xr-x 2 oracle oinstall 4096 Dec 6 12:54 dpdump
    drwxr-xr-x 2 oracle oinstall 4096 Dec 6 12:54 pfile
    drwxr-xr-x 2 oracle oinstall 4096 Dec 6 12:54 scripts
    drwxr-xr-x 2 oracle oinstall 4096 Dec 6 12:54 udump

    =================================================

    检查当前的环境变量
    [oracle@rhel5 /]$ echo $ORACLE_SID
    jia

    登录sqlplus
    [oracle@rhel5 /]$ sqlplus / as sysdba
    SQL*Plus: Release 10.2.0.1.0 - Production on Mon Dec 6 13:10:12 2010
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    Connected to an idle instance.

    启动数据库到mount状态
    idle> startup mount
    ORACLE instance started.

    Total System Global Area 184549376 bytes
    Fixed Size 1218412 bytes
    Variable Size 62916756 bytes
    Database Buffers 117440512 bytes
    Redo Buffers 2973696 bytes
    Database mounted.

    修改控制文件里数据文件的信息
    这个脚本要在原来的数据库上提前写好,可以方便生成脚本

    alter database rename file '/u01/app/oracle/oradata/orcl/control01.dbf' to '/jia/control01.dbf';
    alter database rename file '/u01/app/oracle/oradata/orcl/control02.dbf' to '/jia/control02.dbf';
    alter database rename file '/u01/app/oracle/oradata/orcl/control03.dbf' to '/jia/control03.dbf';
    alter database rename file '/u01/app/oracle/oradata/orcl/system01.dbf' to '/jia/system01.dbf';
    alter database rename file '/u01/app/oracle/oradata/orcl/sysaux01.dbf' to '/jia/sysaux01.dbf';
    alter database rename file '/u01/app/oracle/oradata/orcl/undotbs01.dbf' to '/jia/undotbs01.dbf';
    alter database rename file '/u01/app/oracle/oradata/orcl/temp01.dbf' to '/jia/temp01.dbf';
    alter database rename file '/u01/app/oracle/oradata/orcl/redo01.log' to '/jia/redo01.log';
    alter database rename file '/u01/app/oracle/oradata/orcl/redo02.log' to '/jia/redo02.log';
    alter database rename file '/u01/app/oracle/oradata/orcl/redo03.log' to '/jia/redo03.log';
    alter database rename file '/u01/app/oracle/oradata/orcl/users01.dbf' to '/jia/users01.dbf';
    alter database rename file '/u01/app/oracle/oradata/orcl/stone01.dbf' to '/jia/stone01.dbf';
    alter database rename file '/u01/app/oracle/oradata/orcl/big01.dbf' to '/jia/big01.dbf';
    alter database rename file '/u01/app/oracle/oradata/orcl/tm2.dbf' to '/jia/tm2.dbf';
    alter database rename file '/u01/app/oracle/oradata/orcl/tnolog.dbf' to '/jia/tnolog.dbf';
    alter database rename file '/u01/app/oracle/oradata/orcl/ts4.dbf' to '/jia/ts4.dbf';
    alter database rename file '/u01/app/oracle/oradata/orcl/ts3.dbf' to '/jia/ts3.dbf';
    alter database rename file '/u01/app/oracle/oradata/orcl/undo2.dbf' to '/jia/undo2.dbf';
    alter database rename file '/u01/app/oracle/oradata/orcl/t4k.4' to '/jia/t4k.4';
    alter database rename file '/u01/app/oracle/oradata/orcl/ts1.1' to '/jia/ts1.1';

    =================================================

    打开数据库到open状态

    如果在有文件路径忘记更改的情况下打开数据库到open会报如下错误
    idle> alter database open;
    alter database open
    *
    ERROR at line 1:
    ORA-01157: cannot identify/lock data file 6 - see DBWR trace file
    ORA-01110: data file 6: '/u01/app/oracle/oradata/orcl/ts1.1'

    保证所有文件路径修改正确后打开数据库到open状态
    idle> alter database open;
    Database altered.

    查看实例信息
    idle> select * from v$instance;

    INSTANCE_NUMBER INSTANCE_NAME HOST_NAME --------------- ---------------- ----------------------------------------------------------------
    VERSION STARTUP_TIME STATUS PAR THREAD# ARCHIVE LOG_SWITCH_WAIT LOGINS ----------------- ----------------- ------------ --- ---------- ------- --------------- ----------
    SHU DATABASE_STATUS INSTANCE_ROLE ACTIVE_ST BLO
    --- ----------------- ------------------ --------- ---
    1 jia rhel5.oraclelinux.com
    10.2.0.1.0 20101206 13:10:20 OPEN NO 1 STOPPED ALLOWED
    NO ACTIVE PRIMARY_INSTANCE NORMAL NO

    查看数据库信息
    idle> select * from v$database;

    DBID NAME CREATED RESETLOGS_CHANGE# RESETLOGS_TIME
    ---------- ------------------------------ ----------------- ----------------- -----------------
    PRIOR_RESETLOGS_CHANGE# PRIOR_RESETLOGS_T LOG_MODE CHECKPOINT_CHANGE# ARCHIVE_CHANGE# CONTROL
    ----------------------- ----------------- ------------ ------------------ --------------- -------
    CONTROLFILE_CREAT CONTROLFILE_SEQUENCE# CONTROLFILE_CHANGE# CONTROLFILE_TIME OPEN_RESETL
    ----------------- --------------------- ------------------- ----------------- -----------
    VERSION_TIME OPEN_MODE PROTECTION_MODE PROTECTION_LEVEL REMOTE_A ACTIVATION#
    ----------------- ---------- -------------------- -------------------- -------- -----------
    SWITCHOVER# DATABASE_ROLE ARCHIVELOG_CHANGE# ARCHIVEL SWITCHOVER_STATUS DATAGUAR GUARD_S
    ----------- ---------------- ------------------ -------- -------------------- -------- -------
    SUPPLEME SUP SUP FOR PLATFORM_ID
    -------- --- --- --- -----------
    PLATFORM_NAME
    ----------------------------------------------------------------------------------------------------
    RECOVERY_TARGET_INCARNATION# LAST_OPEN_INCARNATION# CURRENT_SCN FLASHBACK_ON SUP SUP
    ---------------------------- ---------------------- ----------- ------------------ --- ---
    DB_UNIQUE_NAME STANDBY_BECAME_PRIMARY_SCN FS_FAILOVER_STATUS
    ------------------------------ -------------------------- ---------------------
    FS_FAILOVER_CURRENT_TARGET FS_FAILOVER_THRESHOLD FS_FAIL
    ------------------------------ --------------------- -------
    FS_FAILOVER_OBSERVER_HOST
    ----------------------------------------------------------------------------------------------------
    1264786455 HYJT 20101118 14:23:59 1484108 20101205 18:47:06
    1025879 20101201 00:19:28 NOARCHIVELOG 1537148 1484108 CURRENT
    20101118 14:24:01 1822 1537218 20101206 13:36:41 NOT ALLOWED
    20101118 14:23:59 READ WRITE MAXIMUM PERFORMANCE UNPROTECTED ENABLED 1264742415
    1264742415 PRIMARY 1506645 DISABLED SESSIONS ACTIVE DISABLED NONE
    NO NO NO NO 10
    Linux IA (32-bit)
    2 2 1537279 NO NO NO
    hyjt 0 DISABLED
    0

    =================================================

    修改global_name

    idle> select * from global_name;

    GLOBAL_NAME
    -----------
    HYJT

    idle> alter database rename global_name to jsl;

    Database altered.

    idle> select * from global_name;

    GLOBAL_NAME
    -----------
    JSL

    =================================================

    修改 db name

    关闭数据库启动到mount状态
    sys@JIA> shutdown immediate
    Database closed.
    Database dismounted.
    ORACLE instance shut down.
    sys@JIA> startup mount
    ORACLE instance started.

    Total System Global Area 184549376 bytes
    Fixed Size 1218412 bytes
    Variable Size 62916756 bytes
    Database Buffers 117440512 bytes
    Redo Buffers 2973696 bytes
    Database mounted.

    在这里为了体会实例和数据库的关系,我们把数据库的名字设成跟实例的名字不一样。
    [oracle@rhel5 ~]$ nid target=sys/oracle dbname=jsl setname=y

    DBNEWID: Release 10.2.0.1.0 - Production on Mon Dec 6 13:51:03 2010

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

    Connected to database HYJT (DBID=1264786455)

    Connected to server version 10.2.0

    Control Files in database:
    /jia/control01.ctl
    /jia/control02.ctl
    /jia/control03.ctl

    Change database name of database HYJT to JSL? (Y/[N]) => y

    Proceeding with operation
    Changing database name from HYJT to JSL
    Control File /jia/control01.ctl - modified
    Control File /jia/control02.ctl - modified
    Control File /jia/control03.ctl - modified
    Datafile /jia/system01.dbf - wrote new name
    Datafile /jia/undotbs01.dbf - wrote new name
    Datafile /jia/sysaux01.dbf - wrote new name
    Datafile /jia/users01.dbf - wrote new name
    Datafile /jia/stone01.dbf - wrote new name
    Datafile /jia/ts1.1 - wrote new name
    Datafile /jia/big01.dbf - wrote new name
    Datafile /jia/t4k.4 - wrote new name
    Datafile /jia/tnolog.dbf - wrote new name
    Datafile /jia/ts3.dbf - wrote new name
    Datafile /jia/ts4.dbf - wrote new name
    Datafile /jia/undo2.dbf - wrote new name
    Datafile /jia/tm2.dbf - wrote new name
    Datafile /jia/temp01.dbf - wrote new name
    Control File /jia/control01.ctl - wrote new name
    Control File /jia/control02.ctl - wrote new name
    Control File /jia/control03.ctl - wrote new name
    Instance shut down

    Database name changed to JSL.
    Modify parameter file and generate a new password file before restarting.
    Succesfully changed database name.
    DBNEWID - Completed succesfully.

    修改参数文件initjia.ora 里的db_name和dispatchers的值
    *.db_name='jsl'
    *.dispatchers='(PROTOCOL=TCP) (SERVICE=jslXDB)'

    重新登录sqlplus
    [oracle@rhel5 /]$ sqlplus / as sysdba
    SQL*Plus: Release 10.2.0.1.0 - Production on Mon Dec 6 14:28:42 2010
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    Connected to an idle instance.

    利用pfile文件启动数据库
    idle> startup pfile=/u01/app/oracle/product/10.2/dbs/initjia.ora
    ORACLE instance started.

    Total System Global Area 184549376 bytes
    Fixed Size 1218412 bytes
    Variable Size 62916756 bytes
    Database Buffers 117440512 bytes
    Redo Buffers 2973696 bytes
    Database mounted.
    Database opened.
    idle> conn / as sysdba
    Connected.

    验证修改db_name结果

    sys@JSL> select name,db_unique_name from v$database;
    NAME DB_UNIQUE_NAME
    ------------------------------ ------------------------------
    JSL jsl

    sys@JSL> show parameter service
    NAME TYPE VALUE
    ------------------------------------ ----------- ------------------------------
    service_names string jsl


    =================================================

    创建spfile

    因为我们修改的是pfile,接下来创建新的spfile
    sys@JSL> show parameter spfile
    NAME TYPE VALUE
    ------------------------------------ ----------- ------------------------------
    spfile string
    sys@JSL> create spfile from pfile ;
    File created.

    关闭数据库,用spfile重新启动数据库
    sys@JSL> shutdown immediate
    Database closed.
    Database dismounted.
    ORACLE instance shut down.
    sys@JSL> startup
    ORACLE instance started.

    Total System Global Area 184549376 bytes
    Fixed Size 1218412 bytes
    Variable Size 62916756 bytes
    Database Buffers 117440512 bytes
    Redo Buffers 2973696 bytes
    Database mounted.
    Database opened.

    查看是否用spfile正常启动
    sys@JSL> show parameter spfile
    NAME TYPE VALUE
    ------------------------------------ ----------- ------------------------------
    spfile string /u01/app/oracle/product/10.2/d
    bs/spfilejia.ora
    再次验证上面修改的结果没有变化
    sys@JSL> select name,db_unique_name from v$database;
    NAME DB_UNIQUE_NAME
    ------------------------------ ------------------------------
    JSL jsl

    sys@JSL> show parameter service
    NAME TYPE VALUE
    ------------------------------------ ----------- ------------------------------
    service_names string jsl


    =================================================

    重新设置监听器
    vi $ORACLE_HOME/network/admin/listener.ora
    SID_LIST_LISTENER =
    (SID_LIST =
    (SID_DESC =
    (GLOBAL_DBNAME = jsl)
    (ORACLE_HOME = /u01/app/oracle/product/10.2)
    (SID_NAME = jia)
    )
    )

    LISTENER =
    (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = rhel5.oraclelinux.com)(PORT = 1521))
    )

    重新启动监听器
    lsnrctl stop
    lsnrctl start

    =================================================

    远程连接测试

    查看监听器状态,包含一个静态注册和三个动态注册,带有status UNKONWN标识的是静态注册的。
    [oracle@rhel5 admin]$ lsnrctl status

    LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 06-DEC-2010 16:17:48

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

    Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=rhel5.oraclelinux.com)(PORT=1521)))
    STATUS of the LISTENER
    ------------------------
    Alias LISTENER
    Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production
    Start Date 06-DEC-2010 15:50:17
    Uptime 0 days 0 hr. 27 min. 31 sec
    Trace Level off
    Security ON: Local OS Authentication
    SNMP OFF
    Listener Parameter File /u01/app/oracle/product/10.2/network/admin/listener.ora
    Listener Log File /u01/app/oracle/product/10.2/network/log/listener.log
    Listening Endpoints Summary...
    (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rhel5.oraclelinux.com)(PORT=1521)))
    Services Summary...
    Service "jsl" has 2 instance(s).
    Instance "jia", status UNKNOWN, has 1 handler(s) for this service...
    Instance "jia", status READY, has 1 handler(s) for this service...
    Service "jslXDB" has 1 instance(s).
    Instance "jia", status READY, has 1 handler(s) for this service...
    Service "jsl_XPT" has 1 instance(s).
    Instance "jia", status READY, has 1 handler(s) for this service...
    The command completed successfully


    在远端设置tnsnames.ora
    添加如下内容
    JSL =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.222)(PORT = 1521))
    )
    (CONNECT_DATA =
    (SERVER = DEDICATED)
    (SERVICE_NAME = jsl)
    )
    )

    登录测试
    C:\Documents and Settings\Administrator>sqlplus sys/oracle@jsl as sysdba
    SQL*Plus: Release 10.2.0.1.0 - Production on 星期一 12月 6 16:20:06 2010
    Copyright (c) 1982, 2005, Oracle. All rights reserved.

    连接到:
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SQL>
    SQL> select instance_name from v$instance;
    INSTANCE_NAME
    ----------------
    jia

    SQL> select name from v$database;
    NAME
    ---------
    JSL
    登录成功


    接下来测试静态注册

    关闭数据库实例
    sys@JIA> shutdown immediate
    Database closed.
    Database dismounted.
    ORACLE instance shut down.

    查看监听器状态,只剩下静态注册信息
    [oracle@rhel5 admin]$ lsnrctl status
    LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 06-DEC-2010 16:26:38
    Copyright (c) 1991, 2005, Oracle. All rights reserved.
    Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=rhel5.oraclelinux.com)(PORT=1521)))
    STATUS of the LISTENER
    ------------------------
    Alias LISTENER
    Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production
    Start Date 06-DEC-2010 15:50:17
    Uptime 0 days 0 hr. 26 min. 21 sec
    Trace Level off
    Security ON: Local OS Authentication
    SNMP OFF
    Listener Parameter File /u01/app/oracle/product/10.2/network/admin/listener.ora
    Listener Log File /u01/app/oracle/product/10.2/network/log/listener.log
    Listening Endpoints Summary...
    (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rhel5.oraclelinux.com)(PORT=1521)))
    Services Summary...
    Service "jsl" has 1 instance(s).
    Instance "jia", status UNKNOWN, has 1 handler(s) for this service...
    The command completed successfully


    远程登录
    C:\Documents and Settings\Administrator>sqlplus sys/oracle@jsl as sysdba
    SQL*Plus: Release 10.2.0.1.0 - Production on 星期一 12月 6 16:29:21 2010
    Copyright (c) 1982, 2005, Oracle. All rights reserved.

    已连接到空闲例程。

    静态注册测试成功

    至此利用类备份的数据库迁移工作完成。

  • 相关阅读:
    构建之法 阅读笔记04
    团队项目-个人博客6.6
    个人总结
    第十六周学习进度条
    第十五周学习进度条
    构建之法阅读笔记07
    大道至简阅读笔记03
    大道至简阅读笔记02
    大道至简阅读笔记01
    第十四周学习进度条
  • 原文地址:https://www.cnblogs.com/weaver1/p/2365377.html
Copyright © 2011-2022 走看看