Skip to content


查看平均负载的命令

查看平均负载的命令                  有5个可用:

                 tload    能够绘制出负载变化的图形                  uptime   同时显示开机以来的时间                  w        同时显示出已登录的用户                  top      这个对资源占用太高,不建议使用                  cat /proc/loadavg   通过/proc系统信息得到平均负载

        注意:如果你要持续的观察平均负载,建议用 watch uptime              或 watch cat /proc/loadavg

        备注:关于watch:每隔一定时间执行指定的程序,并全屏显示结果                       时间默认是2秒

Posted in Linux 命令, 技术.

Tagged with .


类似web开发的开源手机框架Rhomobile

支持iPhone, Windows Mobile, RIM and Symbian,将来会支持Android ,以类似html标签的方式来编写应用。

 

SugarCRM sample application

Posted in 手机开发平台, 技术.

Tagged with .


sugarcrm

sugarcrm为基于php的开源crm

分为社区版,专业版和企业版,其中社区版为免费使用,和收费版基本一样,工组流和组有差别。

最新版为5.2 http://www.sugarforge.org/content/downloads/downloads.php

中文语言包 http://www.sugarforge.org/frs/?group_id=448

  • 解压并复制文件到SugarCRM安装目录下覆盖原有文件
  • 打开“config”文件
  • 在第196行找到以下代码
  •   array (     ‘en_us’ => ‘US English’,   ), 并更改为   array (     ‘zh_cn’ => ‘简体中文’,     ‘en_us’ => ‘US English’,   ),
    退出系统,然后点击 Options ,选择“简体中文”然后重新登陆…OK!

    Posted in PHP, 技术.

    Tagged with , .


    两个广告代码

    右下角提示窗 兼容ie ff

    http://bbs.blueidea.com/thread-2886823-1-1.html

     

    兼容ie、firefox,多个漂浮不冲突,调用只需两行代码

    http://bbs.blueidea.com/thread-2846202-1-1.html

    Posted in HTML/XHTML/CSS, 技术.

    Tagged with , .


    让tinymce中的链接默认为新窗口方式

    方法一:使用tinymce的函数setupcontent_callback 在内容的开头增加

    function myCustomSetupContent(editor_id, body, doc) {
        body.innerHTML = "" + body.innerHTML;
    }
    
    tinyMCE.init({
        ...
        setupcontent_callback : "myCustomSetupContent"
    });
    方法二:在程序入库前在内容的开头增加
    
    以php为例
    
    $Content = "" +$Content;
    
     
    
    方法三:修改tiny_mce.js文件valid_elements中a属性的默认target属性为_blank
    使用未压缩片的文件是tiny_mce_src.js.
    
    ,a[rel|rev|charset|hreflang|tabindex|accesskey|type|name|href|target
    =_blank|
    
     
    
     
    
    总结:
    tinymce版本为3 0rc1
    
    方法一和二的base方式在FF中有效,IE下需把放在前,并对以后的所有链接都有效,所以效果欠佳。
    
    方法三比较好。

    Posted in JavaScript/DOM/XML, 技术.

    Tagged with , .


    1030-Got error 28 from table handler

    web系统无法登录,用phpmyadmin查看表内容时报”1030-Got error 28 from table handler”

    原因为硬盘没有空间了。

    Posted in Mysql, 技术.

    Tagged with , .


    UCenter Home 1.5 Nginx rewrite

    UCenter Home 1.5 Nginx rewrite http://www.discuz.net/forum-149-1.html

     

     rewrite ^/(space|network)-(.+).html$ /$1.php?rewrite=$2 last;   rewrite ^/(space|network).html$ /$1.php last;   rewrite ^/([0-9]+)$ /space.php?uid=$1 last;

    Posted in Nginx, 技术.

    Tagged with , .


    用jailkit创建一个chroot环境的sftp

    jailkit 官网 http://olivier.sessink.nl/jailkit/

    环境as4 #wget http://olivier.sessink.nl/jailkit/jailkit-2.5.tar.gz #tar zxvf jailkit-2.5.tar.gz #cd jailkit-2.5 #./configure #make #make install

    创建jail环境目录 #mkdir /home/jail 创建初始权限 #jk_init -v -j /home/jail basicshell editors extendedshell netutils ssh sftp scp 上面的斜体字都是可用的服务,可以在/etc/jailkit/jk_init.ini 中找到相应的部分 创建需限制的用户 #groupadd backup #useradd -g backup -m john #passwd john 限制该用户 #jk_jailuser -m -j /home/jail john

    如果遇到错误 ldconfig: Can’t open configuration file /etc/ld.so.conf: No such file or directory 编辑/etc/jailkit/jk_init.ini vi /etc/jailkit/jk_init.ini #增加ldconfig [ldconfig] executables = /sbin/ldconfig regularfiles = /etc/ld.so.conf

    [uidbasics]

    this section probably needs adjustment on 64bit systems

    or non-Linux systems

    regularfiles = /etc/nsswitch.conf /etc/ld.so.conf

    comment = common files for all jails that need user/group information libraries = /lib/libnsl.so.1, /lib64/libnsl.so.1, /lib/libnss.so.2, /lib64/libnss.so.2 regularfiles = /etc/nsswitch.conf #去掉/etc/ld.so.conf增加下面一行

    includesections = ldconfig

    修改完成后相应的passwd如下 #tail /etc/passwd john:x:504:504::/home/jail/./home/john:/usr/sbin/jk_chrootsh

    #cat /home/jail/etc/passwd root:x:0:0:root:/root:/bin/bash john:x:504:504::/home/john:/usr/sbin/jk_lsh

    参考: http://olivier.sessink.nl/jailkit/howtos_chroot_shell.html http://bemike.org/2007/12/14/jailkit.html http://forums.opensuse.org/applications/390698-jailkit-install-problems.html

    Posted in linux 维护优化, 安全, 技术.

    Tagged with , .


    用scponly创建一个chroot环境的sftp

    使用scponly可以使用户只能运行scp / sftp等命令,与rsync、subversion、gftp兼容,对winscp这个open source for Windows的client端支持很好.

    scponly官网 http://sublimation.org/scponly/

    服务器为as4 #wget http://nchc.dl.sourceforge.net/sourceforge/scponly/scponly-4.8.tgz #tar zxvf scponly-4.8.tgz #cd scponly-4.8 #./configure –prefix=/usr/local/scponly –enable-chrooted-binary –enable-winscp-compat –enable-sftp-logging-compat –enable-scp-compat –enable-rsync-compat –enable-passwd-compat #make #make install #echo /usr/local/scponly/sbin/scponlyc >> /etc/shells #make jail

    /usr/bin/install -c -d /usr/local/scponly/bin /usr/bin/install -c -d /usr/local/scponly/man/man8 /usr/bin/install -c -d /usr/local/scponly/etc/scponly /usr/bin/install -c -o 0 -g 0 scponly /usr/local/scponly/bin/scponly /usr/bin/install -c -o 0 -g 0 -m 0644 scponly.8 /usr/local/scponly/man/man8/scponly.8 /usr/bin/install -c -o 0 -g 0 -m 0644 debuglevel /usr/local/scponly/etc/scponly/debuglevel if test “xscponlyc” != “x”; then                        \         /usr/bin/install -c -d /usr/local/scponly/sbin;              \         rm -f /usr/local/scponly/sbin/scponlyc;                 \         cp scponly scponlyc;                            \         /usr/bin/install -c -o 0 -g 0 -m 4755 scponlyc /usr/local/scponly/sbin/scponlyc;      \ fi chmod u+x ./setup_chroot.sh ./setup_chroot.sh   Next we need to set the home directory for this scponly user. please note that the user’s home directory MUST NOT be writeable by the scponly user. this is important so that the scponly user cannot subvert the .ssh configuration parameters.   for this reason, a writeable subdirectory will be created that the scponly user can write into.   Username to install [scponly] larry home directory you wish to set for this user [/home/larry] name of the writeable subdirectory [incoming] incoming ldconfig: /usr/lib/libmcrypt.so.4 is not a symbolic link     creating  /home/larry/incoming directory for uploading files   Your platform (Linux) does not have a platform specific setup script. This install script will attempt a best guess. If you perform customizations, please consider sending me your changes. Look to the templates in build_extras/arch.  – joe at sublimation dot org   please set the password for larry: Changing password for user larry. New UNIX password: BAD PASSWORD: it is too simplistic/systematic Retype new UNIX password: Sorry, passwords do not match New UNIX password: BAD PASSWORD: it is too simplistic/systematic Retype new UNIX password: passwd: all authentication tokens updated successfully. if you experience a warning with winscp regarding groups, please install the provided hacked out fake groups program into your chroot, like so: cp groups /home/larry/bin/groups

    #ll /home/larry/ drwxr-xr-x  2 root  root  4096 11月 10 11:23 bin drwxr-xr-x  2 root  root  4096 11月 10 11:23 etc drwxr-xr-x  2 larry larry 4096 11月 10 11:26 incoming drwxr-xr-x  3 root  root  4096 11月 10 11:23 lib drwxr-xr-x  5 root  root  4096 11月 10 11:23 usr

    larry用户登录后只能在incoming目录里传东西

    创建新用户需在编辑目录里执行setup_chroot.sh #./setup_chroot.sh

    #mkdir /home/larry/dev
    #cp -a /dev/null /home/larry/dev/
    64位系统
    
    # mkdir /home/larry/lib64
    # cp /lib64/ld-linux-x86-64.so.2 /home/larry/lib64/

    参考:http://bbs.chinaunix.net/viewthread.php?tid=785820 http://hi.baidu.com/fengzhenjie/blog/item/2a4b1e7fe072ba0e29388a66.html

    Posted in linux 维护优化, 安全, 技术.

    Tagged with , .


    用squid缓存jsp加速lucene搜索

    前面尝试了使用nginx负载均衡lucene,效果还不错,但更新维护比较麻烦。 搜索来源中大部分是由连接方式过来,所以大部分的页面内容相同,可以使用缓存的方式重复使用。

    方案一:用nginx的proxy stone 方案二:用nginx的ncache 方案三:用Varnish 方案四:用squid

    方案一和方案二: 方案一和二是副本概念不会自动更新缓存,需写脚本来控制 都要使用nginx 的rewrite将html转成jsp 修改jsp中分页等连接地址为html 方案二需修改jsp在header中增加max-age

    尝试结果: jsp的参数超过了10个,但nginx只支持10个,所以不能缓存所有页面,但可以尝试缓存最常用的关键词第一页。 linux上好像没法将文件缓存起来并且没log,以下是windows上error.log

    2008/11/04 16:39:16 [crit] 2828#0: 3 rename() “/proxy_temp/0000000004” to “html/locals.c1gstudio.com/search/” failed (21: Is a directory) while reading upstream, client: 127.0.0.1, server: locals.c1gstudio.com, request: “GET /search/ HTTP/1.1”, upstream: “http://192.168.1.50:8080/search/“, host: “locals.c1gstudio.com” 2008/11/04 16:39:19 [crit] 2828#0: 1 rename() “/proxy_temp/0000000013” to “html/locals.c1gstudio.com/search/result.jsp?keyword=+%E7%BC%96%E8%BE%91&city=0&type=0&do=1” failed (2: No such file or directory) while reading upstream, client: 127.0.0.1, server: locals.c1gstudio.com, request: “GET /search/result.jsp?keyword=+%E7%BC%96%E8%BE%91&city=0&jobtype=0&do=1 HTTP/1.1”, upstream: “http://192.168.1.50:8080/search/result.jsp?keyword=+%E7%BC%96%E8%BE%91&city=0&type=0&do=1“, host: “locals.c1gstudio.com”, referrer: http://locals.c1gstudio.com/search/

    貌似不必rewrite也可缓存。=_=!!!

    方案三: 缓存放在内存里,软件重启后需重新生成,瞬时并发比较大 网卡流量也比较多,性能也比squid差。 参考it流言终结者的比较 IT流言终结者1续篇:varnish vs squid IT流言终结者1:Varnish vs Squid http://www.hiadmin.com/category/service/squid-app/

    方案四: 以前有架设过,改改配置就可以上了。 选择squid2.6stable22,据测试性能稳定。

    架设参考 squid 安装 https://blog.c1gstudio.com/archives/130

    squid.conf中 开1.5G内存,4G硬盘 cache_store_log none access_log none

    refresh_pattern -i .html$  60       25%     240 refresh_pattern -i .htm$   60       25%     240 refresh_pattern -i .jsp$   5       25%     20

    refresh_pattern -i .gif$   1440    50%     2880      ignore-reload refresh_pattern -i .jpg$   1440    50%     2880      ignore-reload refresh_pattern -i .jpeg$  1440    50%     2880     ignore-reload refresh_pattern -i .png$   1440    50%     2880      ignore-reload

    总结: 最终架构是 nginx(80)->squid(81)->tomcat(8080) nginx 跑在80端口代理81 squid 跑81端口代理远程的tomcat (squid跑在80会报access denied,忘改这个了acl Safe_ports port 81) tomcat 在另一台机器上

    jsp中header增加max-age=3600和相应expires,让页面在ie中缓存一小时,squid中缓存5~20分钟。

    目前的负载 跑nginx和squid的 load average: 0.18, 0.14, 0.08 以前是load为1左右 跑tomcat的 load average: 1.57, 1.41, 1.28 以前load为3左右

    现在改动程序只需改动一台机器,结果很满意哈~

     

    Posted in Nginx, Squid/varnish.

    Tagged with , , , .