2009年04月25日

编辑文件:
/usr/lib/gtk-2.0/2.10.0/immodule-files.d/libgtk2.0-0.immodules
把最后一行
"/usr/lib/gtk-2.0/2.10.0/immodules/im-xim.so"
"xim" "X Input Method" "gtk20" "/usr/share/locale" "ko:ja:th:zh"
改为:
"/usr/lib/gtk-2.0/2.10.0/immodules/im-xim.so"
"xim" "X Input Method" "gtk20" "/usr/share/locale" "en:ko:ja:th:zh"

当前用户下运行命令:im-switch -s scim -z default

2009年03月25日

一.权限表
mysql数据库中的3个权限表:user 、db、 host
权限表的存取过程是:
1)先从user表中的host、 user、 password这3个字段中判断连接的IP、用户名、密码是否存在表中,存在则通过身份验证;
2)通过权限验证,进行权限分配时,按照userdbtables_privcolumns_priv的顺序进行分配。即先检查全局权限表user,如果user中对应的权限为Y,则此用户对所有数据库的权限都为Y,将不再检查db, tables_priv,columns_priv;如果为N,则到db表中检查此用户对应的具体数据库,并得到db中为Y的权限;如果db中为N,则检查tables_priv中此数据库对应的具体表,取得表中的权限Y,以此类推。
二.MySQL各种权限(共27个)
(以下操作都是以root身份登陆进行grant授权,以p1@localhost身份登陆执行各种命令。)
1. usage
连接(登陆)权限,建立一个用户,就会自动授予其usage权限(默认授予)。
mysql> grant usage on *.* to ‘p1′@’localhost’ identified by ‘123′;
该权限只能用于数据库登陆,不能执行任何操作;且usage权限不能被回收,也即REVOKE用户并不能删除用户。
2. select
必须有select的权限,才可以使用select table
mysql> grant select on pyt.* to ‘p1′@’localhost’;
mysql> select * from shop;
3. create
必须有create的权限,才可以使用create table
mysql> grant create on pyt.* to ‘p1′@’localhost’;

4. create routine
必须具有create routine的权限,才可以使用{create |alter|drop} {procedure|function}
mysql> grant create routine on pyt.* to ‘p1′@’localhost’;
当授予create routine时,自动授予EXECUTE, ALTER ROUTINE权限给它的创建者:
mysql> show grants for ‘p1′@’localhost’;
+—————————————————————————+
Grants for p1@localhost
+————————————————————————–+
| GRANT USAGE ON *.* TO ‘p1′@’localhost’ IDENTIFIED BY PASSWORD ‘*23AE809DDACAF96AF0FD78ED04B6A265E05AA257′ |
| GRANT SELECT, CREATE, CREATE ROUTINE ON `pyt`.* TO ‘p1′@’localhost’|
| GRANT EXECUTE, ALTER ROUTINE ON PROCEDURE `pyt`.`pro_shop1` TO ‘p1′@’localhost’ |
+————————————————————————————-+
5. create temporary tables(注意这里是tables,不是table)
必须有create temporary tables的权限,才可以使用create temporary tables.
mysql> grant create temporary tables on pyt.* to ‘p1′@’localhost’;
[mysql@mydev ~]$ mysql -h localhost -u p1 -p pyt
mysql> create temporary table tt1(id int);
6. create view
必须有create view的权限,才可以使用create view
mysql> grant create view on pyt.* to ‘p1′@’localhost’;
mysql> create view v_shop as select price from shop;
7. create user
要使用CREATE USER,必须拥有mysql数据库的全局CREATE USER权限,或拥有INSERT权限。
mysql> grant create user on *.* to ‘p1′@’localhost’;
或:mysql> grant insert on *.* to p1@localhost;
8. insert
必须有insert的权限,才可以使用insert into ….. values….
9. alter
必须有alter的权限,才可以使用alter table
alter table shop modify dealer char(15);
10. alter routine
必须具有alter routine的权限,才可以使用{alter |drop} {procedure|function}
mysql>grant alter routine on pyt.* to ‘p1′@’ localhost ‘;
mysql> drop procedure pro_shop;
Query OK, 0 rows affected (0.00 sec)

mysql> revoke alter routine on pyt.* from ‘p1′@’localhost’;
[mysql@mydev ~]$ mysql -h localhost -u p1 -p pyt
mysql> drop procedure pro_shop;
ERROR 1370 (42000): alter routine command denied to user ‘p1′@’localhost’ for routine ‘pyt.pro_shop’
11. update
必须有update的权限,才可以使用update table
mysql> update shop set price=3.5 where article=0001 and dealer=’A’;
12. delete
必须有delete的权限,才可以使用delete from ….where….(删除表中的记录)
13. drop
必须有drop的权限,才可以使用drop database db_name; drop table tab_name;
drop view vi_name; drop index in_name;
14. show database
通过show database只能看到你拥有的某些权限的数据库,除非你拥有全局SHOW DATABASES权限。
对于p1@localhost用户来说,没有对mysql数据库的权限,所以以此身份登陆查询时,无法看到mysql数据库:
mysql> show databases;
+——————–+
| Database |
+——————–+
| information_schema|
| pyt |
| test |
+——————–+
15. show view
必须拥有show view权限,才能执行show create view。
mysql> grant show view on pyt.* to p1@localhost;
mysql> show create view v_shop;
16. index
必须拥有index权限,才能执行[create |drop] index
mysql> grant index on pyt.* to p1@localhost;
mysql> create index ix_shop on shop(article);
mysql> drop index ix_shop on shop;
17. excute
执行存在的Functions,Procedures
mysql> call pro_shop1(0001,@a);
+———+
| article |
+———+
| 0001 |
| 0001 |
+———+
mysql> select @a;
+——+
| @a |
+——+
| 2 |
+——+
18. lock tables
必须拥有lock tables权限,才可以使用lock tables
mysql> grant lock tables on pyt.* to p1@localhost;
mysql> lock tables a1 read;
mysql> unlock tables;
19. references
有了REFERENCES权限,用户就可以将其它表的一个字段作为某一个表的外键约束。
20. reload
必须拥有reload权限,才可以执行flush [tables | logs | privileges]
mysql> grant reload on pyt.* to p1@localhost;
ERROR 1221 (HY000): Incorrect usage of DB GRANT and GLOBAL PRIVILEGES
mysql> grant reload on *.* to ‘p1′@’localhost’;
Query OK, 0 rows affected (0.00 sec)
mysql> flush tables;
21. replication client
拥有此权限可以查询master server、slave server状态。
mysql> show master status;
ERROR 1227 (42000): Access denied; you need the SUPER,REPLICATION CLIENT privilege for this operation
mysql> grant Replication client on *.* to p1@localhost;
或:mysql> grant super on *.* to p1@localhost;
mysql> show master status;
+——————+———-+————–+——————+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+——————+———-+————–+——————+
| mysql-bin.000006 | 2111 | | |
+——————+———-+————–+——————+
mysql> show slave status;
22. replication slave
拥有此权限可以查看从服务器,从主服务器读取二进制日志。
mysql> show slave hosts;
ERROR 1227 (42000): Access denied; you need the REPLICATION SLAVE privilege for this operation
mysql> show binlog events;
ERROR 1227 (42000): Access denied; you need the REPLICATION SLAVE privilege for this operation
mysql> grant replication slave on *.* to p1@localhost;
mysql> show slave hosts;
Empty set (0.00 sec)
mysql>show binlog events;
+—————+——-+—————-+———–+————-+————–+
| Log_name | Pos | Event_type | Server_id| End_log_pos|Info | +—————+——-+————–+———–+————-+—————+
| mysql-bin.000005 | 4 | Format_desc | 1 | 98 | Server ver: 5.0.77-log, Binlog ver: 4 | |mysql-bin.000005|98|Query|1|197|use `mysql`; create table a1(i int)engine=myisam|
……………………………………
23. Shutdown
关闭MySQL:
[mysql@mydev ~]$ mysqladmin shutdown
重新连接:
[mysql@mydev ~]$ mysql
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)
[mysql@mydev ~]$ cd /u01/mysql/bin
[mysql@mydev bin]$ ./mysqld_safe &
[mysql@mydev bin]$ mysql
24. grant option
拥有grant option,就可以将自己拥有的权限授予其他用户(仅限于自己已经拥有的权限)
mysql> grant Grant option on pyt.* to p1@localhost;
mysql> grant select on pyt.* to p2@localhost;
25. file
拥有file权限才可以执行 select ..into outfile和load data infile…操作,但是不要把file, process, super权限授予管理员以外的账号,这样存在严重的安全隐患。
mysql> grant file on *.* to p1@localhost;
mysql> load data infile ‘/home/mysql/pet.txt’ into table pet;
26. super
这个权限允许用户终止任何查询;修改全局变量的SET语句;使用CHANGE MASTER,PURGE MASTER LOGS。
mysql> grant super on *.* to p1@localhost;
mysql> purge master logs before ‘mysql-bin.000006′;
27. process
通过这个权限,用户可以执行SHOW PROCESSLIST和KILL命令。默认情况下,每个用户都可以执行SHOW PROCESSLIST命令,但是只能查询本用户的进程。
mysql> show processlist;
+—-+——+———–+——+———+——+——-+——————+
| Id | User | Host | db | Command | Time | State | Info |
+—-+——+———–+——+———+——+——-+——————+
| 12 | p1 | localhost | pyt | Query | 0 | NULL | show processlist |
+—-+——+———–+——+———+——+——-+——————+
另外,
管理权限(如 super, process, file等)不能够指定某个数据库,on后面必须跟*.*
mysql> grant super on pyt.* to p1@localhost;
ERROR 1221 (HY000): Incorrect usage of DB GRANT and GLOBAL PRIVILEGES
mysql> grant super on *.* to p1@localhost;
Query OK, 0 rows affected (0.01 sec)

–EOF–

2009年03月23日

/etc/mysql/my.cnf

default-character-set=utf8
default-collation=utf8_general_ci

2009年03月17日

Are you using someone else’s backup solution for your MySQL data? Do you care a lot about your data? Are you sure you’re getting a reliable, recoverable backup that’ll work for your business and your application, and won’t impact your critical processes while it runs? Here are ten questions you need to be able to answer:

Does the backup require shutting down MySQL? If not, what is the impact on the running server? Blocking, I/O load, cache pollution, etc?
What technique is used for the backup? Is it mysqldump or a custom product that does something similar? Is it a filesystem copy?
Does the backup system understand that you cannot back up InnoDB by simply copying its files?
Does the backup use FLUSH TABLES, LOCK TABLES, or FLUSH TABLES WITH READ LOCK? These all interrupt processing.
What other effects are there on MySQL? I’ve seen systems that do a RESET MASTER, which immediately breaks replication. Are there any FLUSH commands at all, like FLUSH LOGS?
How does the system guarantee that you can perform point-in-time recovery?
How does the system guarantee consistency with the binary log, InnoDB logs, and replication?
Can you use the system to set up new MySQL replication slaves? How?
Does the system verify that the backup is restorable, e.g. does it run InnoDB recovery before declaring success?
Does anyone stand behind it with support, and guarantee working, recoverable backups? How strong is the legal guarantee of this and how much insurance do they have?
There are a lot of other things a backup solution needs to provide, but these are some of the things I’d require specifically for MySQL, or more so for MySQL than for other types of backups.

Where is this post coming from? Well, I’ve had a couple of frustrating encounters with vendors who sell backup products with some kind of agent for MySQL backup. I am almost never able to get any significant technical detail on how their backups are implemented, and often I can’t even get the most basic information such as “dump or file copy.” Sometimes they tell me to register and download a whitepaper that just has a bullet point “Support for MySQL Databases”. Or “I have to transfer you to the salesperson who covers your region” and I never get to talk to anyone.

Some of them even use the word “proprietary” as if it’s a good thing. In reality, a proprietary, secret backup black-box is unacceptable. MySQL backups are complex and difficult to get right. It is very application-dependent and technology-dependent. Unless I know exactly how it works, I cannot tell the client whether it’ll work for them at all.

So I offer the above list as a way to evaluate your backup provider’s suitability for enterprise-ready backup uses. If you can’t answer these questions, it’s a system that you can’t evaluate seriously, in my opinion.

http://www.mysqlperformanceblog.com/2009/03/03/10-things-you-need-to-know-about-backup-solutions-for-mysql/

2008年12月17日
功能 activemq 5.2.0 jboss messaging 1.4.1 jboss messaging 2.0
状态 稳定 GA alpha
多语言支持(C#,Python) 支持 不支持 预计支持C++
独立启动 不能
嵌入 不能
支持jboss as 能集成 jboss as 5自带 肯定能集成
2008年08月15日

安装软件:sudo apt-get install subversion

建立用户:sudo useradd svn -m

以svn用户登录,建立目录SVN,进去,再:svnadmin create myproj,然后进去编辑那些配置文件,略了。

编辑文件/etc/init.d/svnserve,内容为:
#!/bin/sh
# description: Svnserve auto start-stop script.
# chkconfig: – 20 80
#
SVN_HOME=/usr/bin
SVN_OWNER=svn
SVN_REPO=/home/svn/SVN
if [ ! -f "$SVN_HOME/svnserve" ]
then
    echo "svnserver startup: cannot start"
    exit
fi
case "$1" in
    ’start’)
        su – $SVN_OWNER -c  "$SVN_HOME/svnserve -d -r $SVN_REPO"
        ;;
    ’stop’)
        su – $SVN_OWNER -c  "$SVN_HOME/killall svnserve"
        ;;
    ‘restart’)
        su – $SVN_OWNER -c  "$SVN_HOME/killall svnserve"
        su – $SVN_OWNER -c  "$SVN_HOME/svnserve -d -r $SVN_REPO"
        ;;
esac

然后加执行权限:sudo chmod +x svnserve

进入/etc/rc2.d,打命令:sudo ln -s ../init.d/svnserve S21svnserve

OK了。

2008年07月28日

Adobe的Sean Moore写了篇blog介绍Flex最佳实践,看着有帮助,链接贴过来:http://www.adobe.com/devnet/flex/articles/best_practices_pt1.html
他总结如下:

  • Use workspaces to keep your Flex projects organized.
  • Use a common directory for your Flex workspace in team environments.
  • Follow common naming conventions for Flex project names.
  • Determine your target platform.
  • Use the default "bin-debug" directory.
  • Put your code in the "src" directory.
  • Use object-oriented programming practices for Flex projects.
  • Use a source code control solution.
  • Reference shared SWC libraries using the Flex Library path.
  • Use the libs folder to bundle SWC libraries with your Flex project.
  • Use UpperCamelCasing for MXML file names.
  • Use UpperCamelCasing for ActionScript Class file names.
  • Use UpperCamelCasing for ActionScript Interface file names, and begin the file name with a capitalized letter I.
  • Do not use spaces when naming files!
  • Do not use special characters when naming files.
  • Do not use acronyms or abbreviations.
  • Do not use periods in file names.
  • Use packages to organize and structure your projects codebase.
  • Use the following format for package names: com.seantheflexguy.stringUtils
2008年07月25日

Django官方推荐的部署方式是mod_python,所以,如果没有其他理由,建议用这种部署方法。我参考了官方的文档:

http://www.djangoproject.com/documentation/modpython/。本说明基于Windows平台,其他平台也类似。

1、安装
假设Python和Django已经装好,需要安装的软件是Apache2.2和mod_python3.3,软件版本按照20080725的最新稳定版。

从http://httpd.apache.org/download.cgi下载Win32 Binary including OpenSSL 0.9.8h (MSI Installer): apache_2.2.9-win32-x86-openssl-0.9.8h-r2.msi,安装,基本按默认

就成。

从http://httpd.apache.org/modules/python-download.cgi选择Apache Mod_python 3.3.1下面的Win32 Binaries进去,会进到某个镜像,我这里是

http://apache.mirror.phpchina.com/httpd/modpython/win/3.3.1/,根据Python和Apache的版本选择需要下载的文件,我选的是mod_python-3.3.1.win32-py2.5-

Apache2.2.exe。安装,没什么好说的。

2、应用目录结构
假设开发的应用是flmn.com,文档存在E:/workspace目录下,设计目录结构如下:
flmn
–media
—-admin
——css
——img
——js
—-css
—-img
—-js
–djflmn
—-app1
——__init__.py
——admin.py
——models.py
——views.py
—-__init__.py
—-manage.py
—-settings.py
—-urls.py

解释:整个站点放在E:/workspace/flmn目录下,子目录media用来存静态文件,而djflmn就是Django应用啦,开发应用和平时一样,只是引用的静态文件要用/media/*这样的路径。在media目录里,admin目录是从C:\Python25\Lib\site-packages\django\contrib\admin\media\拷来的admin静态文件,如果你不用Django的admin功能,这个就省了,另外的css、img、js放djflmn应用的静态文件。在djflmn的settings.py里,需要:MEDIA_URL = ‘/media/’ ADMIN_MEDIA_PREFIX = ‘/media/admin/’。

3、配置

打开http.conf,在一堆LoadModule语句后加入:LoadModule python_module modules/mod_python.so。我喜欢用虚拟主机的配置,这样便于配置多个互不影响的站点,

在文件最后找到Include conf/extra/httpd-vhosts.conf,去掉前面的注释#。

打开extra/httpd-vhosts.conf,加入:
<VirtualHost *:80>
    ServerAdmin webmaster@flmn.com
    DocumentRoot "E:/workspace/flmn"
    ServerName www.flmn.com
   
    <Location "/">
        SetHandler python-program
        PythonHandler django.core.handlers.modpython
        SetEnv DJANGO_SETTINGS_MODULE djflmn.settings
        PythonDebug Off
        PythonPath "['E:/workspace/flmn'] + sys.path"
    </Location>
   
    <Location "/media">
        SetHandler None
    </Location>
   
    <Directory "E:/workspace/flmn">
        Options Indexes FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>

</VirtualHost>

这里配置是参考Django的官方网站,不多说了。官方网站上说到这个:PythonOption django.root /mysite,如果你像我一样,直接上来就放在根下,就别PythonOption django.root / 多此一举了,因为我一开始那样配,出了莫名其妙的问题。

最后,为了开发方便,修改C:\Windows\System32\drivers\etc\hosts文件,加入一行:127.0.0.1       www.flmn.com,有朝一日应用上线了,要把这行删了,要不dns不到实际的服务器。

2008年06月23日

我工作上这段在用python开发,说说自己的感受。
  
  首先,对python的总体评价,是非常正面的。
  
  以前用C++开发,用过python和twisted后,再也不想去碰C++了,用python真是太方便了。开发效率大幅提高,生活质量也跟着提高了……
  
  但是,作为一个严肃开发者,python语法还有有点太不严谨了,很多东西,实现起来的逻辑不统一,可以说,没有一个统一的哲学,当然了,造成这种现象的原因肯定是两个字:历史。又要兼容又要发展,最后形成的东西,对于初次接触的人来说,肯定不爽。
  
  我用过c++/java/c#,感觉他们的设计在哲学上比较统一,尤其是后面两个比较年轻的,更是很典范。C++也很古老,但是他的哲学还是很统一,所以,光用历史来说python也是有点开脱的嫌疑。
  
  python3000不知道能有何改观,我没深入研究它的路线图,但是听说解决了一些历史问题,期待着它……
  
  说到web开发,python这块我在看django,感觉他很干净,很内聚,很舒服,公司在用turbogears,我感觉,很恶心,乱七八糟的。我自己的开发逻辑,宁可功能少点,也不能把软件做得乱七八糟。

  如果真是做我自己的网站,我会考虑php的框架symfony,在试用过程中,我觉得它的开发者为广大开发者想了很多,感觉比django成熟,它也从django借鉴了不少东西,当还还借鉴了ror。为什么选symfony呢,因为:php的主机so便宜,python的主机so难觅。

2008年06月05日

其实MySQL一直都是单进程、多线程的工作模式。只是,LinuxThreads并不是真正的线程,因此,这些进程其实还是采用系统调用 clone() 来共享同样的地址空间的。尽管采用 ps 查看的结果看起来是多进程,其实mysqld真正的工作方式还是多线程。