RAC配置(启停库)

 
关库顺序 :先关闭数据库 然后关闭节点资源

[root@rac1 ~]# srvctl stop   database  -d 数据库名
[root@rac1 ~]# srvctl stop   instance  -d  数据库名   -i  实例1
[root@rac1 ~]# srvctl stop   instance  -d  数据库名  -i   实例2
[root@rac1 ~]# srvctl stop   nodeapps  -n  节点1  
[root@rac1 ~]# srvctl start  nodeapps  -n   节点2

启库顺序相反   

[root@rac1 ~]# srvctl start  nodeapps  -n  节点1
[root@rac1 ~]# srvctl start  nodeapps  -n  节点2
[root@rac1 ~]# srvctl start  instance  -d   数据库名  -i 实例1
[root@rac1 ~]# srvctl start  instance  -d   数据库名  -i 实例2
[root@rac1 ~]# srvctl start  database  -d  数据库名




[root@rac1 ~]# srvctl stop  database  -d prod                root用户关库命令
[root@rac1 ~]# srvctl start database  -d prod                root用户启库命令
[root@rac1 ~]# srvctl stop  instance  -d prod  -i prod1      关闭实例
[root@rac1 ~]# crsctl stop  crs                              关闭crs资源
[root@rac1 ~]# crsctl check crs                              查看crs资源的状态
[root@rac1 ~]# crs_stat -t                                    

[root@rac1 ~]# srvctl stop nodeapps -n rac1                  关闭节点应用  rac1


[root@rac1 ~]# more  /etc/inittab   

x:5:respawn:/etc/X11/prefdm -nodaemon
h1:35:respawn:/etc/init.d/init.evmd run >/dev/null 2>&1 </dev/null
h2:35:respawn:/etc/init.d/init.cssd fatal >/dev/null 2>&1 </dev/null   查看 css   fatal  致命的如果启动失败  导致节点重启
h3:35:respawn:/etc/init.d/init.crsd run >/dev/null 2>&1 </dev/null


[root@rac1 ~]# tail -f /var/log/messages 操作系统日志

[root@rac1 ~]# cd /u01/crs_1/log/rac1/

[root@rac1 rac1]# ls
admin  alertrac1.log  client  crsd  cssd  evmd  racg        crs系统日志

[root@rac1 rac1]# tail -f alertrac1.log

2013-01-30 01:33:32.929
[cssd(7013)]CRS-1605:CSSD voting file is online: /dev/raw/raw8. Details in /u01/crs_1/log/rac1/cssd/ocssd.log.
2013-01-30 01:33:36.410
[cssd(7013)]CRS-1601:CSSD Reconfiguration complete. Active nodes are rac1 rac2 .
2013-01-30 01:33:36.792
[crsd(6058)]CRS-1012:The OCR service started on node rac1.
2013-01-30 01:33:36.828
[evmd(6898)]CRS-1401:EVMD started on node rac1.
2013-01-30 01:33:38.762
[crsd(6058)]CRS-1201:CRSD started on node rac1.


SQL> select instance_number,instance_name from gv$instance;

INSTANCE_NUMBER INSTANCE_NAME
--------------- ----------------
              1 prod1
              2 prod2


查看两个节点 两个实例

SQL> show parameter name;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert                 string
db_name                              string      prod
db_unique_name                       string      prod
global_names                         boolean     FALSE
instance_name                        string      prod1
lock_name_space                      string
log_file_name_convert                string
service_names                        string      prod


SQL> show parameter name;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert                 string
db_name                              string      prod
db_unique_name                       string      prod
global_names                         boolean     FALSE
instance_name                        string      prod2
lock_name_space                      string
log_file_name_convert                string
service_names                        string      prod




SQL> select  name from v$datafile;

NAME
--------------------------------------------------------------------------------
+DG1/prod/datafile/system.256.805961653
+DG1/prod/datafile/undotbs1.258.805961657
+DG1/prod/datafile/sysaux.257.805961655
+DG1/prod/datafile/users.259.805961657
+DG1/prod/datafile/example.264.805961789
+DG1/prod/datafile/undotbs2.265.805961897


SQL> select name from v$tempfile;      临时文件放于其他磁盘了

NAME
--------------------------------------------------------------------------------
+DG1/prod/tempfile/temp.263.805961781

SQL> select name from v$controlfile;     控制文件自动多元化  人性化吧

NAME
--------------------------------------------------------------------------------
+DG1/prod/controlfile/current.260.805961753
+RECOVERY/prod/controlfile/current.256.805961755



SQL> select *  from v$log;   查看 thread 线程号      两个节点 故线程号  2个


    GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
         1          1          2   52428800          2 NO  INACTIVE   474739 29-JAN-13
         2          1          3   52428800          2 NO  CURRENT   528602 30-JAN-13
         3          2          1   52428800          2 NO  CURRENT   478694 29-JAN-13
         4          2          0   52428800          2 YES UNUSED0


SQL> alter database add logfile thread 1 group 5 '+dg1' size 50m;   添加日志组  其实后面的group 5  组号 不用写 oracle自行设定

Database altered.

指明文件存放的路径   这就是 OMF 的优势    管理更为方便  文件名 oracle自行管理  我们只需指定路径就好了



SQL> alter database add logfile thread 2 size 50m;  给线程2 添加日志组 默认添加两个成员 磁盘组dg1  磁盘组recovery

Database altered.


SQL> alter database add logfile member '+RECOVERY' to group 5;        指定存储位置 添加日志成员

Database altered.       

SQL> show parameter create;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
create_bitmap_area_size              integer     8388608
create_stored_outlines               string
db_create_file_dest                  string      +DG1          这就是oracle自行设定的路径
db_create_online_log_dest_1          string
db_create_online_log_dest_2          string
db_create_online_log_dest_3          string
db_create_online_log_dest_4          string
db_create_online_log_dest_5          string

SQL> create tablespace tbs1;       创建表空间   路径不用指定     OMF的优势  

Tablespace created.


SQL> create tablespace tbs2 datafile '+RECOVERY' size 50m;     创建表空间  指定磁盘组    指定 大小   如果不指定 默认100m

Tablespace created.    


SQL> select name,bytes/1024/1024 from v$datafile;

NAME                                               BYTES/1024/1024
-------------------------------------------------- ---------------
+DG1/prod/datafile/system.256.808026577                        480
+DG1/prod/datafile/undotbs1.258.808026579                       35
+DG1/prod/datafile/sysaux.257.808026579                        250
+DG1/prod/datafile/users.259.808026581                           5
+DG1/prod/datafile/example.264.808026717                       100
+DG1/prod/datafile/undotbs2.265.808026831                       25
+DG1/prod/datafile/tbs1.270.808033599                          100
+RECOVERY/prod/datafile/tbs2.263.808033653                      50

tbs1  指定大小    100m   
tbs2  不指定大小  50m   对了吧


[oracle@rac1 ~]$ more /u01/app/oracle/product/10.2.0/db_1/dbs/initprod1.ora  rac下的pfile里面只有一句话  指定spfile

SPFILE='+DG1/prod/spfileprod.ora'

SQL> create pfile='/home/oracle/initprod.ora' from spfile;   备份spfile 注意指定路径 不然放于asm磁盘组了

File created.        


[oracle@rac1 ~]$ more /home/oracle/initprod.ora

prod1.__db_cache_size=176160768
prod2.__db_cache_size=167772160
prod1.__java_pool_size=4194304
prod2.__java_pool_size=4194304
prod1.__large_pool_size=4194304
prod2.__large_pool_size=4194304
prod1.__shared_pool_size=96468992
prod2.__shared_pool_size=104857600
prod1.__streams_pool_size=0
prod2.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/prod/adump'
*.background_dump_dest='/u01/app/oracle/admin/prod/bdump'
*.cluster_database_instances=2
*.cluster_database=true
*.compatible='10.2.0.1.0'
*.control_files='+DG1/prod/controlfile/current.260.805961753','+RECOVERY/prod/co
ntrolfile/current.256.805961755'
*.core_dump_dest='/u01/app/oracle/admin/prod/cdump'
*.db_block_size=8192
*.db_create_file_dest='+DG1'
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='prod'
*.db_recovery_file_dest='+RECOVERY'
*.db_recovery_file_dest_size=2147483648
*.dispatchers='(PROTOCOL=TCP) (SERVICE=prodXDB)'
prod2.instance_number=2
prod1.instance_number=1
*.job_queue_processes=10
*.open_cursors=300
*.pga_aggregate_target=94371840
*.processes=150
*.remote_listener='LISTENERS_PROD'
*.remote_login_passwordfile='exclusive'
*.sga_target=285212672
prod2.thread=2
prod1.thread=1
*.undo_management='AUTO'
prod1.undo_tablespace='UNDOTBS1'
prod2.undo_tablespace='UNDOTBS2'
*.user_dump_dest='/u01/app/oracle/admin/prod/udump'


配置客户端


服务器端  tnsnames 文件  注意 host 都是对应 vip地址(漂移地址)

PROD =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = rac1-vip)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = rac2-vip)(PORT = 1521))
    (LOAD_BALANCE = yes)
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = prod)
    )
  )

PROD2 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = rac2-vip)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = prod)
      (INSTANCE_NAME = prod2)
    )
  )

PROD1 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = rac1-vip)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = prod)
      (INSTANCE_NAME = prod1)
    )
  )


修改客户端 tnsnames  


配置归档

[oracle@rac1 ~]# mkdir  /u01/arch
[oracle@rac2 ~]# mkdir  /u01/arch

[oracle@rac1 ~]# vi  /etc/exports   
/u01/arch  192.168.8.30/24(sync,rw)

[oracle@rac1 ~]# service nfs start  

Starting NFS services:  [  OK  ]
Starting NFS quotas: [  OK  ]
Starting NFS daemon: [  OK  ]
Starting NFS mountd: [  OK  ]
               
[oracle@rac1 ~]# chkcofig nfs on

[oracle@rac2 ~]# mount -t nfs -o rw,bg,hard,soft,nointr,rsize=32768,wsize=32768,timeo=600,actimeo=0   rac1:/u01/arch  /u01/arch
[oracle@rac1 ~]# vi /etc/fstab

rac1:/u01/arch  /u01/arch     rw,bg,hard,soft,nointr,rsize=32768,wsize=32768,timeo=600,actimeo=0    参数


两个节点关库 任一节点启库到mount状态

SQL> alter database archivelog ;

Database altered.

SQL> alter system set log_archive_dest='location=/u01/arch' scope=spfile;

System altered.

SQL> alter system archive log current;

System altered.


asm  磁盘组

SQL> desc  v$asm_diskgroup;
 Name                                                                                                              Null?    Type
 ----------------------------------------------------------------------------------------------------------------- -------- ----------------------------------------------------------------------------
 GROUP_NUMBER                                                                                                               NUMBER
 NAME                                                                                                                       VARCHAR2(30)
 SECTOR_SIZE                                                                                                                NUMBER
 BLOCK_SIZE                                                                                                                 NUMBER
 ALLOCATION_UNIT_SIZE                                                                                                       NUMBER
 STATE                                                                                                                      VARCHAR2(11)
 TYPE                                                                                                                       VARCHAR2(6)
 TOTAL_MB                                                                                                                   NUMBER
 FREE_MB                                                                                                                    NUMBER
 REQUIRED_MIRROR_FREE_MB                                                                                                    NUMBER
 USABLE_FILE_MB                                                                                                             NUMBER
 OFFLINE_DISKS                                                                                                              NUMBER
 UNBALANCED                                                                                                                 VARCHAR2(1)
 COMPATIBILITY                                                                                                              VARCHAR2(60)
 DATABASE_COMPATIBILITY                                                                                                     VARCHAR2(60)

SQL> select  GROUP_NUMBER , NAME  ,BLOCK_SIZE, STATE ,TOTAL_MB, FREE_MB  ,USABLE_FILE_MB  ,OFFLINE_DISKS  from v$asm_diskgroup;

GROUP_NUMBER NAME                           BLOCK_SIZE STATE         TOTAL_MB    FREE_MB USABLE_FILE_MB OFFLINE_DISKS
------------ ------------------------------ ---------- ----------- ---------- ---------- -------------- -------------
           1 DG1                                  4096 CONNECTED         8192       5226           2613             0
           2 RECOVERY                             4096 CONNECTED         8192       6840           3420             0

[oracle@rac1 ~]$ export ORACLE_SID=+ASM1
[oracle@rac1 ~]$ sqlplus / as sysdba

SQL> create  diskgroup dg2 external redundancy  disk '/dev/raw/raw5';

Diskgroup created.

alter diskgroup  dg2  mount;
alter diskgroup dg2 dismount;
create  diskgroup dg2 normal redundancy  disk '/dev/raw/rawXXXXX';   创建 normal磁盘 报错  至少需要两块

修改asm 的 pfile  把新加的磁盘组 加入开机自动
asm_disgroups='dg1'.'recovery','dg2'

alter  database backup controlfile to '+dg2/prod/controlfile/controlfile01.ctl'  ;
alter  diskgroup add directory '+dg1/prod/controlfile' scope=spfile;


























   


posted @ 2017-06-22 21:18  Oracle-fans  阅读(992)  评论(0编辑  收藏  举报