首页 > 数据库 > Oracle > 正文

Oracle rac安装过程详解(3)

2019-09-08 23:30:31
字体:
来源:转载
供稿:网友

  在服务器端配置listener.ora和tnsnames.ora 
  
  修改lisnter.ora和tnsnames.ora文件,以增加listener. 
  这一部分,RAC环境和非RAC环境没有区别,可以参考oracle的文档. 
  
  可以一个listener给三个instance服务,也可以启动三个listener给三个instance服务. 
  我启动了三个listener. 
  
  Listener.ora 
  LSNR1 = 
  (ADDRESS_LIST= 
  (ADDRESS=(PROTOCOL=tcp)(HOST=your_ip_or_name)(PORT=1521))) 
  LSNR2 = 
  (ADDRESS_LIST= 
  (ADDRESS=(PROTOCOL=tcp)(HOST=your_ip_or_name)(PORT=1522))) 
  LSNR3 = 
  (ADDRESS_LIST= 
  (ADDRESS=(PROTOCOL=tcp)(HOST=your_ip_or_name)(PORT=1523))) 
  
  tnsnames.ora 
  lsnr1=(DESCRIPTION= 
  (ADDRESS=(PROTOCOL=tcp)(HOST=your_ip_or_name)(PORT=1521))) 
  lsnr2=(DESCRIPTION= 
  (ADDRESS=(PROTOCOL=tcp)(HOST=your_ip_or_name)(PORT=1522))) 
  lsnr3=(DESCRIPTION= 
  (ADDRESS=(PROTOCOL=tcp)(HOST=your_ip_or_name)(PORT=1523))) 
  
  将your_ip_or_name替换为你的IP地址或者hostname. 
  Rac.test.com替换为你init.ora文件中设置的db_name.db_domain 
  
  启动三个listener. 
  $ lsnrctl start lsnr1 
  $ lsnrctl start lsnr2 
  $ lsnrctl start lsnr3

  创建数据库 
  
  可以运行dbca用图形界面来创建,也可以用命令行来创建. 
  因为以前没有创建过集群下的数据库,因此我用图形界面来创建脚本,修改后用命令行来创建. 
  
  先确认ORACM和GSD已经启动: 
  $ ps -ef | grep oracm 
  root 3056 1 0 10:50 pts/1 00:00:00 oracm 
  root 3057 3056 0 10:50 pts/1 00:00:00 oracm 
  root 3059 3057 0 10:50 pts/1 00:00:00 oracm 
  root 3060 3057 0 10:50 pts/1 00:00:00 oracm 
  root 3061 3057 0 10:50 pts/1 00:00:00 oracm 
  root 3062 3057 0 10:50 pts/1 00:00:00 oracm 
  root 3063 3057 0 10:50 pts/1 00:00:00 oracm 
  root 3064 3057 0 10:50 pts/1 00:00:00 oracm 
  root 3065 3057 0 10:50 pts/1 00:00:00 oracm 
  root 3338 3057 0 11:36 pts/1 00:00:00 oracm 
  root 3362 3057 0 11:36 pts/1 00:00:00 oracm 
  oracle 3482 2932 0 11:38 pts/1 00:00:00 grep oracm 
  
  $ gsdctl stat 
  GSD is running on the local node 
  
  然后运行dbca启动数据库配置助手. 
  
  在欢迎画面中,选择Oracle cluster database, 然后一路继续就可以了. 
  
  在最后的总结画面上,可以选择创建数据库,也可以选择创建脚本.我选择了创建脚本. 
  
  手工修改脚本为自己想要的样子,然后跟非集群环境一样手工创建数据库.数据文件使用本地管理,不用数据字典管理.并创建缺省的撤消表空间(undo tablespace)和临时表空间. 
  
  注意: 
  根据我的经验,SGA太小,在创建数据字典的时候会失败,因此SGA可以大一些.但因为是集群,需要启动多个instance,所以在数据字典创建完以后,即catalog.sql,catproc.sql,catclust.sql运行完以后,需要将SGA改小一点. 
  
  
  修改init.ora文件,并拷贝到$ORACLE_HOME/dbs下,改名字为initrac.ora. 
  我是一个instance对应一个listener.也可以一个listener响应多个instnce. 
  
  其余参数可以自己根据自己的情况进行设置,以下是cluster的参数: 
  
  undo_management=AUTO 
  undo_retention=10800 
  
  cluster_database=true 
  cluster_database_instances=5 
  rac1.instance_name=rac1 
  rac1.instance_number=1 
  rac1.local_listener=lsnr1 
  rac1.thread=1 
  rac1.undo_tablespace=UNDOTBS1 
  rac2.instance_name=rac2 
  rac2.instance_number=2 
  rac2.local_listener=lsnr2 
  rac2.thread=2 
  rac2.undo_tablespace=UNDOTBS2 
  rac3.instance_name=rac3 
  rac3.instance_number=3 
  rac3.local_listener=lsnr3 
  rac3.thread=3 
  rac3.undo_tablespace=UNDOTBS3 
  
  如果要多个instance都由一个listener来响应,则改以下两行: 
  rac2.local_listener=lsnr1 
  rac3.local_listener=lsnr1 
  
  注意: 
  尽管数据库名字叫rac,但启动的实例名字不能叫rac.我将ORACLE_SID分别设置成了rac1,rac2,rac3. 
  
  然后启动第一个实例,创建数据库: 
  
  $ export ORACLE_SID=rac1 
  $ sqlplus /nolog 
  SQL*Plus: Release 9.2.0.4.0???j? - Production on Fri Nov 21 13:43:22 2003 
  
  Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved. 
  
  SQL> conn / as sysdba; 
  Connected to an idle instance. 
  SQL> startup pfile=/u01/app/oracle/product/9.2.0.4.0/dbs/initrac.ora; 
  ORACLE instance started. 
  
  Total System Global Area 38867968 bytes 
  Fixed Size 451584 bytes 
  Variable Size 33554432 bytes 
  Database Buffers 4194304 bytes 
  Redo Buffers 667648 bytes 
  Database mounted. 
  Database opened. 
  SQL> 
  
  创建数据库的命令: 
  CREATE DATABASE rac 
  MAXINSTANCES 32 
  MAXLOGHISTORY 100 
  MAXLOGFILES 192 
  MAXLOGMEMBERS 3 
  MAXDATAFILES 1024 
  DATAFILE '/u02/oradata/rac/rac/system01.dbf' SIZE 100M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE 1000M 
  EXTENT MANAGEMENT LOCAL 
  DEFAULT TEMPORARY TABLESPACE TEMP TEMPFILE '/u02/oradata/rac/rac/temp01.dbf' SIZE 40M REUSE AUTOEXTEND ON NEXT 640K MAXSIZE 1000M 
  UNDO TABLESPACE "UNDOTBS1" DATAFILE '/u02/oradata/rac/rac/undotbs01.dbf' SIZE 50M REUSE AUTOEXTEND ON NEXT 5120K MAXSIZE 1000M 
  CHARACTER SET ZHS16GBK 
  LOGFILE GROUP 1 ('/u02/oradata/rac/rac/redo01.log') SIZE 10M REUSE, 
  GROUP 2 ('/u02/oradata/rac/rac/redo02.log') SIZE 10M REUSE, 
  GROUP 3 ('/u02/oradata/rac/rac/redo03.log') SIZE 10M REUSE; 
  
  然后创建数据字典. 
  
  以sysdba身份运行: 
  SQL> @?/rdbms/admin/catalog.sql; 
  SQL> @?/rdbms/admin/catproc.sql; 
  SQL> @?/rdbms/admin/catclust.sql; 
  
  以system身份运行: 
  SQL> @?/sqlplus/admin/pupbld.sql;

  创建并启动多个instance 
  
  在启动多个instance前,需要为每个instance增加一个undo tablespace, 并增加一组 redo logfile. 
  
  SQL>CREATE UNDO TABLESPACE UNDOTBS2 DATAFILE '/u02/oradata/rac/rac/undotbs02.dbf' SIZE 50M REUSE AUTOEXTEND ON NEXT 5120K MAXSIZE 1000M; 
  
  SQL>CREATE UNDO TABLESPACE UNDOTBS3 DATAFILE '/u02/oradata/rac/rac/undotbs03.dbf' SIZE 50M REUSE AUTOEXTEND ON NEXT 5120K MAXSIZE 1000M; 
  
  SQL> ALTER DATABASE ADD LOGFILE THREAD 2 '/u02/oradata/rac/rac/redo2_1.log' SIZE 10M; 
  SQL> ALTER DATABASE ADD LOGFILE THREAD 2 '/u02/oradata/rac/rac/redo2_2.log' SIZE 10M; 
  
  SQL> ALTER DATABASE ADD LOGFILE THREAD 3 '/u02/oradata/rac/rac/redo3_1.log' SIZE 10M; 
  SQL> ALTER DATABASE ADD LOGFILE THREAD 3 '/u02/oradata/rac/rac/redo3_1.log' SIZE 10M; 
  
  SQL> 
  
  然后就可以启动多个instance了. 
  
  $ export ORACLE_SID=rac2 
  $ sqlplus /nolog 
  
  SQL*Plus: Release 9.2.0.4.0 - Production on Fri Nov 21 15:11:16 2003 
  
  Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved. 
  
  SQL> conn / as sysdba; 
  Connected to an idle instance. 
  SQL> startup pfile=/u01/app/oracle/product/9.2.0.4.0/dbs/initrac.ora 
  ORACLE instance started. 
  
  Total System Global Area 38867968 bytes 
  Fixed Size 451584 bytes 
  Variable Size 33554432 bytes 
  Database Buffers 4194304 bytes 
  Redo Buffers 667648 bytes 
  Database mounted. 
  Database opened. 
  SQL> 
  
  然后再启动rac3. 
  
  注意: 
  如果SGA配置太大,启动多个instance可能会死机. 
  在出现Database mounted.后,到Database opened.可能会要一段时间,请耐心等待. 
  
  可以用以下语句查询,确认多个instance已经启动. 
  SQL> select inst_id, instance_number inst_no, instance_name inst_name, 
  2 parallel, status, database_status db_stat, active_state stat, host_name 
  3 from gv$instance;

Oracle

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表