Monday, June 8, 2009

install svn on windows

Setting up a Subversion Server under Windows

I talked a little bit about what Subversion is in my previous post. Now, let's get it set it up in Windows.

Luckily for us, Joe White has done most of the work already; he has a tremendously helpful post that documents how to set up Subversion. I'll see if I can streamline his excellent post a bit further, and illustrate it with screenshots.

A) Download Subversion

You'll need the latest version of..

* the Windows binaries
* the "run Subversion as a windows service" wrapper
* the TortoiseSVN shell integration utility

B) Install Subversion

1. Unzip the Windows binaries to a folder of your choice. I chose c:\program files\subversion\ as my path.
2. Now, add the subversion binaries to the path environment variable for the machine. I used %programfiles%\subversion\bin\

3. You'll also need another environment variable, SVN_EDITOR, set to the text editor of your choice. I used c:\windows\notepad.exe

C) Create a Repository

1. Open a command prompt and type

svnadmin create "c:\Documents and Settings\Subversion Repository"

2. Navigate to the folder we just created. Within that folder, uncomment the following lines in the /conf/svnserve.conf file:

[general]
anon-access = read
auth-access = write
password-db = passwd

Next, uncomment these lines in the /conf/passwd file:

[users]
harry = harryssecret
sally = sallyssecret

D) Verify that everything is working

1. Start the subversion server by issuing this command in the command window:

svnserve --daemon --root "C:\Documents and Settings\Subversion Repository"

2.

Create a project by opening a second command window and entering this command:

svn mkdir svn://localhost/myproject

It's a standard Subversion convention to have three folders at the root of a project:

/trunk
/branches
/tags

3.

At this point, Notepad should launch:

Enter any comment you want at the top of the file, then save and exit.

4.

You'll now be prompted for credentials. In my case I was prompted for the administrator credentials as well:

Authentication realm: 0f1a8b11-d50b-344d-9dc7-0d9ba12e22df
Password for 'Administrator': *********
Authentication realm: 0f1a8b11-d50b-344d-9dc7-0d9ba12e22df
Username: sally
Password for 'sally': ************

Committed revision 1.

Congratulations! You just checked a change into Subversion!

E) Start the server as a service

1. Stop the existing command window that's running svnserve by pressing CTRL+C.
2. Copy the file SVNService.exe from the zip file of the same name to the subversion\bin folder.
3. Install the service by issuing the following commands:

svnservice -install --daemon --root "C:\Documents and Settings\Subversion Repository"
sc config svnservice start= auto
net start svnservice

4. Test the new service by listing all the files in the repository:

svn ls svn://localhost/

You should see the single project we created earlier, myproject/

F) Set up the shell extension

1. Run the TortoiseSVN installer. It will tell you to restart, but you don't need to.
2. Create a project folder somewhere on your hard drive. Right click in that folder and select "SVN Checkout..."



type svn://localhost/myproject/ for the repository URL and click OK.


3. Create a new file in that directory. Right click the file and select "TortoiseSVN, Add"


4. The file hasn't actually been checked in yet. Subversion batches any changes and commits them as one atomic operation. To send all your changes to the server, right click and select "SVN Commit":



And we're done! You now have a networked Subversion server and client set up on your machine. Note that the default port for svnserve is 3690.


CHINESE VERSION:

SubVersion服务器Windows安装指南
SubVersion及TortoiseSVN下载请到其官方网站:http://subversion.tigris.org
注:如果要使用TortoiseSVN中文界面,还要下载其语言安装包. 若只在本地计算机上使用,不使用SubVersion服务,则只需安装TortoiseSVN相关组件即可.

一.下载文件列表:

1.SubVersion 点击这里下载,版本是1.3.0,SubVersion服务程序.

2.TortoiseSVN 点击这里下载,版本是1.3.2,SubVersion客户端程序.

3.TortoiseSVN 中文语言包 点击这里下载,版本与上面的匹配.

4.SVNService 点击这里下载,可以将SubVersion服务包装成Windows NT服务.

二.安装步骤

1.安装SubVersion

2.安装TortoiseSVN及语言包

3.配置SubVersion服务

SubVersion本身是由命令行启动的,在SubVersion安装目录中找到,它不能像Windows NT服务一样随Windows启动,需要借SVNService来包装成Windows NT服务.具体设置如下:

将下载的SVNService解包后,将其中的拷贝到SubVersion的安装目录中的\bin目录, 保证SVNService.exe和svnserve.exe在同一目录.

安装服务:
运行命令:SVNService -install -d -r
在实际操作中,代表SubVersion服务的电子仓库目录.

改变服务设置:
运行命令:SVNService -setup -d -r
在实际操作中,代表与SubVersion服务启动时不同的电子仓库目录.

删除服务:
运行命令:SVNService -remove

4.用TortoiseSVN创建电子仓库

TortoiseSVN客户端不是独立的程序,而是与Windows Explorer进行了外壳集成,其操作通过环境菜单来完成.



如上图所示:
1.创建名为SVNroot的空目录
2在目录上,或在在目录内空白处点右键,从TortoiseSVN菜单中选择Create repository here...(在此处创建电子仓库),在选择电子仓库类型后,将会自动生成一些文件和目录.这样就完成了电子仓库的创建,你可以用同样的方法创建多个电子仓库.

注:电子仓库类型有两种可供选择,选择任意一种即可:
1.Native filesystem(FSFS) 本地文件系统
2.Berkely database(BDB) Berkely数据库
不同的选择只会影响电子仓库的数据存取格式,默认选择为:Native filesystem

在本例中,可以用:SVNService -install -d -r e:\svnroot来安装SubVersion服务

要问本机安装的服务请在右键菜单中选择Reop-browser(电子仓库浏览),弹出如下对话框:

Congratulations, Roger Federer

从你身上, 我看到了执着,坚韧和顽强. 更明白了什么叫天道酬勤. 祝贺你成为历史上最伟大的网球选手, 更欣喜你坚持不懈的付出终于得到了回报.

Monday, June 1, 2009

MYSQL主从数据库同步备份

首先两台机器:
a: 192.168.0.1
b: 192.168.0.2


打开a机器的my.cnf/my.ini设置

首先要保证要同步的数据库内容完全一致

在[mysqld]下添加以下内容
server-id=1

log-bin=/var/db/mysql/master.log

binlog-do-db=要同步的数据库名称 //不写就同步全部。
#binlog-ignore-db = mysql //忽略的数据库

增加一个backup的用户

GRANT FILE,REPLICATION SLAVE,REPLICATION CLIENT,SUPER ON *.* TO backup@'192.168.0.2' IDENTIFIED by 'backuppassword';
这个权限表示,这个backup账号只能由从备份机192.168.0.2访问只能用来进行备份操作


因为要实现双向备份,所以a上还要加以下内容。 如果是单向,则不需要加。
master-host=192.168.0.2
master-user=backup
master-password=backuppassword
master-port=3306
master-connect-retry=60
replicate-do-db=要同步的数据库
#replicate-ignore-db=不同步的数据库

打开b机器的my.cnf/my.ini文件
添加或修改以下内容
server-id=2

master-host=192.168.0.1
master-user=backup
master-password=backuppassword
master-port=3306
master-connect-retry=60
replicate-do-db=要同步的数据库
#replicate-ignore-db=不同步的数据库

如果要双向同步则再加上以下内容

log-bin=/var/db/mysql/master.log
binlog-do-db=要同步的数据库名称
#binlog-ignore-db = mysql //忽略的数据库

再增加一个帐号给a
GRANT FILE,REPLICATION SLAVE,REPLICATION CLIENT,SUPER ON *.* TO backup2@'192.168.0.1' IDENTIFIED by 'backuppassword';


至此基于mysql的同步功能就做好了。
重起两边的服务器。 用show master status查看主服务器状态。 用 show slave status 查看从服务器状态。

slave stop; 停止从服务器
slave start; 启动从服务器
master stop; 停止主服务器
master start; 启动主服务器

用show processlist可以查看同步状态。
如果有什么错误打开mysql的 hostname.err 查看原因,再调用下面的修改命令:

CHANGE MASTER TO
MASTER_HOST='master_host_name',
MASTER_USER='master_user_name',
MASTER_PASSWORD='master_pass',
MASTER_LOG_FILE='recorded_log_file_name',
MASTER_LOG_POS=recorded_log_position;

然后再重起slave;

install multiple mysql instances on windows

1.正常安装Windows版的Mysql,例如安装在d:\mysql文件夹里;

2.按照常规配置好Mysql;

3.复制备份安装好的文件夹,比如备份到另外一个文件夹,或者命名为“复件mysql";

4.运行卸载程序删除安装的MYSQL和文件夹;

5.把备份的mysql文件夹,重新恢复原来的名字,或还原到原来的位置上;

6.再次运行安装程序,安装在另外一个目录,例如:“d:\mysql2"。配置端口为3307;

现在,后面安装的第二个Mysql——mysql2肯定是可以正常运行的,下面让起初安装的第一个Mysql

服务正常运行:

在cmd命令行模式下,进入第一个Mysql的\bin文件夹。

执行mysql-nt install mysql2命令。作用是为Mysql安装一个服务,服务名是mysql2,你也可以自己改名字,比如mysql5,那么命令就是:

mysql-nt install mysql5

完毕后,在运行里运行REGEDIT,打开WINDOWS注册表编辑器,在HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\项目找到你刚才手动安装的服务,

我这里是mysql2。打开,修改下面的ImagePath数值。

你一般将会看到"D:\mysql\bin\mysqld-nt" mysql2类似的数值。

在mysql-nt"和mysql2之间加入my.ini的路径信息,格式为:

--defaults-file="d:\mysql\my.ini"

其中粗体部分替换你的正确的路径,

修改完毕后数据数值一般是类似这个样子:

"D:\mysql\bin\mysqld-nt"
--defaults-file="d:\mysql\my.ini" mysql2

确定,退出注册表编辑器。

然后就可以正常启动mysql2服务了,在CMD窗口下输入命令:

net start mysql2

一般应能正常启动了。

我的经历, 按以上配置好后, 我无法同时启动两个MYSQL服务, 经研究, 原因是

MYSQL5.1把DATA文件夹分离出来, 放在datadir="C:/ProgramData/MySQL/MySQL Server 5.1/Data/", 要修改其中一个MY.INI配置, 把DATA文件夹放在另一个不同的地方, 就可以了.

Saturday, May 30, 2009

a javascript desktop web application

this is amazing:

http://www.jsdesk.com/

Tuesday, May 19, 2009

Medicare levy surcharge

I asked some of my friends and it seems few of them know this 'Medicare levy surcharge' thing. Below is the explanation from ato website:

What is the Medicare levy surcharge (MLS)?

Individuals and families on incomes above the MLS thresholds, who do not have private patient hospital cover pay MLS for any period during 2007-08 that they did not have this cover.

We calculate MLS at the rate of 1% of your taxable income. The MLS is in addition to the 1.5% Medicare levy.

http://www.ato.gov.au/individuals/content.asp?doc=/content/7128.htm

Friday, April 3, 2009

Web database design

I believe most of general datbase design principles apply to web database design as well. However, i also believe web database design should have some specific. No matter all, database design is an old subject in computer science while web application, compared with database, is a pretty new area.

I think the biggest headache to web developers is finding a balance between redundancy and normalization, etc, speed and space. Redundancy can minimize the database query times and the need to join tables. However, this obviously violates the 3rd normalization principle, the school theory of database design.

Personally, i don't mind to have some redundancy in my database. But there is one rule: only the redundent information can let you uniquely identify a row, which means, with that redundent field, you can have construct a unique key for the table.

Let's explain with an example. Suppose we have mobile subscription services. Each service have a shortcode. To subscribe these services, a user can send a signup keyword to a shortcode. Obviously, shortcode and signup keyword must be unique. However, one service can have variety of signup keywords.

The shortcode table may be like this
id, shortcode, country_id

The campaign table is
id, name, shortcode_id

The signup keyword table is
id, keyword, campaign_id

Now if a user send a keywork to a shortcode, i need to find out which campaign he is going to subscribe. Based on the above tables, i cannot uniquely identify a keyword, and then find out the campaign. In this situation, i don't mind adding a shortcode_id to the keyword table, so that with keyword and shortcode, we can uniquely identify the keyword, and then identify the campaign.