配置Sql Server 2008(Win7)
?
1.打開SQL server2012,使用windows身份登錄
?
?
2.登錄后,右鍵選擇“屬性”。左側選擇“安全性”,選中右側的“SQL Server 和 Windows 身份驗證模式”以啟用混合登錄模式
?
?
3.選擇“連接”,勾選“允許遠程連接此服務器”,然后點“確定”
?
?
4.展開“安全性”,“登錄名”;“sa”,右鍵選擇“屬性”
?
?
5.左側選擇“常規”,右側選擇“SQL Server 身份驗證”,并設置密碼
?
?
6.右擊數據庫選擇“方面”
?
?
7.在右側的方面下拉框中選擇“服務器配置”;將“RemoteAccessEnabled”屬性設為“True”,點“確定”
?
?
8.至此SSMS已設置完畢,先退出,再用sa登錄,成功即表示sa帳戶已經啟用
?
?
9.打開sql server配置管理器
?
?
10.下面開始配置SSCM,選中左側的“SQL Server服務”,確保右側的“SQL Server”以及“SQL Server Browser”正在運行
?
?
11.將"客戶端協議"的"TCP/IP"也修改為“Enabled”
?
?
12.選擇“IP 地址”選項卡,設置TCP的端口為“1433”(默認端口)
?
?
13.MSSQLSERVER的協議啟用TCP/IP
?
?
14.配置防火墻
?
?
配置Sql Server 2008(Win2003)
?
?
方法與配置Sql Server 2008(Win7)相同
從Win7連接Win2003的Sql Server 2008
?
1.新建鏈接服務器鏈接到Win2003的Sql Server 2008
?
?
2.查看Win2003上面的IP地址,配置”新建鏈接服務器”中的”常項”
?
?
?
3.配置”新建鏈接服務器”中的”安全項”,本地登錄為”sa”,遠程用戶也為”sa”
?
?
4.鏈接成功
?
?
Win7啟動MSDTC服務
?
1.運行cmd,輸入net start msdtc啟動msdtc服務
?
?
2.在管理工具中打開服務組件,右鍵”本地DTC”, 選擇”本地DTC”的”安全選項卡”,做如下設置:
?
(1)選中”網絡DTC訪問”
?
(2)在客戶端管理中選中”允許遠程客戶端”“允許遠程管理”
?
(3)在事務管理通訊中選”允許入站”“允許出站”“不要求進行驗證”
?
(4)保證DTC登陸賬戶為:NT Authority\NetworkService
?
(5)單擊”確定”。這樣將會提示您”MS DTC 將會停止并重新啟動。
?
?
Win2003啟動MSDTC服務
?
1.打開”控制面板”,打開”添加或刪除程序”,點擊”添加/刪除Windows組件”,選擇”應用程序服務器”,勾選”啟用網絡DTC訪問”
?
?
2.在"開始"里的"運行"中輸入dcomcnfg.exe啟動"組件服務",右鍵”我的電腦”,”屬性”,在MSDTC選項卡中,點擊”安全配置”按鈕,在安全配置窗口中做如下設置:
?
(1)選中”網絡DTC訪問”
?
(2)在客戶端管理中選中”允許遠程客戶端””允許遠程管理”
?
(3)在事務管理通訊中選”允許入站” ”允許出站” ”不要求進行驗證”
?
(4)保證DTC登陸賬戶為:NT Authority\NetworkService
?
(5)單擊"確定"。這樣將會提示您"MS DTC 將會停止并重新啟動”
?
?
?
?
轉載請注明出處:http://www.cnblogs.com/yydcdut/p/3456440.html
配置PHP
1.打開PHP配置文件,找到extension=php_mssql.dll,將前面的注釋符號去掉
2.找到mssql.secure_connection,將Off改為On
?
3.找到com.allow_dcom = true,將前面的注釋符號去掉
4.下載正確版本的 ntwdblib.dll (2000.80.194.0),覆蓋Apache-20/bin/ntwdblib.dll、覆蓋php-5.2.14-Win32/ntwdblib.dll并且復制ntwdblib.dll和php_mssql.dll到系統system32目錄下,重啟Apache
5.測試成功
?
轉載請注明出處:http://www.cnblogs.com/yydcdut/p/3459792.html
數據庫設計
1.E-R圖
2.數據庫創建
Win 7
1 | create ?database ?V3 |
Win 2003
1 | create ?database ?V3 |
3.數據表設計
Win7 創建數據表student_7
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | create ?table ?student_7 ( ???? sid? int ?not ?null , ???? sex nvarchar(1)? not ?null , ???? sname? varchar (20)? not ?null , ???? school? varchar (20)? not ?null , ???? scount? varchar (20)? not ?null , ???? spwd? varchar (20)? not ?null , ???? constraint ?pk_student_7 ???? primary ?key (sid,sex), ???? constraint ?uq_student_7_scount ???? unique (scount), ???? constraint ?chk_student_7_sex ???? check (sex= '1' ) ) |
Check(sex=1)指明存放sex=1的數據,即女生。
Win2003 創建數據表student_2003
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | create ?table ?student_2003 ( ???? sid? int ?not ?null , ???? sex nvarchar(1)? not ?null , ???? sname? varchar (20)? not ?null , ???? school? varchar (20)? not ?null , ???? scount? varchar (20)? not ?null , ???? spwd? varchar (20)? not ?null , ???? constraint ?pk_student_2003 ???? primary ?key (sid,sex), ???? constraint ?uq_student_2003_scount ???? unique (scount), ???? constraint ?chk_student_2003_sex ???? check (sex= '0' ) ) |
Check(sex=0)指明存放sex=0的數據,即男生。
Win7 創建視圖V3_student
1 2 3 4 5 | create ?view ?V3_student as select ?*? from ?student_7 union ?all select ?*? from ?[192.168.116.130].[V3].[dbo].[student_2003] |
Win2003 創建視圖V3_student
1 2 3 4 5 | create ?view ?V3_student as select ?*? from ?student_2003 union ?all select ?*? from ?[192.168.233.1].[V3].[dbo].[student_7] |
student水平分片數據表已經建立,現在可以在任何位置,只要訪問本地V3_student分布式分區視圖,就實現了所有分布式數據庫的操作。此時,對數據庫的全局操作和局部操作就如同操作本地集中式數據庫一樣。
-----------------------------------------------------------------------------------------------------------------
Win7創建數據表teacher
1 2 3 4 5 6 7 8 9 10 11 12 | create ?table ?teacher ( ???? tid? int ?not ?null , ???? tname? varchar (20)? not ?null , tage? int ?not ?null , tsex? int ?not ?null , ???? tcount? varchar (20)? not ?null , ???? tpwd? varchar (20)? not ?null , tsuper? int ?not ?null , ???? primary ?key (tid), ???? unique (tcount) ) |
Win2003創建數據表teacher
1 2 3 4 5 6 7 8 | create ?table ?teacher ( ???? tid? int ?not ?null , nowage? int ?not ?null , tel? char (20)? not ?null , address? varchar (80)? not ?null , ???? primary ?key (tid) ) |
Win7 創建存儲過程V3_teacher
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | create ?proc V3_teacher ( @tid? int , @tname? varchar (20), @tage? int , @tsex? int , @tcount? varchar (20), @tpwd? varchar (20), @super? int , @nowage? int ?, @tel? char (20) , @address? varchar (80) ) as set ?XACT_ABORT? on BEGIN ?DISTRIBUTED? TRANSACTION insert ?into ?teacher values (@tid,@tname,@tage,@tsex,@tcount,@tpwd,@super); insert ?into ?[192.168.116.130].[V3].[dbo].[teacher] values (@tid,@nowage,@tel,@address); COMMIT ?TRANSACTION |
采用存儲過程實現垂直分片。此時插入數據之后,將分別插入到不同地址上的SQL Server的teacher的數據表里面。
-----------------------------------------------------------------------------------------------------------------
Win7創建數據表class
1 2 3 4 5 6 7 8 9 | create ?table ?class ( ???? cid? int ?not ?null , ???? sid? int ?not ?null , tid? int ?not ?null , cname? varchar (20)? not ?null , ???? score? int ?not ?null , ???? primary ?key (cid,sid) ) |
本地數據表。
-----------------------------------------------------------------------------------------------------------------
Win 7:
?
Win2003:
4.程序代碼測試
水平分片測試
垂直分片測試
?
轉載請注明出處:http://www.cnblogs.com/yydcdut/p/3459836.html
?
?
轉載請注明出處:http://www.cnblogs.com/yydcdut/p/3456426.html