Skip to content


快速查看Linux系统软硬件配置bash


wget http://aspersa.googlecode.com/svn/trunk/summary
chmod a+x summary
./summary

用root用户运行在系统信息,内存,磁盘等方面显示会更详细点

# Aspersa System Summary Report ##############################
Date | 2011-02-24 03:40:36 UTC (local TZ: CST +0800)
Hostname | c1gstudio
Uptime | 10:33, 1 user, load average: 3.52, 3.26, 3.32
System | Dell Inc.; PowerEdge R410; vNot Specified ()
Service Tag | xxxxxxx
Platform | Linux
Release | CentOS release 5.5 (Final)
Kernel | 2.6.18-194.el5
Architecture | CPU = 64-bit, OS = 64-bit
Threading | NPTL 2.5
Compiler | GNU CC version 4.1.2 20080704 (Red Hat 4.1.2-48).
SELinux | Disabled
Virtualized | No virtualization detected
# Processor ##################################################
Processors | physical = 2, cores = 8, virtual = 16, hyperthreading = yes
Speeds | 16×2261.061
Models | 16xIntel(R) Xeon(R) CPU E5520 @ 2.27GHz
Caches | 16×8192 KB
# Memory #####################################################
Total | 11.72G
Free | 5.67G
Used | physical = 6.05G, swap = 0.00k, virtual = 6.05G
Buffers | 516.82M
Caches | 2.84G
Dirty | 6724 kB
UsedRSS | 9.8G
Swappiness | vm.swappiness = 60
DirtyPolicy | vm.dirty_ratio = 40, vm.dirty_background_ratio = 10
Locator Size Speed Form Factor Type Type Detail
========= ======== ================= ============= ============= ===========
DIMM_A1 4096 MB 1333 MHz DIMM DDR3 Synchronous
DIMM_A2 4096 MB 1333 MHz DIMM DDR3 Synchronous
DIMM_B1 4096 MB 1333 MHz DIMM DDR3 Synchronous
DIMM_B2 4096 MB 1333 MHz DIMM DDR3 Synchronous
DIMM_A3 {EMPTY} Unknown DIMM DDR3 Synchronous
DIMM_A4 {EMPTY} Unknown DIMM DDR3 Synchronous
DIMM_B3 {EMPTY} Unknown DIMM DDR3 Synchronous
DIMM_B4 {EMPTY} Unknown DIMM DDR3 Synchronous
# Mounted Filesystems ########################################
Filesystem Size Used Type Opts Mountpoint
/dev/mapper/VolGroup00-LogVol01 9.7G 2% ext3 rw /tmp
/dev/mapper/VolGroup00-LogVol02 58G 21% ext3 rw /
/dev/mapper/VolGroup00-LogVol03 196G 11% ext3 rw /opt
/dev/mapper/VolGroup01-Vol01 136G 1% ext3 rw /vm1
/dev/sda1 190M 17% ext3 rw /boot
tmpfs 5.9G 1% tmpfs rw /dev/shm
# Disk Schedulers And Queue Size #############################
sda | [cfq] 128
sdb | [cfq] 128
sr0 | [cfq] 128
# Disk Partioning ############################################
Device Type Start End Size
============ ==== ========== ========== ==================
/dev/sda Disk 300000000000
/dev/sda1 Part 1 25 197406720
/dev/sda2 Part 26 36472 299778554880
/dev/sdb Disk 300000000000
/dev/sdb1 Part 1 36472 299984186880
# Kernel Inode State #########################################
dentry-state | 185384 179820 45 0 0 0
file-nr | 5610 0 1174801
inode-nr | 173045 143
# LVM Volumes ################################################
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
LogVol00 VolGroup00 -wi-ao 7.91G
LogVol01 VolGroup00 -wi-ao 10.00G
LogVol02 VolGroup00 -wi-ao 59.00G
LogVol03 VolGroup00 -wi-ao 202.28G
Vol01 VolGroup01 -wi-ao 138.00G
# RAID Controller ############################################
Controller | Fusion-MPT SAS
# Network Config #############################################
Controller | Broadcom Corporation NetXtreme II BCM5716 Gigabit Ethernet (rev 20)
Controller | Broadcom Corporation NetXtreme II BCM5716 Gigabit Ethernet (rev 20)
FIN Timeout | net.ipv4.tcp_fin_timeout = 60
Port Range | net.ipv4.ip_local_port_range = 1024 65535
# Interface Statistics #######################################
interface rx_bytes rx_packets rx_errors tx_bytes tx_packets tx_errors
========= ========= ========== ========== ========== ========== ==========
lo 3500000000 22500000 0 3500000000 22500000 0
eth0 1000000000 80000000 0 4000000000 70000000 0
eth1 1500000000 10000000 0 4000000000 15000000 0
sit0 0 0 0 0 0 0
virbr0 0 0 0 450 6 0
# Network Connections ########################################
Connections from remote IP addresses
1.80.74.240 1
1.80.133.200 4
1.85.0.140 2
14.104.71.204 1
14.208.109.44 10
14.210.135.2 2
24.141.8.153 6
27.17.180.165 1
27.17.194.85 7
Connections to local IP addresses
61.xxx.xxx.xx 3000
122.xxx.xxx.xx 1000
127.0.0.1 3000
192.168.0.21 2500
Connections to top 10 local ports
80 4000
9000 3000
9354 1
9356 1
9358 1
9360 1
9362 1
9365 1
9366 1
9368 1
States of connections
CLOSING 1
ESTABLISHED 2500
FIN_WAIT1 200
FIN_WAIT2 350
LAST_ACK 100
LISTEN 7
SYN_RECV 15
TIME_WAIT 6000
# Top Processes ##############################################
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
4893 nobody 16 0 254m 73m 55m S 58.7 0.6 8:53.18 php-cgi
4879 nobody 16 0 260m 79m 57m R 47.0 0.7 8:56.18 php-cgi
4896 nobody 16 0 252m 71m 55m S 35.2 0.6 8:55.26 php-cgi
4866 nobody 16 0 254m 74m 56m S 23.5 0.6 8:59.46 php-cgi
4890 nobody 16 0 256m 76m 58m S 23.5 0.6 8:52.82 php-cgi
4851 nobody 16 0 256m 75m 56m S 21.5 0.6 9:02.35 php-cgi
4859 nobody 16 0 254m 74m 58m S 21.5 0.6 9:02.85 php-cgi
4868 nobody 16 0 256m 76m 58m S 21.5 0.6 8:45.38 php-cgi
4826 nobody 16 0 253m 73m 56m S 19.6 0.6 8:41.44 php-cgi
# Simplified and fuzzy rounded vmstat (wait please) ##########
procs —swap– —–io—- —system—- ——–cpu——–
r b si so bi bo ir cs us sy il wa st
6 0 0 0 2 20 60 7 11 2 88 0 0
1 0 0 0 35 0 5000 3500 11 2 87 0 0
5 0 0 0 0 1750 4500 3500 8 2 89 0 0
5 0 0 0 0 80 7000 6000 23 4 73 0 0
4 0 0 0 0 0 9000 8000 22 4 74 0 0
# The End ####################################################

参考:http://bbs.linuxtone.org/thread-8696-1-1.html

Posted in linux 维护优化, 技术.

Tagged with , .


rrdtool数据备份与迁移

迁移cacti后图表一直没出来….

调试注意
1.cacti->System Utilities->Technical Support 调试

2.cacti 0.8.7e 不支持rrdtool-1.4.4
可用1.3x,1.2x

3.rrdtool 显示错误ERROR: This RRD was created on another architecture
不同版本不兼容,32bit和64bit也不兼容

解决不兼容方法
1.在原服务器生成xml文件
创建脚本文件
dumprrdtool.sh

#!/bin/sh

rrddump=”/usr/local/rrdtool/bin/rrdtool dump”
xmldir=/tmp/rraxml
cd /opt/htdocs/www/cacti/rra/
for file in `find ./ -mtime -4 |awk -F\/ “{print $NF}”`
#遍历rra目录,查找近4天修改过的rrd文件;
do
${rrddump} ${file} > ${xmldir}/${file}.xml
done


chmod 775 ./dumprrdtool.sh
mkdir /tmp/rraxml
chmod 777 /tmp/rraxml
./dumprrdtool.sh

2.
脚本会将rra文件转成xml文件
将xml传用ssh或rsync等方式传到新服务器上

3.新服务上还原文件
mkdir /tmp/rraxml
chmod 777 /tmp/rraxml
将xml文件放到/tmp/rraxml下
创建脚本restorerrdtool.sh

#!/bin/sh
rrdrestore=”/usr/local/rrdtool/bin/rrdtool restore”
xmldir=/tmp/rraxml/
cd ${xmldir}
for file in `find ./ |awk -F\/ ‘{print $NF}’ |sed s/.xml//g`
do
${rrdrestore} ${xmldir}${file}.xml /tmp/rra/${file}
done

mkdir /tmp/rra
chmod 777 /tmp/rra
./restorerrdtool.sh
再将新生的rra文件复制到cacti/rra目录下

参考:
http://hiadmin.com/?p=559

Posted in Cacti, RRDtool, 技术.

Tagged with , .


重新配置CPAN源

[root@c1g ~]# perl -MCPAN -e shell
Terminal does not support AddHistory.

cpan shell — CPAN exploration and modules installation (v1.7602)
ReadLine support available (try ‘install Bundle::CPAN’)

cpan>o conf init

一路回车

Posted in cpan, 技术.

Tagged with .


中国新联通(网通)IDC机房分布及资费标准

中国联通集团IDC运营中心介绍
  为加强联通全网业务的专业化运营和管理,中国联通集团IDC运营中心于2008年3月27日正式成立。在北方10省和上海、广东、江苏、浙江、福建、陕西、重庆、四川、江西、安徽、湖北共21省分公司设立省级IDC运营分中心,在全国四星级以上IDC所在的16个中心城市设有地市级IDC运营分中心。

  主要职能:

  · 负责联通全国IDC业务的运营管理;

  · 负责提出全国IDC经营预算目标和发展策略、规划和实施;

  · 负责全网IDC服务等级评审,全网IDC资源调度;

  · 负责跨省客户签约审核;

  · 负责IDC产品的规划、开发与合作,对新产品进行定价、培训;

  · 负责全网性及国际性大客户业务拓展的支撑;

  · 协助联通IDC品牌的建立和维护;

  · 负责全网流量流向、资源和客户信息等支撑平台的数据统计分析等。

联通机房分布

截止2009年11月25日联通官方公布的共有 13个五星机房及24个四星机房。
其中山东最为历害,有4个接入超过100G的机房,开通时间也比较新,但是代理商很少。
1u 百共的代理价格大概是6000/年。

机房名称 地址 星级水平 详细 机房面积 总接入带宽 机房设计机架数 机房现有机架数 机房开通时间
四川成都IDC 成都市二环路北一段111-114号 四星级 查看 1000平方米 5G   180   2003年6月
沈阳IDC 沈阳市铁西区滑翔路29号 四星级 查看 1000平方米 90G   344   2003年1月
陕西西安IDC 西安市高新区科技六路19号 四星级 查看 1100平方米 40G   200   2008年4月
青岛秦岭路IDC 青岛市苗岭路11号 四星级 查看 2000平方米 200G   503   三楼2001年10月
四楼2009年7月
济南二枢纽IDC 济南市经十路168 四星级 查看 2000平方米 150G   600   2001年4月
内蒙古自治区IDC 呼和浩特市金川开发区联通第二枢纽楼 四星级 查看 5000平方米 40G   500   2005年7月
大连软件园IDC 大连市软件园数码路北段28 四星级 查看 1500平方米 60G   384   2002年
长春二枢纽IDC 长春市硅谷大街3057号联通二枢纽10楼 四星级 查看 1500平方米 40G   250   2007年1月
黑龙江IDC 哈尔滨市南岗区湘江路45号 四星级 查看 5500平方米 40G 1000 400   2007年5月
河南郑州二长枢纽IDC 河南省郑州市北环路40号 四星级 查看 3600平方米 40G 1000 500   2005年1月
河北石家庄IDC 石家庄市东开发区昆仑大街89号 四星级 查看 3500平方米 60G   630   2002年12月
中深国际IDC 深圳市南山区科技园深南花园C座裙楼2楼 四星级 查看 1070平方米 20G   91   2002年1月
广州太阳广场IDC 广州市天河天阳路142-144号太阳广场 四星级 查看 6000平方米 20G   197   2002年11月
深南花园IDC机房 深圳市南山区科技园深南花园C座裙楼2楼 四星级 查看 2470平方米 20G   197   2006年1月
北京亦庄电话局IDC 北京市大兴区中和街1号 四星级 查看 1000平方米 8G   411   2008年
北京西三旗电话局IDC 北京市海淀区西三旗 四星级 查看 760平米 8G   323   2008年
北京西红门电话局IDC 北京大兴区西红门镇内宏康路 四星级 查看 2000平米 20G   804   2008年 
北京石景山电话局IDC 北京市石景山老古城前街甲2号 四星级 查看 590平米 8G    242   2008年
北京上地电话局IDC 北京市海淀区上地信息产业基地 四星级 查看 730平米 8G   321   2008年
北京南苑电话局IDC 北京市丰台区三营门 四星级 查看 1200平米 8G   450   2008年
北京酒仙桥IDC 北京市朝阳区酒仙桥路14号D区1号楼 四星级 查看 4000平米 8G   931   2008年
北京广内电话局IDC 北京市宣武区槐柏树街13号 四星级 查看 460平米 8G   153   2008年
北京东四电话局IDC 北京东四南大街164号 四星级 查看 700平米 20G   264   2008年
山东青岛二枢纽IDC 青岛市辽阳东路15号 五星级 查看 6000平方米 200G 1460 960   2006年3月1日
山东济南担山屯IDC 济南市经十西路京福高速入口西行300米路南 五星级 查看 4500平米 150G 658 458   2009年10月
黑龙江哈尔滨IDC 哈尔滨市南岗区中山路155号 五星级 查看 5000平米 40G 600 500   2002年12月1日
广州科学城IDC 广州萝岗区科学城天丰路11号 五星级 查看 4200平米 20G 1600 230   2007年11月
天津华苑IDC 天津市南开区新技术产业园区华苑产业区梓苑路6号 五星级 查看 18064平米 60G   807   2009年7月
天津滨海IDC 天津市塘沽开发区新城东路和盛达街交口 五星级 查看 3800平米 80G   1343   2005年1月
上海漕河泾IDC 上海市徐汇区钦州北路1089号51号楼 五星级 查看 5500平米 12G 1540 1100   2002年
北京皂君庙IDC 北京市海淀区皂君庙路9号 五星级 查看 3800平米 50G   890   2005年
北京亦庄IDC 北京市亦庄经济技术开发区北环东路1号 五星级 查看 3760 60G   1314    
北京土城IDC 北京市朝阳区土城裕民路乙三号 五星级 查看 4500平米 80G   1108   2005年
北京数字北京大厦IDC 北京市北辰西路12号 五星级 查看 3000平米 20G   1048   2006年
北京三元桥IDC 北京市朝阳区霞光里2号 五星级 查看 400平米 40G   160   2006年
北京电报大楼IDC 北京市西长安街11号电报大楼 五星级 查看 2600平米 60G   887   2005年

 

 

中国联通IDC基础业务资费标准

一、主机托管业务

(一)安装调测费:一次性收取。

1.端口调测费:机位出租中独享端口方式按每个端口300元收取,共享端口方式按照每台机器200元收取;

2.设备安装费:设备安装按照每台设备200元收取,机架出租和VIP专用机房(机笼)出租按每机架1000元收取。

(二)月租费:各省公司根据区域的不同,执行该区域对应的价格体系,并根据IDC等级执行不同档次的价格。

1.空间使用费(含机位费、机架费)

区域分类
用户单台设备高度H
(单位:U)
机位费(元/月/U)
五星级
四星级
三星级
二星级
一星级
AA类、
A类地区
1≤H﹤3
440
350
280
220
180
3≤H﹤7 
400
320
260
200
160
7≤H
350
280
220
180
140
单个标准机架/柜(44U及以下)
10000
8000
6500
5000
4000
VIP机房(机笼)费
对应的机架资费×同等面积公共区域可放置的机架个数×130%
B类、
C类地区
1≤H﹤3
350
280
220
180
140
3≤H﹤7 
320
250
200
160
130
7≤H
280
220
180
140
110
单个标准机架/柜(44U及以下)
8000
6500
5000
4000
3500
VIP机房(机笼)费
对应的机架资费×同等面积公共区域可放置的机架个数×130%

注:(1)机位费指用户托管设备与其他用户设备共享一个机架时用户缴纳的空间资源占用费。计费单元是用户的单台设备高度,如用户托管多台设备,所需交纳的机位费为每台设备按相应设备高度对应费率所得机位费的累加值。(2)机架费指用户独享IDC提供的一个机架/柜时所需交纳的空间资源占用费。

2.端口通信费

区域分类
接入方式
端口通信费(元/月)
五星级
四星级
三星级
二星级
一星级
AA类地区
共享100Mbit/s
1500
1200
1000
800
600
独享10Mbit/s
15000
12000
10000
8000
6000
独享50Mbit/s
60000
48000
38000
30000
24000
独享100Mbit/s
90000
72000
58000
46000
37000
独享1Gbit/s
600000
480000
380000
300000
240000
A类地区
共享100Mbit/s
1200
1000
800
600
500
独享10Mbit/s
12000
10000
8000
6000
5000
独享50Mbit/s
48000
38000
30000
24000
19000
独享100Mbit/s
72000
58000
46000
37000
30000
独享1Gbit/s
480000
380000
300000
240000
190000
B类地区
共享100Mbit/s
1000
800
600
500
400
独享10Mbit/s
10000
8000
6000
5000
4000
独享50Mbit/s
38000
30000
24000
19000
15000
独享100Mbit/s
58000
46000
37000
30000
24000
独享1Gbit/s
380000
300000
240000
190000
150000
C类地区
共享100Mbit/s
800
600
500
400
300
独享10Mbit/s
8000
6000
5000
4000
3000
独享50Mbit/s
30000
24000
19000
15000
12000
独享100Mbit/s
46000
37000
30000
24000
19000
独享1Gbit/s
300000
240000
190000
150000
120000

注:以上资费为中国联通IDC基础业务资费标准,具体项目收费由各省分公司根据本省区域分类和机房星级水平的不同进行方案报价。

Posted in IDC, 其它.

Tagged with , , , , .


Discuz! 7.2 升级至 Discuz! X1.5 记录

Discuz! X1.5 【R20101228】
下载

Discuz!7.2/UCHome2.0/SupeSite7.5 至 Discuz!X1.5正式版 升级教程:
http://www.discuz.net/thread-1887968-1-1.html

    需要UCenter 1.5.2的版本
    升级前创建个存放discuzx的新数据库,然后安装discuzx
    执行convert程序会将原discuz数据重新插入到discuzx库中
    新discuzx中的表名和discuz不同,自有程序需要重新修改
    200万会员,800万贴子,4G数据的论坛转换花了11个小时,新数据库大小略有增加
    升级过程中可能会碰到重复的健值造成升级中断
    安装后默认的sql缓存方式可能有bug,一直卡在pre_common_syscache表的发送中,把百M的内网都占满了,改用file方式后解决.
    eaccelerator加速方式需eaccelerator-0.9.5.3版本,但我尝试了0.9.5.2,0.9.5.3,eaccelerator-0.9.6都不成功
    memcache加速方式大概只用200k数据,有导航菜单等cache丢失现像,效率也不是很好
    discuz7.2中的广告升级后可能会占满cpu,原因不详
    后台计划任务第一次要手工执行下
    discuzx论坛负载比discuz7.2略有上升,目前保持在3左右

nginx rewrite

rewrite ^([^\.]*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2 last;
rewrite ^([^\.]*)/article-([0-9]+)-([0-9]+)\.html$ $1/portal.php?mod=view&aid=$2&page=$3 last;
rewrite ^([^\.]*)/forum-(\w+)-([0-9]+)\.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;
rewrite ^([^\.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last;
rewrite ^([^\.]*)/group-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=group&fid=$2&page=$3 last;
rewrite ^([^\.]*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3 last;
rewrite ^([^\.]*)/([a-z]+)-(.+)\.html$ $1/$2.php?rewrite=$3 last;
if (!-e $request_filename) {
return 404;
}

discuz7.2 兼容rewrite

if ($query_string ~* tid=([0-9]+)) {
set $id $1;
rewrite “^(.*)/viewthread.php$” $1/forum.php?mod=viewthread&tid=$id&extra=page%3D&page=1 last;
}
if ($query_string ~* gid=([0-9]+)) {
set $id $1;
rewrite “^(.*)/index.php$” $1/forum.php?gid=$id last;
}
if ($query_string ~* fid=([0-9]+)&filter=type&typeid=([0-9]+)) {
set $id $1;
set $typeid $2;
rewrite “^(.*)/forumdisplay.php$” $1/forum.php?mod=forumdisplay&fid=$id&filter=typeid&typeid=$typeid last;
}
rewrite ^([^\.]*)/archiver/$ $1/forum.php?archiver=1 last;
if ($query_string ~* action=credits) {
rewrite “^(.*)/memcp.php$” $1/home.php?mod=spacecp&ac=credit last;
}
rewrite ^([^\.]*)/attachment.php$ $1/forum.php last;

图片路径修正

cd htdocs/bbs/
ln -s ./static/image ./images
ln -s ./data/attachment/forum ./attachments

Posted in Discuz/Uchome/Ucenter, 其它.

Tagged with , .


PHPExcel在php5.2.10上的bug

Fatal error: Class ‘PHPExcel_Worksheet’ not found in /htdocs/webapp/includes/libs/PHPExcel.php on line 114

PHPExcel.php第114行内容

$this->_workSheetCollection[] = new PHPExcel_Worksheet($this);

PHPExcel使用了自动载入class
PHPExcel/Autoloader.php 第43行输入调试代码

echo $pObjectFilePath;
var_dump(file_exists($pObjectFilePath));
echo “
“;

if ((file_exists($pObjectFilePath) === false) || (is_readable($pObjectFilePath) === false)) {
return false;
}


/htdocs/webapp/includes/libs/PHPExcel/Shared/ZipStreamWrapper.phpbool(true)
/htdocs/webapp/includes/libs/PHPExcel/Worksheet.phpbool(false)

Fatal error: Class ‘PHPExcel_Worksheet’ not found in /htdocs/webapp/includes/libs/PHPExcel.php on line 114

Worksheet.php文件没有存在?
反复检查了php中open_basedir,文件及目录权限,zip扩展,pear都没问题.
并在autoloader前用代码测试文件确实可以检测到.

var_dump(file_exists(‘/htdocs/webapp/includes/libs/PHPExcel/Worksheet.php’));

试了下把ZipStreamWrapper.php禁止载入后就可顺利通过.
注释PHPExcel.php第34行内容

PHPExcel_Autoloader::Register();
//PHPExcel_Shared_ZipStreamWrapper::register();

看来问题确实在这里,再用代码确认下是stream_register_wrapper和file_exists的bug

class VariableStream {
var $position;
var $varname;

function stream_open($path, $mode, $options, &$opened_path)
{
$url = parse_url($path);
$this->varname = $url[“host”];
$this->position = 0;

return true;
}

function stream_read($count)
{
$ret = substr($GLOBALS[$this->varname], $this->position, $count);
$this->position += strlen($ret);
return $ret;
}

function stream_write($data)
{
$left = substr($GLOBALS[$this->varname], 0, $this->position);
$right = substr($GLOBALS[$this->varname], $this->position + strlen($data));
$GLOBALS[$this->varname] = $left . $data . $right;
$this->position += strlen($data);
return strlen($data);
}

function stream_tell()
{
return $this->position;
}

function stream_eof()
{
return $this->position >= strlen($GLOBALS[$this->varname]);
}

function stream_seek($offset, $whence)
{
switch($whence) {
case SEEK_SET:
if ($offset < strlen($GLOBALS[$this->varname]) && $offset >= 0) {
$this->position = $offset;
return true;
} else {
return false;
}
break;

case SEEK_CUR:
if ($offset >= 0) {
$this->position += $offset;
return true;
} else {
return false;
}
break;

case SEEK_END:
if (strlen($GLOBALS[$this->varname]) + $offset >= 0) {
$this->position = strlen($GLOBALS[$this->varname]) + $offset;
return true;
} else {
return false;
}
break;

default:
return false;
}
}
}

var_dump(file_exists(‘/htdocs/webapp/includes/libs/PHPExcel.php’));

stream_register_wrapper(“var”, “VariableStream”)
or die(“Failed to register protocol”);
var_dump(file_exists(‘/htdocs/webapp/includes/libs/PHPExcel.php’));


输出结果

bool(true) bool(false)

解决方法:
1.注释PHPExcel.php第34行内容
PHPExcel_Shared_ZipStreamWrapper::register();

2.更换php版本
目前换成php.5.2.14没有问题

Posted in PHP, 技术.

Tagged with , .


解决nginx access日志中400 bad request 错误

在access.log中有大量400错误,并以每天几百M的速度增加,占用大量空间.
tail -f /opt/nginx/logs/access.log

116.236.228.180 – – [15/Dec/2010:11:00:15 +0800] “-” 400 0 “-” “-”
116.236.228.180 – – [15/Dec/2010:11:00:15 +0800] “-” 400 0 “-” “-”
116.236.228.180 – – [15/Dec/2010:11:00:15 +0800] “-” 400 0 “-” “-”
116.236.228.180 – – [15/Dec/2010:11:00:15 +0800] “-” 400 0 “-” “-”
116.236.228.180 – – [15/Dec/2010:11:00:15 +0800] “-” 400 0 “-” “-”
119.97.196.7 – – [15/Dec/2010:11:00:16 +0800] “-” 400 0 “-” “-”
119.97.196.7 – – [15/Dec/2010:11:00:16 +0800] “-” 400 0 “-” “-”
116.236.228.180 – – [15/Dec/2010:11:00:16 +0800] “-” 400 0 “-” “-”
116.236.228.180 – – [15/Dec/2010:11:00:16 +0800] “-” 400 0 “-” “-”
116.236.228.180 – – [15/Dec/2010:11:00:16 +0800] “-” 400 0 “-” “-”
116.236.228.180 – – [15/Dec/2010:11:00:16 +0800] “-” 400 0 “-” “-”
116.236.228.180 – – [15/Dec/2010:11:00:16 +0800] “-” 400 0 “-” “-”
116.236.228.180 – – [15/Dec/2010:11:00:16 +0800] “-” 400 0 “-” “-”
116.236.228.180 – – [15/Dec/2010:11:00:16 +0800] “-” 400 0 “-” “-”
116.236.228.180 – – [15/Dec/2010:11:00:16 +0800] “-” 400 0 “-” “-”
219.243.95.197 – – [15/Dec/2010:11:00:16 +0800] “-” 400 0 “-” “-”
116.236.228.180 – – [15/Dec/2010:11:00:16 +0800] “-” 400 0 “-” “-”
116.236.228.180 – – [15/Dec/2010:11:00:16 +0800] “-” 400 0 “-” “-”

网上大把的文章说是HTTP头/Cookie过大引起的,可以修改nginx.conf中两参数来修正.

client_header_buffer_size 16k;
large_client_header_buffers 4 32k;

修改后

client_header_buffer_size 64k;
large_client_header_buffers 4 64k;

没有效果,就算我把nginx0.7.62升到最新的0.8.54也没能解决.
官方论坛中nginx作者提到空主机头不会返回自定义的状态码,是返回400错误.
http://forum.nginx.org/read.php?2,9695,11560

最后修正如下
改为原先的值

client_header_buffer_size 16k;
large_client_header_buffers 4 32k;

关闭默认主机的日志记录就可以解决问题

server {
listen *:80 default;
server_name _;
return 444;
access_log off;
}

Posted in Nginx, 技术.

Tagged with , .


discuz 7.2 后台添加ip禁止时的bug

后台添加ip禁止时如果去除有效期保持为空,会造成服务器负载直线上升,数据库大量空连接,网站不能访问.
删险添加的记录并重新生成缓存后可解决问题.

Posted in Discuz/Uchome/Ucenter, 其它.

Tagged with .


mysqlreport 查看mysql状态

mysqlreport以非常友好的方式显示MySQL状态变量值。和SHOW STATUS不同,mysqlreport以一种非常格式化的方式输出状态值,具有非常好的可读性。

wget http://hackmysql.com/scripts/mysqlreport-3.5.tgz
tar zxvf mysqlreport-3.5.tgz
cd mysqlreport-3.5
chmod +x mysqlreport
./mysqlreport

Use of uninitialized value in subtraction (-) at ./mysqlreport line 648.
Use of uninitialized value in subtraction (-) at ./mysqlreport line 648.
Use of uninitialized value in multiplication (*) at ./mysqlreport line 648.
Use of uninitialized value in multiplication (*) at ./mysqlreport line 652.
Use of uninitialized value in multiplication (*) at ./mysqlreport line 652.
MySQL 5.1.26-rc uptime 0 2:57:2 Wed Nov 17 14:48:32 2010

__ Key _________________________________________________________________
Buffer used 366.25M of 3.02G %Used: 11.83
Current 944.89M %Usage: 30.52
Write hit 52.83%
Read hit 99.95%

__ Questions ___________________________________________________________
Total 6.76M 636.3/s
DMS 3.34M 314.0/s %Total: 49.35
Com_ 1.92M 180.5/s 28.36
COM_QUIT 823.41k 77.5/s 12.18
QC Hits 684.24k 64.4/s 10.12
-Unknown 978 0.1/s 0.01
Slow 10 s 83 0.0/s 0.00 %DMS: 0.00 Log: OFF
DMS 3.34M 314.0/s 49.35
SELECT 2.47M 232.2/s 36.49 73.94
UPDATE 360.06k 33.9/s 5.33 10.80
INSERT 238.60k 22.5/s 3.53 7.15
DELETE 172.46k 16.2/s 2.55 5.17
REPLACE 97.91k 9.2/s 1.45 2.94
Com_ 1.92M 180.5/s 28.36
set_option 1.12M 105.5/s 16.57
change_db 743.18k 70.0/s 11.00
show_variab 26.44k 2.5/s 0.39

__ SELECT and Sort _____________________________________________________
Scan 90.27k 8.5/s %SELECT: 3.66
Range 94.02k 8.9/s 3.81
Full join 35 0.0/s 0.00
Range check 0 0/s 0.00
Full rng join 0 0/s 0.00
Sort scan 59.49k 5.6/s
Sort range 136.07k 12.8/s
Sort mrg pass 0 0/s

__ Query Cache _________________________________________________________
Memory usage 50.50M of 128.00M %Used: 39.45
Block Fragmnt 24.56%
Hits 684.24k 64.4/s
Inserts 2.39M 224.6/s
Insrt:Prune 2.39M:1 224.6/s
Hit:Insert 0.29:1

__ Table Locks _________________________________________________________
Waited 156.42k 14.7/s %Total: 3.20
Immediate 4.73M 445.4/s

__ Tables ______________________________________________________________
Open 1238 of 3072 %Cache: 40.30
Opened 2.27k 0.2/s

__ Connections _________________________________________________________
Max used 111 of 350 %Max: 31.71
Total 824.31k 77.6/s

__ Created Temp ________________________________________________________
Disk table 29.99k 2.8/s
Table 100.82k 9.5/s Size: 1.0G
File 0 0/s

__ Threads _____________________________________________________________
Running 2 of 4
Cached 76 of 80 %Hit: 99.97
Created 208 0.0/s
Slow 0 0/s

__ Aborted _____________________________________________________________
Clients 1.78k 0.2/s
Connects 42 0.0/s

__ Bytes _______________________________________________________________
Sent 13.50G 1.3M/s
Received 1.08G 101.5k/s

mysql配置信息参照之前的优化
http://blog.c1gstudio.com/archives/1142

Posted in Mysql, 技术.

Tagged with , .


tuning-primer.sh 调优MySQL的性能

安装运行

wget http://www.day32.com/MySQL/tuning-primer.sh
chmod +x tuning-primer.sh

运行时你可以选择在用户目录下生成一个保存mysql密码的.my.cnf文件方便下次调用
~/.my.cnf文件内容应该是这样的
cat ~/.my.cnf

[client]
user=test
password=123qwe
socket=/opt/mysql/mysql.sock

./tuning-primer.sh

Using login values from ~/.my.cnf
– INITIAL LOGIN ATTEMPT FAILED –
Testing for stored webmin passwords:
None Found
Could not auto detect login info!
Found Sockets: /opt/mysql/mysql.sock
Using: /opt/mysql/mysql.sock
Would you like to provide a different socket?: [y/N] n
Do you have your login handy ? [y/N] : y
User: test
Password: 123qwe

Would you like me to create a ~/.my.cnf file for you? [y/N] : y

~/.my.cnf already exists!

Replace ? [y/N] : y
– FINAL LOGIN ATTEMPT FAILED –
Unable to log into socket: /opt/mysql/mysql.sock

因为我的mysql是编译安装在/opt/mysql/下,这里找不到执行文件,所以没有连接上.
编辑第219和220行,手动修改文件加上路径
vi tuning-primer.sh

215 if [ -f /etc/psa/.psa.shadow ] ; then
216 mysql=”mysql -S $socket -u admin -p$(cat /etc/psa/.psa.shadow)”
217 mysqladmin=”mysqladmin -S $socket -u admin -p$(cat /etc/psa/.psa.shadow)”
218 else
219 mysql=”/opt/mysql/bin/mysql”
220 mysqladmin=”/opt/mysql/bin/mysqladmin”
221 # mysql=”mysql -S $socket”
222 # mysqladmin=”mysqladmin -S $socket”
223 fi

顺带修复生成密码时的错误问题.
第313行”$pass\”后面需加个”n”

313 printf “[client]\nuser=$user\npassword=$pass\nsocket=$socket” > ~/.my.cnf

提示:vi中显示行号方法.在命令模式下输入”:set number”

保存后再次运行,在终端上按照问题重要程度分别用黄色/红色字符标记问题
./tuning-primer.sh

— MYSQL PERFORMANCE TUNING PRIMER —
– By: Matthew Montgomery –

MySQL Version 5.1.26-rc x86_64

Uptime = 0 days 7 hrs 17 min 18 sec
Avg. qps = 286
Total Questions = 7527430
Threads Connected = 6

Warning: Server has not been running for at least 48hrs.
It may not be safe to use these recommendations

To find out more information on how each of these
runtime variables effects performance visit:
http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html
Visit http://www.mysql.com/products/enterprise/advisors.html
for info about MySQL’s Enterprise Monitoring and Advisory Service

SLOW QUERIES
The slow query log is NOT enabled.
Current long_query_time = 10.000000 sec.
You have 29 out of 7527516 that take longer than 10.000000 sec. to complete
Your long_query_time seems to be fine

BINARY UPDATE LOG
The binary update log is NOT enabled.
You will not be able to do point in time recovery
See http://dev.mysql.com/doc/refman/5.1/en/point-in-time-recovery.html

WORKER THREADS
Current thread_cache_size = 80
Current threads_cached = 75
Current threads_per_sec = 0
Historic threads_per_sec = 0
Your thread_cache_size is fine

MAX CONNECTIONS
Current max_connections = 350
Current threads_connected = 7
Historic max_used_connections = 208
The number of used connections is 59% of the configured maximum.
Your max_connections variable seems to be fine.

No InnoDB Support Enabled!

MEMORY USAGE
Max Memory Ever Allocated : 68.78 G
Configured Max Per-thread Buffers : 112.17 G
Configured Max Global Buffers : 2.12 G
Configured Max Memory Limit : 114.29 G
Physical Memory : 15.66 G

nMax memory limit exceeds 90% of physical memory

KEY BUFFER
Current MyISAM index space = 3.00 G
Current key_buffer_size = 2.00 G
Key cache miss rate is 1 : 3262
Key buffer free ratio = 62 %
Your key_buffer_size seems to be fine

QUERY CACHE
Query cache is enabled
Current query_cache_size = 128 M
Current query_cache_used = 61 M
Current query_cache_limit = 2 M
Current Query cache Memory fill ratio = 47.81 %
Current query_cache_min_res_unit = 2 K
Query Cache is 21 % fragmented
Run “FLUSH QUERY CACHE” periodically to defragment the query cache memory
If you have many small queries lower ‘query_cache_min_res_unit’ to reduce fragmentation.
MySQL won’t cache query results that are larger than query_cache_limit in size

SORT OPERATIONS
Current sort_buffer_size = 256 M
Current read_rnd_buffer_size = 32 M
Sort buffer seems to be fine

JOINS
Current join_buffer_size = 32.00 M
You have had 15 queries where a join could not use an index properly
join_buffer_size >= 4 M
This is not advised
You should enable “log-queries-not-using-indexes”
Then look for non indexed joins in the slow query log.

OPEN FILES LIMIT
Current open_files_limit = 51200 files
The open_files_limit should typically be set to at least 2x-3x
that of table_cache if you have heavy MyISAM usage.
Your open_files_limit value seems to be fine

TABLE CACHE
Current table_open_cache = 3072 tables
Current table_definition_cache = 256 tables
You have a total of 658 tables
You have 1814 open tables.
The table_cache value seems to be fine
You should probably increase your table_definition_cache value.

TEMP TABLES
Current max_heap_table_size = 384 M
Current tmp_table_size = 1.00 G
Of 142450 temp tables, 18% were created on disk
Effective in-memory tmp_table_size is limited to max_heap_table_size.
Created disk tmp tables ratio seems fine

TABLE SCANS
Current read_buffer_size = 8 M
Current table scan ratio = 5065 : 1
read_buffer_size seems to be fine

TABLE LOCKING
Current Lock Wait ratio = 1 : 25
You may benefit from selective use of InnoDB.
If you have long running SELECT’s against MyISAM tables and perform
frequent updates consider setting ‘low_priority_updates=1’
If you have a high concurrency of inserts on Dynamic row-length tables
consider setting ‘concurrent_insert=2’.

我的my.cnf

[mysqld]
port = 3306
socket = /opt/mysql/mysql.sock
skip-locking
skip-name-resolve
back_log=100
key_buffer_size = 2048M
query_cache_size = 128M
query_cache_limit = 2M #default=1M
query_cache_min_res_unit = 2k #default=4K

max_allowed_packet = 16M
table_cache = 3072

tmp_table_size = 1024M #default=16M
max_heap_table_size = 384M #default=16M

read_buffer_size = 8M
read_rnd_buffer_size = 32M

sort_buffer_size = 256M
join_buffer_size = 32M
myisam_sort_buffer_size = 256M
thread_cache_size = 80 #default=0
thread_stack = 192K #default=192K

# Try number of CPU’s*2 for thread_concurrency
thread_concurrency = 16 #default=10
connect_timeout = 30
#interactive timeout = 600
max_connection = 350
max_connect_errors = 30
wait_timeout = 30

服务配置为5504(4核) *2,16G内存,centos 5.3 64位
大大小小十几个数据库,几十G数据,主要的应用是discuz论坛

根据提示对my.cnf做一些优化,效率更好了点.
关键还是需要优化sql来减少慢查询及锁定的问题.

key_buffer_size = 3096M
table_definition_cache = 800
join_buffer_size = 4M
low_priority_updates =1

参考:http://www.chedong.com/blog/archives/001451.html

Posted in Mysql, 技术.

Tagged with , , .