0%

备库因为某些错误停止时有发生,最常见的错误就是”HA_ERR_KEY_NOT_FOUND”和 “HA_ERR_FOUND_DUPP_KEY”.这既有可能是主备切换导致的,也可能是MySQL Bug导致的

通常有两种办法来处理备库错误:

  1. 设置 “sql_slave_skip_counter” 来忽略错误.
  2. set slave_exec_mode = ‘idempotent’ 来处理 “HA_ERR_FOUND_DUPP_KEY” (overwritten the record) 和”HA_ERR_KEY_NOT_FOUND”(简单的忽略掉错误).

这两种方法都可能导致主备不一致

如果你使用的是innodb存储引擎,并且使用的是ROW模式复制,那我们就可以fix这个Bug。

很久之前我写了一个工具(http://code.google.com/p/relay-fetch/ ,下面的slave_error_handler文件夹)可以用来处理这个问题。

以下的patch则通过修改代码,为slave_exec_mode增加新的选项SMART,来自动处理。

Read more »

1. 用谷歌账号创建Application(最多10个,这个当然是多多益善!)

进入https://appengine.google.com/ (没有谷歌账号就申请一个,需用手机号验证)

点击红框内的英文


注意!红框内的最重要,输入了什么一定要记住,等等填Appid要用,填完点右边的Check Availability检查有没有被使用过。

蓝框内随便填,不重要,就是这个Application的名字。下面黄底的那些英文直接跳过,不用填!


往下拉橙色框内的复选框勾上。点击绿色框内的英文。

Read more »

Major issue on a hosting server which serve hundreds of website is remain the same: I/O bottleneck. My curiosity began when I received a newsletter from a VPS provider in US, they said they have added SSD as filesystem cache to their server fleet. I asked my Russian virtualization platform support fellow and he gave me link to Flashcache page.

Flashcache is a kernel module released by Facebook engineer back in April 2010 to speed up database I/O on a standard rotational drive with the speed of SSD. Since it works by caching filesystem blocks, so it can speed anything on the slow rotational disk.
We’ve already use RAID10 with SAS disk on all of our hosting servers, but still I/O bottleneck often happens.

Server Configuration
We have 6 of 2.5″ drive bays on our server and load it up with :

  1. Disk 0 : 150GB SAS (/dev/sdb)
  2. Disk 1 : 120GB Intel 520 SSD (/dev/sdc)
  3. Disk 2 – 5 : 4 x 300GB SAS on RAID10 (/dev/sda)

OS : CloudLinux 6.4
Partitioning :
/dev/sdb3 mounted as /
/dev/sdb1 mounted as /boot
/dev/sda1 (RAID 10) mounted as /var/lib
/dev/sda2 (RAID 10) mounted as /home

Flashcache Installation Goals
I decide to try Flashcache to speed up /dev/sda(1-2) as this partition stored user’s file and database.

Flashcache Installation

Flashcache Installation Goals

  1. Update the whole system to get all packages up to date :

    1
    yum update
  2. Install required packages :

    1
    yum -y install dkms gcc make yum-utils kernel kernel-devel git make gcc-c++ device-mapper
  3. Reboot if you got new kernel version installed during update

  4. Flashcache installation :

    1
    2
    3
    4
    5
    cd /usr/local/src/
    git clone git://github.com/facebook/flashcache.git
    yumdownloader --source kernel-'uname -r
    rpm -ivh kernel-'uname -r'.src.rpm
    make && make install
  5. Since I haven’t touch the SSD, I’ll need to do partitioning and format this “fast and furious disk”.
    I spare 20GB of the disk in order to prevent SSD performance degradation and divide the 100GB disk in equal ratio with my /dev/sda1 and /dev/sda2 size :
    /dev/sdc1 80GB (for /dev/sda2 cache)
    /dev/sdc2 20GB (for /dev/sda1 cache)

  6. I’m going to make a writethrough cache, but https://github.com/facebook/flashcache/blob/master/utils/flashcache is only for writeback. So I’ve made a custom script you based on http://sf-alpha.bjgang.org/files/flashcache. You can download it here :

  1. Edit /etc/fstab and give comment to /home and /var/lib and then reboot!

via. https://piyecarane.wordpress.com/2013/05/12/install-flashcache-on-cloudlinux-and-centos/

win7

在默认情况下,任务栏上会有一个“库”按钮,单击之后会进入系统的“库”文件夹,但是我们一般很少用这个库,更多的还是直接到计算机选项,怎样更改显示为计算机,而不是跳到库里面呢?其实更改非常简单:

右键点击“库”按钮,再右键点击“Windows资源管理器”,选择“属性”,如图所示。

win7_windows资源管理器

Read more »

当我们需要通过xml格式处理sql语句时,经常会用到< ,<=,>,>=等符号,但是很容易引起xml格式的错误,这样会导致后台将xml字符串转换为xml文档时报错,从而导致程序错误。

这样的问题在iBatiS中或者自定义的xml处理sql的程序中经常需要我们来处理。其实很简单,我们只需作如下替换即可避免上述的错误:

原符号 | < | <= | > | >= | & | ‘ | “
—|—
替换符号 | &lt; | &lt;= | &gt; | &gt;= | &amp; | &apos; | &quot;

Read more »

CLOSE_WAIT状态

首先我们知道,如果我们的服务器程序APACHE,nginx,resin处于CLOSE_WAIT状态的话,说明套接字是被动关闭的!

因为如果是CLIENT端主动断掉当前连接的话,那么双方关闭这个TCP连接共需要四个packet:

Client —> FIN —> ServerClient <— ACK <— Server

这时候Client端处于FIN_WAIT_2状态;而Server 程序处于CLOSE_WAIT状态。

Client <— FIN <— Server

这时Server 发送FIN给Client,Server 就置为LAST_ACK状态。

Client —> ACK —> Server

Client回应了ACK,那么Server 的套接字才会真正置为CLOSED状态。

Server 程序处于CLOSE_WAIT状态,而不是LAST_ACK状态,说明还没有发FIN给Client,那么可能是在关闭连接之前还有许多数据要发送或者其他事要做,导致没有发这个FIN packet。

Read more »

我的电脑装的是Windows7 64位版,安装的IE版本是IE10 pre-release版,在浏览器的地址栏窗格中输入淘宝网的域名后,浏览器无任何反应,点击窗格右侧的向右箭头也无反应。登录其它网站都很正常,重置IE后也不能解决问题。一直不知道是IE10的设置哪里出了问题,登陆淘宝要先在打开天猫,登陆天猫后再进入淘宝,使用很不方便。今天google搜索,终于找到了解决问题的方法。

从INTERNET选项的“安全”选项卡中,最下方有个“启用保护模式”。把这个勾去掉,再重启浏览器就可以打开淘宝网了。

现有多个文本文件想要合并在一起,以两个文件为例子吧:

1
2
3
4
#fileA.txt
this is File A line1
this is File A line2
this is File A line3
1
2
3
4
#fileB.txt
this is File B line1
this is File B line2
this is File B line3

想要实现交叉的合并,合并后结果为:

1
2
3
4
5
6
this is File A line1
this is File B line1
this is File A line2
this is File B line2
this is File A line3
this is File B line3

command1:

1
paste $fileA $fileB |tr "\t" "\n" > newfile

command2:

1
awk '{getline line < "fileB.txt";print $0;print line}' fileA.txt

问题根源

没有安装或启动 sendmail 组件

解决办法

  1. 确认已经安装sendmail

    1
    yum install sendmail

    Redhat 与
    CentOS 用户可以使用 yum 进行安装;Ubuntu 与 Debian 用户可以使用 apt-get 进行
    安装。

  2. 使用下面的命令重启php-fpm进程

    1
    /etc/init.d/php-fpm restart
  3. 检测sendmail是否运行正常,确保

    1
    /etc/init.d/sendmail status
  4. 配置php.ini,填写sendmail的绝对路径

    1
    sendmail_path = /usr/sbin/sendmail -t -i
  5. 重启php-fpm进程

    1
    /etc/init.d/php-fpm restart