企业运维之云上网络原理与实践-备份与恢复(中)

本文涉及的产品
云原生数据库 PolarDB PostgreSQL 版,企业版 4核16GB
推荐场景:
HTAP混合负载
云原生数据库 PolarDB MySQL 版,Serverless 5000PCU 100GB
云原生数据库 PolarDB MySQL 版,通用型 2核4GB 50GB
简介: 企业运维之云上网络原理与实践-备份与恢复


本地存储目录

 

1. postgres=# show data_directory;  

2.     data_directory  

3. ------------------------  

4. /home/postgres/primary  

5. (1 row)  

 

可以通过上述命令在数据库中获取本地存储目录的位置,可以看到它是类似于PostgreSQL的数据目录。

 

1. .  

2. ├── base  

3. │   ├── 1  

4. │   ├── 13938  

5. │   ├── 13939  

6. │   └── 13940  

7. ├── global  

8. ├── pg_commit_ts  

9. ├── pg_csnlog  

10. ├── pg_dynshmem  

11. ├── pg_log  

12. ├── pg_logical  

13. │   ├── mappings  

14. │   └── snapshots  

15. ├── pg_logindex  

16. ├── pg_multixact  

17. │   ├── members  

18. │   └── offsets  

19. ├── pg_notify  

20. ├── pg_replslot  

21. ├── pg_serial  

22. ├── pg_snapshots  

23. ├── pg_stat  

24. ├── pg_stat_tmp  

25. ├── pg_subtrans  

26. ├── pg_tblspc  

27. ├── pg_xact  

28. ├── polar_cache_trash  

29. ├── polar_fullpage  

30. └── polar_rel_size_cache  

 

本地存储目录中,大多都是通过initdb命令生成的文件或目录。随着数据库服务运行,这里会生成更多的本地文件,如临时文件、缓存文件、配置文件、日志文件。

 

由于本地存储目录中的文件不涉及核心数据,因此在做备份时本地存储目录是可选的。您可以仅备份共享存储上的数据目录,然后用initdb重新生成一份新的本地存储目录。但是需要记住之前的本地配置信息,如postgresql.conf,pg_hba.conf等。

 

提示

 

如果您不能记住历史配置,或者您需要保留历史日志,建议您将本地存储目录也进行备份。可以将这个目录完全复制后修改配置文件来搭建RO或者Standby。

 

共享存储目录

 

1. postgres=# show polar_datadir;  

2.     polar_datadir  

3. -----------------------  

4. /nvme0n1/shared_data/  

5. (1 row)  

 

 

1.

2. .  

3. ├── base  

4. │   ├── 1  

5. │   ├── 16555  

6. │   ├── 16556  

7. │   ├── 16557  

8. │   └── 16558  

9. ├── global  

10. ├── pg_commit_ts  

11. ├── pg_csnlog  

12. ├── pg_logindex  

13. ├── pg_multixact  

14. │   ├── members  

15. │   └── offsets  

16. ├── pg_replslot  

17. ├── pg_tblspc  

18. ├── pg_twophase  

19. ├── pg_wal  

20. │   └── archive_status  

21. ├── pg_xact  

22. ├── polar_dma  

23. │   ├── consensus_cc_log  

24. │   └── consensus_log  

25. ├── polar_flog  

26. ├── polar_flog_index  

27. ├── polar_fraindex  

28. │   ├── fbpoint  

29. │   └── pg_xact  

30. └── polar_fullpage  

 

共享存储目录中存放PolarDB的核心数据文件,如表文件、索引文件、WAL日志、DMA、LogIndex、Flashback等。这些文件被一个RW节点和多个RO节点共享,因此是必须备份的。您可以使用copy命令、存储快照、网络传输等方式进行备份。如果您没有更好的选择,推荐使用polar_basebackup命令。

 

polar_basebackup备份工具

 

下面介绍一下PolarDB的备份工具polar_basebackup,它由pg_basebackup

改造而来,且完全兼容pg_baseabckup,也就是说它同样可以用于对PostgreSQL做备份恢复。polar_basebackup在PolarDB二进制安装目录下的bin/目录中,您可以配置export环境变量来直接使用它。

1.

2. polar_basebackup takes a base backup of a running PostgreSQL server.  

3.  

4. Usage:  

5.  polar_basebackup [OPTION]...  

6.  

7. Options controlling the output:  

8.  -D, --pgdata=DIRECTORY receive base backup into directory  

9.  -F, --format=p|t       output format (plain (default), tar)  

10.  -r, --max-rate=RATE    maximum transfer rate to transfer data directory  

11.                         (in kB/s, or use suffix "k" or "M")  

12.  -R, --write-recovery-conf  

13.                         write recovery.conf for replication  

14.  -T, --tablespace-mapping=OLDDIR=NEWDIR  

15.                         relocate tablespace in OLDDIR to NEWDIR  

16.      --waldir=WALDIR    location for the write-ahead log directory  

17.  -X, --wal-method=none|fetch|stream  

18.                         include required WAL files with specified method  

19.  -z, --gzip             compress tar output  

20.  -Z, --compress=0-9     compress tar output with given compression level  

21.  

22. General options:  

23.  -c, --checkpoint=fast|spread  

24.                         set fast or spread checkpointing  

25.  -C, --create-slot      create replication slot  

26.  -l, --label=LABEL      set backup label  

27.  -n, --no-clean         do not clean up after errors  

28.  -N, --no-sync          do not wait for changes to be written safely to disk  

29.  -P, --progress         show progress information  

30.  -S, --slot=SLOTNAME    replication slot to use  

31.  -v, --verbose          output verbose messages  

32.  -V, --version          output version information, then exit  

33.      --no-slot          prevent creation of temporary replication slot  

34.      --no-verify-checksums  

35.                         do not verify checksums  

36.  -?, --help             show this help, then exit  

37.  

38. Connection options:  

39.  -d, --dbname=CONNSTR   connection string  

40.  -h, --host=HOSTNAME    database server host or socket directory  

41.  -p, --port=PORT        database server port number  

42.  -s, --status-interval=INTERVAL  

43.                         time between status packets sent to server (in seconds)  

44.  -U, --username=NAME    connect as specified database user  

45.  -w, --no-password      never prompt for password  

46.  -W, --password         force password prompt (should happen automatically)  

47.      --polardata=datadir  receive polar data backup into directory  

48.      --polar_disk_home=disk_home  polar_disk_home for polar data backup  

49.      --polar_host_id=host_id  polar_host_id for polar data backup  

50.      --polar_storage_cluster_name=cluster_name  polar_storage_cluster_name for polar data backup  

 

可以看到polar_basebackup的大部分参数及用法都和pg_basebackup

一致,只是多了以下几个参数,下面重点来介绍一下:

 

polardata:如果您备份的实例是PolarDB共享存储架构,这个参数用于指定PolarDB共享存储目录的位置。如果您不指定,将会使用默认目录polar_shared_data,并且放在本地存储目录(即-D/--pgdata所指定的参数)下面。如果您对PostgreSQL备份则无需关心他。

 

polar_disk_home:如果您备份的实例是PolarDB共享存储架构,且您希望将共享存储目录通过PFS写入共享存储设备,则需要指定这个参数,它是PFS的使用参数。

 

polar_host_id:如果您备份的实例是PolarDB共享存储架构,且您希望将共享存储目录通过PFS写入共享存储设备,则需要指定这个参数,它是PFS的使用参数。

 

polar_storage_cluster_name:如果您备份的实例是PolarDB共享存储架构,且您希望将共享存储目录通过PFS写入共享存储设备,则需要指定这个参数,它是PFS的使用参数。

接下篇:https://developer.aliyun.com/article/1223083?groupCode=polardbforpg

相关文章
|
4天前
|
NoSQL Java Redis
Redis系列学习文章分享---第十八篇(Redis原理篇--网络模型,通讯协议,内存回收)
Redis系列学习文章分享---第十八篇(Redis原理篇--网络模型,通讯协议,内存回收)
12 0
|
4天前
|
存储 消息中间件 缓存
Redis系列学习文章分享---第十七篇(Redis原理篇--数据结构,网络模型)
Redis系列学习文章分享---第十七篇(Redis原理篇--数据结构,网络模型)
12 0
|
2天前
|
运维 监控 Devops
DevOps实践:构建高效运维流程
【6月更文挑战第29天】在现代软件开发周期中,DevOps已成为推动开发和运维团队紧密合作的重要哲学。本文将探讨如何通过DevOps实践来构建一个更高效的运维流程,从而提升软件交付速度、提高产品质量,并确保系统的稳定性和安全性。我们将从持续集成、自动化测试、配置管理、容器化部署、监控与告警等关键方面入手,深入分析DevOps实施过程中的关键环节及其对运维工作的影响。
15 3
|
2天前
|
运维 监控 测试技术
自动化运维实践:CI/CD流程详解
【6月更文挑战第30天】CI/CD实践推动软件开发自动化,通过持续集成确保代码质量,自动部署提升交付速度。核心流程包括:代码管理(Git等)、自动化构建与测试、代码审查、部署。关键点涉及选择工具、测试覆盖率、监控及团队协作。采用CI/CD能减少错误,但需应对挑战,如工具选型、全面测试和团队沟通。
|
3天前
|
运维 Kubernetes 安全
自动化运维在现代IT架构中的角色与实践
【6月更文挑战第28天】随着企业对信息技术的依赖日益加深,高效、可靠的运维体系变得至关重要。本文将探讨自动化运维如何优化现代IT架构,提升运维效率和系统稳定性。我们将从实际案例出发,分析自动化工具的选择、部署策略以及面临的挑战,为读者提供一套可行的自动化运维解决方案。
|
4天前
程序技术好文:计算机网络(九)——STP原理
程序技术好文:计算机网络(九)——STP原理
|
2月前
|
消息中间件 Java Linux
2024年最全BATJ真题突击:Java基础+JVM+分布式高并发+网络编程+Linux(1),2024年最新意外的惊喜
2024年最全BATJ真题突击:Java基础+JVM+分布式高并发+网络编程+Linux(1),2024年最新意外的惊喜
|
25天前
|
网络协议 算法 Linux
【嵌入式软件工程师面经】Linux网络编程Socket
【嵌入式软件工程师面经】Linux网络编程Socket
41 1
|
10天前
|
安全 物联网 Linux
学习Linux对网络安全的重要性
**学习Linux对网络安全至关重要:** 1. 开源操作系统广泛应用于服务器、网络设备,掌握Linux是安全专家必备技能。 2. Linux内置安全特性,如最小权限和防火墙,加上丰富的安全工具,提供强大保障。 3. 可定制性允许灵活配置,满足安全需求,开源社区提供持续更新和教育资源。 4. 学习Linux能提升攻防能力,用于系统加固和渗透测试,适应跨平台安全场景。 5. 随着云计算和物联网发展,Linux在网络安全中的角色日益关键。
36 3
|
5天前
|
监控 安全 Linux
虚拟专用网络(VPN):远程访问与点对点连接及其在Linux中的IPSec实现与日志管理
虚拟专用网络(VPN):远程访问与点对点连接及其在Linux中的IPSec实现与日志管理
17 0