顯示具有 Oracle 標籤的文章。 顯示所有文章
顯示具有 Oracle 標籤的文章。 顯示所有文章

星期四, 3月 08, 2018

Oracle Database on VMware 的授權買法

Oracle Database on VMware 的授權買法

*2018.4.13  最新發現, Oracle有Certify 自家的Oracle VM 以及 Hyper-V!!!    (VMware表示...OOXX)
link :    http://www.oracle.com/technetwork/database/virtualizationmatrix-172995.html


在業界久了有很多客戶、Partner都會問到底Oracle on VMware是否允許用限制vCPU的方式來節省oracle license, 答案是yes or no..如下闡述:

*在以下的link節錄一段,Oracle on VMware 要計算所有ESXI HOST CORES (VM Cluster內都要買oracle license)
*如果不想踩雷 只能考慮採用Oracle database Named User Plus的買法 也許更加划算一點

https://blogs.vmware.com/apps/2017/01/oracle-vmware-vsan-dispelling-licensing-myths.html
Oracle Licensing requires licensing every vSphere host attached to a given vCenter



或可參考MOS上的這篇文章也有提到一段比較特別的字眼,   Oracle has not certified any of its products on VMware virtualized environments.


如果要真正合法的在虛擬化環境裡面運行Oracle Database, 推薦使用Oracle提供的的虛擬化Hypervisor (Oracle VM), 技術源自Citrix 所開源的Xenserver...

目前是免費使用( 免費用但不能在MOS上面開SR- Service Request問問題 ) 

另外如果要確保CPU的核心是被綁訂到Guest OS進行使用,更進階一點的設定是需在OVM Server上用指令來綁定/ PIN CPU,讓CPU核心資源對應到要跑的VM(類似VMware affinity技術)

參考設定方式如下:
https://finnishingthoughts.wordpress.com/2017/05/02/oracle-vm-3-4-2-cpu-pinning-licensing/

當然如果不想使用Oracle VM的話可以考慮使用業界硬體廠商所提供的hardware partition技術(不過會較貴)

關於Oracle官方文件描述,所支援的hypersvior/ partition技術, 可以參考 http://www.oracle.com/us/corporate/pricing/partitioning-070609.pdf

主要重點如下:

Oracle DB接受的硬體平台可為software partition or hardware partition
1.Software partition(想像為軟體虛擬化技術)
Solaris 9 Resource Containers, AIX Workload
Manager, HP Process Resource Manager, Affinity Management, Oracle VM, and VMware.


*請注意 雖然VMware有列在software partition裡面, 不過並非O社所認可的平台,也就是說如果客戶決定要在VMware上面跑Oracle Database,當遇到DB以外的異常情形,建議向VMware原廠進行技術諮詢。VMware 所闡述的support policy link 

2.Hardware partition技術
   則是各個原廠所提供的技術例如 HP Superdome/ HP Superdome X / IBM LPAR / Fujisu PPAR ...

*當然 如果以上方案真的都不想用
可以考慮使用Oracle ODA (Oracle database appliance)一體機,他也是x86 based的CPU,
最大好處就是安裝且升級簡便; 
運行效能又超越一般X86 Server + All Flash Storage
不需要額外再買兩台SAN Switch所以相對成本較低~
在CPU效能不足的時候還可以彈性擴充DB license   (Capacity On Demand : from 2 to 72 cores)

星期二, 8月 20, 2013

Check if Oracle parameter is dynamic/can be changed online

SQL>
select name, ISSYS_MODIFIABLE from v$parameter where name='shared_pool_size';

--Find all dynamic parameter
select name, ISSYS_MODIFIABLE from v$parameter;

other parameter:
open_cursor,
sga_target,

星期二, 8月 13, 2013

[Sybase] 如果用BCP cmd再export/ import 遇到CP insert operation is disabled 問題

如果使用BCP 做資料庫匯出匯入時, 遇到CP insert operation is disabled 問題

Symptom:
BCP insert operation is disabled when data size is changing between client and server character sets.

Sol:
isql -Usa –P …etc
sp_configure "disable character set conversion",1
go

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

如果是Oracle export/ import遇到類似問題 要改的DB 參數是
NLS_LENGTH_SEMANTICS  from byte to char…

Oracle data pump 指令參照:

http://jaychu649.blogspot.tw/2011/12/oracle-data-pump.html

星期二, 12月 13, 2011

10g以上的Oracle group by 語法並不會保證sort排序

今天客戶反映11.2.0.1 的資料庫 下了group by 和9i 的行為不一樣,
在網路上查了一下,
將以下參數由default true è 改為false 就正常了,10g以上的group by 並不會保證撈取資料的sort , 除非修改此參數~

"_gby_hash_aggregation_enabled parameter" = false

example :
select ... from ...
group by f1, f2...

要改寫為 
(select ... from ...
group by f1, f2
order by f1, f2)

或把資料庫參數
"_gby_hash_aggregation_enabled parameter" = false


參考資料
Default Sorting behaviour of Oracle 9i in 11g along with group by clause
https://forums.oracle.com/forums/thread.jspa?threadID=2266443

底下這篇文章也有提到9i to 10g 應該注意的兩個參數

http://oradbatips.blogspot.tw/2007/07/tip-51-performance-issue-after-upgrade.html
SQL>
alter session set "_optimizer_cost_based_transformation" =off; (Disable subquery unnesting and view merging -- New 10g optimizer feature).

alter session set "_gby_hash_aggregation_enabled" = FALSE; (Disable Hash group by aggregation -- New 10g optimizer feature).

星期四, 12月 01, 2011

index 建立到一半 , system crash的處理方式



查詢dba_indexes ,dba_objects 都有indx_l_prenms_info記錄,
但是 dba_segments 沒有查到相應的記錄。

1。drop and recreate
2。可能需要等待每小時SMON清理IND$

10g 設定使用OMF 管理資料庫


OMF 中存放的檔案為:
1.controlfile auto backup(RMAN or SQL backup controlfile to trace)
2.RMAN backup set ==> 存放到 db_recovery_file_dest
3.archive log              ==> 存放到 db_recovery_file_dest
4.flashback logs(not archived)
--
如空間不夠,須設定加大db_recovery_file_dest_size   或者將RMAN backup redunancy 設定成少一點。

C:\>mkdir omf_datafile

C:\>mkdir omf_logfile_1

C:\>mkdir omf_logfile_2

C:\>mkdir omf_recovery_file

C:\>exit

SQL> show parameter db_create

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_create_file_dest                  string
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> alter system set db_create_file_dest='c:\omf_datafile';

已更改系統.

SQL> alter system set db_create_online_log_dest_1='c:\omf_logfile_1';

已更改系統.

SQL> alter system set db_create_online_log_dest_2='c:\omf_logfile_2';

已更改系統.

SQL> show parameter db_recovery_file_dest

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest                string      C:\oracle\product\10.2.0\flash
                                                 _recovery_area
db_recovery_file_dest_size           big integer 2G
SQL> alter system set db_recovery_file_dest='c:\omf_recovery_file';

已更改系統.

SQL> show parameter db_recovery_file_dest

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest                string      c:\omf_recovery_file
db_recovery_file_dest_size           big integer 2G
SQL>

日期常用函數 sysdate

日期常用函數 sysdate
--

http://blog.blueshop.com.tw/pili9141/articles/52486.aspx

 SYSDATE
 ◎ 可得到目前系統的時間

   ex.
     select sysdate from dual;

     sysdate
     ----------
     20-SEP-07

 常用之日期格式

 日期格式                 說明
 ------------------------------------------------------------------------
 YYYY/MM/DD          -- 年/月/日
 YYYY                      -- 年(4位)
 YYYY                      -- 年(4位)
 YYY                        -- 年(3位)
 YY                         -- 年(2位)
 MM                        -- 月份
 DD                        -- 日期
 D                          -- 星期
                             -- 星期日 = 1  星期一 = 2 星期二 = 3
                             -- 星期三 = 4  星期四 = 5 星期五 = 6 星期六 = 7

 DDD                      -- 一年之第幾天
 WW                      -- 一年之第幾週
 W                         -- 一月之第幾週
 YYYY/MM/DD HH24:MI:SS   -- 年/月/日 時(24小時制):分:秒
 YYYY/MM/DD HH:MI:SS     -- 年/月/日 時(非24小時制):分:秒
 J                           -- Julian day,Bc 4712/01/01 為1
 RR/MM/DD            -- 公元2000問題
             -- 00-49 = 下世紀;50-99 = 本世紀
 ex.
 select to_char(sysdate,'YYYY/MM/DD') FROM DUAL;             -- 2007/09/20
 select to_char(sysdate,'YYYY') FROM DUAL;                   -- 2007
 select to_char(sysdate,'YYY') FROM DUAL;                    -- 007
 select to_char(sysdate,'YY') FROM DUAL;                     -- 07
 select to_char(sysdate,'MM') FROM DUAL;                     -- 09
 select to_char(sysdate,'DD') FROM DUAL;                     -- 20
 select to_char(sysdate,'D') FROM DUAL;                      -- 5
 select to_char(sysdate,'DDD') FROM DUAL;                    -- 263
 select to_char(sysdate,'WW') FROM DUAL;                     -- 38
 select to_char(sysdate,'W') FROM DUAL;                      -- 3
 select to_char(sysdate,'YYYY/MM/DD HH24:MI:SS') FROM DUAL;  -- 2007/09/20 15:24:13
 select to_char(sysdate,'YYYY/MM/DD HH:MI:SS') FROM DUAL;    -- 2007/09/20 03:25:23
 select to_char(sysdate,'J') FROM DUAL;                      -- 2454364
 select to_char(sysdate,'RR/MM/DD') FROM DUAL;               -- 07/09/20

Oracle User profile --使用PROFILE來限制使用者資源


http://www.itpub.net/viewthread.php?tid=752785&highlight=session

可以使用PROFILE來限制使用者資源:

一、目的:
Oracle系統中的profile可以用來對使用者所能使用的資料庫資源進行限制,使用Create
Profile命令創建一個Profile,用它來實現對資料庫資源的限制使用,如果把該profile
分配給使用者,則該使用者所能使用的資料庫資源都在該profile的限制之內。

二、條件:
創建profile必須要有CREATE PROFILE的系統許可權。
為使用者指定資源限制,必須:
1.動態地使用alter system或使用初始化參數resource_limit使資源限制生效。
該改變對密碼資源無效,密碼資源總是可用。
SQL> show parameter resource_limit

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
resource_limit                       boolean     FALSE

SQL> alter system set resource_limit=true;

系統已更改。

SQL> show parameter resource_limit;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
resource_limit                       boolean     TRUE

SQL>

2.使用create profile創建一個定義對資料庫資源進行限制的profile。
3.使用create user 或alter user命令把profile分配給使用者。

三、語法:
    CREATE PROFILE profile
LIMIT { resource_parameters
        | password_parameters
        }
          [ resource_parameters
          | password_parameters
          ]... ;


{ { SESSIONS_PER_USER
| CPU_PER_SESSION
| CPU_PER_CALL
| CONNECT_TIME
| IDLE_TIME
| LOGICAL_READS_PER_SESSION
| LOGICAL_READS_PER_CALL
| COMPOSITE_LIMIT
}
{ integer | UNLIMITED | DEFAULT }
| PRIVATE_SGA
{ integer [ K | M ] | UNLIMITED | DEFAULT }
}

< password_parameters >
{ { FAILED_LOGIN_ATTEMPTS
| PASSWORD_LIFE_TIME
| PASSWORD_REUSE_TIME
| PASSWORD_REUSE_MAX
| PASSWORD_LOCK_TIME
| PASSWORD_GRACE_TIME
}
{ expr | UNLIMITED | DEFAULT }
| PASSWORD_VERIFY_FUNCTION
    { function | NULL | DEFAULT }
}

四、語法解釋:
      profile:配置檔的名稱。Oracle資料庫以以下方式強迫資源限制:
      1.如果使用者超過了connect_time或idle_time的會話資源限制,資料庫就回滾當前
      事務,並結束會話。使用者再次執行命令,資料庫則返回一個錯誤,
      2.如果使用者試圖執行超過其他的會話資源限制的操作,資料庫放棄操作,回滾當前
      事務並立即返回錯誤。使用者之後可以提交或回滾當前事務,必須結束會話。
      提示:可以將一條分成多個段,如1小時(1/24天)來限制時間,可以為使用者指定資源
      限制,但是資料庫只有在參數生效後才會執行限制。

      Unlimited:分配該profile的使用者對資源使用無限制,當使用密碼參數時,
      unlimited意味著沒有對參數加限制。

      Default:指定為default意味著忽略對profile中的一些資源限制,Default
      profile初始定義對資源不限制,可以通過alter profile命令來改變。

      Resource_parameter部分

      Session_per_user:指定限制使用者的併發會話的數目。
      Cpu_per_session:指定會話的CPU時間限制,單位為百分之一秒。
      Cpu_per_call:指定一次調用(解析、執行和提取)的CPU時間限制,單位為百分之
      一秒。
      Connect_time:指定會話的總的連接時間,以分鐘為單位。
      Idle_time:指定會話允許連續不活動的總的時間,以分鐘為單位,超過該時間,會
      話將斷開。但是長時間運行查詢和其他操作的不受此限制。
      Logical_reads_per_session:指定一個會話允許讀的資料塊的數目,包括從記憶體
      和磁片讀的所有資料塊。
      Logical_read_per_call:指定一次執行SQL(解析、執行和提取)調用所允許讀的
      資料塊的最大數目。
      Private_sga:指定一個會話(session)可以在共用池(SGA)中所允許分配的最大空間,以位
      元組為單位。(該限制只在使用共用伺服器結構時才有效,會話在SGA中的私有空間
      包括私有的SQL和PL/SQL,但不包括共用的SQL和PL/SQL)。
      Composite_limit:指定一個會話的總的資源消耗,以service units單位表示。
      Oracle資料庫以有利的方式計算cpu_per_session,connect_time,
      logical_reads_per_session和private-sga總的service units


      Password_parameter部分:

      Failed_login_attempts:指定在帳戶被鎖定之前所允許嘗試登陸的的最大次數。
      Password_life_time:指定同一密碼所允許使用的天數。如果同時指定了
      password_grace_time參數,如果在grace period內沒有改變密碼,則密碼會失效\
,連
      接資料庫被拒絕。如果沒有設置password_grace_time參數,預設值unlimited將引
      發一個資料庫警告,但是允許使用者繼續連接。

      Password_reuse_time和password_reuse_max:這兩個參數必須互相關聯設置,
      password_reuse_time指定了密碼不能重用前的天數,而password_reuse_max
      則指定了當前密碼被重用之前密碼改變的次數。兩個參數都必須被設置為整數。
      1.如果為這兩個參數指定了整數,則使用者不能重用密碼直到密碼被改變了
      password_reuse_max指定的次數以後在password_reuse_time指定的時間內。
      如:password_reuse_time=30,password_reuse_max=10,使用者可以在30天以後重用
      該密碼,要求密碼必須被改變超過10次。
      2.如果指定了其中的一個為整數,而另一個為unlimited,則使用者永遠不能重用一
      個密碼。
      3.如果指定了其中的一個為default,Oracle資料庫使用定義在profile中的預設值
     ,默認情況下,所有的參數在profile中都被設置為unlimited,如果沒有改變
      profile預設值,資料庫對該值總是默認為unlimited。
      4.如果兩個參數都設置為unlimited,則資料庫忽略他們。

      Password_lock_time:指定登陸嘗試失敗次數到達後帳戶的縮定時間,以天為單位
      。
      Password_grace_time:指定寬限天數,資料庫發出警告到登陸失效前的天數。如果
      資料庫密碼在這中間沒有被修改,則過期會失效。
      Password_verify_function:該欄位允許將複雜的PL/SQL密碼驗證腳本做為參數傳
      遞到create profile語句。Oracle資料庫提供了一個默認的腳本,但是自己可以創
      建自己的驗證規則或使用第三方軟體驗證。 對Function名稱,指定的是密碼驗證規
      則的名稱,指定為Null則意味著不使用密碼驗證功能。如果為密碼參數指定運算式
      ,則該運算式可以是任意格式,除了資料庫標量子查詢。

五、舉例:
      1.創建一個profile:
      create profile new_profile
             limit password_reuse_max 10
                    password_reuse_time 30;

      2.設置profile資源限制:
      create profile app_user limit
             sessions_per_user unlimited
             cpu_per_session unlimited
             cpu_per_call 3000
             connect_time 45 / unlimited
             idle_time unlimited
             logical_reads_per_session default
             logical_reads_per_call 1000
             private_sga 15k
             composite_limit 5000000;
             總的resource cost不超過五百萬service units。計算總的resource
             cost的公式由alter resource cost語句來指定。

      3.設置密碼限制profile:
      create profile app_users2 limit
             failed_login_attempts 5
             password_life_time 60
             password_reuse_time 60
             password_reuse_max 5
             password_verify_function verify_function
             password_lock_time 1/24
             password_grace_time 10;
             password_reuse_max 5
             password_verify_function verify_function
             password_lock_time 1/24
             password_grace_time 10;

      4.將配置檔分配給使用者:
             SQL> alter user dinya profile app_user;
使用者已更改。
SQL>

             SQL> alter user dinya profile default;
使用者已更改。

Oracle 如何檢查隱含參數 ( implicit parameter )是否生效

Oracle 9i 如何檢查隱含參數是否生效


SQL> alter system set "_log_archive_callout"='LOCAL_FIRST=TRUE' ;
system altered.
-
Verify
select ksppinm, ksppstvl
from x$ksppi pi, x$ksppcv cv
where cv.indx=pi.indx and pi.ksppinm ='_log_archive_callout';
-
另一個隱含參數:
_allow_resetlogs_corruption= true   (如果redo損毀,或在重建controlfile,到open狀態時有錯 : ORA-01194: file 1 needs more recovery to be consistent )

Oracle 10g isqlplus webDba 權限設定


作者: Ora-600(http://ora-600.itpub.net)
發表於: 2008.06.14 23:30
分類: Oracle
出處: http://ora-600.itpub.net/post/203/464380
---------------------------------------------------------------
從oracle9i開始,oracle提供了web方式的sqlplus介面,通過isqlplus,用戶可以不需要安裝任何oracle用戶端,就能夠通過流覽器方式的sqlplus進行資料操作與資料庫管理。普通的資料庫用戶可以直接通過isqlplus的網址http://ip:port/isqlplus 登入,進入該網址後會直接進入資料庫用戶登入介面,使用資料庫中的普通用戶即可登入;但如果是DBA用戶登入isqlpus,則需要首先配置isqlplus dba的用戶和口令,然後輸入網址http://ip:port/isqlplus/dba ,進入該網址後首先會彈出一個登入框,要求先輸入iSQL*Plus DBA的用戶和密碼,注意這裏不是資料庫用戶,而是isqlplus應用伺服器要求的用戶和密碼,也就是前面配置的isqlplus dba的用戶名和口令,然後才能出現isqlplus登入介面,此時可以輸入sys或者system用戶,登入資料庫進行管理。
要以DBA身份登入isqlplus,必須先配置好oc4j用戶。oc4j可以使用兩種身份認證方式:基於xml配置檔(jazn-data.xml) 或者基於LDAP(Oracle Internet Directory) 。通常採用xml配置檔認證的方式較多,這種方式使用的該配置檔位於$ORACLE_HOME/oc4j/j2ee/isqlplus/application-deployments/isqlplus/config,但是該配置檔中的密碼是加密過的,所以無法手動修改該檔,配置用戶密碼需要通過JAZN(Java AuthoriZatioN)來配置,JAZN是oracle提供的一個JASS(Java Authentication and Authorization Service)工具。
通過JAZN,可以完成以下任務:Create user / List user / Grant the webDba role / Remove users / Revoke the webDba role / Change user passwords
上述任務既可以先進入JAZN命令環境後再執行,也可以直接直接在命令行中實現。
下面是Oracle 10g上配置isqlplus dba的方法,注意unix和windows上稍有不同。
unix:
$ isqlplusctl stop
$ JAVA_HOME=$ORACLE_HOME/jdk
$ export JAVA_HOME
$ cd $ORACLE_HOME/oc4j/j2ee/isqlplus/application-deployments/isqlplus
$ $JAVA_HOME/bin/java Djava.security.properties=$ORACLE_HOME/oc4j/j2ee/home/config/jazn.security.props -jar $ORACLE_HOME/oc4j/j2ee/home/jazn.jar -user "iSQL*Plus DBA/admin" -
password welcome –shell
JAZN:> adduser "iSQL*Plus DBA" oracle oracle
JAZN:> grantrole webDba "iSQL*Plus DBA" oracle
JAZN:> exit
$ isqlplusctl start
windows:
set ORACLE_HOME=...
set JAVA_HOME=%ORACLE_HOME%/jdk
cd %ORACLE_HOME%/oc4j/j2ee/isqlplus/application-deployments/isqlplus
%JAVA_HOME%/bin/java Djava.security.properties=%ORACLE_HOME%/oc4j/j2ee/home/config/jazn.security.props -jar %ORACLE_HOME%/oc4j/j2ee/home/jazn.jar -user "iSQL*Plus DBA/admin" -
password welcome –shell

注意:
1、admin雖然是預設的管理員,但初始並沒有真正被授權
2、必須在$ORACLE_HOME/oc4j/j2ee/isqlplus/application-deployments/isqlplus目錄中執行命令,否則會出現下面的錯誤:
oracle.security.jazn.JAZNRuntimeException: Configuration file "configjazn.xml" does not exist. Check your JAAS configuration settings.
或者
Realm [iSQL*Plus DBA] does not exist in system.
3、在windows中注意目錄的書寫,不能使用'',而要像unix一樣使用'/'
4、iSQL*Plus DBA的默認管理員admin的預設密碼是 'welcome',為了安全起見,最好修改密碼
-
How to Change the iSQL*Plus Port
1)Stop the iSQL*Plus.

bash-3.00$ isqlplusctl stop
iSQL*Plus 10.2.0.1.0
Copyright (c) 2003, 2005, Oracle. All rights reserved.
iSQL*Plus instance on port 5560 is not running ...

2)Take a backup of the files,

$ORACLE_HOME/host_sid/sysman/config/emoms.properties
$ORACLE_HOME/oc4j/j2ee/isqlplus/config/http-web-site.xml

3)Modify the following parameters in the file $ORACLE_HOME/host_sid/sysman/config/emoms.properties

In my computer hostname is neptune and database is data1, so I edited,/oracle/app/oracle/product/10.2.0/db_1/neptune_data1/sysman/config/emoms.properties

oracle.sysman.db.isqlplusUrl=http\://host.domain\:5561/isqlplus/dynamic
oracle.sysman.db.isqlplusWebDBAUrl=http\://host.domain\:5561/isqlplus/

And,
/oracle/app/oracle/product/10.2.0/db_1/oc4j/j2ee/isqlplus/config/http-web-site.xml

4)Start the iSql*Plus server.

bash-3.00$ isqlplusctl start
And enter new post number to your browser like,
http://neptune:5561/isqlplus/

--
revokerole webDba "iSQL*Plus DBA" oracle
remuser "iSQL*Plus DBA" oracle
etpasswd "iSQL*Plus DBA" oracle passold passnew

Oracle log_buffer parameter

Oracle performance consideration(10g) b14211.pdf
-

Log Buffer Statistics
SELECT NAME, VALUE
FROM V$SYSSTAT
WHERE NAME = 'redo buffer allocation retries';
應該接近0 ,太大表示正在checkpoint or log buffer 太小。
initialization parameter LOG_BUFFER.

system event waited
select event  , time_waited from v$system_event  where rownum < 11 order by time_waited desc ;

將tablespace 從data dictionary mgt. --> local extent mgt(bitmap)


前言.
從8i 舊版本,SYSTEM tablespace的資訊檢索為dictionary based tablespace. 此存取方式有點類似B tree的方法. 但如果從8i 升到9i以上,可執行指令將其升為bitmap based tablespace(local managed) , 此資料型態讓檢索只需要查詢一次,故效率較好(如果為bitmap , 效率為Log N )

-
Oracle 10g administration guide
b14231.pdf  (p.226)
Oracle 9i administration guide
a96521.pdf  (p.354)
-
Migrating from a Dictionary-Managed to a Locally Managed Tablespace

Migrating the SYSTEM Tablespace to a Locally Managed Tablespace
SQL> EXECUTE DBMS_SPACE_ADMIN.TABLESPACE_MIGRATE_TO_LOCAL('SYSTEM');
Before performing the migration the following conditions must be met:
■ The database has a default temporary tablespace that is not SYSTEM.
■ There are no rollback segments in the dictionary-managed tablespace.
■ There is at least one online rollback segment in a locally managed tablespace, or if
using automatic undo management, an undo tablespace is online.
■ All tablespaces other than the tablespace containing the undo space (that is, the
tablespace containing the rollback segment or the undo tablespace) are in
read-only mode.
Transporting Tablespaces Between Databases
Managing Tablespaces 8-25
■ The system is in restricted mode.
■ There is a cold backup of the database.

-
所有非system 的tablespace 須先轉為local mgt. 最後再將system 轉為local mgt.
否則在system 轉為local  mgt.後,其他dictionary mgt. tablespace 永遠只能停在read only mode.

Note: ''After the SYSTEM tablespace is migrated to locally managed, any dictionary-managed tablespaces in the database cannot be made read/write''. If you want to be able to use the dictionary-managed tablespaces in read/write mode, then Oracle recommends that you first migrate these tablespaces to locally managed before migrating the SYSTEM tablespace.

Oracle 10g RMAN incremental backup的增強


若在Oracle 10g中,可enable block change tracking方式,做漸進式備份的時候,不需去scan level 0 or level 1 的backup set,如果有用OMF來管理,則block change記錄在db_create_file_dest,加速incremental backup 速度(process為CTWR)。
SQL>
alter system set db_create_file_dest='/home/oracle/';
alter database enable block change tracking;
or
SQL> ALTER DATABASE ENABLE BLOCK CHANGE TRACKING USING FILE '/mydir/rman_change_track.f' REUSE;


Verify:
SQL>
select * from v$block_change_tracking;
STATUS FILENAME BYTES
———- ————————————————– ———-
ENABLED /home/oracle/change.trc 11599872

10g Rac的cluster_interconnect信息


http://www.eygle.com/archives/2007/12/10g_rac_cluster_interconnect.html
-
rac會自動找private ip 去溝通

[轉載 + 心得] Oracle 9i , 10g , 11g load balance

Oracle 9i , 10g , 11g load balance
--
Ref : http://space.itpub.net/35489/viewspace-600653
-
在Oracle9i,10g,11g版本中都適用的LB配置分為以下兩種。
(1) Client Side Connect Time Load Balance
(2) Server SideListenerConnection Load Balance (此處的Listener用以跟10g之後的Server Side Service Load Balance區分開)  關於10g之後的設定則看[[Oracle 10g rac workload balancing]]
1. Client Side Connect Time Load Balance
既然是Client端的LB,那麼也就是不需要在資料庫伺服器端配置任何參數,完全由用戶端機器上的tnsnames.ora檔中對於TNS的配置來決定,實際上也就是LOAD_BALANCE參數。
看一個例子,下面這樣的TNS配置就是啟用了用戶端的LB。
CLIENT_LOADBALANCE =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = node1-vip)(PORT = 1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = node2-vip)(PORT = 1521))
      (LOAD_BALANCE = yes)
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = rac_lb)
    )
  )
(LOAD_BALANCE = yes)指示SQLNet隨機選擇ADDRESS_LIST列表中的任意一個監聽,將用戶端請求發送到此監聽上,通過這種方法來實現負載平衡。如果(LOAD_BALANCE = no)那麼將會按照ADDRESS_LIST列表中的順序選擇監聽,只要這個監聽能夠正常連接那麼就使用該監聽。
因此在某些負載平衡的解決方案中會使用(LOAD_BALANCE = no)但是在多個用戶端或者應用伺服器端配置順序不同的ADDRESS_LIST,以此來實現人為的負載平衡。
如果在TNS配置時使用的是ADDRESS_LIST語法,那麼必須顯示設置LOAD_BALANCE = yes,預設值LOAD_BALANCE = no。
2. Server Side Listener Connection Load Balance
要實現server side load balance要求監聽能夠知道在整個RAC環境中的各節點負載情況,節點負載情況是由PMON進程來定期更新的,而要讓PMON進程能夠通知其他節點自己節點的負載情況則需要設置資料庫初始化參數REMOTE_LISTENER。
在RAC資料庫伺服器端的每個節點上的tnsnames.ora檔中設置如下的TNS名稱。
LISTENERS_RAC =
(DESCRIPTION =
 (ADDRESS_LIST =
  (ADDRESS = (PROTOCOL = TCP)(HOST=node1-vip)(PORT = 1521))
  (ADDRESS = (PROTOCOL = TCP)(HOST=node2-vip)(PORT = 1521))
 )
)
然後設置REMOTE_LISTENER參數值為LISTENERS_RAC
sql>ALTER system SET REMOTE_LISTENER='LISTENERS_RAC' scope=BOTH;
當某個實例的監聽收到用戶端連接請求,將會統籌考慮RAC環境中各個節點的負載情況,然後將該連接傳遞到具有最小負載的節點的最小負載實例上。
在10gR2版本之後,節點和實例的負載計算通過lbscore來完成,而lbscore則由兩個動態值決定:”goodness” 和 “delta”,這兩個值均由PMON來定期更新,計算公式如下:
Lbscore = Goodness (Received from PMON update)
Delta = New Delta (Received from PMON update)
在PMON定期更新的間隔,如果有新連接進入,那麼lbscore的計算公式是:
Lbscore = Lbscore(previous) + Listener Delta
可以通過添加監聽的trace(TRACE_LEVEL_LISTENER = 16)來獲取lbscore的產生情況,更詳細的文檔請參看Metalink Note: 263599.1。
關於Failover,多說一句,其實Failover也有兩種,一種是Connect Time Failover,由用戶端TNS配置的(failover=on)參數控制,另外一種是TAF,由用戶端TNS配置中的failover_mode參數控制。

--
10g的connection load balancing可參考[[Oracle 9i , 10g , 11g load balance]] (B28759)''Oracle® Database
2 Day + Real Application Clusters Guide 10g Release 2 (10.2)''
-
Server load  balancing
(p.103)Workload balancing 可以選用兩種
1.Service Time-所有連線加總時間,如較少則分給該Node
2.Throughput - 根據消耗的CPU time,
OEM->[Maintenance]->[Services]
設定[Enable Load Banancing Advisory]: 選擇 Service TimeThroughput

Client load balancing : 在tnsnames.ora中/ AP端的Connection String定義

--For 10g RAC tests
經過實測後 發現 就算關閉Client load balance (LOAD_BALANCE = no) , (FAILOVER=yes) 後, 為何還是會隨機連到 RAC nodes
==> 須關閉Server load balance
==> unset remote listener parameter

--For 11g RAC test
remote_listener 是註冊到scan-listener , 所以預設也是會有server load balance....
ex : remote_listener string myrac-cluster-scan:1521

2015.12.3.update
failover預設值為yes
(failover=on) is default for ADDRESS_LISTs, DESCRIPTION_LISTs, and a set of  DESCRIPTIONs., therefore, you do not have to specify it explicitly. 

disk_asynch_io & db_writer_process


disk_asynch_io 預設為true
但若OS不支援,也就無AIO 功效, 此時可設定多個db_writter_process模擬aio,數量為CPU的兩倍

-
db_writer_process 設定需考量CPU count , 通常跟CPU count數量一致.

DML 原理-Stages in Processing DML Statements


http://www.lslnet.com/linux/dosc1/47/linux-327395.htm
-
1.在做commit 時,交易只會寫入redo log ,但不會寫到datafile 去

2.在commit 同時,table/row lock 會被釋放,rollback segment lock 也會被釋放

3.datafile 寫入時機 : 在checkpoint 產生時,才會將已更動的block(dirty block)
寫回到datafile 去

4.在任何insert/update/delete的DML動作後,資料庫的SCN number 都會一直增加。
-
Stages in Processing DML Statements
At this point, meet yet another “behind-the-scenes” player in Oracle
transaction processing—the rollback segment. The rollback segment is a
database object in Oracle that stores old versions of data being changed by
DML statements issued by the user process. Rollback segments only store the
old values, not the new values—the new values are stored in the object
itself.

With this in mind, return to the processing of DML statements. There are
several differences between how Oracle processes select statements and how it
processes DML statements such as update, insert, and delete. Though the
operations involved in executing DML statements fall into the same general
pattern as those for select statements shown in Figure 6-2, the specific flow
of operation in processing DML statements is as follows:

1.Parse statement
The RDBMS creates a parse tree, or execution plan, for the statement and
places it in the library cache. This is a list of operations the RDBMS uses
to process the data change. If a parse tree already exists for this
statement, the RDBMS can omit this step.

2.Execute statement
The RDBMS performs all processing to execute the DML statement. For update or
delete statements, the server process will retrieve the data from disk into
the buffer cache, implicitly acquire a lock on the data to be changed, and
then make the specified data change in the buffer cache. A lock is an Oracle
internal resource that one user process acquires before updating or deleting
existing data to prevent other users from doing the same thing. For insert
statements, the server process will retrieve a block from disk that has
enough space available to house the new row of data, and will place that new

row into the block. Also, part of executing the DML statement is writing the
old and new versions of the data to the rollback segment acquired for that
transaction. A lock must be acquired on the rollback segment to write changes
to a rollback segment as well.

3.Generate redo information
Recall from the prior lesson that the redo log buffer stores redo or data
change information produced as the result of DML operations running in user
sessions. After issuing DML statements, the user process must write a redo
entry to the redo log buffer. In this way, Oracle can recover a data change
if damage is later done to the disk files containing Oracle data.

Stages in Processing COMMIT Statements
As discussed in Unit I, issuing a commit statement ends the current
transaction by making permanent any data change the user process may have
issued to the Oracle database. A rollback statement discards the data change
in favor of how the data appeared before the change was made. The rollback
segment is how Oracle manages to offer this functionality. By keeping a copy
of the old data in the rollback segment for the duration of the transaction,
Oracle is able to discard any change made by the transaction until the commit
statement is issued.

Before proceeding any further, make sure you understand the following
important point—issuing commit has no effect on when Oracle copies that data
change in the buffer cache to disk. Thus, a commit statement does not somehow
trigger DBWR activity. Only a checkpoint, a timeout, or a need for room in
the buffer cache for blocks requested by users will make DBWR write dirty
blocks to disk. With that fact in mind, what exactly does processing a commit
statement consist of? The following list tells all:

-Release table/row locks acquired by transaction
All row locks (or even table locks, if any were acquired) are released by
issuing commit statements. Other users can then modify the rows (or tables)
previously locked by this user.

-Release rollback segment locks acquired by transaction
Changes to rollback segments are subject to the same locking mechanisms as
other objects. Once the change is committed, the space to hold both old and
new versions of data for that transaction in the rollback segment is
available for another user’s transaction.

-Generate redo for committed transaction
Once the commit takes place, a redo entry is generated by the user process
stating that all the changes associated with that transaction have now been
committed by the user.

Note that Oracle takes no special action related to redo information as the
result of that commit, other than to indicate that the transaction has been
committed. How does Oracle know which DML statement redo entries to associate
with each transaction? The answer is the system change numbers (SCNs).

An SCN is an ID that Oracle generates for each and every transaction that a
user process engages.
Every redo entry for every data change lists the change made and the SCN the
change is associated with. The redo entry for the commit also identifies the
SCN and simply notes that this SCN has been committed.
Thus, Oracle can keep easy track of the status of every transaction via the SCN.

User 在RAC環境可能會遇到之AP 連線設定問題

User 在RAC環境可能會遇到之AP 連線設定問題

敘述:  以jdbc去連會發生,連到第一個node成功,但重連時連到第二個node會失敗: 出現JDBC connection Failure : Network Adapter Could not establish connection 訊息。

1.  在jdbc connection string 中 要確定   (SERVER = DEDICATED) 模式去連,因server 如果為shared server,須在client端指定AP連線為dedicated方式,connection request     才不會有資源切換共享。

2.在/etc/hosts沒有設定好hostsnames/ip ,使得listener 無法把connection request 導到該主機去。

3.DB端有設定防火牆,且沒開放1521 port
(以redhat4 ES為例)
vi /etc/sysconfig/iptables



"""-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited"""

改為

"""-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 1520:1523 -j ACCEPT"""
允許1520到1523的port

[root@localhost ~]# service iptables restart
Flushing firewall rules:                                   [  OK  ]
Setting chains to policy ACCEPT: filter                    [  OK  ]
Unloading iptables modules:                                [  OK  ]
Applying iptables firewall rules:                          [  OK  ]

4.亦或是listener 沒有啟動..
$lsnrctl start


Ref:
Oracle jdbc Frequently Asked Questions
http://www.oracle.com/technology/deploy/availability/htdocs/9ifaq.html#A20

139775.1
JDBC Connection Failure Network Adapter Could not Establish Connection

Oracle import 心得

imp error _其中某些index無法成功import


. . importing table    "WP_SUB_XXX"    7609037 rows imported

IMP-00017: following statement failed with ORACLE error 1658:

 "CREATE INDEX "WP_SUB_PICT_PIC_IDX" ON "WP_SUB_PAID_INFO_CODE_TBL" ("PAID_IN"

 "FO_CODE" )  PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE(INITIAL 346161152 NE"

 "XT 131072 MINEXTENTS 1 MAXEXTENTS 8192 PCTINCREASE 0 FREELISTS 1 FREELIST G"

 "ROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "INDX" LOGGING"

IMP-00003: ORACLE error 1658 encountered

ORA-01658: unable to create INITIAL extent for segment in tablespace INDX

IMP-00017: following statement failed with ORACLE error 20000:

 "BEGIN  DBMS_STATS.SET_INDEX_STATS(NULL,'"WP_SUB_PICT_PIC_IDX"',NULL,NULL,NU"

 "LL,5915993.14285714,37008,78,474,2,724299,2,0); END;"

IMP-00003: ORACLE error 20000 encountered

''ORA-20000: Unable to set values for index WP_SUB_PICT_PIC_IDX: does not exist or insufficient privileges''

ORA-06512: at "SYS.DBMS_STATS", line 3718

ORA-06512: at "SYS.DBMS_STATS", line 3823

ORA-06512: at line 1




-
1.要確定target 資料庫裡面 user 是否有create index 的權限  (grant resource to bvuser;)

2.或是User 在tablespace 裡面有無quota?  (grant unlimited tablespace to user; )

3.或有可能遇到tablespace datafile大小達到上限
ex:
8k block size , 單一 datafile size : 32GB

4.當初建index 的時候是用特定USER連到資料庫建的,所以匯入時,DDL 中不會顯示出index owner,而造成misleading....
例如create index INDEX_NAME on... 要改成 create index USER_NAME.INDEX_NAME...

[Example] tnsnames.ora for 9i/10g/11g RAC, DataGuard

orcl =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.11.158)(PORT = 1521))
    )
    (CONNECT_DATA = (SID = orcl))
  )

-
For Oracle RAC  Failover:
請在一台有安裝Oracle Client軟體上,修改tnsnames.ora設定檔,加入以下

orcl =
 (DESCRIPTION =
 (ADDRESS_LIST =
 (ADDRESS = (PROTOCOL = TCP)(HOST = rac1pub)(PORT = 1521))
 (ADDRESS = (PROTOCOL = TCP)(HOST = rac2pub)(PORT = 1521))
)
 (CONNECT_DATA =
 (SERVICE_NAME = orcl)
 (failover_mode=(type=select)(method=basic))
)
 (LOAD_BALANCE=ON)
 (FAILOVER=ON)
)

For Oracle DataGuard :
---------------------------------------------------------

TAFTEST=
   (DESCRIPTION=
      (LOAD_BALANCE=ON)
      (FAILOVER=ON)
      (ADDRESS=
         (PROTOCOL=tcp)(HOST=orcl)(PORT=1521))
      (ADDRESS=
         (PROTOCOL=tcp)(HOST=orclstdby)(PORT=1521))
      (CONNECT_DATA=
         (SERVICE_NAME=orcl)
         (FAILOVER_MODE=
            (TYPE=select)
            (METHOD=basic)
         )
      )
   )

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

sql> select instance_name from v$instance(利用sql plus工具)
(得知目前連到那一台Instance上,假設為orcl2的話,故意將orcl2的Instance關閉,並且再執行一次,您會發現已變更為orcl1,證實已經自動進行 Failover)
-
Configure TAF failover on Oracle 9i rac Oracle9i Real Application Clusters Setup and Configuration 9.2 a96600(p.160) tnsnames.ora
db.us.acme.com=
 (description=
  (address=
        (protocol=tcp)
        (host=db1-server)
        (port=1521))
  (address=
        (protocol=tcp)
        (host=db2-server)
        (port=1521))
   (connect_data=
     (service_name=db.us.acme.com)
        (failover_mode=
        (type=select)
        (method=basic)
        (retries=20)
        (delay=15))))

-
note
Oracle9i Database Migration Release 2 (9.2) (a96530.pdf)(p.240)
file:///D:\Oracle_docs\9i_B10501_01\server.920\a96530.pdf
Replace the SID parameter with the SERVICE_NAME parameter to connect to a release 8.1 or higher service, as in the following example.

sales=
(DESCRIPTION=
  (ADDRESS=(PROTOCOL=tcp)(HOST=sales-server)(PORT=1521))
  (CONNECT_DATA=
     (SERVICE_NAME=sales.us.acme.com)))

LinkWithin-相關文件

Related Posts Plugin for WordPress, Blogger...