我最近也在找资料,可以用另外的工具usogreshttp://usogres.good-day.net一个日本的网站!如何用USOGRES做数据库热备份
How to install(怎样安装)
First, to confirm duplication, start two PostgreSQL in one machine and execute usogres.(首先,要确定复制,在一台机器上启动两个POSTGRESQL 然后执行USOGRES)
This type setup processes are following.(下面是安装过程)
And if you want to create a backup of PostgreSQL database in another machine, your work is only rewrite a setup file.(如果你想建一台POSTGRESQL 数据库的备份机器,你的工作仅仅是重写一个配置文件)
Let's try to install it to confirm a duplication. (我们试试安装一下吧)
A necessity(第一步,必须品)
· PostgreSQL which is the condition that it can work.(POSTGRESQL能够正常动作 )
· The source code of Usogres. You can get here.(USOGRES的源文件)
· A set of database which you want to duplicate. (你想要复制的数据库)
· development tools(c++ compiler is indispensable.) (开发工具,C++编译器是不可少的)
Setup process<第二,安装过程>
· Confirm that a development tool such as c++ is gathered. <开发工具,C++编译器已经安装好了>
· PostgreSQL is made the condition that it can work. Refer to this page for the introduction of PostgreSQL. (POSTGRESQL能够正常动作)
Now, this linked page is english. (Thanks lot! Sebastien Paviot).
· You should get the source code of usogres. Stable version is here.
· A taken source code should be set in the suitable place, and type below (取得的源文件放在一个适当的位置,然后输入:)
tar xzf usogres-0.0.x.tar.gz
If you are using Slackware and expanding bz2 file, use 'tar xyf
usogres-0.0.x.tar.bz2' (如果你用Slackware and expanding bz2 文件你的命令是: 'tar xyf usogres-0.0.x.tar.bz2')
· Change directory to the directory where the source codes are expanded. (进入你的源文件解压后的目录输入:./configure …..)
· type
· ./configure
· make
su -c "make install"
When you type above, then executable file was installed in name /usr/local/bin/usogres. (当你执行完上面的命令后,可执行文件就安装在/usr/local/bin/usogres这个目录)
· You should create the setup file for usogres in the home directory of the user who execute usogres.(你要建立配置文件到可执行USOGRES人的主目录,配置文件的名称是:.usogresrc)
The name of the setup file is '.usogresrc'.
The file of the sample is shown here.(配置文件内容大致如下:)
· host = "127.0.0.1"
· port = 5432
· hostorg = "127.0.0.1"
· portorg = 5434
· hostcopy = "127.0.0.1"
portcopy = 5436
The contents of setup file are as the following. (配置文件内容大致如下:)
o host : The host address where usogres stands by.( usogres的安装主机IP)
o port : The port number where usogres stands by. (usogres的安装主机的端口号)
o hostorg : The host address that a main PostgreSQL stands by.( PostgreSQL的主要数据库的主机IP)
o portorg : The port number that a main PostgreSQL stands by. ( PostgreSQL的主要数据库的主机端口)
o hostcopy : The host address that a sub PostgreSQL stands by. ( PostgreSQL的次要数据库的主机IP)
o portcopy : The port number that a sub PostgreSQL stands by. ( PostgreSQL的次要数据库的主机端口)
· The compulsion of the database synchronizes.(强制数据库同步)
If you done a process to show here, the contents of the sub database are completely destroyed.(如果你执行下面的动作,数据库的潜在容量将全被破坏)
Do work after you surely take a backup. (最好是你 先备份一下)
o Stop a main database.(用 pg_ctl 的 kill 命令停止所有的数据库)
o Stop a sub database, too.(If you excuted second postmaster)
o The data directory of /usr/local/pgsql/data(of the main database) and the sub database is described in the following as /usr/local/pgsql/data2 . (主要数据库的目录是’ /usr/local/pgsql/data’,备份数据库的目录是’ /usr/local/pgsql/data2’)
o If /usr/local/pgsql/data2 doesn't exist, it is made as 'mkdir /usr/local/pgsql/data2'. (如果备份数据库的目录不存在则用MKDIR建立)
o Change directory to /usr/local/pgsql/data, and the following command you should execute, then the main database and sub database are made the same contents forcibly.(进入目录’ /usr/local/pgsql/data’,你要执行下面的命令,这时主要的和备份的数据库容量将是一样大)
tar cf - . | (cd ../data2; tar xf -)
A little more easily when you using a GNU tar(如果你用早期的GNU TAR 就是下面的)
tar cf - . | tar xf - -C ../data2
· Start the main postmaster. It is the setup shown here, because it stands by in the port of 5434 (启动主要数据库,它的配置有所改变,端口为5434,命令如下:)
su pgsql -c "/usr/local/pgsql/bin/postmaster -S -i -p 5434 -D /usr/local/pgsql/data"
· Start sub postmaster. It is the setup shown here, because it stands by in the port of 5436 (启动备份数据库,它的配置有所改变,端口为5436,命令如下:)
su pgsql -c "/usr/local/pgsql/bin/postmaster -S -i -p 5436 -D /usr/local/pgsql/data2"
· Start usogres. It is never especially difficult. (启动USOGRES,它没有什么特别的地方)
/usr/local/bin/usogres
It is all right as the above if it just starts without an option. Usogres uses setup file for his execution. (就是上面这样了,启动时不带OPTION 参数)
· For the client setup, two environment variable should setup below. (客户端的设置:pghost,和pgport 是usogres 所在的机器和端口)
o PGHOST : Host name that usogres to stand by.
o PGPORT : Port address that usogres to stand by. The example of bash and the example of csh are shown. (下面是csh应用的列子)
o bash
o export PGHOST=localhost
export PGPORT=5432
o csh
o setenv PGHOST localhost
setenv PGPORT 5432
Two databases and usogres started in the above.
Try variously by using the psql command and so on.
(现在OK了,用不同的命令试试吧!)
How to install(怎样安装)
First, to confirm duplication, start two PostgreSQL in one machine and execute usogres.(首先,要确定复制,在一台机器上启动两个POSTGRESQL 然后执行USOGRES)
This type setup processes are following.(下面是安装过程)
And if you want to create a backup of PostgreSQL database in another machine, your work is only rewrite a setup file.(如果你想建一台POSTGRESQL 数据库的备份机器,你的工作仅仅是重写一个配置文件)
Let's try to install it to confirm a duplication. (我们试试安装一下吧)
A necessity(第一步,必须品)
· PostgreSQL which is the condition that it can work.(POSTGRESQL能够正常动作 )
· The source code of Usogres. You can get here.(USOGRES的源文件)
· A set of database which you want to duplicate. (你想要复制的数据库)
· development tools(c++ compiler is indispensable.) (开发工具,C++编译器是不可少的)
Setup process<第二,安装过程>
· Confirm that a development tool such as c++ is gathered. <开发工具,C++编译器已经安装好了>
· PostgreSQL is made the condition that it can work. Refer to this page for the introduction of PostgreSQL. (POSTGRESQL能够正常动作)
Now, this linked page is english. (Thanks lot! Sebastien Paviot).
· You should get the source code of usogres. Stable version is here.
· A taken source code should be set in the suitable place, and type below (取得的源文件放在一个适当的位置,然后输入:)
tar xzf usogres-0.0.x.tar.gz
If you are using Slackware and expanding bz2 file, use 'tar xyf
usogres-0.0.x.tar.bz2' (如果你用Slackware and expanding bz2 文件你的命令是: 'tar xyf usogres-0.0.x.tar.bz2')
· Change directory to the directory where the source codes are expanded. (进入你的源文件解压后的目录输入:./configure …..)
· type
· ./configure
· make
su -c "make install"
When you type above, then executable file was installed in name /usr/local/bin/usogres. (当你执行完上面的命令后,可执行文件就安装在/usr/local/bin/usogres这个目录)
· You should create the setup file for usogres in the home directory of the user who execute usogres.(你要建立配置文件到可执行USOGRES人的主目录,配置文件的名称是:.usogresrc)
The name of the setup file is '.usogresrc'.
The file of the sample is shown here.(配置文件内容大致如下:)
· host = "127.0.0.1"
· port = 5432
· hostorg = "127.0.0.1"
· portorg = 5434
· hostcopy = "127.0.0.1"
portcopy = 5436
The contents of setup file are as the following. (配置文件内容大致如下:)
o host : The host address where usogres stands by.( usogres的安装主机IP)
o port : The port number where usogres stands by. (usogres的安装主机的端口号)
o hostorg : The host address that a main PostgreSQL stands by.( PostgreSQL的主要数据库的主机IP)
o portorg : The port number that a main PostgreSQL stands by. ( PostgreSQL的主要数据库的主机端口)
o hostcopy : The host address that a sub PostgreSQL stands by. ( PostgreSQL的次要数据库的主机IP)
o portcopy : The port number that a sub PostgreSQL stands by. ( PostgreSQL的次要数据库的主机端口)
· The compulsion of the database synchronizes.(强制数据库同步)
If you done a process to show here, the contents of the sub database are completely destroyed.(如果你执行下面的动作,数据库的潜在容量将全被破坏)
Do work after you surely take a backup. (最好是你 先备份一下)
o Stop a main database.(用 pg_ctl 的 kill 命令停止所有的数据库)
o Stop a sub database, too.(If you excuted second postmaster)
o The data directory of /usr/local/pgsql/data(of the main database) and the sub database is described in the following as /usr/local/pgsql/data2 . (主要数据库的目录是’ /usr/local/pgsql/data’,备份数据库的目录是’ /usr/local/pgsql/data2’)
o If /usr/local/pgsql/data2 doesn't exist, it is made as 'mkdir /usr/local/pgsql/data2'. (如果备份数据库的目录不存在则用MKDIR建立)
o Change directory to /usr/local/pgsql/data, and the following command you should execute, then the main database and sub database are made the same contents forcibly.(进入目录’ /usr/local/pgsql/data’,你要执行下面的命令,这时主要的和备份的数据库容量将是一样大)
tar cf - . | (cd ../data2; tar xf -)
A little more easily when you using a GNU tar(如果你用早期的GNU TAR 就是下面的)
tar cf - . | tar xf - -C ../data2
· Start the main postmaster. It is the setup shown here, because it stands by in the port of 5434 (启动主要数据库,它的配置有所改变,端口为5434,命令如下:)
su pgsql -c "/usr/local/pgsql/bin/postmaster -S -i -p 5434 -D /usr/local/pgsql/data"
· Start sub postmaster. It is the setup shown here, because it stands by in the port of 5436 (启动备份数据库,它的配置有所改变,端口为5436,命令如下:)
su pgsql -c "/usr/local/pgsql/bin/postmaster -S -i -p 5436 -D /usr/local/pgsql/data2"
· Start usogres. It is never especially difficult. (启动USOGRES,它没有什么特别的地方)
/usr/local/bin/usogres
It is all right as the above if it just starts without an option. Usogres uses setup file for his execution. (就是上面这样了,启动时不带OPTION 参数)
· For the client setup, two environment variable should setup below. (客户端的设置:pghost,和pgport 是usogres 所在的机器和端口)
o PGHOST : Host name that usogres to stand by.
o PGPORT : Port address that usogres to stand by. The example of bash and the example of csh are shown. (下面是csh应用的列子)
o bash
o export PGHOST=localhost
export PGPORT=5432
o csh
o setenv PGHOST localhost
setenv PGPORT 5432
Two databases and usogres started in the above.
Try variously by using the psql command and so on.
(现在OK了,用不同的命令试试吧!)
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货