修复Ubuntu Natty 64位 在DELL OptiPlex 790 机器上无法重启的问题 

这个坑爹的问题,在我拿到公司刚配的DELL OptiPlex 790型号的电脑的当天就发现了~当我兴冲冲的安装好最新的Ubuntu 11.04 Natty,打好最新的内核补丁,我发现重启后,机器没反应了。只能强制关机了~

我发现这可能是一个bug,我先是在Ubuntu的邮件列表里面提出了问题,果然很多人有这个问题,不仅仅是DELL OptiPlex 790的问题,还有DELL OptiPlex 的其他64位机型.

之后,我便向ubuntu 提交了这个bug,见:https://bugs.launchpad.net/ubuntu/+source/linux/+bug/819260

等啊等,这个bug一直没有得到修复。直到几天前,一个patch 解决了这个问题。现在只需要下载最新的linux kernel 源码,打入这个patch.编译并安装使用上该内核。重启就不会再假死拉~

下载该patch(感谢Leann Ogasawara),地址:http://ftp.xiazhengxin.name/xzx/patch/0004-UBUNTU-SAUCE-x86-reboot-Make-Dell-Optiplex-790-use-r.patch

下载最新的Linux kernel (3.0.4),地址:http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.0.4.tar.bz2

解压内核,进入目录:
1.打入重启补丁:
patch arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c /path/to/0004-UBUNTU-SAUCE-x86-reboot-Make-Dell-Optiplex-790-use-r.patch

2.编译内核:
make allyesconfig
生成临时.config 文件。


使用Ubuntu 的.config 文件编译,一般位于/boot/下,如下:
sharl@sharl-laptop:~$ ls /boot/config* -lh
-rw-r--r-- 1 root root 135K 2011-08-30 05:58 /boot/config-2.6.38-11-generic
-rw-r--r-- 1 root root 135K 2011-04-29 05:13 /boot/config-2.6.38-9-generic

复制过来,覆盖
cp /boot/config-X.X.XX-XX-generic ./.config

接来来,开始编译(时间很长~)
make

3.编译完成后,打成debian 包.
首先安装工具包:
sudo apt-get install kernel-package

之后,打包(时间也很长):
fakeroot make-kpkg --initrd --append-to-version=-by-sharl kernel-image kernel-headers

完成之后。就会在源码目录的上层目录里面发现,生成的deb包.
4.安装内核.
依次安装 linux-image、linux-headers包.
dpkg -i linux-image*
dpkg -i linux-headers*

5.关机.(现在重启还没好~)
6.再开机即可。

至此,我的DELL OptiPlex 790 就可以正常的重启拉~

注:
1.如果你不想自己重新编译内核,这里有我编译好的.可供下载.
http://ftp.xiazhengxin.name/xzx/linux-kernel/

2.DELL 其他机型重启内核补丁下载,见:
http://people.canonical.com/~ogasawara/ ... ot-quirks/

3.编译内核时,参考了Ubuntu官方文档,地址:
https://help.ubuntu.com/community/Kernel/Compile
[ ] ( 1904 次浏览 ) 永久链接 ( 3 / 2587 )
在Ubuntu 下导入CyanogenMod 的模块项目到Eclipse 

其实,这篇文章着实不应该发布在我的GNU/Linux学习站,因为这和GNU/Linux应该没有半毛钱关系~不过又实在没地方可放,所以只能发表于此了~(如果非要和GNU/Linux车上点关系,那就是是在Ubuntu下操作的 囧rz)

好了,言归正传。很多Android开发者都会或多或少的在现有项目的基础上进行二次开发,而我的工作则是基于著名的第三方Android ROM - CyanogenMod 进行的。

比如,改进下短信模块(MMS),改善下拨号界面(Contacts)等等,这个时候我就需要导入CM的单个模块到我的IDE(即Eclipse Platform)中。

一般的做法是,在Eclipse 中新建一个Android 项目,然后勾选掉“使用默认路径”,选中“使用已存在的路径”,再定位到指定模块的目录(如src/packages/apps/Mms),就可以导入了。

不过,这样的做法会有一个问题,那就是Eclipse的Egit不会认出该模块项目下的.git,也就是说我不能在导入的这个项目上使用版本控制。这的确很坑爹~

但是,这个方法也是
CM的官方WIKI(http://wiki.cyanogenmod.com/wiki/Loading_source_in_eclipse)

Android 官方的文档(http://source.android.com/source/using-eclipse.html)
里面建议的做法。

不过我本人极力的不推荐那样做,特别是前者,除了上面说到的没有GIT之外,它的.classpath 文件还会在你的项目下新增一堆用不到的文件夹。

好在,现在我找到了一个更好的办法~那就是:

1.打开Eclipse SDK.
2.选择菜单 "File"->"Import From".
3.选择GIT项下的 "From existed GIT Project".
4.点击 "Add",浏览到要导入模块的目录,如Mms.
5.点击 "Refresh",这时候会显示出 Mms.git,确定即可。
6.选择 "Import as General Project",下一步即可(要确保项目根目录下没有.project文件).
7.点击 "Finish".这个时候项目已经被导入进Eclipse了。不过还没完。
8.下载我事先准备好的模板(http://ftp.xiazhengxin.name/xzx/etc/pre-standard-template-for-android-project.7z),解压,覆盖至项目根目录下。
9.先 “Close Project”,再 "Open Project"下,最好在 "Refresh" 下。
10.右击项目,选择右键菜单 "Android Tools" -> "Fix Project Property".
11.你会发现,一个带有GIT的、可编译的CM模块项目回来了~

注:打开我提供的预模板,其实里面一共就三个文件: .project、.classpath、default.properties。
其实这些文件都是我之前以"Android Project"方式导入模块项目时,自动生成的。只不过为了以"GIT Project" 方式导入,预先删除了。待导入之后,又放进来了。

原理就是这样。
[ ] ( 2026 次浏览 ) 永久链接 ( 2.9 / 2593 )
升级安装 Hiawatha 7.6、nginx 1.1.1 和 Varnish Cache 3.0.1 RC1 

本周我所使用的web server —— Hiawatha 发布了7.6的版本,重写了关于防止SQL注入方面的模块,官方推荐升级标记为低。考虑到稳定性,我决定还是跟进,因为hiawatha 并不常更新。

还有就是我所使用的缓存服务器varnish 也放出了3.0.1的测试版 RC1,考虑到前一版本的varnishadm 有点问题,我也打算更新到该版本。

最后就是nginx 发布了1.1.1的光棍版,本来我用1.0.4版用的好好的,唯一不爽的就是时区总是不对。我怀疑是在编译安装时被定义死了,所以我便打算重新编译一个版本,看看能不能修复这个问题。

首先,停掉相关所有服务。
killall hiawatha
killall nginx
killall varnishd

删除所有旧程序,备份配置文件。

现在,开始安装新版本。首先是hiawatha.
下载源码包(http://www.hiawatha-webserver.org/files/hiawatha-7.6.tar.gz),解压,进入目录:

我的configure:
[root@PowerPC hiawatha-7.6]# ./configure \
> --prefix=/usr/local/hiawatha \
> --exec-prefix=/usr/local \
> --sysconfdir=/etc/sysconfig \
> --localstatedir=/var \
> --disable-largefile \
> --enable-chroot \
> --enable-command \
> --disable-ipv6 \
> --disable-monitor \
> --disable-ssl

检查依赖,没有问题,接下来make && make install安装.一切顺利。之后,覆盖掉新生成的配置文件即可。

便可以启动hiawatha服务器了。

接来下是nginx,下载源码包(http://nginx.org/download/nginx-1.1.1.tar.gz),解压,进入目录:

我的configure:
[root@PowerPC nginx-1.1.1]# ./configure \
> --prefix=/usr/local/nginx \
> --sbin-path=/usr/local/sbin/nginx \
> --conf-path=/etc/sysconfig/nginx/nginx.conf \
> --error-log-path=/var/log/nginx/error.log \
> --pid-path=/var/run/nginx.pid \
> --lock-path=/tmp/nginx.lock \
> --user=http \
> --group=web \
> --with-select_module \
> --with-poll_module \
> --with-http_image_filter_module \
> --with-http_dav_module \
> --with-http_flv_module \
> --with-http_gzip_static_module \
> --without-http_ssi_module \
> --without-http_auth_basic_module \
> --without-http_geo_module \
> --without-http_rewrite_module \
> --without-http_proxy_module \
> --without-http_fastcgi_module \
> --without-http_uwsgi_module \
> --without-http_scgi_module \
> --http-log-path=/var/log/nginx/access.log \
> --http-client-body-temp-path=/tmp/nginx/request \
> --without-mail_pop3_module \
> --without-mail_imap_module \
> --without-mail_smtp_module \
> --without-pcre

检查依赖,没有任何问题。之后configure给出了编译概况,见下:

Configuration summary
+ PCRE library is disabled
+ OpenSSL library is not used
+ md5: using system crypto library
+ sha1 library is not used
+ using system zlib library

nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/sbin/nginx"
nginx configuration prefix: "/etc/sysconfig/nginx"
nginx configuration file: "/etc/sysconfig/nginx/nginx.conf"
nginx pid file: "/var/run/nginx.pid"
nginx error log file: "/var/log/nginx/error.log"
nginx http access log file: "/var/log/nginx/access.log"
nginx http client request body temporary files: "/tmp/nginx/request"


确认一下,没有任何问题,make && make install 编译安装至指定目录。然后在恢复下配置文件,即 nginx.conf 文件。便可以启动nginx 服务器了~

最后就是varnish cache 了,下载源码包(http://repo.varnish-cache.org/source/varnish-3.0.1-rc1.tar.gz),解压,进入目录:

我的configure:
[root@PowerPC varnish-3.0.1-rc1]# ./configure \
> --prefix=/usr/local/varnish \
> --exec-prefix=/usr/local \
> --sysconfdir=/etc/sysconfig \
> --localstatedir=/var \
> --disable-largefile

检查依赖,没有问题,之后便编译安装 make && make install.完了之后就是恢复下之前备份的配置文件,即 default.vcl 文件.

一切OK后。便可以启动varnish 服务器了。

试了一下,所有网站访问正常。唯一的问题……就是nginx,肿么时区还是UTC?为神马??晕了~
[ ] ( 1904 次浏览 ) 永久链接 ( 3.1 / 2411 )
CentOS下改变系统和nginx的时区 

我的VPS是在美国的,所以默认时区当然不可能是中国标准时间(CST),我也一直没改。不过这几天,我发现了问题,就是我的nginx是使用的我系统的默认时区(UTC),而我是使用nginx做我的ftp用户目录文件的展示的,也就是说,我上传文件的时间和用户在nginx上看到的时间是不吻合的,之间相差了8个小时~

这的确很坑爹~我决定把时区改回来。在CentOS下,有tzselect命令可以改。直接运行即可:
[root@PowerPC ~]# tzselect
Please identify a location so that time zone rules can be set correctly.
Please select a continent or ocean.
1) Africa
2) Americas
3) Antarctica
4) Arctic Ocean
5) Asia
6) Atlantic Ocean
7) Australia
8) Europe
9) Indian Ocean
10) Pacific Ocean
11) none - I want to specify the time zone using the Posix TZ format.
##选择所在洲
#? 5
Please select a country.
1) Afghanistan 18) Israel 35) Palestine
2) Armenia 19) Japan 36) Philippines
3) Azerbaijan 20) Jordan 37) Qatar
4) Bahrain 21) Kazakhstan 38) Russia
5) Bangladesh 22) Korea (North) 39) Saudi Arabia
6) Bhutan 23) Korea (South) 40) Singapore
7) Brunei 24) Kuwait 41) Sri Lanka
8) Cambodia 25) Kyrgyzstan 42) Syria
9) China 26) Laos 43) Taiwan
10) Cyprus 27) Lebanon 44) Tajikistan
11) East Timor 28) Macau 45) Thailand
12) Georgia 29) Malaysia 46) Turkmenistan
13) Hong Kong 30) Mongolia 47) United Arab Emirates
14) India 31) Myanmar (Burma) 48) Uzbekistan
15) Indonesia 32) Nepal 49) Vietnam
16) Iran 33) Oman 50) Yemen
17) Iraq 34) Pakistan
##选择所在国家
#? 9
Please select one of the following time zone regions.
1) east China - Beijing, Guangdong, Shanghai, etc.
2) Heilongjiang (except Mohe), Jilin
3) central China - Sichuan, Yunnan, Guangxi, Shaanxi, Guizhou, etc.
4) most of Tibet & Xinjiang
5) west Tibet & Xinjiang
##选择所在城市区域
#? 1

The following information has been given:

China
east China - Beijing, Guangdong, Shanghai, etc.

Therefore TZ='Asia/Shanghai' will be used.
Local time is now: Sat Aug 13 19:32:00 CST 2011.
Universal Time is now: Sat Aug 13 11:32:00 UTC 2011.
Is the above information OK?
1) Yes
2) No
##确认修改
#? 1

You can make this change permanent for yourself by appending the line
TZ='Asia/Shanghai'; export TZ
to the file '.profile' in your home directory; then log out and log in again.

Here is that TZ value again, this time on standard output so that you
can use the /usr/bin/tzselect command in shell scripts:
Asia/Shanghai

至此,时区修改完成。

不过我打印了下"date"好像还是没有即时生效?!
又查了下,看来只好手动改了~

首先,删除位于/etc 下的localtime 文件。
rm -rf /etc/localtime

之后,创建一个同名的软连接到/usr/share/zoneinfo/Asia 下的Shanghai文件。
ls -s /etc/localtime /usr/share/zoneinfo/Asia/Shanghai

即可。

查看效果:
[root@PowerPC ~]# ls /etc/local* -lh
lrwxrwxrwx 1 root root 33 Aug 13 19:41 /etc/localtime -> /usr/share/zoneinfo/Asia/Shanghai
[root@PowerPC ~]# date
Sun Aug 21 17:14:19 CST 2011
[root@PowerPC ~]# date -u
Sun Aug 21 09:14:21 UTC 2011
[root@PowerPC ~]#

看,这样一来,时区立马生效了~

不过,系统的时区是改过来了,nginx的时区好像还是UTC.这是肿么回事?

难道要重启生效? killall nginx 杀死nginx进程
再启动,问题依旧。

难道要在配置文件指定? 根据nginx官方wiki(地址:http://wiki.nginx.org/CoreModule#env)的说明,在nginx.conf 里加上一句:

# set timezone
env TZ=CST;

重启,还是不行。

在系统变量里添加$TZ为CST,
export TZ="CST"

重启,依旧不行~

杯具~

在以“nginx change timezone”为关键词搜索的时候,看到了nginx 更新日志里面有这么一行:

*) Feature: now nginx takes into account a time zone change while
reconfiguration on FreeBSD and Linux.


难不成nginx只会在编译时候才会读取系统时区?以后要改变时区只能重新编译???!!

至于你们信不信,反正我是不信~囧rz

针对这个问题,我已经在nginx的官方邮件列表提问了(地址见:http://mailman.nginx.org/pipermail/nginx/2011-August/028562.html),现在只有等官方的回答了~
[ ] ( 3954 次浏览 ) 永久链接 ( 3 / 2474 )
Varnish Cache 升级到3.0后配置文件的改动 

早在N天前,我的varnish cache就升级到了最新的3.0版本,不过由于我的配置文件一直备份的,所以当我每次编译完新版本的varnish cache 后,新生成的配置文件default.vcl 总是被我删掉的。

不过,每次varnish升级,它的配置语言VCL的标准总是有变化,像这次 2.1 到 3.0 也不例外。

这也就导致了每次升级后,varnish可能会不能启动。用户就得去根据新标准去修改老配置文件了~

这次,2.1到3.0的更新,除了官方给出的不同之处外,
见:https://www.varnish-cache.org/docs/trunk/installation/upgrade.html#upgrading-from-varnish-2-1-to-3-0

最大的不同就是增加了"+"这个连接符,而我以前配置文件里连接字符的地方会全部报错,尤其是vcl_error 这个sub块。

为了方便启动,我之前把里面所有的变量都删掉了,直接打印给客户端"ERROR".不过考虑到这样实在是不方便用户排查原因。故而打算,写的更详细一点,就像以前一样~

于是我在varnish cache 的trac(地址:https://www.varnish-cache.org/trac/browser/bin/varnishd/default.vcl)上找到了最新版本3.0里面的vcl_error 写法,替换掉了我之前的那块.

我把两个都贴出来,以做比较~

之前(2.1)的写法:

sub vcl_error {
set obj.http.Content-Type = "text/html; charset=utf-8";
synthetic {"
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>"} obj.status " " obj.response {"</title>
</head>
<body>
<h1>Error "} obj.status " " obj.response {"</h1>
<p>"} obj.response {"</p>
<h3>Guru Meditation:</h3>
<p>XID: "} req.xid {"</p>
<hr>
<p>Varnish cache server</p>
</body>
</html>
"};
return (deliver);
}


现在(3.0)的写法:

sub vcl_error {
set obj.http.Content-Type = "text/html; charset=utf-8";
set obj.http.Retry-After = "5";
synthetic {"
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>"} + obj.status + " " + obj.response + {"</title>
</head>
<body>
<h1>Error "} + obj.status + " " + obj.response + {"</h1>
<p>"} + obj.response + {"</p>
<h3>Guru Meditation:</h3>
<p>XID: "} + req.xid + {"</p>
<hr>
<p>Varnish cache server</p>
</body>
</html>
"};
return (deliver);
}


编辑完后,保存下。进入varnishadm的控制台,
[root@PowerPC ~]# varnishadm -T 127.0.0.1:2000
CLI connected to 127.0.0.1:2000
200
-----------------------------
Varnish Cache CLI 1.0
-----------------------------
Linux,2.6.18-194.8.1.el5.028stab070.5,i686,-sfile,-smalloc,-hcritbit

Type 'help' for command list.
Type 'quit' to close CLI session.

varnish> stop #停止缓存服务器
200
#重新读取新配置文件
varnish> vcl.load one /etc/sysconfig/varnish/varnish/default.vcl
varnish> vcl.load one /etc/sysconfig/varnish/varnish/default.vcl
200
VCL compiled.
varnish> vcl.use one #使用新配置文件
varnish> vcl.use one
200

varnish> start #启动缓存服务器
varnish> start
200
varnish> quit
500
Closing CLI connection

至此,一切完成。
注:话说3.0还增加了vcl_init{} 和 vcl_fini{}两个sub,不知道是做神马用的~
[ ] ( 3305 次浏览 ) 永久链接 ( 2.9 / 2548 )

<< <上一页 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 下一页> >>