RAC修改字符集

字符集修改作過幾回了,此次感受仍是有點不順,走了彎路,再記一遍
【概況】
準備搭建RAC+RAC DG,發現兩端字符集不大一致,擔憂到時出問題。css

【目標】
將備庫NLS_NCHAR_CHARACTERSET修改爲與主庫一致。
--備
NLS_NCHAR_CHARACTERSET UTF8
修改成
--主
NLS_NCHAR_CHARACTERSET AL16UTF16數據庫

0、備庫 修改前
PRIMARY-SYS@TESTDB2>set pagesize 100
PRIMARY-SYS@TESTDB2>col value$ for a30
PRIMARY-SYS@TESTDB2>select name,value$ from props$ where name like '%NLS%';oracle

NAME VALUE$
------------------------------------------------------------------------------------------ ------------------------------
NLS_LANGUAGE AMERICAN
NLS_TERRITORY AMERICA
NLS_CURRENCY $
NLS_ISO_CURRENCY AMERICA
NLS_NUMERIC_CHARACTERS .,
NLS_CHARACTERSET ZHS16GBK
NLS_CALENDAR GREGORIAN
NLS_DATE_FORMAT DD-MON-RR
NLS_DATE_LANGUAGE AMERICAN
NLS_SORT BINARY
NLS_TIME_FORMAT HH.MI.SSXFF AM
NLS_TIMESTAMP_FORMAT DD-MON-RR HH.MI.SSXFF AM
NLS_TIME_TZ_FORMAT HH.MI.SSXFF AM TZR
NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH.MI.SSXFF AM TZR
NLS_DUAL_CURRENCY $
NLS_COMP BINARY
NLS_LENGTH_SEMANTICS BYTE
NLS_NCHAR_CONV_EXCP FALSE
NLS_NCHAR_CHARACTERSET UTF8
NLS_RDBMS_VERSION 11.2.0.4.0app

20 rows selected.this

一、節點2 先停掉,在節點1修改完成後再啓動
[root@NODE2 ~]# ls -l /u01/app/11.2.0/grid/bin/crsctl
-rwxr-xr-x 1 root oinstall 8576 Jan 13 2017 /u01/app/11.2.0/grid/bin/crsctl
[root@NODE2 ~]#
[root@NODE2 ~]# /u01/app/11.2.0/grid/bin/crsctl stop cluster
CRS-2673: Attempting to stop 'ora.crsd' on 'NODE2'
CRS-2790: Starting shutdown of Cluster Ready Services-managed resources on 'NODE2'
CRS-2673: Attempting to stop 'ora.LISTENER_SCAN1.lsnr' on 'NODE2'
CRS-2673: Attempting to stop 'ora.LISTENER.lsnr' on 'NODE2'
CRS-2673: Attempting to stop 'ora.CRSDG.dg' on 'NODE2'
CRS-2673: Attempting to stop 'ora.TESTDB.db' on 'NODE2'
CRS-2677: Stop of 'ora.LISTENER_SCAN1.lsnr' on 'NODE2' succeeded
CRS-2673: Attempting to stop 'ora.scan1.vip' on 'NODE2'
CRS-2677: Stop of 'ora.LISTENER.lsnr' on 'NODE2' succeeded
CRS-2673: Attempting to stop 'ora.NODE2.vip' on 'NODE2'
CRS-2677: Stop of 'ora.scan1.vip' on 'NODE2' succeeded
CRS-2672: Attempting to start 'ora.scan1.vip' on 'NODE1'
CRS-2677: Stop of 'ora.NODE2.vip' on 'NODE2' succeeded
CRS-2672: Attempting to start 'ora.NODE2.vip' on 'NODE1'
CRS-2677: Stop of 'ora.TESTDB.db' on 'NODE2' succeeded
CRS-2673: Attempting to stop 'ora.DATA.dg' on 'NODE2'
CRS-2673: Attempting to stop 'ora.FRA.dg' on 'NODE2'
CRS-2677: Stop of 'ora.DATA.dg' on 'NODE2' succeeded
CRS-2677: Stop of 'ora.FRA.dg' on 'NODE2' succeeded
CRS-2676: Start of 'ora.scan1.vip' on 'NODE1' succeeded
CRS-2672: Attempting to start 'ora.LISTENER_SCAN1.lsnr' on 'NODE1'
CRS-2676: Start of 'ora.NODE2.vip' on 'NODE1' succeeded
CRS-2676: Start of 'ora.LISTENER_SCAN1.lsnr' on 'NODE1' succeeded
CRS-2677: Stop of 'ora.CRSDG.dg' on 'NODE2' succeeded
CRS-2673: Attempting to stop 'ora.asm' on 'NODE2'
CRS-2677: Stop of 'ora.asm' on 'NODE2' succeeded
CRS-2673: Attempting to stop 'ora.ons' on 'NODE2'
CRS-2677: Stop of 'ora.ons' on 'NODE2' succeeded
CRS-2673: Attempting to stop 'ora.net1.network' on 'NODE2'
CRS-2677: Stop of 'ora.net1.network' on 'NODE2' succeeded
CRS-2792: Shutdown of Cluster Ready Services-managed resources on 'NODE2' has completed
CRS-2677: Stop of 'ora.crsd' on 'NODE2' succeeded
CRS-2673: Attempting to stop 'ora.ctssd' on 'NODE2'
CRS-2673: Attempting to stop 'ora.evmd' on 'NODE2'
CRS-2673: Attempting to stop 'ora.asm' on 'NODE2'
CRS-2677: Stop of 'ora.evmd' on 'NODE2' succeeded
CRS-2677: Stop of 'ora.asm' on 'NODE2' succeeded
CRS-2673: Attempting to stop 'ora.cluster_interconnect.haip' on 'NODE2'
CRS-2677: Stop of 'ora.cluster_interconnect.haip' on 'NODE2' succeeded
CRS-2677: Stop of 'ora.ctssd' on 'NODE2' succeeded
CRS-2673: Attempting to stop 'ora.cssd' on 'NODE2'
CRS-2677: Stop of 'ora.cssd' on 'NODE2' succeeded
[root@NODE2 ~]#spa

二、節點1.net

PRIMARY-SYS@TESTDB1>show parameter pfile;orm

NAME TYPE VALUE
------------------------------------ --------------------------------- ------------------------------
spfile string +DATA/TESTDB/parameterfile/spf
ile.344.1016736315
PRIMARY-SYS@TESTDB1>create pfile from spfile;
--這樣的話就直接修改上面生成的pfile文件中cluster_database=false 用pfile mount +修改INTERNAL_USE + open ,而後再建立spfile共節點2一塊兒使用ip

--下面不必修改spfile,保持spfile(兩節點共享的)中cluster_database=TRUE
--alter system set cluster_database=false;
PRIMARY-SYS@TESTDB1>alter system set cluster_database=false scope=spfile;string

System altered.

--須要【重啓】才能生效,儘管上面已經修改了
PRIMARY-SYS@TESTDB1>show parameter cluster_database

NAME TYPE VALUE
------------------------------------ --------------------------------- ------------------------------
cluster_database boolean TRUE
cluster_database_instances integer 2
PRIMARY-SYS@TESTDB1>shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

--mv initTESTDB1.ora initTESTDB1.ora.bak,最後又mv回來了,沒改回就報下面的錯了
PRIMARY-SYS@TESTDB1>startup mount;
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/11.2.0/db_home1/dbs/initTESTDB1.ora'

PRIMARY-SYS@TESTDB1>startup mount;
ORACLE instance started.

Total System Global Area 7.4826E+10 bytes
Fixed Size 2261048 bytes
Variable Size 4.6976E+10 bytes
Database Buffers 2.7649E+10 bytes
Redo Buffers 199049216 bytes
Database mounted.
PRIMARY-SYS@TESTDB1>ALTER SYSTEM ENABLE RESTRICTED SESSION;

System altered.

PRIMARY-SYS@TESTDB1>ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;

System altered.

PRIMARY-SYS@TESTDB1>ALTER SYSTEM SET AQ_TM_PROCESSES=0;

System altered.

PRIMARY-SYS@TESTDB1>ALTER DATABASE OPEN;

Database altered.
--這一步是【重點要修改的】
PRIMARY-SYS@TESTDB1>ALTER DATABASE NATIONAL CHARACTER SET INTERNAL_USE AL16UTF16;

Database altered.

--pfile啓動了,無法修改spfile了
PRIMARY-SYS@TESTDB1>alter system set cluster_database=true scope=spfile sid='*';
alter system set cluster_database=true scope=spfile sid='*'
*
ERROR at line 1:
ORA-32001: write to SPFILE requested but no SPFILE is in use


PRIMARY-SYS@TESTDB1>show parameter pfile;

NAME TYPE VALUE
------------------------------------ --------------------------------- ------------------------------
spfile string

--手動修改initTESTDB1.ora中的cluster_database=true,重建spfile
PRIMARY-SYS@TESTDB1>create spfile from pfile='/u01/app/oracle/product/11.2.0/db_home1/dbs/initTESTDB1.ora';

File created.

PRIMARY-SYS@TESTDB1>shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
PRIMARY-SYS@TESTDB1>startup mount;
ORACLE instance started.

Total System Global Area 7.4826E+10 bytes
Fixed Size 2261048 bytes
Variable Size 4.6976E+10 bytes
Database Buffers 2.7649E+10 bytes
Redo Buffers 199049216 bytes
Database mounted.
--還得改回去,0->1
PRIMARY-SYS@TESTDB1>ALTER SYSTEM DISABLE RESTRICTED SESSION;

System altered.

PRIMARY-SYS@TESTDB1>ALTER SYSTEM SET JOB_QUEUE_PROCESSES=1;

System altered.

PRIMARY-SYS@TESTDB1>ALTER SYSTEM SET AQ_TM_PROCESSES=1;

System altered.

PRIMARY-SYS@TESTDB1>show parameter pfile;

NAME TYPE VALUE
------------------------------------ --------------------------------- ------------------------------
spfile string /u01/app/oracle/product/11.2.0
/db_home1/dbs/spfileTESTDB1.or
a
PRIMARY-SYS@TESTDB1>alter system set cluster_database=true scope=spfile sid='*';

System altered.

PRIMARY-SYS@TESTDB1>alter database open;

Database altered.


--cluster_database【重啓】才生效

PRIMARY-SYS@TESTDB1>show parameter cluster_database

NAME TYPE VALUE
------------------------------------ --------------------------------- ------------------------------
cluster_database boolean FALSE
cluster_database_instances integer 1
PRIMARY-SYS@TESTDB1>shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
PRIMARY-SYS@TESTDB1>
PRIMARY-SYS@TESTDB1>
PRIMARY-SYS@TESTDB1>
PRIMARY-SYS@TESTDB1>startup
ORACLE instance started.

Total System Global Area 7.4826E+10 bytes
Fixed Size 2261048 bytes
Variable Size 4.9392E+10 bytes
Database Buffers 2.5233E+10 bytes
Redo Buffers 199049216 bytes
Database mounted.
Database opened.
PRIMARY-SYS@TESTDB1>show parameter cluster_database

NAME TYPE VALUE
------------------------------------ --------------------------------- ------------------------------
cluster_database boolean TRUE
cluster_database_instances integer 2
PRIMARY-SYS@TESTDB1>

PRIMARY-SYS@TESTDB1>set pagesize 100
PRIMARY-SYS@TESTDB1>col value$ for a30
PRIMARY-SYS@TESTDB1>select name,value$ from props$ where name like '%NLS%';

NAME VALUE$
------------------------------------------------------------------------------------------ ------------------------------
NLS_LANGUAGE AMERICAN
NLS_TERRITORY AMERICA
NLS_CURRENCY $
NLS_ISO_CURRENCY AMERICA
NLS_NUMERIC_CHARACTERS .,
NLS_CHARACTERSET ZHS16GBK
NLS_CALENDAR GREGORIAN
NLS_DATE_FORMAT DD-MON-RR
NLS_DATE_LANGUAGE AMERICAN
NLS_SORT BINARY
NLS_TIME_FORMAT HH.MI.SSXFF AM
NLS_TIMESTAMP_FORMAT DD-MON-RR HH.MI.SSXFF AM
NLS_TIME_TZ_FORMAT HH.MI.SSXFF AM TZR
NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH.MI.SSXFF AM TZR
NLS_DUAL_CURRENCY $
NLS_COMP BINARY
NLS_LENGTH_SEMANTICS BYTE
NLS_NCHAR_CONV_EXCP FALSE
--發現已【修改】成功
NLS_NCHAR_CHARACTERSET AL16UTF16
NLS_RDBMS_VERSION 11.2.0.4.0

20 rows selected.

PRIMARY-SYS@TESTDB1>


三、第二個節點啓動
[root@NODE2 ~]# /u01/app/11.2.0/grid/bin/crsctl start cluster
CRS-2672: Attempting to start 'ora.cssdmonitor' on 'NODE2'
CRS-2676: Start of 'ora.cssdmonitor' on 'NODE2' succeeded
CRS-2672: Attempting to start 'ora.cssd' on 'NODE2'
CRS-2672: Attempting to start 'ora.diskmon' on 'NODE2'
CRS-2676: Start of 'ora.diskmon' on 'NODE2' succeeded
CRS-2676: Start of 'ora.cssd' on 'NODE2' succeeded
CRS-2672: Attempting to start 'ora.ctssd' on 'NODE2'
CRS-2676: Start of 'ora.ctssd' on 'NODE2' succeeded
CRS-2672: Attempting to start 'ora.evmd' on 'NODE2'
CRS-2672: Attempting to start 'ora.cluster_interconnect.haip' on 'NODE2'
CRS-2676: Start of 'ora.evmd' on 'NODE2' succeeded
CRS-2676: Start of 'ora.cluster_interconnect.haip' on 'NODE2' succeeded
CRS-2672: Attempting to start 'ora.asm' on 'NODE2'
CRS-2676: Start of 'ora.asm' on 'NODE2' succeeded
CRS-2672: Attempting to start 'ora.crsd' on 'NODE2'
CRS-2676: Start of 'ora.crsd' on 'NODE2' succeeded

--設置了自動重啓,因此失敗。。。
PRIMARY-SYS@TESTDB2>startup mount
ORA-10997: another startup/shutdown operation of this instance inprogress
ORA-09968: unable to lock file
Linux-x86_64 Error: 11: Resource temporarily unavailable
Additional information: 169786
。。。自啓動了。。。

--稍等發現已啓動OK
PRIMARY-SYS@TESTDB2>select inst_id,instance_name,status from gv$instance;

INST_ID INSTANCE_NAME STATUS
---------- ------------------------------------------------ ------------------------------------
2 TESTDB2 OPEN
1 TESTDB1 OPEN

2 rows selected.

自此兩個節點都OK了


【總結】
上面可能說的有點亂,捋一捋。。。不知道說的對不對
0、作事以前要盤算計劃好,眼高手低是技術一大障礙,說來都很美好,作起來總不是那麼一路順風的,稍微一個錯誤浪費的時間比事前多花點時間準備好多了,固然牛人除外,可以及時處理。
一、根據節點1生成的pfile,修改cluster_database=false啓動修改,而後再改回來是否是少點麻煩
二、修改字符集要關閉一個節點,在另一個節點修改,修改前要把這個節點的cluster_database改爲false(別改spfile,spfile是兩個節點公用的,改了等下又要改回來,重複工做!),重啓(才生效),修改時按照上面mount以後操做便可,修改後再把0改爲1,cluster_database再改爲true,重啓(生效),啓動節點2(仍是修改以前的spfile額,cluster_database仍爲true),結束。


【小插曲】兩節點不從ASM中的spfile啓動了
PRIMARY-SYS@DINPAY1>show parameter pfile;

NAME TYPE VALUE
------------------------------------ --------------------------------- ------------------------------
spfile string /u01/app/oracle/product/11.2.0
/db_home1/dbs/spfileDINPAY1.or
a
PRIMARY-SYS@DINPAY1>create pfile from spfile;

File created.

PRIMARY-SYS@DINPAY1>create spfile from pfile='/u01/app/oracle/product/11.2.0/db_home1/dbs/initDINPAY1.ora';
create spfile from pfile='/u01/app/oracle/product/11.2.0/db_home1/dbs/initDINPAY1.ora'
*
ERROR at line 1:
ORA-32002: cannot create SPFILE already being used by the instance

PRIMARY-SYS@DINPAY1>shut immediate

PRIMARY-SYS@DINPAY1>startup pfile='/u01/app/oracle/product/11.2.0/db_home1/dbs/initDINPAY1.ora';

PRIMARY-SYS@DINPAY1>show parameter pfile;

NAME TYPE VALUE
------------------------------------ --------------------------------- ------------------------------
spfile string
PRIMARY-SYS@DINPAY1>create spfile='+data' from pfile='/u01/app/oracle/product/11.2.0/db_home1/dbs/initDINPAY1.ora';

File created.
PRIMARY-SYS@DINPAY1>show parameter pfile;

NAME TYPE VALUE
------------------------------------ --------------------------------- ------------------------------
spfile string
PRIMARY-SYS@DINPAY1>shut immediate

--grid登錄查找生成spfile位置
ASMCMD> cd +DATA/dinpay/parameterfile/
ASMCMD> ls
spfile.282.1016709123
spfile.343.1016734531
spfile.344.1016736315
spfile.346.1025548589
--剛剛生成的
+DATA/dinpay/parameterfile/spfile.346.1025548589

--更新pfile,別這樣create pfile from spfile;指定pfile生成位置
[oracle@zhjlrac1 dbs]$ pwd
/u01/app/oracle/product/11.2.0/db_home1/dbs
[oracle@szml02-db01 dbs]$ cat initDINPAY1.ora
SPFILE='+DATA/dinpay/parameterfile/spfile.346.1025548589'

PRIMARY-SYS@DINPAY1>startup
ORACLE instance started.

Total System Global Area 7.4826E+10 bytes
Fixed Size 2261048 bytes
Variable Size 4.9124E+10 bytes
Database Buffers 2.5501E+10 bytes
Redo Buffers 199049216 bytes
Database mounted.
Database opened.
PRIMARY-SYS@DINPAY1>

PRIMARY-SYS@DINPAY1>show parameter pfile;

NAME TYPE VALUE
------------------------------------ --------------------------------- ------------------------------
spfile string +DATA/dinpay/parameterfile/spf
ile.346.1025548589
另一個節點頁如上指向這個spfile,重啓OK。

若是直接使用create pfile from spfile;命令建立pfile,那麼生成的pfile 文件將覆蓋原有$ORACLE_HOME/dbs 目錄下的pfile 文件。 而在以前的pfile文件裏面值保留了一條指向spfile存放位置的記錄。 這樣修改以後,就會形成數據庫啓動時會由於找不到spfile文件而讀取本地的pfile文件,而不是共享設備上的spfile文件。這樣對參數管理上就會帶來麻煩,也帶來其餘的隱患。
因此對於RAC,要慎用 create pfile from spfile; 來建立pfile 文件, 在建立的時候,儘可能指定pfile的生成位置

相關文章
相關標籤/搜索