使用pg_basebackup 创建流复制备库时,需要复制并传送数据,带来大量 I/O,9.4 版本 pg_basebackup 增加流量控制选项,搭建流复制备库时降低对主库的性能影响。
关于 –max-rate 选项
指数据的最大传输速率,默认是 kb/s 为单位,也可以是 Mb/s, 允许的值范围是 32K 到 1024 Mb,超出这个范围为报以下错误。
超出速率范围
1 2 3 4 5
|
[pg94@db2 pg94]$ pg_basebackup -D /database/pg94/pg_root -Fp -Xs -v -P -h 192.168.2.37 -p 1924 -U repuser pg_basebackup: transfer rate "2" is out of range [pg94@db2 pg94]$ pg_basebackup -D /database/pg94/pg_root -Fp -Xs -v -P -h 192.168.2.37 -p 1924 -U repuser pg_basebackup: transfer rate "1025M" is out of range
|
设置最大传输速率 64 KB/s
1 2 3 4
|
[pg94@db2 pg94]$ pg_basebackup -D /database/pg94/pg_root -Fp -Xs -v -P -h 192.168.2.37 -p 1924 -U repuser --max-rate=64 transaction log start point: 0/50000058 on timeline 1 pg_basebackup: starting background WAL receiver 10145/1449790 kB (0%), 0/2 tablespaces (...ncs/PG_9.4_201405111/16386/16587)
|
查看网卡流量
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
[root@db2 ~]# sar -n DEV 1 1000 02:39:22 PM IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s 02:39:23 PM lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00 02:39:23 PM eth0 50.00 41.00 66.65 2.61 0.00 0.00 0.00 02:39:23 PM IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s 02:39:24 PM lo0.00 0.00 0.00 0.00 0.00 0.00 0.00 02:39:24 PM eth0 56.57 48.48 75.72 3.01 0.00 0.00 0.00 02:39:24 PM IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s 02:39:25 PM lo0.00 0.00 0.00 0.00 0.00 0.00 0.00 02:39:25 PM eth0 50.51 47.47 67.32 2.95 0.00 0.00 0.00 02:39:25 PM IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s 02:39:26 PM lo0.00 0.00 0.00 0.00 0.00 0.00 0.00 02:39:26 PM eth0 51.52 35.35 67.41 2.31 0.00 0.00 0.00 02:39:26 PM IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s 02:39:27 PM lo0.00 0.00 0.00 0.00 0.00 0.00 0.00 02:39:27 PM eth0 56.00 31.00 74.96 2.08 0.00 0.00 0.00 02:39:27 PM IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s 02:39:28 PM lo0.00 0.00 0.00 0.00 0.00 0.00 0.00 02:39:28 PM eth0 56.57 48.48 75.72 3.01 0.00 0.00 0.00
|
参考
原创文章,作者:306829225,如若转载,请注明出处:https://blog.ytso.com/238069.html