change mysql data directory
[
2009/07/30 12:08 | by askwan ]
2009/07/30 12:08 | by askwan ]
案例描述:
某公司某数据原来安装于系统的/usr/local/mysql下
数据库文件存放路径自然是/usr/local/mysql/data目录
现在挂载这个区的空间快full了,增加了块1T硬盘挂在系统下/opt/mysql下
1.停mysql数据库
2.转移原来的/usr/local/mysql/data 到/opt/mysql 下
3.修改my.cnf配置文件
[mysqld]段修改datadir=/opt/mysql/data
[mysqld]
datadir=/opt/mysql/data
4.按照原方式启动mysql
-----------END------------
某公司某数据原来安装于系统的/usr/local/mysql下
数据库文件存放路径自然是/usr/local/mysql/data目录
现在挂载这个区的空间快full了,增加了块1T硬盘挂在系统下/opt/mysql下
1.停mysql数据库
2.转移原来的/usr/local/mysql/data 到/opt/mysql 下
3.修改my.cnf配置文件
[mysqld]段修改datadir=/opt/mysql/data
[mysqld]
datadir=/opt/mysql/data
4.按照原方式启动mysql
-----------END------------
"Metadata file does not match checksum"
[
2009/07/30 11:55 | by askwan ]
2009/07/30 11:55 | by askwan ]
yum有时候不是很稳定?不知道是不是RP问题
每次出现这个 都要“清仓”才行
yum clean all
奈何?
[Errno -1] Metadata file does not match checksum
Trying other mirror.
Trying other mirror.
每次出现这个 都要“清仓”才行
yum clean all
奈何?
The 2nd Sino - Japanese War
[
2009/07/26 09:47 | by askwan ]
2009/07/26 09:47 | by askwan ]
不朽的光荣:第二次中日战争史 重温那段慢慢被淡忘的历史 接近历史与否 不知道 60多年过去了 各D有各D的说法 不过想 相信每个人心里都有一杆秤
偶然 找到了本书的网上的电子版 原文在铁血网上刊载过
Download ( 173 downloads) 对抗战史感兴趣的friends and fans 可以download下来读读
1000多页的书
http://www.verycd.com/topics/2773486/
http://www.verycd.com/topics/2789066/
Download ( 173 downloads)
附1:《抗日战争正面战场》(中国第二历史档案馆)影印版[PDF]
1000多页的书http://www.verycd.com/topics/2773486/
附2:《抗日战争史话》(朱宗震)扫描版[PDF]
http://www.verycd.com/topics/2789066/
PostgreSQL的mulitmaster replication解决方案Cybercluster
[
2009/07/24 10:50 | by askwan ]
2009/07/24 10:50 | by askwan ]
简介:
Cybercluster是一种Postgresql数据库的mulitmaster replication solution, shared-nothing构架,基于BSD协议发放,由奥地利一家做基于postgresql数据库解决方案和服务的公司团队维护开发,cybercluster整体架构设计基于古老的pgcluster。
因工作原因,小小研究了一番。
四类节点:
LoadBlancer 节点 :负责给客户端应用请求做负载均衡,在一个架构中是可选的节点
Cluster DB 节点:存储数据的节点,在一个架构中是必须的节点,只少要一个(这不废话吗,呵呵)
Replication Manager 节点: 负责分析和判断应用请求以及同步数据的节点
Monitor 节点 :负责监控架构中各个cluster 节点
对于读请求,看下图

通过LoadBlancer 节点分配到负载最小的一个cluster db 节点
对于写请求,看下图

如果是写等修改数据库内容请求,则Replication Manager节点会连接每一个activer的 cluster db都执行同一操作
这个flash比较形象 ,http://www.postgresql.at/flash/cybercluster.swf
从这个意义上说,这种同步方式属于 SQL Statement类型的 ,而不是Row level型。
环境搭建:
这个可以参看软件包内说明,比较简单。
故障恢复:
cybercluster提供了三种cluster db node 故障恢复方式,例如,启动cluster db node 节点,指定
1. pg_ctl -D /usr/local/pgsql/data start -o "-R"
2. pg_ctl -D /usr/local/pgsql/data start -o "-u"
3. pg_ctl -D /usr/local/pgsql/data start -o "-U"
前两种方式属于cold recovery,依赖于架构配置好ssh + rsync 无密码访问,简言之,通过rsync来做文件级别的copy达到恢复数据的目地,这个比较特别
如下我做实验的恢复过程:
后一种则是基于逻辑意义上的恢复,
如下我做的是实验的恢复过程:
Start in recovery mode!
Please wait until a data synchronization finishes from Master DB...
LOG: autovacuum launcher started
LOG: database system is ready to accept connections
1st restore from pg_dump 1st exec:[/usr/local/pgsql/bin/pg_dumpall -i -o -c -h cluster1 -p 5432 -U postgres | /usr/local/pgsql/bin/psql -p 5432 template1]
You are now connected to database "postgres".
ERROR: current user cannot be dropped
STATEMENT: DROP ROLE postgres;
ERROR: current user cannot be dropped
ERROR: role "postgres" already exists
STATEMENT: CREATE ROLE postgres;
ERROR: role "postgres" already exists
ALTER ROLE
DROP DATABASE
CREATE DATABASE
REVOKE
REVOKE
GRANT
GRANT
You are now connected to database "askwan01".
CREATE TABLE
ALTER TABLE
REVOKE
REVOKE
GRANT
GRANT
You are now connected to database "postgres".
REVOKE
REVOKE
GRANT
GRANT
You are now connected to database "template1".
COMMENT
REVOKE
REVOKE
GRANT
GRANT
->OK
2nd restore from pg_dump 2nd exec:[/usr/local/pgsql/bin/pg_dump -i -Fc -o -b -h cluster1 -p 5432 -U postgres postgres | /usr/local/pgsql/bin/pg_restore -i -c -p 5432 -d postgres]
.2nd exec:[/usr/local/pgsql/bin/pg_dump -i -Fc -o -b -h cluster1 -p 5432 -U postgres askwan01 | /usr/local/pgsql/bin/pg_restore -i -c -p 5432 -d askwan01]
.->OK
2nd recovery successed
OK! The data synchronization with Master DB was finished.
能清楚的看到这两个之间的区别。
监控节点:
没有什么好说的,做的非常简陋
感受:
优点:
1.架设简单。
2.支持负载均衡。
3.原理易懂,应用不需要做任何变更。
4.可扩展性比较好,各类型节点可以很容易的增加到集群中。
缺点:
1.文档其少,相关资料也少,要使用它,真得慎重
2.恢复的时候,Replication Manager节点配置文件中cluster db node位置得手动修改,希望高版本改进!
性能:
没有时间做测试,暂不评价!
Cybercluster是一种Postgresql数据库的mulitmaster replication solution, shared-nothing构架,基于BSD协议发放,由奥地利一家做基于postgresql数据库解决方案和服务的公司团队维护开发,cybercluster整体架构设计基于古老的pgcluster。
因工作原因,小小研究了一番。
四类节点:
LoadBlancer 节点 :负责给客户端应用请求做负载均衡,在一个架构中是可选的节点
Cluster DB 节点:存储数据的节点,在一个架构中是必须的节点,只少要一个(这不废话吗,呵呵)
Replication Manager 节点: 负责分析和判断应用请求以及同步数据的节点
Monitor 节点 :负责监控架构中各个cluster 节点
对于读请求,看下图
通过LoadBlancer 节点分配到负载最小的一个cluster db 节点
对于写请求,看下图
如果是写等修改数据库内容请求,则Replication Manager节点会连接每一个activer的 cluster db都执行同一操作
这个flash比较形象 ,http://www.postgresql.at/flash/cybercluster.swf
从这个意义上说,这种同步方式属于 SQL Statement类型的 ,而不是Row level型。
环境搭建:
这个可以参看软件包内说明,比较简单。
故障恢复:
cybercluster提供了三种cluster db node 故障恢复方式,例如,启动cluster db node 节点,指定
1. pg_ctl -D /usr/local/pgsql/data start -o "-R"
2. pg_ctl -D /usr/local/pgsql/data start -o "-u"
3. pg_ctl -D /usr/local/pgsql/data start -o "-U"
前两种方式属于cold recovery,依赖于架构配置好ssh + rsync 无密码访问,简言之,通过rsync来做文件级别的copy达到恢复数据的目地,这个比较特别
如下我做实验的恢复过程:
Start in recovery mode!
Please wait until a data synchronization finishes from Master DB...
1st recovery step of [global] directory...OK
1st recovery step of [base] directory...OK
1st recovery step of [pg_clog] directory...OK
1st recovery step of [pg_xlog] directory...OK
1st sync_table_space OK
2nd recovery step of [global] directory...OK
2nd recovery step of [base] directory...OK
2nd recovery step of [pg_clog] directory...OK
2nd recovery step of [pg_xlog] directory...OK
2nd sync_table_space OK
2nd recovery successed
LOG: database system was interrupted; last known up at 2009-07-24 10:02:05 CST
LOG: database system was not properly shut down; automatic recovery in progress
Start in recovery mode!
Please wait until a data synchronization finishes from Master DB...
OK! The data synchronization with Master DB was finished.
LOG: redo starts at 0/4FC8A0
LOG: record with zero length at 0/522AE4
LOG: redo done at 0/522AB8
LOG: last completed transaction was at log time 2009-07-24 10:01:53.911028+08
LOG: autovacuum launcher started
LOG: database system is ready to accept connections
Please wait until a data synchronization finishes from Master DB...
1st recovery step of [global] directory...OK
1st recovery step of [base] directory...OK
1st recovery step of [pg_clog] directory...OK
1st recovery step of [pg_xlog] directory...OK
1st sync_table_space OK
2nd recovery step of [global] directory...OK
2nd recovery step of [base] directory...OK
2nd recovery step of [pg_clog] directory...OK
2nd recovery step of [pg_xlog] directory...OK
2nd sync_table_space OK
2nd recovery successed
LOG: database system was interrupted; last known up at 2009-07-24 10:02:05 CST
LOG: database system was not properly shut down; automatic recovery in progress
Start in recovery mode!
Please wait until a data synchronization finishes from Master DB...
OK! The data synchronization with Master DB was finished.
LOG: redo starts at 0/4FC8A0
LOG: record with zero length at 0/522AE4
LOG: redo done at 0/522AB8
LOG: last completed transaction was at log time 2009-07-24 10:01:53.911028+08
LOG: autovacuum launcher started
LOG: database system is ready to accept connections
后一种则是基于逻辑意义上的恢复,
如下我做的是实验的恢复过程:
Start in recovery mode!
Please wait until a data synchronization finishes from Master DB...
LOG: autovacuum launcher started
LOG: database system is ready to accept connections
1st restore from pg_dump 1st exec:[/usr/local/pgsql/bin/pg_dumpall -i -o -c -h cluster1 -p 5432 -U postgres | /usr/local/pgsql/bin/psql -p 5432 template1]
You are now connected to database "postgres".
ERROR: current user cannot be dropped
STATEMENT: DROP ROLE postgres;
ERROR: current user cannot be dropped
ERROR: role "postgres" already exists
STATEMENT: CREATE ROLE postgres;
ERROR: role "postgres" already exists
ALTER ROLE
DROP DATABASE
CREATE DATABASE
REVOKE
REVOKE
GRANT
GRANT
You are now connected to database "askwan01".
CREATE TABLE
ALTER TABLE
REVOKE
REVOKE
GRANT
GRANT
You are now connected to database "postgres".
REVOKE
REVOKE
GRANT
GRANT
You are now connected to database "template1".
COMMENT
REVOKE
REVOKE
GRANT
GRANT
->OK
2nd restore from pg_dump 2nd exec:[/usr/local/pgsql/bin/pg_dump -i -Fc -o -b -h cluster1 -p 5432 -U postgres postgres | /usr/local/pgsql/bin/pg_restore -i -c -p 5432 -d postgres]
.2nd exec:[/usr/local/pgsql/bin/pg_dump -i -Fc -o -b -h cluster1 -p 5432 -U postgres askwan01 | /usr/local/pgsql/bin/pg_restore -i -c -p 5432 -d askwan01]
.->OK
2nd recovery successed
OK! The data synchronization with Master DB was finished.
能清楚的看到这两个之间的区别。
监控节点:
没有什么好说的,做的非常简陋
postgres@testpg1$ pgrplmon rep1 9000
RPLMonitor v1.0
DB server #1
Hostname: cluster1
Resolved host: 192.168.233.144
Port: 5432
# of started transactions: 0
# of COMMITed transactions: 0
# of ROLLBACKed transactions: 0
# of INSERT statements: 13
# of UPDATE statements: 0
# of DELETE statements: 0
# of DDL statements: 6
DB server #2
Hostname: cluster2
Resolved host: 192.168.233.145
Port: 5432
# of started transactions: 0
# of COMMITed transactions: 0
# of ROLLBACKed transactions: 0
# of INSERT statements: 0
# of UPDATE statements: 0
# of DELETE statements: 0
# of DDL statements: 0
RPLMonitor v1.0
DB server #1
Hostname: cluster1
Resolved host: 192.168.233.144
Port: 5432
# of started transactions: 0
# of COMMITed transactions: 0
# of ROLLBACKed transactions: 0
# of INSERT statements: 13
# of UPDATE statements: 0
# of DELETE statements: 0
# of DDL statements: 6
DB server #2
Hostname: cluster2
Resolved host: 192.168.233.145
Port: 5432
# of started transactions: 0
# of COMMITed transactions: 0
# of ROLLBACKed transactions: 0
# of INSERT statements: 0
# of UPDATE statements: 0
# of DELETE statements: 0
# of DDL statements: 0
感受:
优点:
1.架设简单。
2.支持负载均衡。
3.原理易懂,应用不需要做任何变更。
4.可扩展性比较好,各类型节点可以很容易的增加到集群中。
缺点:
1.文档其少,相关资料也少,要使用它,真得慎重
2.恢复的时候,Replication Manager节点配置文件中cluster db node位置得手动修改,希望高版本改进!
性能:
没有时间做测试,暂不评价!




