2011年10月20日 星期四

SQL Server 交易日誌清除

情境1.因為壓力測試的關係,交易紀錄長到接近2TB ,系統效能受到影響,資料備份也受到嚴重影響。

情境2.使用資料庫複寫進行資料備份,導致產生大量交易日誌。

SQL Server 2008 :
方法一
1.將資料庫還原模式切換至簡單模式  (簡單模式不會記錄交易紀錄,所以交易紀錄會被截斷)
2.執行資料庫壓縮
3.將資料庫還原模式切換至完整模式(恢復正常交易紀錄)

方法二
1.將資料庫還原模式切換至簡單模式
2.在要清除交易日誌的資料庫上新增查詢

select * from sys.database_files
查出NAME後
3.改下DBCC命令

DBCC SHRINKFILE ( 帶入剛剛查到的NAME , 2)


以往我們都只有做完整備份,而完整備份會將資料庫以及交易日誌進行完整備份,
但是不會進行交易日誌截斷,所以會有越備份越大的問題。

而做了完整備份卻沒有做交易紀錄備份跟資料庫壓縮,自然交易紀錄不會被截斷,當然會越長越大。

所以標準做法應該是在維護計畫中,做完完整備份後,再做一次交易紀錄備份,
把交易紀錄截斷,然後再接著執行資料庫壓縮,就不會發生爆資料庫的問題了。



未完待續..

資料庫複寫設定筆記

這是土法煉鋼出來的筆記,或許有誤。

1.資料庫基礎結構 必須有完善的主鑰 P-Key (快照式除外)
2.複寫端資料庫還原模式最好選簡單模式或是限制交易日誌大小,不然很快就爆了。
3.代理程式帳密必須一致。
4.快照式複寫的複寫端無法寫入但是可以讀取,交易式可以在複寫端讀寫。



SQL 2008 資料庫鏡像(無仲裁)


1. 來源資料庫 完整備份及交易日誌備份 並複製到 鏡射端

2. 鏡射資料庫 還原完整備份 還原狀態選 RESTORE WITH NORECOVERY  記得覆蓋資料

3. 鏡射資料庫 還原交易日誌備份 還原狀態選 RESTORE WITH NORECOVERY

4. 啟動鏡射設定精靈




可能需求:
A.資料庫的DNS對應,可由修改Hosts檔達成
B.出現1418錯誤,確認不是防火牆問題可以將 DB server, Agent權限提升後解決

2011年10月19日 星期三

Mac OSX Kernel info

http://developer.apple.com/library/mac/#documentation/Darwin/Conceptual/KernelProgramming/BSD/BSD.html


The BSD portion of the Mac OS X kernel is derived primarily from FreeBSD, a version of 4.4BSD that offers advanced networking, performance, security, and compatibility features. BSD variants in general are derived (sometimes indirectly) from 4.4BSD-Lite Release 2 from the Computer Systems Research Group (CSRG) at the University of California at Berkeley. BSD provides many advanced features, including the following: Preemptive multitasking with dynamic priority adjustment. Smooth and fair sharing of the computer between applications and users is ensured, even under the heaviest of loads. Multiuser access. Many people can use a Mac OS X system simultaneously for a variety of things. This means, for example, that system peripherals such as printers and disk drives are properly shared between all users on the system or the network and that individual resource limits can be placed on users or groups of users, protecting critical system resources from overuse. Strong TCP/IP networking with support for industry standards such as SLIP, PPP, and NFS. Mac OS X can interoperate easily with other systems as well as act as an enterprise server, providing vital functions such as NFS (remote file access) and email services, or Internet services such as HTTP, FTP, routing, and firewall (security) services. Memory protection. Applications cannot interfere with each other. One application crashing does not affect others in any way. Virtual memory and dynamic memory allocation. Applications with large appetites for memory are satisfied while still maintaining interactive response to users. With the virtual memory system in Mac OS X, each application has access to its own 4 GB memory address space; this should satisfy even the most memory-hungry applications. Support for kernel threads based on Mach threads. User-level threading packages are implemented on top of kernel threads. Each kernel thread is an independently scheduled entity. When a thread from a user process blocks in a system call, other threads from the same process can continue to execute on that or other processors. By default, a process in the conventional sense has one thread, the main thread. A user process can use the POSIX thread API to create other user threads. SMP support. Support is included for computers with multiple CPUs. Source code. Developers gain the greatest degree of control over the BSD programming environment because source is included. Many of the POSIX APIs.