Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1196133
  • 博文数量: 245
  • 博客积分: 10185
  • 博客等级: 上将
  • 技术积分: 2744
  • 用 户 组: 普通用户
  • 注册时间: 2006-10-30 17:07
文章分类

全部博文(245)

文章存档

2015年(1)

2014年(1)

2013年(1)

2012年(1)

2011年(37)

2010年(20)

2009年(14)

2008年(38)

2007年(88)

2006年(44)

分类: Oracle

2007-08-03 23:37:55

环境:

      os:  centos4.4

   oracle:  oracle10gR1(安装软件为10201_database_linux32.zip,暂未升级到R2,不影响下面的配置)

primary: 192.168.0.5 (主机名RAC1)

standby: 192.168.0.7(主机名RAC3)

 

1)       配好双机的(rac1,rac3)profile .

# .sh_profile

# Get the aliases and functions

#if [ -f ~/.bashrc ]; then

#       . ~/.bashrc

#fi

# User specific environment and startup programs

#export BASH_ENV=$HOME/.bashrc

export  PATH=$ORACLE_HOME/bin:$HOME/bin:$PATH:/sbin:/usr/local/bin:/usr/local/sbin

PATH=$PATH:/sbin:/home/oracle/product/10.2.0/db_1/bin:$oracle_home/jre/bin:/bin:/usr/bin:/usr/bin:/etc:/usr/local/bin:

export PATH

unset USERNAME

ORACLE_OWNER=oracle

export ORACLE_BASE=/home/oracle

export ORACLE_HOME=/home/oracle/product/10.2.0/db_1

export ORACLE_SID=rac

TNS_ADMIN=/home/Oracle/config/10.2.0; export TNS_ADMIN

NLS_LANG=american_america.ZHS16GBK; export NLS_LANG

#ORA_NLS33=$Oracle_HOME/ocommon/nls/admin/data; export ORA_NLS33

CLASSPATH=$Oracle_HOME/JRE:$Oracle_HOME/jlib:$Oracle_HOME/rdbms/jlib:/opt/j2sdk_nb/j2sdk1.4.2/bin

export CLASSPATH

TMPDIR=/tmp;export TMPDIR

umask 022

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib

#export LD_PRELOAD=/home/oracle/libcwait.so;

LD_ASSUME_KERNEL=2.6.9; export LD_ASSUME_KERNEL

#NLS_LANG="Simplified Chinese_china".ZHS16GBK;export NLS_LANG

LC_CTYPE=zh_CN.GB2312

NLS_LANG=american_america.ZHS16GBK; export NLS_LANG

export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"

LANG=

LC_ALL=

DISPLAY=192.168.0.3:0.0;export DISPLAY;

export PS1="\u@\H $"

   if [ $USER = "oracle" ]; then

             if [ $SHELL = "/bin/sh" ]; then

                     ulimit -p 16384

                     ulimit -n 65536

             else

                     ulimit -u 16384 -n 65536

             fi

   fi

 

2)       检查所需软件

在每个节点上执行相同的操作:

   执行下面的命令: rpm -q binutils compat-db control-center gcc gcc-c++ glibc gnome-libs libstdc++ libstdc++-devel make openmotif21

  缺少的包请安装。

 

3)   配置内核参数

    在每个节点上执行相同的操作:

    编辑/etc/sysctl.conf 文件,添加下面的内容:

    #For Oracle  

   kernel.sem = 250      32000        100        128

   kernel.shmmni = 4096

   kernel.shmall = 2097152

   kernel.shmmax = 2147483648

   net.ipv4.ip_local_port_range = 1024 65000

   net.core.rmem_default = 1048576

   net.core.rmem_max = 1048576

   net.core.wmem_default = 262144

   net.core.wmem_max = 262144

 然后执行:

   sysctl –p  或重起系统

 

4)  设置 Shell Oracle 用户的限制

   在每个节点上执行相同的操作:

   编辑       /etc/security/limits.conf,添加如下内容:

oracle soft nofile 65536

oracle hard nofile 65536

oracle soft nproc 16384

oracle hard nproc 16384

 

   编辑/etc/pam.d/login,添加如下内容:

   session required /lib/security/pam_limits.so

     

 5)在主库(rac1)上安装10gr1 软件,不装数据库

   product, oraInventory目录打包传到辅的(rac3)oracle_home目录下(即/home/oracle)并在rac3上解开。

 

6)在主库(rac1)上通过dbca创建数据库,选用默认配置。

Sidprofile里指定的一样,为rac

 

 7) 关闭主库,将/home/oracle/oradata/rac/下的文件copy rac3上的相同位置。

 

SQL> startup

ORACLE instance started.

 

Total System Global Area  167772160 bytes

Fixed Size                  1218292 bytes

Variable Size              67111180 bytes

Database Buffers           92274688 bytes

Redo Buffers                7168000 bytes

Database mounted.

Database opened.

SQL> archive log list

Database log mode              Archive Mode

Automatic archival             Enabled

Archive destination            /home/oracle/product/10.2.0/db_1/dbs/arch

Oldest online log sequence     0

Next log sequence to archive   1

Current log sequence          

 

SQL> alter system set log_archive_dest_1='location=/home/oracle/oradata/rac/archive';

 

System altered.

 

SQL> alter system set log_archive_format='log_%t_%s_%r.arc' scope=spfile;

 

System altered.

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

 

SQL> startup

ORACLE instance started.

-----------------------------

Database mounted.

Database opened.

 

SQL> archive log list;

Database log mode              Archive Mode

Automatic archival             Enabled

Archive destination            /home/oracle/oradata/rac/archive

Oldest online log sequence     0

Next log sequence to archive   1

Current log sequence           1

 

创建standby控制文件

SQL> alter database create standby controlfile as '/home/oracle/standby.ctl' ;

Database altered.

 

standby.ctl传到 rac3 /home/oracle/oradata/rac/

 

配置主库的listener.ora tnsnames.ora

 

oracle@rac1 $cat listener.ora

LISTENER_RAC1 =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.5)(PORT = 1521))

  )

 

SID_LIST_LISTENER_RAC1 =

  (SID_LIST =

    (SID_DESC =

      (GLOBAL_DBNAME = rac)

      (ORACLE_HOME = /home/oracle/product/10.2.0/db_1)

      (SID_NAME = rac)

    )

  )

 

rac1,rac3tnsnames.ora皆为

RAC3 =

  (DESCRIPTION =

    (ADDRESS_LIST =

      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.7)(PORT = 1521))

    )

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = rac)

    )

  )

 

RAC1 =

  (DESCRIPTION =

    (ADDRESS_LIST =

      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.5)(PORT = 1521))

    )

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = rac)

    )

  )

 

辅库的listener.ora

oracle@rac3 $vi  listener.ora

# listener.ora Network Configuration File: /home/oracle/product/10.2.0/db_1/network/admin/listener.ora

# Generated by Oracle configuration tools.

 

SID_LIST_LISTENER =

  (SID_LIST =

    (SID_DESC =

      (GLOBAL_DBNAME = rac)

      (ORACLE_HOME = /home/oracle/product/10.2.0/db_1)

      (SID_NAME = rac)

    )

  )

 

LISTENER =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = rac3)(PORT = 1521))

  )

 

如果觉得手工编辑上述文件容易出错,建议用netca创建。

 

启动主库的istener

oracle@rac1 $lsnrctl start

-----------------------------------

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rac1)(PORT=1521)))

The listener supports no services

The command completed successfully

启动辅库的istener

oracle@rac3 $lsnrctl start

----------------------------------

  Instance "rac", status UNKNOWN, has 1 handler(s) for this service...

The command completed successfully

tnsping检查tns配置

oracle@rac3 $tnsping rac1

oracle@rac3 $tnsping rac3

oracle@rac1 $tnsping rac1

oracle@rac1 $tnsping rac3

在主库rac1上创建pfile并将其传到辅库rac3上相应位置$oracle_home/dbs

oracle@rac1 $sqlplus '/as sysdba'

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

File created.

rac1上的/home/oracle/initrac.ora ftp 传到辅库rac3上相应位置$oracle_home/dbs

rac3上修改刚传来的initrac.ora文件

oracle@rac3 $more initrac.ora

rac.__db_cache_size=92274688

rac.__java_pool_size=4194304

rac.__large_pool_size=4194304

rac.__shared_pool_size=58720256

rac.__streams_pool_size=0

*.audit_file_dest='/home/oracle/admin/rac/adump'

*.background_dump_dest='/home/oracle/admin/rac/bdump'

*.compatible='10.2.0.1.0'

*.control_files='/home/oracle/oradata/rac/standby.ctl'

*.core_dump_dest='/home/oracle/admin/rac/cdump'

*.db_block_size=8192

*.db_domain=''

*.db_file_multiblock_read_count=16

*.db_name='rac'

*.dispatchers='(PROTOCOL=TCP) (SERVICE=racXDB)'

*.job_queue_processes=10

*.log_archive_dest_1='location=/home/oracle/oradata/rac/archive'

*.log_archive_format='log_%t_%s_%r.arc'

*.open_cursors=300

*.pga_aggregate_target=16777216

*.processes=150

*.remote_login_passwordfile='EXCLUSIVE'

*.sga_target=167772160

*.undo_management='AUTO'

*.undo_tablespace='UNDOTBS1'

*.user_dump_dest='/home/oracle/admin/rac/udump'

*.STANDBY_ARCHIVE_DEST='/home/oracle/oradata/rac/standbyarchive'

*.fal_server='rac1'

*.fal_client='rac3'

*.STANDBY_FILE_MANAGEMENT='AUTO'

*.DB_FILE_NAME_CONVERT='/home/oracle/oradata/rac/','/home/oracle/oradata/rac/'

*.LOG_FILE_NAME_CONVERT='/home/oracle/oradata/rac/archivelog','/home/oracle/oradata/rac/archivelog'

 

其中/home/oracle/oradata/rac/standbyarchive需要新建

将主库上的口令文件orapwrac传到辅库rac3上的对应位置。

 

将辅库rac3启动

oracle@rac3 $sqlplus '/as sysdba'

 

SQL> startup nomount;

ORACLE instance started.

 

SQL> alter database mount standby database;

Database altered.

 

SQL> alter database recover managed standby database disconnect from session;

Database altered.

 在主库上设置到辅库rac3上的归档路径

oracle@rac1 $sqlplus '/as sysdba'

SQL> alter system set log_archive_dest_2='service=rac3 mandatory reopen=60';

System altered.

定义了主库向副库传输日志

# 定义归档到备用库,强制归档,重试时间60秒。
# 如果定义为可选状态(optional),那么在归档失败后不会再次尝试归档的。定义
# madatory状态后,如果本次归档失败,则在归档下一个日志时会再次尝试

 

SQL> select * from v$log;

GROUP#  THREAD#  SEQUENCE#   BYTES    MEMBERS  ARCHIV  STATUS      FIRST_CHANGE# FIRST_TIME

   1         1          0        52428800          1 YES  UNUSED       

   2         1          0        52428800          1 YES  UNUSED                  0

   3         1          1        52428800          1 NO   CURRENT                 446075 2007-06-28 13:41:10

 

SQL> alter system switch logfile;

System altered.

 

SQL>  select * from v$log;

    GROUP#  THREAD#  SEQUENCE#      BYTES    MEMBERS ARCHIV STATUS     IRST_CHANGE#  FIRST_TIME

-------------------------------- ------------- -------------------

         1     1        2   52428800      1 NO  CURRENT             457776   2007-06-29 23:47:06

         2     1        0   52428800      1 YES  UNUSED               0

         3     1        1   52428800       1 NO  ACTIVE                446075    2007-06-28 13:41:10

 

察看辅库上alert日志

oracle@rac3 $tail -f alert_rac.log

Mon Jul  9 18:50:51 2007

Completed: alter database recover managed standby database disconnect from session

Mon Jul  9 18:50:51 2007

Clearing online redo logfile 3 complete

Media Recovery Log /home/oracle/oradata/rac/standbyarchive/log_1_1_626449270.arc

Media Recovery Log /home/oracle/oradata/rac/standbyarchive/log_1_2_626449270.arc

Media Recovery Log /home/oracle/oradata/rac/standbyarchive/log_1_3_626449270.arc

Media Recovery Log /home/oracle/oradata/rac/standbyarchive/log_1_4_626449270.arc

Media Recovery Log /home/oracle/oradata/rac/standbyarchive/log_1_5_626449270.arc

Media Recovery Waiting for thread 1 sequence 6

 

Mon Jul  9 18:54:03 2007

Redo Shipping Client Connected as PUBLIC

-- Connected User is Valid

RFS[1]: Assigned to RFS process 3025

RFS[1]: Identified database type as 'physical standby'

Mon Jul  9 18:54:03 2007

RFS LogMiner: Client disabled from further notification

阅读(1838) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~