1.下載mysql-noinstall-5.0.45-win32.zip
2.解壓到E:\mysql,然后將文件夾E:\mysql\mysql-noinstall-5.0.45-win32改為E:\mysql\master
3.再解壓到E:\mysql,然后將文件夾E:\mysql\mysql-noinstall-5.0.45-win32改為E:\mysql\slave
4.復(fù)制E:\mysql\master\my-small.ini為E:\mysql\master\my.ini
編輯內(nèi)容:,增加log-bin和binlog-do-db參數(shù)
示例如下:
#skip-networking
server-id = 1
# Uncomment the following if you want to log updates
#log-bin=mysql-bin
log-bin=mysql-bin
binlog-do-db = testdb1 #需同步數(shù)據(jù)庫 testdb1
binlog-do-db = testdb2 #需同步數(shù)據(jù)庫 testdb2
5.復(fù)制E:\mysql\slave\my-small.ini為E:\mysql\slave\my.ini
編輯內(nèi)容:,修改端口,
port = 3310
示例如下:
[client]
#password = your_password
port = 3310
socket = /tmp/mysql.sock
# Here follows entries for some specific programs
# The MySQL server
[mysqld]
port = 3310
socket = /tmp/mysql.sock
skip-locking
key_buffer = 16K
max_allowed_packet = 1M
table_cache = 4
sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
net_buffer_length = 2K
thread_stack = 64K
#skip-networking
server-id = 2
# Uncomment the following if you want to log updates
#log-bin=mysql-bin
master-host=127.0.0.1
master-user=root
master-password=
master-port=3306
replicate-do-db=testdb1
replicate-do-db=testdb2
6.保存 E:\mysql\master\my.ini.和E:\mysql\slave\my.ini
7.在命令行下運(yùn)行E:\mysql\master\bin\mysqld.exe,
Microsoft Windows XP [版本 5.1.2600]
(C) 版權(quán)所有 1985-2001 Microsoft Corp.
E:\mysql\master\bin>mysqld
8.再新開命令行,運(yùn)行E:\mysql\slave\bin\mysqld.exe
Microsoft Windows XP [版本 5.1.2600]
(C) 版權(quán)所有 1985-2001 Microsoft Corp.
E:\mysql\slave\bin>mysqld
071013 21:41:06 [Warning] The syntax for replication startup options is deprecat
ed and will be removed in MySQL 5.2. Please use 'CHANGE MASTER' instead.
9.用mysql 客戶端 HeidiSQL連接到 127.0.0.1的3306,創(chuàng)建數(shù)據(jù)庫testdb1和testdb2,
并在數(shù)據(jù)庫中新建表,然后插入一些數(shù)據(jù).
10.客戶端連接 到 127.0.0.1的3310,可以看見數(shù)據(jù)庫testdb1和testdb2,且數(shù)據(jù)庫中的數(shù)據(jù)與master的數(shù)據(jù)庫數(shù)據(jù)一致.
11.t查看 E:\mysql\master\data\mysql-bin.000001 和E:\mysql\master\data\mysql-bin.index,可以看到被記錄的sql操作,
Tomcat使用apr之后的ssl雙向認(rèn)證配置如下:
<Connector port="8443" maxHttpHeaderSize="8192" protocol="HTTP/1.1"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" disableUploadTimeout="true"
acceptCount="100" scheme="https" secure="true"
clientAuth="true" <!--雙向驗(yàn)證-->
SSLEngine="on" bufferSize="8192"
SSLEnabled="true"
SSLProtocol="all"
SSLCipherSuite="ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL"
SSLCertificateFile="..\conf\ca\www.crt"
SSLCertificateKeyFile="..\conf\ca\www.key"
SSLCACertificateFile="..\conf\ca\ca.crt"
SSLCACertificatePath="..\conf\ca"
SSLVerifyDepth="15"
SSLVerifyClient="require"
/>
4.6.6 Squid HTTPS
squid.conf中加上:
https_port 3443 cert=D:/ca/www.crt key=D:/ca/www.key
4.7.6 LightTPD HTTPS
首先使用copy命令把 key和crt合并為一個(gè)文件,
D:\ca>copy /b www.key+www.crt www.pem
然后配置如下:
$SERVER["socket"] == ":443" {
ssl.engine = "enable"
ssl.pemfile = "D:/ca/www.pem"
ssl.ca-file = "D:/ca/ca.crt"
server.name = "www"
server.document-root = "D:/httpsdosc"
server.errorlog = "httpserror.log"
accesslog.filename = "httpsaccess.log"
}
(下面的雙向驗(yàn)證沒有測試是否可用)
如需啟用雙向驗(yàn)證,則還需下面的配置參數(shù):
ssl.verify-peer = "enable"
ssl.verify-depth = 1
參考:http://trac.lighttpd.net/trac/ticket/921
附件下載流程 attachment.php
1.處理 common.inc.php 流程
2.檢查Referer頭信息
3.檢查每日下載限制時(shí)間 periodscheck
4.查詢附件信息檢查附件是否存在
5.判斷是否允許下載
6.判斷是否已經(jīng)購買
7.執(zhí)行購買操作.
8.執(zhí)行下載
視圖層使用jsp+jstl.
1.首先將所有的htm文件名替換成jsp,
在命令行下運(yùn)行 rename *.htm *.jsp即可.
2.將bbs\forumdata\cache\style_1.php中的css變量TABLEWIDTH等,
替換成類似${crtStyles['TABLEWIDTH']}的jstl語法.
全部只能手工替換
3.將*.jsp中的{lang forum_favorite}等替換成類似 <fmt:message key="faq" bundle="${forum_favorite}"/>
使用正則表達(dá)式進(jìn)行替換:
editplus中的 查找內(nèi)容為: {lang (.+)},替換內(nèi)容為:<fmt:message key="faq" bundle="${\1}"/>
Jbuilder中的查找內(nèi)容為 \{lang (.+)\},Pattern為:Regular Expressions,
替換內(nèi)容為:(暫時(shí)未寫出來,打算寫程序進(jìn)行替換操作)
用java程序替換的核心代碼為:
//替換樣式變量
content = content.replaceAll("FORMHASH", "formhash");
//替換樣式變量 ${crtStyle['TABLEWIDTH']}
content = content.replaceAll("\\{([A-Z0-9]+)\\}", "\\${crtStyle\\['$1'\\]}");
//替換國際化定義
//content = content.replaceAll("\\{lang (.+?)\\}",
// "<fmt:message key=\"$1\" bundle=\"\\$\\{templates\\}\"/>");
//對標(biāo)簽屬性里的值暫時(shí)不替換
content = content.replaceAll("([^\"])\\{lang (.+?)\\}",
"$1<fmt:message key=\"$2\" bundle=\"\\$\\{templates\\}\"/>");
//替換單層的屬性訪問
content = content.replaceAll("\\$([a-z]+?)\\[([a-z]+?)\\]",
"\\$\\{$1\\['$2'\\]\\}");
//替換標(biāo)題部分的聲明
content = content.replaceAll("\\{template header\\}",
"<%@page pageEncoding=\"UTF-8\" " +
"contentType=\"text/html;" +
" charset=UTF-8\"%>\n"
+ "<%@include file=\"/WEB-INF/" +
"inc/taglibs.jspf\"%>\n" +
"<jsp:include flush=\"true\" " +
"page=\"header.jsp\"/>\n");
////替換底部部分的聲明
content = content.replaceAll("\\{template footer\\}",
"\n<jsp:include flush=\"true\" " +
"page=\"footer.jsp\"/>");
//替換其它引用聲明
content = content.replaceAll("\\{template (.+?)\\}",
"\n<jsp:include flush=\"true\" " +
"page=\"$1.jsp\"/>");
//替換url定義
content = content.replaceAll("\\$indexname", "\\${settings.indexname}");
//替換網(wǎng)站名字
content = content.replaceAll("\\$bbname", "\\${settings.bbname}");
//替換導(dǎo)航標(biāo)簽
content = content.replaceAll("\\$navigation", "\\${navigation}");
//替換一些變量
//content = content.replaceAll("\\$pid", "\\${pid}");
content = content.replaceAll("\\$([a-z_]+)(\"|<|\\))", "\\${$1}$2");
2.風(fēng)格機(jī)制
使用.jsp,使用jstl語法,允許用戶寫jstl
依然按目錄存放到templates目錄下,每個(gè)風(fēng)格為一個(gè)文件夾.
3.緩存機(jī)制
使用oscache 標(biāo)簽 來緩存頁面的方式.
4.特殊標(biāo)簽的解析 hidden標(biāo)簽,reply標(biāo)簽
采取在顯示的時(shí)候,進(jìn)行 jsp:include page="/tag/hidden.jsp" 這樣的方式來實(shí)現(xiàn).
5.日歷選擇框: 使用jscalendar
6.頁面gzip壓縮,使用專門的gzip過濾器.
7.全文檢索,使用compass.
8.視圖層的模板.
discuz 已經(jīng)使用了 mvc的模式,只是使用自己開發(fā)的模板技術(shù),
D:\xampp\htdocs\bbs\templates每個(gè)文件夾為一個(gè)主題,每個(gè)主題內(nèi)對應(yīng)的是各種視圖的htm.
因此在用java實(shí)現(xiàn)的時(shí)候,使用spring mvc ,
視圖層使用jsp來展示.
其中頁面的布局分為三段
{template header} 是最上面的導(dǎo)航部分
{template footer} 是最下方的版權(quán)申明等部分.
中間部分為各具體模塊的視圖.
后臺則是使用的固定框架,然后來合成內(nèi)容的.
9.國際化支持
discuz使用的是 .lang.php定義數(shù)組的方式實(shí)現(xiàn)的,而且一次只支持一種語言
而java開發(fā)則使用I18N方式.多種語言均使用同一個(gè)系統(tǒng).
1.php的array功能非常強(qiáng)大,而java中只能用map和list結(jié)合起來處理.
2.在一個(gè)http請求中php的變量幾乎都是全局生效,而jstl中,則可以放到requestScope中.
1.discuz的有些表的主鍵不是自動增長的,因此不能夠生成@GeneratedValue(strategy = GenerationType.AUTO)的注釋.
這些表有: new String[] {
"validating", "trades", "relatedthreads", "pushedthreads", "polls",
"onlinetime", "memberspaces", "memberfields", "forumfields",
"admingroups", "adminactions", "activities"}
2.mysql的hibernate dao單元測試中,insert是無法回滾的,而delete卻可以不操作數(shù)據(jù)庫,
因此crud單元測試的時(shí)候,導(dǎo)致不停的插入數(shù)據(jù)卻沒有刪除數(shù)據(jù).
解決辦法,在 crud 測試方法的最后加上一行代碼: this.setComplete();
3.mysql的jdbc需要幾個(gè)特殊設(shè)置
a.字符編碼集必須指定.
b.對于"0000-00-00" 這樣的默認(rèn)日期,在轉(zhuǎn)化成java.sql.Date的時(shí)候會出錯(cuò),因此需要加上個(gè)zeroDateTimeBehavior屬性.
datasource.url=jdbc:mysql://localhost:3306/discuz?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
4.mysql的jdbc驅(qū)動存在bug : http://bugs.mysql.com/bug.php?id=22215
在usergroups 表中, readaccess字段是 tinyint(3)類型,而有值為200的,mysql的jdbc就會報(bào)錯(cuò),說數(shù)字越界了.
java.sql.SQLException: '200' in column '1' is outside valid range for the
datatype TINYINT.
暫時(shí)無解決辦法,采取修改200為20回避之.
(update:后來使用Short代替byte類型)
discuz 已經(jīng)使用了 mvc的模式,只是使用自己開發(fā)的模板技術(shù),
D:\xampp\htdocs\bbs\templates每個(gè)文件夾為一個(gè)主題,每個(gè)主題內(nèi)對應(yīng)的是各種視圖的htm.
因此在用java實(shí)現(xiàn)的時(shí)候,使用spring mvc ,
視圖層使用jspx來展示.
其中頁面的布局分為三段
{template header} 是最上面的導(dǎo)航部分
{template footer} 是最下方的版權(quán)申明等部分.
中間部分為各具體模塊的視圖.
后臺則是使用的固定框架,然后來合成內(nèi)容的.