根据文件大小删除一个特殊文件名的文件

文件名为不可见字符,不太好删除,使用find命令找出来,是用exec来删除,找文件的办法有多种,这里根据文件的大小来找。
ls -l 显示的文件大小的单位是字节。 find的size的单位默认为block,可以使用c来说明是字节,如下:

find . -size +22156c -exec  rm {} \;

如果find命令不熟悉的话,就不要这么写了,不如先把其他文件移走,删除目录,然后再创建目录,在移动回来,这样要快的多哦

IE 的bug

在很短的时间内连续打开多个IE窗口做网络请求时,容易产生“网页无法显示”的错误,其它浏览器就没有问题,可以使用如下脚本:

cd C:\Program Files\Internet Explorer\

for /L %i in (1,1,15) do iexplore.exe  http://www.baidu.com/

但是使用如下脚本是没有问题的:

cd C:\Program Files\Internet Explorer\

for /L %i in (1,1,15) do iexplore.exe  http://baidu.com/

原因:

http://baidu.com/  是cache的,第一次可能使用的不是cache,但是后来浏览器的第一个访问一定是走cache的,于是没有出问题;

而,http://www.baidu.com/ 是不cache的,启动浏览器后的第一个请求是不能走cache的,于是可能出错

为什么会出错呢 ? 我也不知道了

不知道多次打开都出现在标签页中是否会有这种问题? 那么如何指定IE在标签页中打开呢?(这里不考虑IE6了)

PHP加速器 eaccelerator 缓存原理

通过eaccelerator 可以了解多种进程间共享的技术,参看: mm.c; 我们会发现,在linux上,这里实现了 5 中进程间共享内存的方式供我们选择使用。

linux 上编译PHP加速器: eaccelerator
[eaccelerator-0.9.6.1]# ./configure

checking for sysvipc shared memory support… yes
checking for mmap shared memory support… yes
checking for mmap on /dev/zero shared memory support… yes
checking for anonymous mmap shared memory support… yes
checking for posix mmap shared memory support… no
checking for best shared memory type… sysvipc
checking for spinlock semaphores support… yes
checking for pthread semaphores support… yes
checking for posix semaphores support… no
checking for sysvipc semaphores support… yes
checking for fcntl semaphores support… yes
checking for flock semaphores support… yes
checking for best semaphores type… spinlock

config后的config.h:
———————–

* Define if you like to use fcntl based semaphores */
/* #undef MM_SEM_FCNTL */

/* Define if you like to use flock based semaphores */
/* #undef MM_SEM_FLOCK */

/* Define if you like to use sysvipc based semaphores */
/* #undef MM_SEM_IPC */

/* Define if you like to use posix based semaphores */
/* #undef MM_SEM_POSIX */

/* Define if you like to use pthread based semaphores */
/* #undef MM_SEM_PTHREAD */

/* Define if you like to use spinlock based semaphores */
#define MM_SEM_SPINLOCK 1

/* Define if you like to use sysvipc based shared memory */
#define MM_SHM_IPC 1

/* Define if you like to use anonymous mmap based shared memory */
/* #undef MM_SHM_MMAP_ANON */

/* Define if you like to use mmap on temporary file shared memory */
/* #undef MM_SHM_MMAP_FILE */

/* Define if you like to use posix mmap based shared memory */
/* #undef MM_SHM_MMAP_POSIX */

/* Define if you like to use mmap on /dev/zero based shared memory */
/* #undef MM_SHM_MMAP_ZERO */

———————
其中:
semaphores  是用来实现锁的机制的,因为对共享内存的(写)操作一定要有锁的机制来保证的。eaccelerator 也还为我们提供了锁的相关函数。

shared memory 是用来缓存opcode的,eaccelerator也为我们提供了相关的函数用来缓存用户自定义的一些信息。

使用时的情况:

Apache 中AddType与AddHandler

AddType 是与类型表相关的,描述的是扩展名与文件类型之间的关系,如:
AddType application/x-x509-ca-cert .crt

说明 .crt 扩展名的文件就是application/x-x509-ca-cert类型的; 在内容协商时,如果客户端需要是application/x-x509-ca-cert类型的,就将 .crt结尾的资源返回
注意: 经过内容协商的资源,在http相应头中有相应的Content-Location说明,如:

GET /a HTTP/1.1


Content-Location: a.php

AddHandler 说明什么样的扩展名使用什么样的程序来处理,描述的是扩展名与处理程序之间的关系
AddHandler cgi-script .cgi

关于Apache的内容协商

该功能使得服务器可以根据agent指定的http头来选择合适的资源。
涉及的http头包括: Accept-*
涉及的Apache中的知识: 类型表

1。 需要模块 : modules/mod_negotiation.so
2。 需要在目录的Options中添加: MultiViews;  如: Options FollowSymLinks MultiViews Indexes
3。 参考文档: http://apache.jz123.cn/content-negotiation.html
4。 该功能可能会影响到rewrite,参考: http://www.linuxpk.com/4941.html

apache根据你给的资源名称a,查找所有的a.*资源,加入有两种资源: a.txt 和a.php, 在类型表中查出:
.txt 对应文档类型为: text/plain 
.php 对应文档类型为: application/x-httpd-php

如果请求时使用的 accept为: text/plain ,则返回a.txt
如果请求时使用的 accept为: application/x-httpd-php ,则返回a.php
如果请求时使用的accept为: text/none ,找不到这种类型,则协商失败,apache返回406,并返回所有可用的类型列表,如:

Not Acceptable

An appropriate representation of the requested resource /a could not be found  on this server.

Available variants:

        

  • a.php , type application/x-httpd-php
  •     

  • a.txt , type text/plain

MySQL Show命令的使用

MySQL Show命令的使用

show tables或show tables from database_name;
解释:显示当前数据库中所有表的名称

show databases;
解释:显示mysql中所有数据库的名称

show processlist;
解释:显示系统中正在运行的所有进程,也就是当前正在执行的查询。大多数用户可以查看
他们自己的进程,但是如果他们拥有process权限,就可以查看所有人的进程,包括密码。

show table status;
解释:显示当前使用或者指定的database中的每个表的信息。信息包括表类型和表的最新更新时间

show columns from table_name from database_name; 或show columns from database_name.table_name;
解释:显示表中列名称

show grants for user_name@localhost;
解释:显示一个用户的权限,显示结果类似于grant 命令

show index from table_name;
解释:显示表的索引

show status;
解释:显示一些系统特定资源的信息,例如,正在运行的线程数量

show variables;
解释:显示系统变量的名称和值

show privileges;
解释:显示服务器所支持的不同权限

show create database database_name;
解释:显示create database 语句是否能够创建指定的数据库

show create table table_name;
解释:显示create database 语句是否能够创建指定的数据库

show engies;
解释:显示安装以后可用的存储引擎和默认引擎。

show innodb status;
解释:显示innoDB存储引擎的状态

show logs;
解释:显示BDB存储引擎的日志

show warnings;
解释:显示最后一个执行的语句所产生的错误、警告和通知

show errors;
解释:只显示最后一个执行语句所产生的错误

关于安装mysql的一些辛酸

现象:
新安装了一台机器,Apache + PHP; 访问时候出现错误:
*** glibc detected *** /data1/apache2/bin/httpd: double free or corruption (!prev): 0x0971ef80 ***

调试步骤:
1。 让apache的进程数减少为2个, strace -p pid; 观察异常所在,没有发现明显的出错地点

2。 在请求的PHP文件中添加断点,发现在mysql_connect 时出现的上述错误

3。 ldd mysql.so 和 ldd mysql 相比较,发现使用的libmysqlclient.so文件不同,系统里面有两套;相比是使用的include头文件和lib文件不是一个版本的

4。 删除安装的杂乱的mysql文件

5。 安装: mysql-5.1.47-linux-i686-glibc23.tar.gz    这个解压就行,不需要编译

6。 指定上面解压的mysql目录,重新编译PHP的mysql模块,问题解决

关于启动mysqld的一些问题:
1。 安装mysqld系统表文件,使用脚本scripts/mysql_install_db ; 需要在script平级的目录执行; 其原理是,使用越过权限检查的方式启动mysqld,默认的my.cnf是/etc/my.cnf ; 将创建系统表的sql语句放到mysqld中执行,于是生成的系统表就放在了(my.cnf中指定的)mysql数据库目录中了

2。 安装后的系统表可能用户权限不对,导致无法启动数据库,这就需要修改系统表和mysql数据库的权限了

调试过程中分别使用了:
strace、ldd、sh -x 等办法