2013年6月月 发布的文章

MySQL手册已经悄悄移除了GPL许可证

刚刚引起我们注意的是 MySQL 的手册已经修改了授权许可证,这是从 MySQL 5.5.30 到 5.5.31 时做的改动,该改动影响源码包中的 man 文件夹里的所有页面。
老的手册遵循 GPLv2 许可证(MySQL 5.5.30 或者更早版本):
This documentation is free software; you can redistribute it and/or modify it only under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License.
而新的手册页面(MySQL 5.5.31 或者更新版本)则采用如下授权协议:
This software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is prohibited.
此举明显的显示出 Oracle 非常不友善的行为。新的许可证跟 GPL 差别巨大,并且明确表达不再使用 GPL 许可证。
oracle你这是要闹哪样啊???
 

利用hdfs搭建网盘–数据模型设计

先阐述下利用hdfs搭建网盘的思路:
(1)、首先要搭建hadoop集群,确保该集群正常运行
(2)、通过API访问文件到存储在hdfs中的文件,能对文件进行增删改查
(3)、文件的其他结构化信息,,比如:文件名称,上传时间,所属用户、文件类型等信息,需要存储在数据库里,我们使用mysql
(4)、用户需要通过操作界面来访问网盘系统,而不是直接操作hdfs,这里采用java、struts2框架来实现web端开发
(5)、有用户系统,存储用户相关信息,另外hdfs中文件存放的路径也和用户有直接关系
网盘系统的截图:http://pan.baidu.com/share/link?shareid=3253971941&uk=772112791
第一点已经在《Hadoop集群搭建详细简明教程》里详细写明步骤了,再次就不再提了
第二点已经在《利用HDFS java API增删改查操作》里详细阐述了
这篇文章先阐述下第三、第五点
网盘数据模型的设计,以及mysql在linux下的安装
网盘数据模型的设计:

file_info

file_info


user

user


tables

tables


目前只用到这file_ifno,user这两个表
mysql在linux:
我是在《Hadoop集群搭建详细简明教程》中搭建好的hadoopm主机上,通过yum安装的mysql,并设置mysql密码

yum install mysql
yum install mysql-server
yum install mysql-devel
chgrp -R mysql /var/lib/mysql
chmod -R 770 /var/lib/mysql
service mysqld start
mysql
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('secret_password');

PS:设置密码的时候可能会报错:ERROR 1372 (HY000): Password hash should be a 41-digit hexadecimal number
可通过这个命令:select password(‘root’);得知root的 41-digit是什么
设置mysql开机启动:

chkconfig --levels 345 mysqld on

相关参考资料:
1、linux下安装mysql
2、设置用户
http://www.hackbase.com/tech/2011-09-09/65234.html
yum install mysql
http://www.cnblogs.com/xiaochaohuashengmi/archive/2011/10/16/2214272.html
3、远程连接
http://www.cnblogs.com/smallstone/archive/2010/04/29/1723838.html
4、创建数据库–奇怪的问题:必须得使用特别奇怪的引号,否则不生效
http://tdcq.iteye.com/blog/363955
http://blog.sina.com.cn/s/blog_5dc960cd0100ea2h.html
5、在数据库上创建表
http://www.51cto.com/html/2005/1129/12524.htm
6、mysql中文乱码
http://www.2cto.com/database/201108/101151.html
7、修改表结构
http://database.51cto.com/art/201005/201148.htm
8、2007-07-20 10:59 在mysql中查询一个数据库中的所有表
http://hi.baidu.com/aigyoo/item/d56a8c01dcb50c10cd34eacf
9、mysql查看表结构命令
http://www.blogjava.net/etlan/archive/2007/07/12/129794.html

Linux配置IP

Linux配置IP
先执行命令:

ifconfig

如果没有ip,则通过配置文件进行ip配置。
执行命令:

cd /etc/sysconfig/network-scripts
vi ifcfg-eth0

将其修改为如下所示结果:

DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT="yes"
IPADDR=172.21.34.1
NETMASK=255.255.252.0
GATEWAY=172.21.32.1

然后保存,重启网卡(service network restart)。
如果重启网卡报eth0 failed。
则执行以下操作:

ifconfig -a

如果显示的结果中有eth1,则接着执行:

cd /etc/sysconfig/network-scripts/
mv ifcfg-eth0 ifcfg-eth1
vi ifcfg-eth1

将其内容改为:

DEVICE="eth1"
NM_CONTROLLED="yes"
ONBOOT="yes"
IPADDR=172.21.34.1
NETMASK=255.255.252.0
GATEWAY=172.21.32.1

然后保存,接着重启网卡。

检测java方法执行时间

在方法开始处加上第一句
long a = System.currentTimeMillis();
在要监测的点加上下面这句:
System.out.println(“监测的时间:”+(System.currentTimeMillis()-a)/1000f+” 秒 “);
就OK了!