月度归档:2017年03月

13.4.2.1 CHANGE MASTER TO Syntax

HANGE MASTER TO option [, option] ...

option:
    MASTER_BIND = 'interface_name'
  | MASTER_HOST = 'host_name'
  | MASTER_USER = 'user_name'
  | MASTER_PASSWORD = 'password'
  | MASTER_PORT = port_num
  | MASTER_CONNECT_RETRY = interval
  | MASTER_RETRY_COUNT = count
  | MASTER_DELAY = interval
  | MASTER_HEARTBEAT_PERIOD = interval
  | MASTER_LOG_FILE = 'master_log_name'
  | MASTER_LOG_POS = master_log_pos
  | MASTER_AUTO_POSITION = {0|1}
  | RELAY_LOG_FILE = 'relay_log_name'
  | RELAY_LOG_POS = relay_log_pos
  | MASTER_SSL = {0|1}
  | MASTER_SSL_CA = 'ca_file_name'
  | MASTER_SSL_CAPATH = 'ca_directory_name'
  | MASTER_SSL_CERT = 'cert_file_name'
  | MASTER_SSL_CRL = 'crl_file_name'
  | MASTER_SSL_CRLPATH = 'crl_directory_name'
  | MASTER_SSL_KEY = 'key_file_name'
  | MASTER_SSL_CIPHER = 'cipher_list'
  | MASTER_SSL_VERIFY_SERVER_CERT = {0|1}
  | IGNORE_SERVER_IDS = (server_id_list)

server_id_list:
    [server_id [, server_id] ... ]
STOP SLAVE; -- if replication was running
CHANGE MASTER TO MASTER_PASSWORD='new3cret';
START SLAVE; -- if you want to restart replication

实例:

stop slave;
CHANGE MASTER TO
 MASTER_HOST = 'master',
 MASTER_USER = 'repl',
 MASTER_PASSWORD = 'xxxxxxxx',
 MASTER_PORT = 3306,
 MASTER_LOG_FILE ='mysql-bin.005029',
 MASTER_LOG_POS =0;
set global replicate_do_db = 'doufu';
set global replicate_ignore_db ='mysql,information_schema,performance_schema';
start slave;
show slave status;
show variables like '%Replicate%';

CouchDB 笔记

CouchDB PHP客户端:https://github.com/sn01615/couchdb-client

创建数据库
curl -X PUT http://127.0.0.1:5984/test

获取数据库列表
curl -X GET http://127.0.0.1:5984/_all_dbs

创建数据库
curl -vX PUT http://127.0.0.1:5984/albums-backup

删除数据库
curl -vX DELETE http://127.0.0.1:5984/albums-backup

保存一条数据
curl -X PUT http://127.0.0.1:5984/test/6e1295ed6c29495e54cc05947f18c8af -d ‘{“title”:”There is Nothing Left to Lose”,”artist”:”Foo Fighters”}’

获取一条数据
curl -X GET http://127.0.0.1:5984/test/6e1295ed6c29495e54cc05947f18c8af

创建用户名密码
HOST=”http://127.0.0.1:5984″
curl -X PUT $HOST/_config/admins/username -d ‘”password”‘

要在配置文件里设置密码

使用用户名密码获取数据
HOST=”http://username:password@127.0.0.1:5984″
curl -X GET $HOST/test/6e1295ed6c29495e54cc05947f18c8af

继续阅读

pt-online-schema-change 在线热修改表,不锁表

连接到master上执行

pt-online-schema-change --user=root --password=xxxxx--host=master D=doufu,t=user_comment --execute --alter "ADD COLUMN content_image text NULL COMMENT '' AFTER like_uids" --nocheck-replication-filters

选项说明:
–user=root 用户名
–password=xxxxx 密码
–host=master 主机ip或域名
D=doufu,t=user_comment 数据库名和表明
–execute 不加此参数不会真的执行
–alter “ADD COLUMN content_image text NULL COMMENT ” AFTER like_uids” 需要执行的修改操作
–nocheck-replication-filters 如果有主从结构必须加此参数才能运行, 必须在主库上执行