Monthly Archives: 十一月 2009

MySQL Cluster 7.0 试用(一)


1.MySQL Cluster是一个以独特的无共享体系的架构,适合于分布式计算环境的高可用,高冗余版本,采用NDB存储引擎并且由一组数据节点构成,可以通过MySQL Server用标准SQL来访问,也可以用NDB API进行实时访问。
MySQL Cluster 7.0 新特性:

1.支持Data Node 多线程访问
2.可以在线添加节点
3.支持windows平台
4.改进大数据处理能力
5.可配置数据缓存

Mysql  Cluster 组成节点及每个节点的特点:
管理节点(Management(MGMD)node):
负责集群的初始化,Cluster的启动,停止管理节点在集群配置完成并启动后,无论处于什么状态都不会影响整个集群的可用性。
SQL节点(SQL Node):
可以是MySQL Server也可以是NDB API,SQL节点可以在线添加来提高集群系统的性能和高可用.最少用两个SQL节点来避免单点故障.
数据节点(Data Nodes):
节点之间相互同步
管理数据和存储数据
自动故障恢复
支持多线程
2.操作系统要求
生产系统要求必须是linux或unix,而在开发[......]

继续阅读

用Google-perftools的TCMalloc优化MySQL


TCMalloc(Thread-Caching Malloc)可以提高MySQL在内存分配方面的性能和效率,具体请看官方文档
http://google-perftools.googlecode.com/svn/trunk/doc/tcmalloc.html

一.下载软件
wget http://google-perftools.googlecode.com/files/google-perftools-1.4.tar.gz
如果是64位系统请安装libunwind,32位请跳过
wget http://ftp.twaren.net/Unix/NonGNU/libunwind/libunwind-0.99.tar.gz

tar -zxvf libunwind-0.99.tar.gz
cd libunwind-0.99/
CFLAGS=-fPIC ./configure
make CFLAGS=-fPIC
make CFLAGS=-fPIC install

二.安装

tar -zxvf google-perftools-1.4.tar.gz
cd google-perftools[......]

继续阅读

Linux下安装pptpd服务器


一.环境介绍:
OS:Centos5.3(32位)
二.下载pptpd
wget http://poptop.sourceforge.net/yum/stable/packages/pptpd-1.3.4-1.rhel5.1.i386.rpm
注:64位的机器请下载相应版本
三.安装pptpd

rpm -ivh pptpd-1.3.4-1.rhel5.1.i386.rpm

四.主要相关配置文件

/etc/pptpd.conf
/etc/ppp/options.pptpd
/etc/ppp/chap-secrets

1.vim /etc/ppp/options.pptpd在其中加入

ms-dns 208.67.222.222
ms-dns 208.67.222.220

2.vim /etc/pptpd.conf 在最后加入

localip 172.16.1.1
remoteip 172.16.1.10-20

3.vim /etc/ppp/chap-secrets 添加相应的账户信息

# Secrets for authentication using CHAP
# cl[......]

继续阅读

切换到普通用户的问题


用Nginx做反向代理时,网站首页top上的照片无法显示,查看Nginx的日志发现

2009/11/18 10:01:16 [crit] 19653#0: *7 open()
"/usr/local/nginx/proxy_temp/1/00/0000000001"
failed (13: Permission denied)
while reading upstream, client: 123.114.223.21,
server: www.lsanotes.cn,request:
"GET /images/090324A49.jpg HTTP/1.1",
upstream: " http://192.168.1.7:80/images/090324A49.jpg
host:lsanotes.cn , referrer: "http://www.lsanotes.cn/"

因为Nginx使用的是www用户,查看proxy_temp目录发现www有权限啊,放大权限直接给了个77[......]

继续阅读

expect 自动登录服务器执行操作


以下expect脚本是用root用户登录某server并执行touch test.txt

#!/usr/bin/expect -f
#Filename:login.exp
#write by zhangll
set ip [lindex $argv 0 ]
set password [lindex $argv 1 ]
set timeout 50
spawn ssh root@$ip
expect {
"*yes/no" { send "yes\r"; exp_continue}
"*password:" { send "$password\r" }
}
expect "]*"
send "touch test.txt\r"
send "exit\r"
expect eof

执行:

chmod +x login.exp
[......]

继续阅读

max_open_files 导致MySQL产生异常


今天同事说跑程序时MySQL总自动断开而后程序会停止,因为MySQL和程序是在同一台机器排除网络原因,后来随便找一个数据少的表,用select count(*) from news;一直不断的刷新,过一小会就会出现:

MySQL server has gone away No connection. Trying TO reconnect…

之前出现类似has gone away的时候是因为导入数据时max_allowed_packet值太小的原因,试着加大没有效果,接着看日志发现问题了

Nov 12 16:05:09 spider mysqld[763]: 091112 16:05:09 [Warning] Could not increase number of max_open_files to more than 1024 (request: 1210)

接着查看MySQL的open_files_limit为1024,如下:

mysql> SHOW VARIABLES LIKE ‘open%’;
+—–[......]

继续阅读

Shell Script-查看文件上次修改访问时间


#!/bin/bash
# Time of last access
# Time of last modification
# Time of last change
 
FILE="$1"
 
# 判断是否带有参数
if [ $# -eq 0 ]
then
echo "$0 file-name"
exit 1
fi
 
which stat > /dev/null
 
# 查看是否安装有stat
if [ $? -eq 1 ]
then
echo "stat command not found!"
exit 2
fi
 
# 判断文件是否存在
if [ ! -e $FILE ]
then
echo "$FILE not a file"
exit 3
fi
 
# 用stat得到文件的相关信息
echo "Time of last access : $([......]

继续阅读

Linux下LVS+Keepalived实现高可用的负载均衡


在2008年12月份的时候写过一版,这个只是一个升级版本,当时的keepalived是
2007-09-16 Release 1.1.15,而现在最新版本为2009-10-01 Release 1.1.19
一.环境介绍
Master:Centos5.2
Backup:Centos5.2
RealServer1:RHEL5 (安装有apache2.2)
RealServer2:RHEL5 (安装有apache2.2)
VIP:192.168.3.241
RealServer1:192.168.3.160
RealServer2:192.168.3.170
用到的软件包:
ipvsadm-1.24.tar.gz
下载地址:
wget http://www.linuxvirtualserver.org/software/kernel-2.6/ipvsadm-1.24.tar.gz
keepalived-1.1.19.tar.gz
下载地址:
wget http://www.keepalived.org/software/keepalived-1.1.19.tar.gz
二.首先在mas[......]

继续阅读

ext3grep恢复ext3文件系统下误删的文件


环境说明:OS:Centos5.2 文件系统为ext3
1.首先模拟一个分区:

  1. mkdir /home/store
    cd /home/store
    dd if=/dev/zero of=file count=102400
    mkfs.ext3 file
    mount -o loop /home/store/file /mnt/

可以看到已经挂上去了

  • df -h
    Filesystem Size Used Avail Use% Mounted on
    /dev/mapper/VolGroup00-LogVol00
    13G 4.7G 7.5G 39% /
    /dev/hda1 99M 18M 77M 19% /boot
    tmpfs 107M 0 107M 0% /dev/shm
    /home/store/file 49M 4.9M 42M 11% /mnt

把/boot整个copy到/mnt里面

cp -r /boot /mnt/
cd /mnt/boot

以下是boot里面的内容

ls
System.map-2.6.18-92.1.17.el5 lost+found
[......]

继续阅读

Jabber客户端Gajim


  • 内部通讯一直用spark,因为它支持xmpp协议,也是跨平台的,
  • 但是在linux下点击关闭或是最小化不能最小化到任务栏只能关闭或在最下面的任务条很不方便,
  • 试了很多支持xmpp协议的Client,像Pidgin,Jabbim,Coccinella,Psi等效果都不满意,
  • 后果选择了Gajim,用了一段时间还算满意,Gajim也有Windows版,但是我个人感觉支持的不怎么样

gajim