2008年9月27日星期六

vim环境ctags taglist 整合

需要在linux改c程序,所以需要弄下vim的环境.
系统 centos 5.2
安装ctags

yum install ctags

获得taglist

wget "http://www.vim.org/scripts/download_script.php?src_id=7701"
unzip taglist_45.zip
在你的用户目录下创建.vim目录(如/home/gogo407/.vim ; /root/.vim)
分别把taglist_45.zip解压出来的doc,plugin移入.vim文件夹中,如果.vim中已经存在doc和plugin文件夹,则讲doc中的文档和plugin中的插件,移入.vim中的相应位置
修改plugin中的taglist.vim中的76行,添加 let Tlist_Ctags_Cmd = "/usr/bin/ctags"
72 " function is not available, then don't load the plugin.
73 if !exists('*system')
74 echomsg 'Taglist: Vim system() built-in function is not available. ' .
75 \ 'Plugin is not loaded.'
76 let Tlist_Ctags_Cmd = "/usr/bin/ctags"
77 let loaded_taglist = 'no'
78 let &cpo = s:cpo_save
79 finish
80 endif


用cronolog为例子

cd cronolog-1.6.2/
cd src/
ls *.c|ctags -R



准备就绪,我们看看效果

vim cronolog.c
:set nu
:TlistToggle


这个就是我们能看到的图像了
还有一些基本的命令,是我以前没有到的如

ctrl +ww 切换窗口
还有就是最有用的
:help
:help tag

参考资料 :http://www.softpanorama.org/Editors/ctags.shtml

2008年9月26日星期五

系统问题:Set_rtc_mmss: can’t update from 0 to 59

一朋友的服务器频繁的报:Set_rtc_mmss: can’t update from 0 to 59,帮朋友处理下

/usr/bin/rdate -s rdate.darkorb.net 先和标准世界时间同步下 linux下
hwclock -w
date
hwclock --show

把系统时间和cmos时间同步下就可以了!问题解决了。
具体代码

2008年9月16日星期二

nfs优化

参考: IBM的lamp优化文档
每个客户机应该用 rsize=32768,wsize=32768,intr,noatime 挂装远程文件系统,从而确保:

* 使用大的读/写块(数字指定最大块大小,在这个示例中是 32KB)。
* 在挂起时 NFS 操作可以被中断。
* 不持续更新 atime。

对 intr我可是深有感触,查看没有使用intr导致的问题及其处理
下面是起用noatime,并添加到fstab中
/dev/VolGroup00/LogVol00 / ext3 defaults,noatime 1 1
LABEL=/boot /boot ext3 defaults,noatime 1 2
devpts /dev/pts devpts gid=5,mode=620 0 0
tmpfs /dev/shm tmpfs defaults 0 0
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
LABEL=SWAP-hdb2 swap swap defaults 0 0
LABEL=SWAP-hda3 swap swap defaults 0 0

mysql性能之内存

通过最近的工作,发现内存对mysql来讲是相当重要的!以前觉得只要满足mysql的基本需要,就应该没有问题。所谓满足mysql的基本需要,就是基本上没有使用到swap.
而实际上系统cache对mysql的性能也会有比较大的帮助。
以前一台mysql 3G 内存(32系统默认的内存不支持4G以上大内存),在insert 或者update的高峰期,会导致系统负载从1上升到几十,而且这种情况多发生在cache不够用(我们的应用是cache<2500M),同时出现扫表或者建立硬盘临时表的时候。
当给系统的内存加至4G后(cache始终〉3000M),系统负载很少大于1,几乎没有超过2的。
所以我比较迷惑的有两点
1.cache对mysql的帮助?减少硬盘扫描的时间,怎么减少?
2.如何判断多少的cache值才是当前系统的合理值

php之allow_url_fopen

默认的php配置文件中有
allow_url_fopen = On
allow_url_include = Off

很显然,默认配置中是关闭了include远端的php文件,但是还是支持url_open.所以可能还是可以通过一些操作,通过url_fopen实现url_include。这样可能会引发一些webserver的安全问题。
但直接关闭url_fopen可能又会影响一些正常应用。
总之url_fopen和url_include需要稍加注意。

2008年9月9日星期二

怎么样在mysql中建表中使用IDENTITY

  时常有人需要在mysql中使用identity.如
create table admin
(
adminId int not null identity(1000,1),
adminName varchar(40) not null,
adminPass varchar(40) not null,

);

总是identity出错...想请教下为什么? 在mysql数据库下 把identity(1000,1),去掉就行.

可是我语法有错误么?

 从t-sql手册中这里可以了解identity的意思。
 换句话说,其实就是mysql中的auto_increment,详细方法参考这里
 对于问题的解决
 

  create table admin ( adminId int not null auto_increment,adminName varchar(40) not null, adminPass varchar(40) not null ,primary key (adminId) );
  alter table admin AUTO_INCREMENT=1000

  特记录:)

2008年9月8日星期一

linux发行版本号查看

以前不太知道的,但是想知道的

cat /etc/issue
CentOS release 5 (Final)
Kernel \r on an \m

这两个不是同一台:)

cat /etc/redhat-release
CentOS release 4.5 (Final)


cat /proc/version
Linux version 2.6.18-8.el5 (mockbuild@builder4.centos.org) (gcc version 4.1.1 20070105 (Red Hat 4.1.1-52)) #1 SMP Thu Mar 15 19:57:35 EDT 2007


uname -a
Linux db-mysql-1 2.6.18-8.el5 #1 SMP Thu Mar 15 19:57:35 EDT 2007 i686 i686 i386 GNU/Linux


一台centos 4.5
lsb_release -a
LSB Version: :core-3.0-ia32:core-3.0-noarch:graphics-3.0-ia32:graphics-3.0-noarch
Distributor ID: CentOS
Description: CentOS release 4.5 (Final)
Release: 4.5
Codename: Final
另一台centos 5.0
lsb_release -a
LSB Version: :core-3.1-ia32:core-3.1-noarch:graphics-3.1-ia32:graphics-3.1-noarch
Distributor ID: CentOS
Description: CentOS release 5 (Final)
Release: 5
Codename: Final


以前不清楚,标记下:)

2008年9月1日星期一

nfs故障处理

状况: 因为各种原因导致一台nfs不能使用,而以前挂这这nfs的前端web负载节节升高,经过观察发现,每当执行地方这个命令的时候,总是执行不完.
情况类似于Blog ^A jianingy's
解决:
killall -KILL rpciod
杀掉rpcio的话可以解决df堆积的问题,但是不能根除,因为下次执行df的时候rpcio还是会出现.特别是如果你在crond中使用了df的时候.
根本解决,卸载出问题的nfs,如果你出问题的nfs为
222.222.222.222:/opt/nfs
,那你可以直接卸载掉,
umount 222.222.222.222:/opt/nfs
这样执行df的时候就不会再出问题了.
反思:

soft If an NFS file operation has a major timeout then report an I/O error to the calling program. The default is to continue retrying NFS file operations indefinitely.
hard If an NFS file operation has a major timeout then report "server not responding" on the console and continue retrying indefinitely. This is the default.
intr If an NFS file operation has a major timeout and it is hard mounted, then allow signals to interupt the file operation and cause it to return EINTR to the calling program. The default is to not allow file operations to be interrupted.

使用intr应该不会出现类似的问题.不过还好,我们可以解决问题.所以做sa&dba一定要思考严密

linux下切换用户启动服务

在linux用其他用户启动进程
如启动svn服务


#!/bin/sh
su svnuser -c '/opt/svn/bin/svnserve -d -r /opt/www/svnroot'


切换到svnuser这个用户去启动svn服务