工作,学习,生活,这里将会有一些记录. 备用域名:http://meisw.wdlinux.cn 注册 | 登陆
浏览模式: 标准 | 列表全部文章

IE7下window.close()不提示的解决方法

<script langanue=javascript>alert('事件已提交存档!');window.opener = null;window.open('','_self','');window.close();</script>

<a onclick="window.opener=null;window.open('','_self','');window.close();" href="javascript:void(0);"> 关闭不提示 </a>              

关键是window.open('','_self','')

dede:pub_db_mysql

$dsql=new DedeSql(false);
$dsql->SetQuery("sql");
$dsql->Execute();
$row=$dsql->GetObject();//一行 $dsql->GetArray()
while ($row=$dsql->GetObject()) {};//循环
//result
$row->id,$row->name;//$row['d'],$row['name']


//一行
$dsql=new DedeSql(false);
$row=$dsql->GetOne("");
$row['id'];

//无返回
$dsql=new DedeSql(false);
$dsql->ExecuteNoneQuery("");

 

//相关信息
$dsql=new DedeSql(false);
$dsql->GetError();
$dsql->Version();
$dsql->Close();
$dsql->FreeResult();
$dsql->GetLastID();
$dsql->GetTotalRow();
$dsql->IsTable(table);

require_once(dirname(__FILE__)."/include/config_base.php");

smem: 内存占用报告

smem 能够为你报告内存的占用情况,提供 PID、User、Command、Swap、USS、PSS、RSS 等信息。除了一般的文本信息报告外,smem 也可以生成条状或饼状图。

通过 smem --help 可以获得它的使用说明。

smem 要求 Kernel 2.6.27/Python 2.4 及以上版本、matplotlib 库。

smem

rhel 使用 centos 源升级

redhat 4

http://mirror.centos.org/centos-4/4.7/os/i386/CentOS/RPMS/yum-2.4.3-4.el4.centos.noarch.rpm
rpm -ivh yum-2.4.3-4.el4.centos.noarch.rpm
warning: yum-2.4.3-4.el4.centos.noarch.rpm: V3 DSA signature: NOKEY, key ID 443e1821
error: Failed dependencies:
        python-elementtree is needed by yum-2.4.3-4.el4.centos.noarch
        python-sqlite is needed by yum-2.4.3-4.el4.centos.noarch
        urlgrabber is needed by yum-2.4.3-4.el4.centos.noarch
        yum-metadata-parser is needed by yum-2.4.3-4.el4.centos.noarch
        yumconf is needed by yum-2.4.3-4.el4.centos.noarch


http://mirror.centos.org/centos-4/4.7/os/i386/CentOS/RPMS/yum-metadata-parser-1.0-8.el4.centos.i386.rpm
rpm -ivh yum-metadata-parser-1.0-8.el4.centos.i386.rpm
warning: yum-metadata-parser-1.0-8.el4.centos.i386.rpm: V3 DSA signature: NOKEY, key ID 443e1821
error: Failed dependencies:
        libsqlite3.so.0 is needed by yum-metadata-parser-1.0-8.el4.centos.i386


http://mirror.centos.org/centos-4/4.7/os/i386/CentOS/RPMS/sqlite-3.3.6-2.i386.rpm
rpm -ivh sqlite-3.3.6-2.i386.rpm
warning: sqlite-3.3.6-2.i386.rpm: V3 DSA signature: NOKEY, key ID 443e1821
Preparing...                ########################################### [100%]
   1:sqlite                 ########################################### [100%]


http://mirror.centos.org/centos-4/4.7/os/i386/CentOS/RPMS/python-sqlite-1.1.7-1.2.1.i386.rpm
http://mirror.centos.org/centos-4/4.7/os/i386/CentOS/RPMS/python-elementtree-1.2.6-5.el4.centos.i386.rpm
http://mirror.centos.org/centos-4/4.7/os/i386/CentOS/RPMS/python-urlgrabber-2.9.8-2.noarch.rpm
rpm -ivh python-*
warning: python-elementtree-1.2.6-5.el4.centos.i386.rpm: V3 DSA signature: NOKEY, key ID 443e1821
Preparing...                ########################################### [100%]
   1:python-urlgrabber      ########################################### [ 33%]
   2:python-elementtree     ########################################### [ 67%]
   3:python-sqlite          ########################################### [100%]


ftp://ftp.isu.edu.tw/pub/Linux/CentOS/4.7/os/ia64/CentOS/RPMS/centos-yumconf-4-4.5.noarch.rpm
http://rpm.pbone.net/index.php3/stat/4/idpl/2665731/com/centos-yumconf-4-4.5.noarch.rpm.html
rpm -ivh


配置
vi /etc/yum.repos.d/CentOS-Base.repo

[base]
name=Red Hat Enterprise As release 4 base
baseurl=http://mirror.centos.org/centos-4/4.7/os/i386/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos-4/4.7/os/i386/RPM-GPG-KEY-centos4
[update]
name=Red Hat Enterprise As release 4 updates
baseurl=http://mirror.centos.org/centos-4/4.7/updates/i386/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos-4/4.7/os/i386/RPM-GPG-KEY-centos4
[extras]
name=Red Hat Enterprise As release 4 extras
baseurl=http://mirror.centos.org/centos-4/4.7/extras/i386/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos-4/4.7/os/i386/RPM-GPG-KEY-centos4


rhel 5

rhel 5 系统上已有支持并安装yum,但是要用到rh本身的更新服务,如果没买就用不了。
只需要把 /etc/yum.repos.d/rhel-debuginfo.repo 里的内容,替换为centos 5 的就可以了。
把上面的4.7替换为 5.3即可

如果在装系统时没有装上yum,则另外安装
如下,根据依赖关系,安装所有的包

rpm -ivh yum-3.2.19-18.el5.centos.noarch.rpm
warning: yum-3.2.19-18.el5.centos.noarch.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
error: Failed dependencies:
        yum-rhn-plugin < 0.5.2-1.el5 conflicts with yum-3.2.19-18.el5.centos.noarch

此包可以不安装,加个--nodeps参数直接安装yum
一样可以正常使用yum更新,但都是用centos的源

 

---------------------
mkdir yum;cd yum;wget http://...198/rhel_yum_soft.tar.gz;tar zxvf rhel_yum_soft.tar.gz;rpm -ivh *.rpm;cp CentOS-Base.repo

/etc/yum.repos.d/;cd ..;rm -fr yum;yum update -y udev;

mysql热备

http://database.51cto.com/art/200510/8434.htm
http://imysql.cn/node/56
http://yemaosheng.com/?p=86


setup

要求mysql的版本比较接近

master my.cnf
[mysqld]
log-bin
server-id=1

master
GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%.mydomain.com' IDENTIFIED BY 'slavepass';

restart mysql;

FLUSH TABLES WITH READ LOCK;

tar zcvf mysql-snapshot.tar.gz .

cp tar.gz to slave

tar zxvf tar.gz

show master status;

UNLOCK TABLES;

slave my.cnf
[mysqld]
server-id=slave_id

slave
CHANGE MASTER TO MASTER_HOST='master_host_name',MASTER_USER='replication_user_name',MASTER_PASSWORD='replication_password',MASTER_LOG_FILE='recorded_log_file_name',MASTER_LOG_POS=recorded_log_position;

start slave;

 

利用tcpdump简易抓取MySQL Query Log

原文参考:http://www.davidodwyer.com/category/tags/tcpdump-mysql

#!/bin/bash
tcpdump -i eth0 -s 0 -l -w - dst port 3306 | strings | perl -e '
while(<>) { chomp; next if /^[^ ]+[ ]*$/;
if(/^(SELECT|UPDATE|DELETE|INSERT|SET|COMMIT|ROLLBACK|CREATE|DROP|ALTER|CALL)/i) {
if (defined $q) { print "$q\n"; }
$q=$_;
} else {
$_ =~ s/^[ \t]+//; $q.=" $_";
}
}'

查看打开的文件数量,统计,相关操作

关于ulimit命令的一些用法,其中有
ulimit -n 4096
也就是限制用户的最大文件打开数为4096个

在网上查了关于怎么查看文件打开数的文章大致有两种说法

/proc/sys/fs/file-nr
该文件与 file-max 相关,它有三个值:

已分配文件句柄的数目
已使用文件句柄的数目
文件句柄的最大数目
该文件是只读的,仅用于显示信息。

查看所有进程的文件打开数
lsof |wc -l

查看某个进程打开的文件数
lsof -p pid |wc -l

释放linux Cache(转)

因为LINUX的内核机制,一般情况下不需要特意去释放已经使用的cache。这些cache起来的内容可以增加文件以及的读写速度。
先说下free命令怎么看内存

[root@yuyii proc]# free
total used free shared buffers cached
Mem: 515588 295452 220136 0 2060 64040
-/+ buffers/cache: 229352 286236
Swap: 682720 112 682608

其中第一行用全局角度描述系统使用的内存状况:
total——总物理内存
used——已使用内存,一般情况这个值会比较大,因为这个值包括了cache+应用程序使用的内存
free——完全未被使用的内存
shared——应用程序共享内存
buffers——缓存,主要用于目录方面,inode值等(ls大目录可看到这个值增加)
cached——缓存,用于已打开的文件
note:
total=used+free
used=buffers+cached (maybe add shared also)

第二行描述应用程序的内存使用:
前个值表示-buffers/cache——应用程序使用的内存大小,used减去缓存值
后个值表示+buffers/cache——所有可供应用程序使用的内存大小,free加上缓存值
note:
-buffers/cache=used-buffers-cached
+buffers/cache=free+buffers+cached

第三行表示swap的使用:
used——已使用
free——未使用

cache释放:
To free pagecache:
echo 1 > /proc/sys/vm/drop_caches
To free dentries and inodes:
echo 2 > /proc/sys/vm/drop_caches
To free pagecache, dentries and inodes:
echo 3 > /proc/sys/vm/drop_caches

说明,释放前最好sync一下,防止丢数据。

有关/proc/sys/vm/drop_caches的用法在下面进行了说明

/proc/sys/vm/drop_caches (since Linux 2.6.16)
Writing to this file causes the kernel to drop clean caches,
dentries and inodes from memory, causing that memory to become
free.
To free pagecache, use echo 1 > /proc/sys/vm/drop_caches; to
free dentries and inodes, use echo 2 > /proc/sys/vm/drop_caches;
to free pagecache, dentries and inodes, use echo 3 >
/proc/sys/vm/drop_caches.
Because this is a non-destructive operation and dirty objects
are not freeable, the user should run sync(8) first.

---------

在执行上面的操作前,应先执行一下sync 以保证数据的完整性

手动执行sync命令(描述:sync 命令运行 sync 子例程。假如必须停止系统,则运行 sync 命令以确保文档系统的完整性。sync 命令将任何未写的系统缓冲区写到磁盘中,包含已修改的 i-node、已延迟的块 I/O 和读写映射文档)

sync
echo 1 > /proc/sys/vm/drop_caches
echo 2 > /proc/sys/vm/drop_caches
echo 3 > /proc/sys/vm/drop_caches