2009年7月27日 星期一

Oracle 9i for Windows Platform 32bit 解決Memory-SGA 最多有1.7G限制的設定(AWE)

環境 : Windows 2003 Enterprise Edition SP2 (32bit Windows platform)
使用windows cluster機制& Oracle Failsafe實現oracle instance cluster。
Oracle: Oracle Enterprise Edition 9i (9.2.0.1 patch to 9208)
Memory: 8G RAM


由於Oracle on 32-bit Windows platforms,限制預設使用的SGA設定最多不能2G(實作上1.6G),而metalink上有解決方法,在此提出並將實作結果記錄下來:

Metalink doc:

Subject: Implementing Address Windowing Extensions (AWE) or VLM on Windows Platforms
Doc Id: 225349.1


設置的方式有2,稱之為"PAE" (Physical Address Extensions) 或"AWE" (Address Windowing Extensions) 這兩種方式可以交替使用。
而AWE的設定前提條件: Physical RAM在4G以上。
可使用的平台有
* Windows 2000 Datacenter Server
* Windows 2000 Advanced Server
* Windows 2003 Data Center Edition (32-Bit)
* Windows 2003 Enterprise Edition (32-Bit)
在以上的OS 平台,AWE可內嵌設定於OS層,因此不需要特別指定driver去驅動,就可使用多餘的memory。
而不能使用的平台有:
* Windows 2000 Server (Standard)
* Windows 2000 Professional
* Windows XP Home Edition
* Windows XP Professional
* Windows 2003 Standard Edition
* Windows 2003 Web Edition

ps: 64bit的windows platform 不需要AWE的設定,因為64bit-Windows platforms上,單一process最高可使用到8 TeraBytes的memory。

AWE in 32Bit RDMS release 版本為:
* Oracle 8.1.6.x
* Oracle 8.1.7.x
* Oracle 9.2.x
* Oracle 10.1.x
* Oracle 10.2.x
ps: Oracle does NOT implement AWE support in release 9.0.1.x
而且只限制Enterprise Edition and Standard Edition 才可生效!

##設定步驟##
1. OS level:
  • C:\boot.ini 修改內容:
[operating systems]multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Windows Server 2003, Enterprise" /3GB /PAE /noexecute=optout /fastdetect
"/3GB" 及"/PAE"同時設定的話,則Address space for ORACLE.exe會是3G,且要注意主機RAM是否最多到16G,若超過的話~則建議只使用一種即可。
  • 確認user的系統權限

在服務中設定的oracle SID 登入身份必需要被授與" Lock Page in Memory"的系統權限,一般oracle SID service登入身份會是" LocalSystem" account,請確認LocalSystem的帳號擁有此系統權限。

設定方式: 開始\控制台\系統管理工具\本機安全性原則-->選擇--> "本機原則\使用者權利指派\鎖定記憶體分頁",

在本機安全性設定新增使用者或群組,並加入該使用者。這個設定是為了保留process的實際記憶體分頁,阻止系統將資料分頁至virtual虛擬記憶體中,這種方式會減少實際記憶體的可使用量。設定後記得重啟service。

  • 基碼修改(新增: AWE_WINDOW_MEMORY)

在HKLM\Software\Oracle\HomeX 新增一個基碼(reg_sz格式),計算單位為bytes,default為1g,因此新增值 AWE_WINDOW_MEMORY=1073741824

2. Database/Instance level:

  • init.ora

Add [ USE_INDIRECT_DATA_BUFFERS=TRUE ]
Add [DB_BLOCK_BUFFERS= /8192(db_block_size)]

注意: 若DB_CACHE_SIZE與USE_INDIRECT_DATA_BUFFERS=TRUE 同時存在時,會出現ORA-00385: cannot enable Very Large Memory with new buffer cache 的錯誤發生。

因此只要設置DB_BLOCK_BUFFERS,移除DB_CACHE_SIZE的參數即可。其實buffer cache size的大小設定還要保留4G 的RAM下來給os或其它應用程式使用,因此可算出buffer cache最多可設定的值為多少。

舉例說明: 8G RAM,use Default value of 1G for AWE_WINDOW_MEMORY,buffer cache最多可以設至的公式

Max Buffer cache (Total Ram-4G + AWE_WINDOW_MEMORY) =8G-4G+1G=5G

而db block size=8192 ,則db_block_buffers的設定最大值為5G/8192 =5368709120/8192=655360

3. 重新啟動instance。

##完成設定##

總SGA size= ((db_block_buffers*buffer size ) + (shared_pool_size+large_pool_size +java_pool_size+log_buffers) +1MB

SGA +oracle 臨界值不能超過可用的虛擬記憶體,因為虛擬記憶體要計算buffer cache=db_block_buffer*db_block_size得出值。

註: 「監控mapping memory狀態」

可使用下列sql:select * from v$sysstat where statistic# in (154, 155);

10gr2: select statistic#, name from v$sysstat where name like '%map %';

若在10g要設定USER_INDIRECT_DATA_BUFFER,也就是使用AWE,則INIT.ORA不能使用SGA_TARGET的參數,SGA_TARGET=0。

2009年6月5日 星期五

ORA-12638 身份證明檢索失敗-解決原因與方法

今天在裝ap server時,遇到sqlplus id/pass@SID時出現 ORA-12638 身份證明檢索失敗的error。

後來在客戶端沒有外網,也沒遇這樣的問題~call friend幫忙查一下,將

Sqlnet.Authentication_Services=(NTS) 改為Sqlnet.Authentication_Services=(NONE)

就可以正常連線了!



後來查了一下官方的文件

SQLNET.AUTHENTICATION_SERVICES
Purpose


Use the parameter SQLNET.AUTHENTICATION_SERVICES to enable one or more authentication services. If authentication has been installed, it is recommended that this parameter be set to either none or to one of the authentication methods.
.Default
.None
.Values
Authentication Methods Available with Oracle Net Services:
none -- for no authentication methods. A valid username and password can be used to access the database.
all -- for all authentication methods
nts -- for Windows NT native authentication


Authentication Methods Available with Oracle Advanced Security:
kerberos5 for Kerberos authentication
cybersafe for Cybersafe authentication
radius for RADIUS authentication
dcegssapi for DCE GSSAPI authentication

See Also:
Oracle Advanced Security Administrator's Guide



表示這是一種認證方式,如果是NTS就是用windows的認證模式,表示登入sysdba時,不需要輸入帳號密碼即可登入,若對於Oracle on windows cluster來說,使用的一組virtual IP 本來就不能使用windows認證方式進入database,故解決辦法就是改為none(表示只要在oracle資料庫的使用者、密碼對了~就可以登入了)

要注意一件事!!這個設定只適合在AP Client端作設定,如果在DB server端作此設定的話,會造成"conn / as sysdba" 匿名登入時會失效!

2009年5月15日 星期五

Auto create ORA_DBA group on Windows when install Oracle Database.

居然是由同事告訴我一件oracle 權限大事!

原來是oracle會在Windows 環境上安裝時自動於系統內建立 「ORA_DBA」 group,
administrator也加入此群組中,
看到系統說明,這個群組是要讓本機的administrator登入者,可以利用 sqlplus "/ as sysdba"
登入sysdba角色而不需要帶任何password!



以下是在網址上找到的相關說明!
好詳細哦~

2009-06-30補充說明: 讓本機使用者可以利用匿名(windows帳戶認證)方式進入,還要多一項配合,在TNS_ADMIN\sqlnet.ora "authentication_service=(NTS)"才可以哦!若改為none則不行!
http://www.windowsitpro.com/Article/ArticleID/42280/42280.html?Ad=1 Database Server Windows Group Authentication When you install Oracle on a Windows server, the system creates an ORA_DBA Windows group and automatically adds to that group the Windows account used to install Oracle. The DBA can then add to the group other Windows users who need full Oracle DBA privileges. But be careful—Windows local and domain users within the ORA_DBA group don't have to supply an Oracle username and password. As the Description property for the ORA_DBA group says, Members can connect to the Oracle database as a DBA without a password. For Oracle to accept users in the ORA_DBA group as authenticated users, you need to properly configure the sqlnet.ora file, which Figure 1 shows. For Oracle9i and Oracle8i, this file is in the \%ORACLE_HOME%\network\admin folder, where %ORACLE_HOME% represents the path used to install the Oracle server software. The sqlnet.ora file lets you configure how connections to the Oracle server will be made. The NAMES.DIRECTORY_PATH parameter in the sqlnet.ora file specifies the methods that Oracle clients use to resolve the database connection string name alias. For example, when I type at the command line sqlplus /@test9 the SQL*Plus utility attempts to resolve the test9 alias by using the NAMES.DIRECTORY_PATH entries in the sqlnet.ora file. (For a description of the SQL*Plus tool and information about obtaining the tool, see the "Manipulate Oracle with SQL*Plus" sidebar.) In the sample sqlnet.ora file that Figure 1 shows, the client first attempts Oracle name resolution by using a tnsnames.ora text file, which can reside either locally or on a shared network resource. If the tnsnames.ora file doesn't contain the name, the client will attempt to resolve the name by using an Oracle Names server (Oracle now recommends using Lightweight Directory Access Protocol—LDAP—instead of Oracle Names servers). Finally, the client tries to resolve the name by using a host-name resolution method such as DNS or Network Information Service (NIS). The SQLNET.AUTHENTICATION_SERVICES parameter in the sqlnet.ora file specifies which authentication service Oracle should use when a user attempts to connect to the Oracle server. By default, Oracle9i and Oracle8i enable Windows authentication by means of the following setting: SQLNET.AUTHENTICATION_SERVICES=(NTS) Windows NT always uses NT LAN Manager (NTLM) authentication. Windows Server 2003, Windows XP, and Windows 2000 all use Kerberos authentication when the Oracle client machine is in a Windows 2003 or Win2K domain; otherwise, they use NTLM authentication. The default setting of enforcing Windows authentication isn't compatible with applications that use standard Oracle authentication. And many third-party vendors have applications that use standard Oracle usernames and passwords to connect to Oracle. To support both Oracle and Windows authentication, you can change the authentication service parameter in the server's sqlnet.ora file as follows: SQLNET.AUTHENTICATION_SERVICES= (NONE,NTS) Any changes that you make to the authentication methods can result in connection failures. To detect any such failures, whenever you change the authentication service parameter, use SQL*Plus first to perform basic connectivity testing, then test your Oracle client applications. Because the ORA_DBA group is a Windows group, the Oracle database server uses it only when SQLNET.AUTHENTICATION_SERVICES is using Windows authentication. For example, if Windows authentication is enabled and I go to the command line and type set oracle_sid=test9 sqlplus "/ as sysdba" I can create a SYSDBA privileged connection without supplying an Oracle username and password. The ORACLE_SID value shown in our example in the first command line (i.e., test9) identifies the database connection string alias for sqlplus.exe to use to connect to an Oracle database instance. The second command line specifies the authentication credentials. Double quotes are required for SQL*Plus to interpret the entire connect string, including the spaces, as one command-line parameter. The syntax "\ as sysdba" specifies that the client would like to connect to the Oracle database as the currently logged on Windows user with SYSDBA privileges. Upon entering both commands on my Oracle client machine, the system returned the results that Figure 2 shows. If an Oracle username and password are supplied to SQL*Plus when connecting as SYSDBA, SQL*Plus ignores them. This action isn't a security breach because the Oracle server has authenticated the Windows credentials and not the Oracle credentials.

2009年3月25日 星期三

使用Merge Into 语句实现 Insert/Update - Digest Net

EYGLE上面真的好多寶文章!!

使用MERGE INTO 的SQL 語法完成一些資料比對的處理!
應該會是個好方法~但是對於ROW LOCK是否有影響~還要評估一下~分享:)
使用Merge Into 语句实现 Insert/Update - Digest Net

Merge用法:Oracle 10g中对Merge语句的增强 - Digest Net

從EYGLE網誌查到的一個新語法~~可以試試~

Merge用法:Oracle 10g中对Merge语句的增强 - Digest Net

資料匹配或許會很方便~

Merge用法:Oracle 10g中对Merge语句的增强 - Digest Net

從EYGLE網誌查到的一個新語法~~可以試試~

Merge用法:Oracle 10g中对Merge语句的增强 - Digest Net

資料匹配或許會很方便~

2009年3月17日 星期二

MS SQL Server 如何取sysdate

若建立table,
oracle 寫法
-取日期yymmdd則使用 to_char (sysdate,'YYYYMMDD')
-取時間hh24miss則使用to_char(sysdate,'HH24MISS')

MS SQL Server中文版的預設日期datetime格式是yyyy-mm-dd hh:mm:ss.mmm
sql server寫法上非常不同
-取日期yymmdd,使用 CONVERT(VARCHAR(8), GETDATE(), 112)
-取時間yymmdd,使用REPLACE(CONVERT(VARCHAR(8), GETDATE(), 108), ':', '')
取時間的時候需要多作一次轉換,將":"的地方去除。

另外~convert參數中的112、108,sql server在轉換日期格式時,所代表的編號。
附上Online book上描述的convert 格式編號:

url= http://msdn.microsoft.com/zh-tw/library/ms174450(SQL.90).aspx

一般來說,沒有標示世紀的話~就以yy為主,例如yymmdd的格式編號就是12,
但若要標示世紀的話,就要將12+100,要使用112的編號才能顯示 yyyymmdd。