有时候因为一些情况,需要把 linux 下符合某一项条件的所有进程 kill 掉,又不能用 killall 直接杀掉某一进程名称包含的所有运行中进程(我们可能只需要杀掉其中的某一类或运行指定参数命令的进程),这个时候我们需要运用 ps, grep, cut 和 kill 一起操作。
ok,下面给出具体的参考:
ps -ef|grep LOCAL=NO|grep -v grep|cut -c 9-15|xargs kill -9
运行这条命令将会杀掉所有含有关键字”LOCAL=NO”的进程,是不是很方便?
下面将这条命令作一下简单说明:
管道符”|”用来隔开两个命令,管道符左边命令的输出会作为管道符右边命令的输入。
“ps -ef” 是linux里查看所有进程的命令。这时检索出的进程将作为下一条命令”grep LOCAL=NO”的输入。
“grep LOCAL=NO” 的输出结果是,所有含有关键字”LOCAL=NO”的进程。
“grep -v grep” 是在列出的进程中去除含有关键字”grep”的进程。
“cut -c 9-15″ 是截取输入行的第9个字符到第15个字符,而这正好是进程号PID。
“xargs kill -9″ 中的 xargs 命令是用来把前面命令的输出结果(PID)作为”kill -9″命令的参数,并执行该命令。”kill -9″会强行杀掉指定进程。
其它类似的情况,只需要修改”grep LOCAL=NO”中的关键字部分就可以了。
另一种方法,使用awk
ps x|grep gas|grep -v grep |awk ‘{print $1}’|xargs kill -9
转自:http://www.cnblogs.com/lichkingct/archive/2010/08/27/1810463.html
其实和以前的centos5没啥区别,只不过centos的安装是选mini的还真够mini的,啥都要自己yum。这不连nfs都默认不装了。
mount -t nfs 192.168.1.1:/nfs1 /mnt/nfs
直接提示
mount: wrong fs type, bad option, bad superblock on 192.168.1.1:/nfs1,
missing codepage or helper program, or other error
(for several filesystems (e.g. nfs, cifs) you might
need a /sbin/mount.<type> helper program)
In some cases useful info is found in syslog - try
dmesg | tail or so
需要安装下相关的软件包
yum -y install nfs-utils nfs-utils-lib
这时再尝试依然会出错
mount.nfs: rpc.statd is not running but is required for remote locking.
mount.nfs: Either use '-o nolock' to keep locks local, or start statd.
mount.nfs: an incorrect mount option was specified
原因是rpcbind没启动
chkconfig –list看见是默认启动的,应该是刚装后没启动,手工启动下。
/etc/rc.d/init.d/rpcbind start
然后再
mount -t nfs 192.168.1.1:/nfs1 /mnt/nfs 就正常了
新增文件 /etc/modprobe.d/ipv6-off.conf 内容:
alias net-pf-10 off
alias ipv6 off
编辑 /etc/sysconfig/network 增加内容:
关闭自动启动ip6tables
chkconfig ip6tables off
重启即可
在克隆centos6的虚拟机后会发现启动网络的时候有报错
Bringing up interface eth0: Device eth0 does not seem to be present, delaying initialization.
查看配置文件发现并没有像centos5那样克隆后会把原先的ifcfg-eth0备份成ifcfg-eth0.bak然后生成新的初始化的ifcfg-eth0
上网查了查资料,原来centos6会对mac地址和网卡设备名进行绑定,克隆前网卡的mac地址已经绑定了eth0,在克隆后生成的新的mac地址被顺延绑定到了eth1,但是我们又没有对应eth1
的配置文件所以启动就提示出错了。
只需要编辑
vi /etc/udev/rules.d/70-persistent-net.rules
将原来eth0那行删除,把新生成的eth1那行里面的eth1改成eth0 然后修改或者删除下配置文件里面的mac地址和uuid和最后重启下即可。
完美解决nginx环境下服务器上多站点WebShell访问限制问题
http://www.discuz.net/thread-1497466-1-1.html
wget http://www.php.net/get/php-5.2.10.tar.gz/from/this/mirror
wget http://php-fpm.org/downloads/php-5.2.10-fpm-0.5.13.diff.gz
tar zxvf php-5.2.10.tar.gz
gzip -cd php-5.2.10-fpm-0.5.11.diff.gz | patch -d php-5.2.10 -p1
cd php-5.2.10/
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-ftp --without-pear
vi main/fopen_wrappers.c
/* {{{ php_check_open_basedir
*/
PHPAPI int php_check_open_basedir_ex(const char *path, int warn TSRMLS_DC)
{
/* Only check when open_basedir is available */
if (PG(open_basedir) && *PG(open_basedir)) {
char *pathbuf;
char *ptr;
char *end;
下面加上:
char *env_document_root = sapi_getenv("DOCUMENT_ROOT", sizeof("DOCUMENT_ROOT")-1 TSRMLS_CC);
if (php_check_specific_open_basedir(ptr, path TSRMLS_CC) == 0) {
efree(env_document_root);
return 0;
}
然后保存,退出。
php.in的open_basedir配置:
修改:
;open_basedir =
为
open_basedir = “/tmp/:/var/tmp/”
重启
/usr/local/php/sbin/php-fpm restart
今天一个部门打电话来说文件传不上ftp,看了下提示是空间满了,结果扫描了下实际容量似乎没满,感觉是quota的识别容量错了。
说实话这pureftpd用的还很少在安装目录里面逛了圈发现了pure-quotacheck这个命令,应该就是了。
试了试使用格式如下:
/usr/local/pureftpd/sbin/pure-quotacheck -u www -d /www/aaa.com
-u 是你指定pure-quotacheck运行时以系统的什么用户去扫描
-d 就是你ftp站点的目录
根据我以前的测试 Ext4 的性能好过 Ext3,在 RHEL5 上的 2.6.18-110 也有加入 Ext4 了。但默认没有让我们使用,怎么样才能不重起,能使用这个啦。
其实我们只要加入一个包e4fsprogs 就行,它其实和 e2fsprogs 是一样的功能,这 RHEL-6 中,会变成一个默认的包的。所以我们目前还只能使用这个包来调整和设置Ext4.
yum -y install e4fsprogs
在 RHEL 和 Centos5 中使用 Ext4 前,很多想可能想先给现有的文件系统转换成 Ext4 ,只要运行下面的命令就行了
tune4fs -O extents,uninit_bg,dir_index,flex_bg /dev/sdb1
在重起前,我还要让内核支持 Ext4 的文件系统,需要修改 initrd 的文件本身的内容。如下命令来生成 支持 Ext4 的 initrd。
mkinitrd --with=ext4 --with=ext3 -f /boot/initrd-2.6.18-194.8.1.el5.img 2.6.18-194.8.1
转载自:扶凯[http://www.php-oa.com]
open_basedir是php提升安全性的重要功能,eaccelerator是提速php的扩展模块,但是似乎默认环境下他们2一起用只要有require就会造成大量的php错误。
PHP Warning: Unknown: open_basedir restriction in effect. File() is not within the allowed path(s): (/www/:/tmp/) in Unknown on line 0
要解决这个问题的话在编译eaccelerator时 加上一个参数就行 –without-eaccelerator-use-inode
官方也说将在0.9.6.1的下一个release中默认启用这个参数。
最近再做个mysql一从多主的配置,需要在一台机器上安装多个mysql。
起先是按照复制了多了mysql 同时起,在琢磨如何做启动脚本的时候发现support-files目录下有个mysqld_multi.server文件,一查发现原来是现成的多实例管理工具。
首先得新建个data目录给新的实例,可以把原来的data目录复制个新的 只需要mysql库,也可以用工具部属个
1
| ./scripts/mysql_install_db --basedir=/usr/local/mysql3307 --datadir=/mysql/mysql3307/data --user=mysql |
然后修改下my.cnf
主要增加
1
2
3
4
5
6
| [mysqld_multi]
mysqld = /usr/local/mysql/bin/mysqld_safe
mysqladmin = /usr/local/mysql/bin/mysqladmin
user = shutdown
password = 123456
log = /mysql/mysqld_multi.log |
然后把原来的 [mysqld] 改为 [mysqld1]
在新增新的实例配置
1
2
3
4
5
6
| [mysqld2]
port = 3307
socket = /tmp/mysql3307.sock
datadir = /storage/mysql/data3307
............
............ |
然后把 mysqld_multi.server 做成启动服务
1
2
3
4
5
6
| cp ./support-files/mysqld_multi.server /etc/rc.d/init.d/mysqld
chown root:root /etc/rc.d/init.d/mysqld
chmod 755 /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 3 mysqld on
chkconfig --level 5 mysqld on |
启动和关闭全部mysql实例
启动:service mysqld start
关闭:service mysqld stop
对单台数据库的启动和关闭
启动: service mysqld start 1
关闭: service mysqld stop 1
也可以同时启动和关闭多个数据库实例
启动: service mysqld start 1-2
关闭: service mysqld stop 1-2
如果启动的时候提示出错信息:
WARNING: my_print_defaults command not found.
Please make sure you have this command available and
in your path. The command is available from the latest
MySQL distribution.
ABORT: Can’t find command ‘my_print_defaults’.
This command is available from the latest MySQL
distribution. Please make sure you have the command
in your PATH.
先添加
export PATH=/usr/local/mysql/bin:$PATH
然后在启动mysql
今天在装sphinx,收尾准备做个增量的脚本放crontab里面去,结果每次执行都是提示: No such file or directory。搞来搞去最后发现文本格式忘了改成unix的了,汗