mysql 基于 master-master 的双机热备配置

master-master 就是两台服务器互为主从:
master1-slave(master2) && master2-slave(master1)

  • master1: 192.168.100.191
  • master2: 192.168.100.166

master1-slave(master2)

mysql 版本最好一致

设置 master1

  1. 创建给 slave 登录用的用户名密码:

    mysql> GRANT REPLICATION SLAVE ON *.* TO 'backup'@'192.168.100.166' IDENTIFIED BY 'yNZE7fK9*@aMA?*ppF';
    
    # humanreadable
    mysql> # grant replication slave on *.* to 'backup'@'192 ...
more ...

[python]第三方模块 python-dateutil:扩展并增强 datetime 模块的功能

简介

扩展并增强 datetime 模块的功能。支持 Python 2.3+。

主页

http://labix.org/python-dateutil

文档

http://labix.org/python-dateutil

安装

pip install python-dateutil

# or
# download from https://pypi.python.org/pypi/python-dateutil
python setup.py install

简单使用

获取历史上的今天,上个月的今天,下个月的今天 link

>>> import datetime
>>> from dateutil.relativedelta import relativedelta
>>>
>>> today
datetime.date ...
more ...

[python]解决使用 argparse 时出现:ValueError: unsupported format character 'p' (0x70) at index 8

将程序从 optparse 转到 argparse 后,出现了如下错误:

...
  File "C:\PYTHON26\lib\site-packages\argparse-1.2.1-py2.6.egg\argparse.py", line 230, in format_help
    func(*args)
  File "C:\PYTHON26\lib\site-packages\argparse-1.2.1-py2.6.egg\argparse.py", line 317, in _format_usage
    usage = usage % dict(prog=self._prog ...
more ...