linux下关于PostgreSQL数据库同步的问题!slony
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux下关于PostgreSQL数据库同步的问题!slony相关的知识,希望对你有一定的参考价值。
<stdin>:22: waiting for event (1,5000000006) to be confirmed on node 2
<stdin>:22: waiting for event (1,5000000006) to be confirmed on node 2
<stdin>:22: waiting for event (1,5000000006) to be confirmed on node 2
<stdin>:22: waiting for event (1,5000000006) to be confirmed on node 2
<stdin>:22: waiting for event (1,5000000006) to be confirmed on node 2
<stdin>:22: waiting for event (1,5000000006) to be confirmed on node 2
<stdin>:22: waiting for event (1,5000000006) to be confirmed on node 2
<stdin>:22: waiting for event (1,5000000006) to be confirmed on node 2
<stdin>:22: waiting for event (1,5000000006) to be confirmed on node 2
脚本什么的都写好了,配置都弄好了,两个服务器都能相互连接
就是运行脚本 这样显示,,,连接不上第二个节点!!
两个服务器上都运行了这个脚本 结果还是一样!!
哪儿出问题了!!?
http://laser.dyndns.zhengmai.net.cn/download/slony1-1.0.2.tar.gz
解压缩后,有slony1-1.0.2目录。
2,进入该目录,configure --with-pgsourcetree=<postgresql 源代码目录>
3,make & make install
4,以一个数据库用户的身份,我先说一个最简单的,所有表都有主键
的,点对点的主从复制方案,我们需要写下面这么一个脚本:
#!/bin/sh
CLUSTER=『你的集群的名称,随意』
DBNAME1=『需要复制的源数据库』
DBNAME2=『需要复制的目的数据库』
HOST1=『源库IP或主机名』
HOST2=『目的库IP或主机名』
SLONY_USER=『源库数据库超级用户名』
PGBENCH_USER=『源库用户名,没啥用』本回答被提问者采纳
Linux下关于/tmp目录的清理规则
本文将介绍Linux下/tmp目录的清理规则,rhel6和rhel7将以完全不同的两种方式进行清理。
RHEL6
tmpwatch命令
tmpwatch 是专门用于解决“删除 xxx天没有被访问/修改过的文件”这样需求的命令。
安装:
[[email protected] ~]# yum install tmpwatch.x86_64
使用:
man tmpwatch tmpwatch - removes files which haven‘t been accessed for a period of time. By default, tmpwatch dates files by their atime (access time), not their mtime (modification time). The time parameter defines the threshold for removing files. If the file has not been accessed for time, the file is removed. The time argument is a number with an optional single-character suffix specifying the units: m for minutes, h for hours, d for days. If no suffix is specified, time is in hours. -u, --atime Make the decision about deleting a file based on the file‘s atime (access time). This is the default. Note that the periodic updatedb file system scans keep the atime of directories recent. -m, --mtime Make the decision about deleting a file based on the file‘s mtime (modification time) instead of the atime. -c, --ctime Make the decision about deleting a file based on the file‘s ctime (inode change time) instead of the atime; for directo‐ ries, make the decision based on the mtime. -M, --dirmtime Make the decision about deleting a directory based on the directory‘s mtime (modification time) instead of the atime; completely ignore atime for directories.
举例: (清除/tmp目录下30天没有被访问文件)
[[email protected] ~]# tmpwatch --atime 30d /tmp
RHEL7
systemd-tmpfiles-clean.service服务
服务: systemd-tmpfiles-clean.service
服务何时被执行呢?
Linux下该服务的执行可以根据systemd-tmpfiles-clean.timer进行管理
[[email protected] ~]# cat /usr/lib/systemd/system/systemd-tmpfiles-clean.timer # This file is part of systemd. # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. [Unit] Description=Daily Cleanup of Temporary Directories Documentation=man:tmpfiles.d(5) man:systemd-tmpfiles(8) [Timer] OnBootSec=15min OnUnitActiveSec=1d # OnBootSec 表示相对于机器被启动的时间点 # 表示相对于匹配单元(本标签下Unit=指定的单元)最后一次被启动的时间点
上述配置文件表示两种情况会执行该服务
- 开机15分钟执行服务
- 距离上次执行该服务1天后执行服务
服务如何执行呢?
[[email protected] ~]# cat /usr/lib/systemd/system/systemd-tmpfiles-clean.service # This file is part of systemd. # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. [Unit] Description=Cleanup of Temporary Directories Documentation=man:tmpfiles.d(5) man:systemd-tmpfiles(8) DefaultDependencies=no Conflicts=shutdown.target After=systemd-readahead-collect.service systemd-readahead-replay.service local-fs.target time-sync.target Before=shutdown.target [Service] Type=oneshot ExecStart=/usr/bin/systemd-tmpfiles --clean IOSchedulingClass=idle # Type=oneshot 这一选项适用于只执行一项任务、随后立即退出的服务 # 命令文件 /usr/bin/systemd-tmpfiles # 命令参数 --clean # 通过定期执行 /usr/bin/systemd-tmpfiles --clean 完成清理
命令: /usr/bin/systemd-tmpfiles
[[email protected] ~]# /usr/bin/systemd-tmpfiles --help systemd-tmpfiles [OPTIONS...] [CONFIGURATION FILE...] Creates, deletes and cleans up volatile and temporary files and directories. -h --help Show this help --version Show package version --create Create marked files/directories --clean Clean up marked directories --remove Remove marked files/directories --boot Execute actions only safe at boot --prefix=PATH Only apply rules with the specified prefix --exclude-prefix=PATH Ignore rules with the specified prefix --root=PATH Operate on an alternate filesystem root # --clean 将会清理被标记的文件目录
哪些目录被标记,又是什么样的标记呢?
定义在配置文件/usr/lib/tmpfiles.d/tmp.conf中
配置文件: /usr/lib/tmpfiles.d/tmp.conf
[[email protected] ~]# cat /usr/lib/tmpfiles.d/tmp.conf # This file is part of systemd. # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # See tmpfiles.d(5) for details # Clear tmp directories separately, to make them easier to override v /tmp 1777 root root 10d v /var/tmp 1777 root root 30d # Exclude namespace mountpoints created with PrivateTmp=yes x /tmp/systemd-private-%b-* X /tmp/systemd-private-%b-*/tmp x /var/tmp/systemd-private-%b-* X /var/tmp/systemd-private-%b-*/tmp
x 在根据"寿命"字段清理过期文件时, 忽略指定的路径及该路径下的所有内容。 可以在"路径"字段中使用shell风格的通配符。 注意,这个保护措施对 r 与 R 无效。 X 在根据"寿命"字段清理过期文件时, 仅忽略指定的路径自身而不包括该路径下的其他内容。 可以在"路径"字段中使用shell风格的通配符。 注意,这个保护措施对 r 与 R 无效。
上述配置表示:
-
清理/tmp目录超过10天的内容,但是匹配/tmp/systemd-private-%b-*的目录及其路径下的全部内容会被保留
-
清理/var/tmp目录超过30天的内容,但是匹配/var/tmp/systemd-private-%b-*的目录及其路径下的全部内容被保留
总结
-
RHEL6 根据文件的访问时间等条件使用tmpwatch命令进行/tmp目录的清理,可以使用crond daemon进行定期执行
-
RHEL7 根据服务systemd-tmpfiles-clean.service 进行临时文件的清理,清理规则定义在配置文件/usr/lib/tmpfiles.d/tmp.conf,调用命令为/usr/bin/systemd-tmpfiles --clean,执行时间依靠systemd-tmpfiles-clean.timer进行管理
以上是关于linux下关于PostgreSQL数据库同步的问题!slony的主要内容,如果未能解决你的问题,请参考以下文章