解決 centos -bash: vim: command not found

使用centos 的主機的時候, 用 vim 的時候發現 -bash: vim: command not found. 只能使用 vi. 那麼如何安裝 vim 呢?
輸入 rpm -qa|grep vim 命令, 如果 vim 已經正確安裝,會返回下面的三行代碼:

1
2
3
4
root@server1 [~]# rpm -qa|grep vim
vim-enhanced-7.0.109-7.el5
vim-minimal-7.0.109-7.el5
vim-common-7.0.109-7.el5

如果少了其中的某一條,比如 vim-enhanced 的,就用命令 yum -y install vim-enhanced 來安裝:

1
yum -y install vim-enhanced

如果上面的三條一條都沒有返回, 可以直接用 yum -y install vim* 命令

1
yum -y install vim*

评论

CentOS 5.6(X64)下编译安装php mysql问题

建立libmcrypt相关库的软连接,为编译mcrypt作准备。因为mcrypt依赖libmcrypt。

#如果是CENTOS 5.6(64位)

以下内容为程序代码 以下内容为程序代码
ln -sf /usr/local/lib/libmcrypt.la /usr/lib64/libmcrypt.la
ln -sf /usr/local/lib/libmcrypt.so /usr/lib64/libmcrypt.so
ln -sf /usr/local/lib/libmcrypt.so.4 /usr/lib64/libmcrypt.so.4
ln -sf /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib64/libmcrypt.so.4.4.8
ln -sf /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config
ln -sf /usr/local/lib/libiconv.so.2 /usr/lib64/libiconv.so.2
ldconfig

#如果是CENTOS 5.6(32位)

以下内容为程序代码 以下内容为程序代码
ln -sf /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -sf /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -sf /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -sf /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
ln -sf /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config
ln -sf /usr/local/lib/libiconv.so.2 /usr/lib/libiconv.so.2
ldconfig

mhash(hash加密算法库)

以下内容为程序代码 以下内容为程序代码
tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9
./configure
make
make install
cd ..

建立libmhash相关库的软连接,为编译mcrypt作准备。mcrypt也依赖libmhash。

 

#如果是CENTOS 5.6(64位)

以下内容为程序代码 以下内容为程序代码
ln -sf /usr/local/lib/libmhash.a /usr/lib64/libmhash.a
ln -sf /usr/local/lib/libmhash.la /usr/lib64/libmhash.la
ln -sf /usr/local/lib/libmhash.so /usr/lib64/libmhash.so
ln -sf /usr/local/lib/libmhash.so.2 /usr/lib64/libmhash.so.2
ln -sf /usr/local/lib/libmhash.so.2.0.1 /usr/lib64/libmhash.so.2.0.1
ldconfig

#如果是CENTOS 5.6(32位)

以下内容为程序代码 以下内容为程序代码
ln -sf /usr/local/lib/libmhash.a /usr/lib/libmhash.a
ln -sf /usr/local/lib/libmhash.la /usr/lib/libmhash.la
ln -sf /usr/local/lib/libmhash.so /usr/lib/libmhash.so
ln -sf /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
ln -sf /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
ldconfig

评论

Linux建立Swap分区文件并自动mount

目的:建立一个2G大小的swap分区,并在系统启动时自动mount。
系统环境:RedHat53

1. dd if=/dev/zero of=/swapfile bs=1k count=2048000
2. mkswap /swapfile
3. swapon /swapfile
4. 修改/etc/fstab使其启动时自动mount:
在/etc/fstab中增加如下语句:
/swapfile                             swap                                        swap        defaults                0 0
5. 搞定!

评论

kloxo更新后出现:Starting httpd: Syntax error on line 12 of /home/apache/conf/defaults/_default.conf

Starting httpd: Syntax error on line 12 of /home/apache/conf/defaults/_default.conf:
UserDir “enable” keyword requires a list of usernames

修改

/usr/local/lxlabs/kloxo/httpdocs/lib/domain/web/driver/web__apachelib.php

文件中,把所有

$string .= “\t\tUserDir enabled\n”

改成

$string .= “\t\tUserDir enabled *\n”

运行:

/script/fixweb

service httpd restart

评论

用 iptables 把来自某个国家的 IP 重定向到预定页面

昨天有位客户想在他网站上阻止所有来自中国的 IP 并且把来自中国的访问重定向到某个预定的页面(或网站)。正统的做法应该是用 apache + mod_geoip 或者 nginx + http_geoip_module 来做,但是发现这位客户使用了 apache/directAdmin/suexec,suexec 好像和 mod_geoip 在一起有问题,VPSee 不想大动客户的配置,所以打算用 iptables 来实现这个要求。想法是这样的,用 iptables 把来自中国的流量全部导向到网站的 81 端口,并在 apache 上启动监听81端口,放上预定的页面(或网站)。

先到 IPdeny 下载以国家代码编制好的 IP 地址列表,比如下载 cn.zone:

# wget http://www.ipdeny.com/ipblocks/data/countries/cn.zone

得到需要的所有 IP 地址后,用下面的脚本逐行读取 cn.zone 文件并加入到 iptables 中:

#!/bin/bash
# Redirect traffic from a specific country to a specific page
# written by vpsee.com

COUNTRY="cn"
YOURIP="1.2.3.4"

if [ "$(id -u)" != "0" ]; then
   echo "you must be root" 1>&2
   exit 1
fi

iptables -F
iptables -X
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
iptables -A INPUT -i eth0 -j ACCEPT
iptables -A OUTPUT -o eth0 -j ACCEPT

# Redirect incoming http (80) from China to 81
for c in $COUNTRY
do
        country_file=$c.zone

        IPS=$(egrep -v "^#|^$" $country_file)
        for ip in $IPS
        do
           echo "redirecting $ip"
           iptables -t nat -I PREROUTING -p tcp --dport 80 -s $ip -j DNAT \
                   --to-destination $YOURIP:81
        done
done

iptables-save > /etc/sysconfig/iptables
chmod go-r /etc/sysconfig/iptables
service iptables restart

这样来自中国的 IP 访问 YOURIP 这个网站后就会自动导向到 YOURIP:81 这个端口,然后我们修改 apache 的配置,增加一个 Listen 81 和 以及在 DocumentRoot 里面放上预定的页面(或网站)就可以了

Comments (2)

ifto[ 安装教程

 

直接省略上面的步骤

CentOS系统:

yum install flex byacc  libpcap ncurses ncurses-devel

wget ftp://fr2.rpmfind.net/linux/dag/redhat/el5/en/i386/dag/RPMS/iftop-0.17-1.el5.rf.i386.rpm

rpm -ivh iftop-0.17-1.el5.rf.i386.rpm

评论

三款免费的PHP加速器:APC、eAccelerator、XCache比较

一直想找一些关于PHP加速的文章,偶然看到杀客的这篇文章,感觉不错,分享给大家,再此感谢杀客。

一、PHP加速器介绍

PHP加速器是一个为了提高PHP执行效率,从而缓存起PHP的操作码,这样PHP后面执行就不用解析转换了,可以直接调用PHP操作码,这样速度上就提高了不少。

Apache中使用mod_php的请求、响应执行流程:

1、Apache接收请求。
2、Apache传递请求给mod_php。
3、mod_php定位磁盘文件,并加载到内存中。
4、mod_php编译源代码成为opcode树。
5、mod_php执行opcode树。

PHP加速器相应的就是第四步,它的目的就是防止PHP每次请求都重复编译PHP代码,因为在高访问量的网站上,大量的编译往往没有执行速度快呢?所以这里面有个瓶颈就是PHP的重复编译既影响了速度又加载了服务器负载,为了解决此问题,PHP加速器就这样诞生了。

二、PHP加速器安装与配置

1、安装配置APC

APC全称是Alternative PHP Cache,官方翻译叫”可选PHP缓存”,它是PHP PECL中的一个扩展,好像是facebook在使用它,下面开始安装(ubuntu环境):
$wget http://pecl.php.net/get/APC-3.0.19.tgz
$tar xvzf APC-3.0.19.tgz
$cd APC-3.0.19/APC-3.0.19
$/usr/local/php/bin/phpize
$./configure –enable-apc –enable-apc-mmap –with-php-config=/usr/local/php/bin/php-config
$make
$sudo make install

下面我们再配置APC,因为我的PECL扩展路径改变了,所以我得移动下编译好的文件:
$sudo mv /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/apc.so /usr/local/php/lib/php/extensions/PECL

然后我们再编辑php.ini文件进行配置,请把下面的代码加入到php.ini中即可:
extension_dir = “/usr/local/php/lib/php/extensions/PECL”
extension = apc.so
; APC
apc.enabled = 1
apc.shm_segments = 1
apc.shm_size = 64
apc.optimization = 1
apc.num_files_hint = 0
apc.ttl = 0
apc.gc_ttl = 3600
apc.cache_by_default = on

这样重启apache就会在phpinfo()信息中显示。

       2、安装配置eAccelerator

eAccelerator的前身其实是truck-mmcache,因为开发truk-mmcache的人被Zend给招安了,所以开发eAccelerator的人继承了truk-mmcache的一些特性,设计出eAccelerator加速器。安装如下:
$wget http://jaist.dl.sourceforge.net/sourceforge/eaccelerator/eaccelerator-0.9.5.tar.bz2
$tar -jxf eaccelerator-0.9.5.tar.bz2
$cd eaccelerator-0.9.5
$/usr/local/php/bin/phpize
$./configure –enable-eaccelerator=shared –with-php-config=/usr/local/php/bin/php-config
$make
$sudo make install
$sudo mv /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so /usr/local/php/lib/php/extensions/PECL

将下面代码加入php.ini文件中
extension = eaccelerator.so
; eAccelerator
eaccelerator.shm_size = “16”
eaccelerator.cache_dir = “/tmp/eaccelerator”
eaccelerator.enable = “1”
eaccelerator.optimizer = “1”
eaccelerator.check_mtime = “1”
eaccelerator.debug = “0”
eaccelerator.filter = “”
eaccelerator.shm_max = “0”
eaccelerator.shm_ttl = “0”
eaccelerator.prune_period = “0”
eaccelerator.shm_only = “0”
eaccelerator.compress = “1”
eaccelerator.compress_level = “9”

创建缓存目录,重启apache

$sudo mkdir /tmp/eaccelerator
$sudo chmod 777 /tmp/eaccelerator
$sudo /usr/local/apache/apachectl restart

在phpinfo()检查是否安装成功.

3、安装配置XCache

XCache作为国人自己开发的东西,做小菜鸟的我也感到骄傲,而且XCache无论在速度还是性能上都做的不错。下面就赶紧让我们品尝它吧!

$wget http://xcache.lighttpd.net/pub/Releases/1.2.2/xcache-1.2.2.tar.gz
$tar xvzf xcache-1.2.2.tar.gz
$cd xcache-1.2.2
$/usr/local/php/bin/phpize
$./configure –enable-xcache –enable-xcache-coverager –with-php-config=/usr/local/php/php-config
$make
$sudo make install
$sudo mv /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/xcache.so /usr/local/php/lib/php/extensions/PECL

在php.ini添加配置信息:

extension = xcache.so
; xcache
xcache.admin.user = “admin”
xcache.admin.pass = “(执行) echo ’(你的密码)’|md5sum(得出的密文)”
;
xcache.size = 24M
xcache.shm_scheme = “mmap”
xcache.count = 2
xcache.slots = 8k
xcache.ttl = 0
xcache.gc_interval = 0

xcache.var_size = 8M
xcache.var_count = 1
xcache.var_slots = 8k
xcache.var_ttl = 0
xcache.var_maxttl = 0
xcache.var_gc_interval = 300
xcache.test = Off
xcache.readonly_protection = On
xcache.mmap_path = “/tmp/xcache”
xcache.coredump_directory = “”
xcache.cacher = On
xcache.stat = On
xcache.optimizer = Off
;
xcache.coverager = On
xcache.coveragedump_directory = “”

创建缓存目录,重启apache

$sudo mkdir /tmp/xcache
$sudo chmod 777 /tmp/xcache
$sudo /usr/local/apache/bin/apachectl restart

去查看phpinfo()信息吧!

三、PHP加速器测试

1、测试环境

硬件: AMD Athlon 64 X2 Dual Core Processor 4400+ @ 2.2GHz CPU, 2GB 内存. 160GB SATA 硬盘

软件: Linux Ubuntu server Gutsy 7.10, Apache 2.2.4, MySQL 5.0.45 和 PHP 5.2.3

测试指令: ab -c5 -n3000 http://example.com/ (我们使用的是Apache Benchmark (ab) 工具,并发连接为5,3000次请求)

2、测试结果

无任何加速器:

Document Path: /
Document Length: 21757 bytes
Concurrency Level: 5
Time taken for tests: 288.255212 seconds
Complete requests: 3000
Failed requests: 0
Write errors: 0
Total transferred: 66777000 bytes
HTML transferred: 65271000 bytes
Requests per second: 10.41 [#/sec] (mean)
Time per request: 480.425 [ms] (mean)
Time per request: 96.085 [ms] (mean, across all concurrent requests)
Transfer rate: 226.23 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.5 0 19
Processing: 181 479 186.0 444 1822
Waiting: 166 461 184.7 427 1708
Total: 181 479 186.0 444 1822
Percentage of the requests served within a certain time (ms)
50% 444
66% 525
75% 577
80% 619
90% 732
95% 819
98% 946
99% 1012
100% 1822 (longest request)

APC加速器:

Document Path: /
Document Length: 21757 bytes
Concurrency Level: 5
Time taken for tests: 98.530068 seconds
Complete requests: 3000
Failed requests: 0
Write errors: 0
Total transferred: 66777000 bytes
HTML transferred: 65271000 bytes
Requests per second: 30.45 [#/sec] (mean)
Time per request: 164.217 [ms] (mean)
Time per request: 32.843 [ms] (mean, across all concurrent requests)
Transfer rate: 661.84 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 2
Processing: 58 163 71.2 155 2452
Waiting: 53 158 69.6 150 2329
Total: 58 163 71.2 155 2452
Percentage of the requests served within a certain time (ms)
50% 155
66% 178
75% 193
80% 204
90% 235
95% 258
98% 285
99% 302
100% 2452 (longest request)

eAccelerator加速器:

Document Path: /
Document Length: 21757 bytes
Concurrency Level: 5
Time taken for tests: 95.983986 seconds
Complete requests: 3000
Failed requests: 0
Write errors: 0
Total transferred: 66777000 bytes
HTML transferred: 65271000 bytes
Requests per second: 31.26 [#/sec] (mean)
Time per request: 159.973 [ms] (mean)
Time per request: 31.995 [ms] (mean, across all concurrent requests)
Transfer rate: 679.39 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.1 0 3
Processing: 57 159 91.3 148 3830
Waiting: 50 152 89.8 142 3704
Total: 57 159 91.3 148 3830
Percentage of the requests served within a certain time (ms)
50% 148
66% 174
75% 193
80% 205
90% 239
95% 263
98% 289
99% 309
100% 3830 (longest request)

XCache加速器:

Document Path: /
Document Length: 21757 bytes
Concurrency Level: 5
Time taken for tests: 99.76300 seconds
Complete requests: 3000
Failed requests: 0
Write errors: 0
Total transferred: 66777000 bytes
HTML transferred: 65271000 bytes
Requests per second: 30.28 [#/sec] (mean)
Time per request: 165.127 [ms] (mean)
Time per request: 33.025 [ms] (mean, across all concurrent requests)
Transfer rate: 658.19 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 2
Processing: 59 164 83.4 155 3367
Waiting: 52 156 66.4 148 1802
Total: 59 164 83.4 155 3367
Percentage of the requests served within a certain time (ms)
50% 155
66% 178
75% 196
80% 206
90% 237
95% 263
98% 287
99% 305
100% 3367 (longest request)

3、结果摘要

请求时间(秒)单次请求时间(毫秒)最大内存占用(MB)最小内存占用(MB)
None10.4196.082424
APC30.4532.842121
eAccelerator31.2631.992318
XCache30.2833.022919

四、PHP加速器比较结果总结

1、通过测试得出eAccelerator在请求时间和内存占用综合方面是最好的。

2、通过测试得出使用加速器比无加速器在请求时间快了3倍左右。

3、通过各个官方观察,XCache是更新最快的,这也说明最有发展的。

以上是总结结果,你也许会问我到底用那个加速器好呢?我只能告诉你,首先,用一定比不用好,其次每个加速器还有一些可以调优的参数,所以要根据你的系统环境而定,然后,我个人觉得你可以详细研究下eAccelerator和XCache,这两款潜力还是很大的,最后我从比较专业的测试网站搞了一张结果图:

cache

评论

linux下如何实时查看mysql当前连接数??命令是啥?

mysqadmin -uroot -p processlist
可以看出连接的详细资料.

如果只是想看连接数.
直接打mysqladmin status
Threads就是连接数

评论

服务器安全计划

To ensure that my CentOS machines run as efficiently and securely as possible, I disable a number of services after each installation. The end result is a system that accepts ssh connections on TCP port 22, and on one or more service ports that are in use by the applications hosted on the platform. To get to this state, I go through and disable numerous services that come enabled by default. Here is the default list of services that are enabled after a CentOS 4.4 installation:

chkconfig –list | grep on

atd             0:off   1:off   2:off   3:on    4:on    5:on    6:off
messagebus      0:off   1:off   2:off   3:on    4:on    5:on    6:off
smartd          0:off   1:off   2:on    3:on    4:on    5:on    6:off
portmap         0:off   1:off   2:off   3:on    4:on    5:on    6:off
sendmail        0:off   1:off   2:on    3:on    4:on    5:on    6:off
netfs           0:off   1:off   2:off   3:on    4:on    5:on    6:off
cups            0:off   1:off   2:on    3:on    4:on    5:on    6:off
irqbalance      0:off   1:off   2:off   3:on    4:on    5:on    6:off
rpcgssd         0:off   1:off   2:off   3:on    4:on    5:on    6:off
xfs             0:off   1:off   2:on    3:on    4:on    5:on    6:off
isdn            0:off   1:off   2:on    3:on    4:on    5:on    6:off
autofs          0:off   1:off   2:off   3:on    4:on    5:on    6:off
gpm             0:off   1:off   2:on    3:on    4:on    5:on    6:off
apmd            0:off   1:off   2:on    3:on    4:on    5:on    6:off
crond           0:off   1:off   2:on    3:on    4:on    5:on    6:off
acpid           0:off   1:off   2:off   3:on    4:on    5:on    6:off
microcode_ctl   0:off   1:off   2:on    3:on    4:on    5:on    6:off
pcmcia          0:off   1:off   2:on    3:on    4:on    5:on    6:off
cpuspeed        0:off   1:on    2:on    3:on    4:on    5:on    6:off
xinetd          0:off   1:off   2:off   3:on    4:on    5:on    6:off
rpcidmapd       0:off   1:off   2:off   3:on    4:on    5:on    6:off
readahead_early 0:off   1:off   2:off   3:off   4:off   5:on    6:off
readahead       0:off   1:off   2:off   3:off   4:off   5:on    6:off
sshd            0:off   1:off   2:on    3:on    4:on    5:on    6:off
anacron         0:off   1:off   2:on    3:on    4:on    5:on    6:off
network         0:off   1:off   2:on    3:on    4:on    5:on    6:off
kudzu           0:off   1:off   2:off   3:on    4:on    5:on    6:off
syslog          0:off   1:off   2:on    3:on    4:on    5:on    6:off
nfslock         0:off   1:off   2:off   3:on    4:on    5:on    6:off
rawdevices      0:off   1:off   2:off   3:on    4:on    5:on    6:off
mdmonitor       0:off   1:off   2:on    3:on    4:on    5:on    6:off
haldaemon       0:off   1:off   2:off   3:on    4:on    5:on    6:off

Several of these services are required, but several others serve no purpose in my environment, and use CPU and memory resources that would be better allocated to my applications. Since I don’t use RPC services, autofs or NFS, those are the first to get disabled:

$ /sbin/chkconfig –level 0123456 portmap off
$ /sbin/chkconfig –level 0123456 nfslock off
$ /sbin/chkconfig –level 0123456 netfs off
$ /sbin/chkconfig –level 0123456 rpcgssd off
$ /sbin/chkconfig –level 0123456 rpcidmapd off
$ /sbin/chkconfig –level 0123456 autofs off

I also don’t allow individual hosts to receive mail from the outside world, so sendmail gets nixed next:

$ /sbin/chkconfig –level 0123456 sendmail off

On server platforms, who needs printing?:

$ /sbin/chkconfig –level 0123456 cups off

Now we get to the font server, isdn capabilities, console mouse and pcmcia support. I don’t use these services on my servers, so they get disabled as well:

$ /sbin/chkconfig –level 0123456 xfs off
$ /sbin/chkconfig –level 0123456 isdn off
$ /sbin/chkconfig –level 0123456 gpm off
$ /sbin/chkconfig –level 0123456 pcmcia off

Once these services are disabled (and optionally stopped with the service command or a reboot), my netstat output looks nice and clean:

netstat –tcp –udp –listening

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State
tcp        0      0 *:ssh                       *:*                         LISTEN

This has served me well over the years, since it reduces boot time (less rc scripts to run), and frees up additional resources for my applications (while this isn’t substantial, every page of memory helps!).

评论

CentOS 5 中OpenSSL和OpenSSH升级

CentOS 5 中OpenSSL和OpenSSH升级

2010-10-24 23:44

把OpenSSL和OpenSSH升级了。CentOS 5.2所带的OpenSSL是0.9.8b,OpenSSH是4.0p1。升级方法如下:

 

openssh 最新版本(http://www.openssh.com/portable.html)

 

wget http://www.openssl.org/source/openssl-0.9.8j.tar.gz

 

tar zxvf openssl-0.9.8j.tar.gz

 

cd openssl-0.9.8j

 

./config –prefix=/usr

 

make

 

make test

 

make install

 

wget http://openbsd.noc.jgm.gov.ar/pub/OpenBSD/OpenSSH/portable/openssh-5.2p1.tar.gz

 

tar zxvf openssh-5.2p1.tar.gz

 

cd openssh-5.2p1

 

./configure –prefix=/usr –with-pam –with-zlib –sysconfdir=/etc/ssh –with-ssl-dir=/usr –with-md5-passwords

 

make

 

make install

评论

管理OpenVZ资源-CPU share篇

 

继续昨天的内容,今日描述的是OpenVZ中如何控制VE可使用的CPU资源。OpenVZ资源管理器允许通过保证VE可使用的CPU time来实现QoS。在

 

没有设定cpulimit,以及没有其他VE竞争CPU资源的情况下,VE在获得设置的最小设定保证值外,还可以超过该值,以充分利用HW的CPU资源。

 

一、可设定参数
OpenVZ使用特定的运算规则计算CPU time,而设定值的单位就是CPU time。这就能避免单CPU和多CPU负载不平均,不能充分利用资源的问题。
可设定参数有:

引用
ve0cpuunits:该参数在全局配置文件中设置,定义VPS 0可使用的最少CPU time,也就是HW可获得保证的最少资源值。建议设置为HW CPU time总值的5~10%;
cpuunits:VE可获得保证的最少CPU time资源;
cpulimit:该VE不允许超过的CPU time百分比。

正如开头提到的,cpuunits不是固定值,只要资源许可,在没有超过cpulimit百分比的情况下,VE可充分获取CPU资源。

二、设置CPU share
1、计算HW总的CPU time
第一步,当然是需要计算当前VPS 0(HW)有多少CPU time可以支配。

引用
# vzcpucheck
Current CPU utilization: 1000 #已由HW和启动的VE占用的CPU time
Power of the node: 85105 #HW的CPU time总数

2、HW可用CPU time

引用
# grep ‘VE0CPUUNITS=1000’ /etc/vz/vz.conf
VE0CPUUNITS=1000

这是默认值,也等于没启动VE前,运行vzcpucheck得到的结果。

3、设置VE的CPU time

# vzctl set 115 –cpuunits 2500 –cpulimit 5 –save

或者

引用
# vi /etc/vz/conf/115.conf
CPUUNITS=”2500″
CPULIMIT=”5″

意思就是:

引用
1)即使在HW的CPU满负荷,或者讲,the current CPU utilization等于the power of the Node的情况下,115 VE都可以得到约3%(2500/85105)的CPU time资源;
2)但在CPU空闲的情况下,115 VE并不能得到超过5%的CPU time资源;
3)也就是讲,正常情况下,115 VE可用的CPU time资源在3%~5%之间;
4)若不设置cpulimit,那么115 VE在没有其他VE竞争,而资源又允许的情况下,就可以超过3%,但只要不超过HW的负荷就可以了。

启动VE,结果:

引用
# vzctl start 115
# vzcpucheck
Current CPU utilization: 3500
Power of the node: 85105

该设置还是动态有效的:

引用
# vzctl set 115 –cpuunits 4000 –cpulimit 5 –save
Setting CPU limit: 5
Setting CPU units: 4000
Configure meminfo: 49152
Saved parameters for VE 115
# vzcpucheck
Current CPU utilization: 5000
Power of the node: 85105

4、问题
从上面的描述可以知道,OpenVZ通常用最少保证值来让VE可充分的利用系统资源,这是其设计原理之一。但由此会带来一个问题,就是:

引用
# vzctl set 112 –cpuunits 85000 –cpulimit 5 –save
# vzctl start 112
# vzcpucheck
Current CPU utilization: 105000
Power of the node: 85105
Warning: hardware node is overcommited

万一,你为所有VE设定的其最少保证可用CPU time资源总值大于HW实际的CPU time。那么,就可能会发生CPU过载的问题。当真正发生此情况的时候,115 VE就不能获得其原来保证可获得的3%的CPU time资源,由此可能会导致整个虚拟系统出错。
当然,这只会发生在112 VE完全使用CPU time,HW超负荷的情况下。而大部分情况下,VE占用CPU的高峰并非同时的,根据OpenVZ的动态分配原则,CPU time都可以获得比较充分的利用,所以,仅是Warning,而不是Error。但为了避免问题,建议还是让current CPU utilization等于power of the Node比较好。


评论

Xen server 挂接本地新硬盘

1、进入XenCenter服务器端的控制台
2、[root@szwj-xenvm01 ~]# fdisk -l    查找新硬盘的设备号(如:/dev/sdb)
3、[root@szwj-xenvm01 ~]# xe sr-create name-label=”新硬盘的设备名” shared=false device-config-device=/dev/sdb type=lvm  (/dev/sdb是新硬盘的设备号)

评论

HyperVM安装手记(OpenVZ篇)

首先要说一说OpenVZ的安装
cd /etc/yum.repos.d
wget http://download.openvz.org/openvz.repo
yum install ovzkernel

即可完成安装。重启后,从http://download.lxlabs.com/?software=hypervm选择下载需要的安装脚本

(master的地址为http://download.lxlabs.com/download/hypervm/production/hypervm-install-master.sh),在服务器上

运行sh ./hypervm-install-master.sh –-virtualization-type=openvz
安装过程是会自动完成的,安装完HyperVM后init 6重启,然后通过浏览器访问http://<server address>:8888就能操作虚拟机了。

评论

whmcs 恢复后 就乱码了

$mysql_charset=”utf8″;

评论

Zen-cart Session_start报错导致页面显示空白

zen-cart. 有些由于空间原因。在编辑或者下载文档后会在?>后多加了一空白行。这个导致了前台与后台无法正常显示情况。。经常会出现空白页面。或者是session_start()错误。报错为 头部信息早已发送。 而在添加购物车和支付流程上常出现。以下是症状:

Warning: session_start() [function.session-start]: Cannot send session cookie – headers already sent by (output started at /home1/megacoll/public_html/shopping/admin/includes/classes/logger.php:106) in /home1/megacoll/public_html/shopping/includes/functions/sessions.php on line 108

Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent (output started at /home1/megacoll/public_html/shopping/admin/includes/classes/logger.php:106) in /home1/megacoll/public_html/shopping/includes/functions/sessions.php on line 108

Warning: Cannot modify header information – headers already sent by (output started at /home1/megacoll/public_html/shopping/admin/includes/classes/logger.php:106) in /home1/megacoll/public_html/shopping/admin/includes/init_includes/init_templates.php on line 69

Warning: Cannot modify header information – headers already sent by (output started at /home1/megacoll/public_html/shopping/admin/includes/classes/logger.php:106) in /home1/megacoll/public_html/shopping/admin/includes/functions/general.php on line 37

导致网站后台不能登录。

如果你拥有php.ini的管理权限,那么,直接编辑php.ini,将output_buffer打开(随便给个1024-4086的值),如果 没有php.ini的权限,但是服务器提供了.htaccess 功能的话,那么在.htaccess中加一句这个东西就可以了:

把所有的php档案都查了还是一样。
最后发现原來主机在 php.ini里沒设定 output_buffering。虽尚未请他们改正,不过先用 .htaccess试了可以。

.htaccess 设定如下:
php_value output_buffering 4096

经测试 。无问题。

评论

« 上一页« Previous entries « 上一页 · 下一页 » Next entries »下一页 »