2014年3月20日 星期四

[ZFS] 效能調校觀念 (ZIL、ARC、L2ARC)

要調校 ZFS storage 的效能,首先必須知道的就是 ZIL、ARC、L2ARC 這三個重要的機制,以下說明一下這三個機制的特性:

ZIL

因為 ZFS 在寫入的特性是 copy-on-write,因此若是要將 storage 用在大量 sync write 的情境下(例如:ESXi over NFS),要在大量的 IO 下兼顧效率與穩定性,SLC SSD 將會是較好的選擇。
且因為 ZIL 不需要太大容量,因此選擇小容量且高速的 SLC SSD 可以在大量 sync write 的情況下提升不少效能(國外論壇推薦 ZeusRAM)。
【重要】ZIL 要儘量選用耐用的裝置(或是不要設定 ZIL),因為 ZIL 掛掉可能也會造成 zpool 的損毀。(這問題在 ZFS v28 之後似乎已經解決,可參考此討論串)

ARC (Adaptive Replacement Cache)

ARC 是存在於記憶體中的超快速暫存區,大小約為系統總記憶體容量減去 1GB,假設系統共安裝了 32GB 的記憶體,ARC 的容量約為 31(32 - 1)GB。
這表示若是安裝了 32 GB 的記憶體在 server 上,ZFS system 則會使用約 31GB 作為 ARC 暫存讀取資料用。
想當然爾,系統記憶體越大,ARC 空間自然就越大,read performance 自然就會提升。

L2ARC (Second Level Adaptive Replacement Cache)

由於 RAM 價格的關係,ARC 的容量無法無限制的提升,因此 L2ARC 就被用來做為第二部份的 read cache 之用,因此適合使用速度快且符合經濟效益的裝置,以目前的狀況來說 SSD 是最佳選擇。(雖然速度比記憶體慢,但卻比一般硬碟快上許多)
由於此區掛了不會讓 zpool 中的資料損毀,選擇大容量且速度快的 MLC SSD 就可以了,建議容量是 ARC 容量(假設 31GB RAM)的 5 倍以下(150GB SSD),因為 L2ARC 的資料還是需要存放 index 資訊於 ARC 中,所以 L2ARC 容量過大也不會有太顯著的效果,當然選企業級的 SSD 穩定性肯定是更好,推薦 Intel DC S3500/S3700 系列(容量越大速度越快......)。
若是上述例子,做成 80GB SSD striped,效能應該會比單顆 160GB 更好。

ARC + L2ARC = 減少硬碟實際存取次數

當 ZFS 收到  read request 時,會做以下動作:
  1. 到 ARC 尋找資料,找到則 response
  2. ARC 沒有資料,到 L2ARC 尋找資料,找到則 response
  3. ARC 與 L2ARC 都沒有,到 Hard Disk 尋找資料,找到則 response
因此可以得知,若是 ARC & L2ARC 可以 cache 越多常用資料,容量大但速度慢的硬碟存取資料機會相對就會少了許多,資料大多都從 memory & SSD 回傳,自然可以大幅提升 ZFS 的讀取效能。

其他注意事項

  1. 在 ZFS layout 設定中,選擇兩個裝置 for ZIL,ZFS 會將其視為 miror,但 L2ARC 則不會視為 mirror。(實際上也真的不需要....)
  2. L2ARC 可以選用便宜的 MLC SSD,但 ZIL 最好選用 SLC SSD,因為 SLC SSD 較耐用且穩定(速度沒比較快)。
  3. 若是要打造全 SSD 的 ZFS filesystem,L2ARC 也就不需要了.....
  4. 若是要將 ZFS 用於虛擬化環境中,透過 template 產生大量 VM,讓每個 VM 擁有許多共同的資料;在存取時就會被視為常用資料存於 ARC or L2ARC 中,如此一來讀取效率可大幅提升。

參考資料

2013年10月13日 星期日

[Azure] 障礙排除筆記



Q1:從其他資料庫將資料匯入到 Windows Azure SQL Database 時(或是直接新增資料時),出現以下訊息:

Tables without a clustered index are not supported in this version of SQL Server. Please create a clustered index and try again
Ans:Windows Azure SQL Database 規定每個 table 都必須要有一個 clustered index,才可以進行資料的編輯。
新增 Clustered Index 的語法如下:
CREATE UNIQUE CLUSTERED INDEX [index name] ON [Schema Name].[Table Name]([Column Name 1], [Column Name 2], .... etc);

Q2:如何將 Visual Studio、Team Foundation Service、Windows Azure 整合在一起?

Ans:這使用到 Continuous Integration(持續整合) 的技術,請參考此篇文章 => Continuous delivery with Team Foundation Service in Windows Azure

Q3:在專案中加入 Entity Framework 後,在本機測試正常,但佈署到 Windows Azure 卻出現以下訊息:

Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
Ans:將專案中的所有參考,在屬性頁中都設定為"複製到本機(Copy To Local)"即可


Q4:在本機中存取 Windows Azure Storage 都正常,但佈署到 Windows Azure Web Site 上後,卻出現以下訊息:

 Could not load file or assembly 'msshrtmi' or one of its dependencies
Ans:Windows Azure Web Site 不支援 Microsoft.WindowsAzure.ServiceRuntime,改用雲端服務(Cloud Services) 即可。

Q5:WCF Data Services 不支援 $format=json

Ans:預設安裝的 WCF Data Services 元件的版本為 5.0.0.0,升級到 5.6.0.0 即可(目前最新版本為 5.6.0.0),同時為了避免部署到 Azure 上之後發生錯誤,必須修改 WcfDataService1.svc 的內容,將 Version 的參數從 5.0.0.0 改為 5.6.0.0














2013年4月10日 星期三

[MCSA] Windows Server 2012 - Install Servers


License

Windows Server DataCenter & Standard 兩種版本都支援 Hyper-V,其中差別在於可用的 VM 數量不同;每一個 Windows Server 2012 的執行個體都可被分類為 POSE(Physical Operation System Environment) or VOSE(Virtual Operating System Environment)。

或有虛擬化的需求,則要按照以下流程安裝:
  1. 進行 POSE 的安裝
  2. 安裝 Hyper-V 的 Role
  3. 透過 Hyper-V Role 來建立 VM 並安裝 VOSE

以下是 Windows Server 2012 各版本合法授權內的 POSE & VOSE 的數量:
  • Datacenter:1 POSE + Unlimited VOSE
  • Standard:1 POSE + 2 VOSE
  • Foundation:1 POSE + 0 VOSE
  • Essentials:1 (POSE or VOSE) + 1 (POSE or VOSE)
以上是各版本合法授權內可用的 POSE & VOSE,但並不代表為軟體的限制;若安裝超過授權數量的軟體,必須購買足夠的授權才行。

Minimum Server Interface

安裝 Windows Server 2012 時,除了可以選擇傳統式的全圖形化安裝,也可選擇最精簡的 Server Core 的安裝方式。

除了上述兩者,還有另外一種折衷的選擇,稱作 Minimum Server Interface,僅留下 Server Manager & MMC Applications(例如:Device Manager & 完整的 PowerShell 介面),足以讓管理者用來管理本地 & 遠端伺服機。

若要讓 Server 變成僅有 Minimum Server Interface,可透過以下步驟執行:
  1. 點選左下角的 Server Manager
  2. 在 Server Manager 的視窗中點選右上角的 Manage -> Remove Roles and Features
  3. 經過了幾個畫面,到了 Features 的視窗,將 User Interfaces and Infrastructure -> Server Graphic Shell 取消勾選,並選擇 Remove
  4. 重新開機



























Features on Demand

Windows Serve 2012 安裝時,安裝程式會將所有相關元件程式放在 C:\Windows\WinSxS 資料夾中,因此若是隨時要啟用特定功能,就不需要使用光碟或是其他安裝媒體。

但若是很多功能都不需要時怎辦? 一堆其他不需要的元件程式都擺在 server 上,若是 server 很多台時,許多寶貴的磁碟空間就浪費掉了;於是,微軟提供了 Features on Demand 這樣的功能。

Features on Demand 針對每種系統程式功能提供了三種安裝狀態:
  • Enabled
  • Disabled
  • Disabled with payload removed

在之前的 Windows Server 版本中,只有提供前兩種,在 2012 裡面提供了第三種安裝狀態,第三種表示除了將特定功能停用外,也移除在 C:\Windows\WinSxS 資料夾中相對應的安裝程式,但此種方式只能透過 PowerShell 的 cmdlet 來完成,假設以上面要移除 Server Graphic Shell 來舉例,就要執行以下指令:
Uninstall-WindowsFeature Server-Gui-Shell -Remove
透過加上 -Remove 參數,指定 2012 將相關的安裝程式一併移除。

不過,將本機上的安裝程式移除了,也不代表沒辦法再度安裝相關的服務或功能,可以透過以下幾種方式重新安裝啟用服務:
  • Windows Update
  • 使用 PowerShell 中的 Install-WindowsFeature 指令搭配 -Source 指定 image 的位置
  • 系統管理員可以透過 Group Policy 指定多個安裝來源

Upgrade Servers

透過 Upgrade 的方式也可以升級至 2012(如果可以,還是儘量執行 clean installation 最穩定),但有以下限制:
  1. 無法從 2008 之前的版本升級
  2. 無法從 2012 pre-RTM 版本升級
  3. 無法從 WorkStation 版本升級
  4. 無法跨版本升級,例如 Enterprise -> Datacenter
  5. 無法跨平台升級,例如 32-bits -> 64 bits
  6. 無法從任何的 Itanium 版本升級
  7. 無法跨語言升級,例如 English -> Chinese

Migration

要從其他版本升級到 2012,比起 Upgrade,Migration 或許是比較好的方式,因為 Migration 是將目前系統中重要的設定,透過 Migration Tool 備份起來後,再移到 2012 上面。

透過 Migration,幾乎就沒有前述 Upgrade 的限制存在,不論是不同的 Version(例:2003 -> 2012)、Edition(例:Enterprise -> Datacenter)、Platform(例:x86 -> x64)、實體轉虛擬、不同的安裝選項(GUI -> Server Core),都可以透過 Migration Tool,搭配 2012 的 Migration Guide 來完成轉移的工作。

但要注意的是,在 2012 上的 Migration,並非像以往一次可以完成,而是將 Role 與 Role Service 分開處理的。

要進行 Migration,首先必須要在 2012 上安裝 Migration Tool,安裝方式如下:
  1. 點選左下角的 Server Manager
  2. 在 Server Manager 的視窗中點選右上角的 Manage -> Add Roles and Features
  3. 經過了幾個畫面,到了 Features 的視窗,勾選 Windows Server Migration Tools,選擇 Next -> Install 即可,如下圖:




























但 Migration Tool 的使用,又是另一個 topic 了,下回有讀到再來分享!

問答時間

Ralph recently took delivery of a new server with Windows Server 2012 Datacenter Edition already installed with the full GUI option. Ralph wants to configure the system as a web server, using the absolute minimum of hardware resources. His first step is to use Server Manager to install the Web Server (IIS) role.
With this in mind, answer the following questions:

1. What PowerShell command should Ralph use to convert the full GUI installation to Server Core?
Ans: Uninstall-WindowsFeature Server-Gui-Mgmt-Infra,Server-Gui-Shell –Restart

2. What PowerShell command should Ralph use to remove the GUI installation files completely from the system?
Ans: Uninstall-WindowsFeature Server-Gui-Mgmt-Infra,Server-Gui-Shell -Remove (加上 Remove 參數即可)

3. Which of the following roles implement what can be classified as infrastructure services? (Choose all that apply)
A. DNS
B. Web Server (IIS)
C. DHCP
D. Remote Desktop Services
Ans: A & C
【備註】IIS & RDS 屬於 Application Service,不屬於 Infrastructure Service

4. Which of the following is a valid upgrade path to Windows Server 2012?
A. Windows Server 2003 Standard to Windows Server 2012 Standard
B. Windows Server 2008 Standard to Windows Server 2012 Standard
C. Windows Server 2008 R2 32-bit to Windows Server 2012 64-bit
D. Windows 7 Ultimate to Windows Server 2012 Essentials
Ans: B

5. Which feature must you add to a Windows Server 2012 Server Core installation to convert it to the Minimal Server Interface?
A. Graphical Management Tools and Infrastructure
B. Server Graphical Shell
C. Windows PowerShell
D. Microsoft Management Console
Ans: A
【備註】B 選項會安裝成 Full GUI,C 選項僅有 Command Line 模式,D 選項是 Minimal Service Interface 的其中一個圖形化應用程式,無法單獨安裝

6. What is the name of the directory where Windows stores all of the operating system modules it might need to install at a later time?
A. Windows
B. System32
C. bin
D. WinSxS
Ans: D

7. Which of the following are valid reasons why administrators might want to install their Windows Server 2012 servers using the Server Core option? (Choose all that apply)
A. A Server Core installation can be converted to the full GUI without reinstalling the operating system.
B. The PowerShell 3.0 interface in Windows Server 2012 includes more than 10 times as many cmdlets as PowerShell 2.0
C. The new Server Manager in Windows Server 2012 makes it far easier to administer servers remotely.
D. A Windows Server 2012 Server Core license costs significantly less than a full GUI license.
Ans: A & B & C

2012年12月22日 星期六

[.NET] 輔助開發工具

Entity Visualizer

Entity Framework Debugger Visualizer to display SQL source code generated by Entity Framework.

ADO.NET Entity Framework Query Samples


ADO.NET Entity Framework Query Samples is a small Windows Forms program which contains several basic Entity SQL and LINQ to Entities queries against that NorthwindEF Entity Data Model (a modified version of Northwind).
Its goal is to help you learn the features of the different query languages available in the Entity Framework, and to let you visualize how the results and the translated store queries look like.

LINQPad


LINQPad supports everything in C# 5.0 and Framework 4.x:
And that's not all - there's also specific support for:
LINQPad is also a great way to learn LINQ: it comes loaded with 500 examples from the book, C# 5.0 in a Nutshell.  There's no better way to experience the coolness of LINQ and functional programming.

2011年9月16日 星期五

[ASP.NET] Performance Tuning

1. 使用 SqlCommand 搭配 SqlDataReader 時,記得先呼叫 SqlCommand.Cancel() 再呼叫 SqlDataReader.Close(),順序錯誤效能會低落很多
    (若僅呼叫 SqlDataReader.Close() 效能也會很低落)

2. 資料來源控制項的 DataSourceMode 要根據實際需求選擇
    (選擇 DataSet 模式,功能雖然強大,但耗費資訊)

3. 處理大量資料避免使用 ADO.NET Entity Framework 這一類的工具,速度很慢

2011年8月3日 星期三

[.NET] 如何不安裝 Oracle Client 並與 Oracle DB 連線

恩.......我目前手邊這一台 NB 真的很怪....無法安裝 Oracle Client....

但是我要連 Oracle 阿!! 這該怎辦ㄌㄟ....

上網找了一下,必須要在程式執行目錄(bin/)中,放入以下五個 DLL 檔案:

  1. Oracle.DataAccess.dll
  2. oci.dll 
  3. OraOps11w.dll
  4. oraociei11.dll
  5. msvcr71.dll
這些檔案可以在有安裝 Oracle Client 的電腦上找到....我是請同事找給我的.....


另外在連線字串部分,沒辦法使用 OracleDBConnectionStringBuilder 物件產生連線字串,必須用自行組成語法的方式:
string DBConnectionString = @"Data Source=(DESCRIPTION = (ADDRESS_LIST =
                                    (ADDRESS = (PROTOCOL = TCP)(HOST = 這是 Oracle Server IP)(PORT = 1521)) )
                                    (CONNECT_DATA = (SID = 這裡放SID)(SERVER = DEDICATED) ) )
                                    ;Persist Security Info=True;User ID=這是使用者帳號;Password=使用者密碼;";

最後程式中引用 Oracle.DataAccess.dll 作為參考,相關的 Oracle API 就可以使用囉!


2011年6月1日 星期三

[LINQ] 集合已修改; 列舉作業可能尚未執行??

今天同事在寫程式遇到這問題.....

問我.... LINQ 可以在 multi-thread 環境下執行嗎?? 程式起來一直有問題......

我心裡想......怎麼會不行? 如果不行,微軟不就搞了一個大飛機了..........?

後來發現其實跟 LINQ 無關,而是在進行列舉作業時不能去修改集合的值

[JVM] Performance Tuning 相關資源蒐集

JVM調優總結- See World - ITeye技術網站

JVM調優總結(一)-- 一些概念- 和你在一起- ITeye技術網站

JVM調優總結(二)-一些概念- 和你在一起- ITeye技術網站

JVM調優總結(三)-基本垃圾回收算法- 和你在一起- ITeye技術網站

JVM調優總結(四)-垃圾回收面臨的問題- 和你在一起- ITeye技術網站

JVM調優總結(五)-分代垃圾回收詳述1 - 和你在一起- ITeye技術網站

JVM調優總結(六)-分代垃圾回收詳述2 - 和你在一起- ITeye技術網站

JVM調優總結(七)-典型配置舉例1 - 和你在一起- ITeye技術網站

JVM調優總結(八)-典型配置舉例2 - 和你在一起- ITeye技術網站

JVM調優總結(九)-新一代的垃圾回收算法- 和你在一起- ITeye技術網站

JVM調優總結(十)-調優方法- 和你在一起- ITeye技術網站

JVM調優總結(十一)-反思- 和你在一起- ITeye技術網站

JVM調優總結(十二)-參考資料- 和你在一起- ITeye技術網站

2011年5月31日 星期二

[Windows] 修改 JVM 啟動參數

今天早上為了 H2 執行五六個小時後會出現 out of memory 的問題在頭痛...

上到 Google Group 查了一下,有人建議先把 JVM 的 heap 開大一點試試看....

於是.......問題來了,要怎麼開大??

在 Linux 裡面可以直接透過 Alias 的方式解決.......

那 Windows 呢? 答案就是設定一個名稱為 "_JAVA_OPTIONS" 的環境變數

值的部分就設定為 "-Xms512m -Xmx1024m" 應該是很夠用了....

再來繼續長時間測試 H2 看看.....

2011年5月30日 星期一

[HTML5] 學習資源

基本觀念

教學(投)影片

工具

2011年5月26日 星期四

[LINQ] 如何直接更改物件集合中的物件值而不建立新物件

用過 LINQ 的人應該會對 LINQ 處理資料集合的功力印象深刻....

但....LINQ 是 Query 阿! 不是 Update!

那如果我只是要針對物件集合中的某幾個物件進行值的變更.......要怎麼作呢....??

答案是 => 只要自己撰寫一個 extension method,method 中回傳原本的物件集合

在網路上找到一個很不錯的參考範例連結:
LINQ: Select an object, but change some properties without creating a new object (Rob Volk's Blog)


以下寫了一個簡單的 sample


但有一點真的需要注意的是,這種方式只能用在物件集合中,若是用在基本型態的資料集合中(例如:整數陣列、整數 List) 則沒有效果......


2011/06/08 Updated: 

今天有找到初始化陣列的方式囉! 只要使用 extension method 就可以簡單達成了....以下為範例:

2010年8月31日 星期二