Sample Header Ad - 728x90

Error creating PolarDB standby node on macOS

0 votes
0 answers
16 views
I am trying to set up a standby disaster recovery node for PolarDB on a macOS host using Docker. However, I am encountering an issue during the polar_basebackup process where it fails to create necessary directories. The error suggests that the directory /nvme2n1/shared_data/base could not be created, although /nvme2n1/shared_data/ seems to be created automatically. Below are the steps I've followed and the error details. How can I resolve this directory creation issue? Steps to Reproduce: 1. Create a Virtual Disk for Standby:
cd ~/data_volumn    
dd if=/dev/zero of=./VirtualDisk_standby.img bs=1m count=20480 oflag=direct
2. Start the Container pb3:
cd ~/data_volumn    
PWD=pwd    
    
docker run -d -it -v $PWD:/data -P --shm-size=1g --cap-add=SYS_PTRACE --cap-add SYS_ADMIN --privileged=true --name pb3 registry.cn-hangzhou.aliyuncs.com/polardb_pg/polardb_pg_devel:ubuntu22.04 bash
3. Enter container pb3 and view the address:
docker exec -ti pb3 bash    
    
ip addr show    
  
116: eth0@if117:  mtu 65535 qdisc noqueue state UP group default   
    link/ether 02:42:ac:11:00:04 brd ff:ff:ff:ff:ff:ff link-netnsid 0  
    inet 172.17.0.4/16 brd 172.17.255.255 scope global eth0  
       valid_lft forever preferred_lft forever
4. Confirm that the network communication between pb3, pb1 and pb2 containers is normal:
# 安装ping 客户端  
  
sudo apt update    
sudo apt-get install -y inetutils-ping    
    
# 确认可以连通PolarDB 主节点和replica节点  
  
ping 172.17.0.2   
64 bytes from 172.17.0.2: icmp_seq=0 ttl=64 time=0.050 ms    
...  
ping 172.17.0.3   
64 bytes from 172.17.0.3: icmp_seq=0 ttl=64 time=0.050 ms
5. Create a loop device in pb3 to map to the virtual disk VirtualDisk_standby.img:
# 找一个可用的loop设备  
sudo losetup -f  
返回  
/dev/loop2  
  
# 使用新建的虚拟磁盘创建loop设备  
  
sudo losetup --direct-io=on /dev/loop2 /data/VirtualDisk_standby.img    
  
# 现在可以看到该loop设备  
$ losetup -a  
/dev/loop1: :36827 (/data/VirtualDisk.img)  
/dev/loop2: :109941 (/data/VirtualDisk_standby.img)  
/dev/loop0: :3407876 (/mount-services-cache/entries/services.iso/16203eaee29495c5a513341af851be45c30488427f5e3c87764e8b89a4a47d7a)
6. Softlink the loop device to nvme2n1 (note that nvme2n1 is different from nvme1n1 of primary & replica, it is not necessary, nvme2n1 is used here just to distinguish), easy to use
sudo ln -s /dev/loop2 /dev/nvme2n1
7. Format nvme2n1 using pfs:
sudo pfs -C disk mkfs -f nvme2n1
8. Start pfsd
sudo /usr/local/polarstore/pfsd/bin/start_pfsd.sh -p nvme2n1 -w 1
9. Copy the compiled polardb binary to the $HOME directory
$ cp -r /data/polardb/tmp_polardb_pg_15_base ~/    
  
    
$ which psql    
/home/postgres/tmp_polardb_pg_15_base/bin/psql
10. Back up PolarDB data to local storage and shared storage Perform the backup in the pb3 container used to deploy the Standby node, using ~/standby as the local data directory and /nvme2n1/shared_data as the shared storage directory:
polar_basebackup \
    --host=172.17.0.2 \
    --port=5432 \
    -D /home/postgres/standby \
    --polardata=/nvme2n1/shared_data/ \
    --polar_storage_cluster_name=disk \
    --polar_disk_name=nvme2n1 \
    --polar_host_id=3 \
    -X stream --progress --write-recovery-conf -v
The error is as follows: It looks likepolar_basebackup automatically created /nvme2n1/shared_data/, but did not automatically create /nvme2n1/shared_data/base
[PFSD_SDK INF Dec 17 17:42:37.947483]pfs_mount_prepare 103: begin prepare mount cluster(disk), PBD(nvme2n1), hostid(3),flags(0x13)  
[PFSD_SDK INF Dec 17 17:42:37.947583]pfs_mount_prepare 165: pfs_mount_prepare success for nvme2n1 hostid 3  
[PFSD_SDK INF Dec 17 17:42:37.983903]chnl_connection_poll_shm 1238: ack data update s_mount_epoch 1  
[PFSD_SDK INF Dec 17 17:42:37.983917]chnl_connection_poll_shm 1266: connect and got ack data from svr, err = 0, mntid 0  
[PFSD_SDK INF Dec 17 17:42:37.984060]pfsd_sdk_init 191: pfsd_chnl_connect success  
[PFSD_SDK INF Dec 17 17:42:37.984082]pfs_mount_post 208: pfs_mount_post err : 0  
[PFSD_SDK ERR Dec 17 17:42:37.989320]pfsd_opendir 1437: opendir /nvme2n1/shared_data/ error: No such file or directory  
[PFSD_SDK INF Dec 17 17:42:37.989439]pfsd_mkdir 1320: mkdir /nvme2n1/shared_data  
polar_basebackup: initiating base backup, waiting for checkpoint to complete  
polar_basebackup: checkpoint completed  
polar_basebackup: write-ahead log start point: 0/485F0700 on timeline 1  
polar_basebackup: starting background WAL receiver  
polar_basebackup: created temporary replication slot "pg_basebackup_64335"  
[PFSD_SDK INF Dec 17 17:42:38.149108]pfsd_mkdir 1320: mkdir /nvme2n1/shared_data/pg_wal  
[PFSD_SDK INF Dec 17 17:42:38.149659]pfsd_mkdir 1320: mkdir /nvme2n1/shared_data/pg_wal/archive_status  
[PFSD_SDK INF Dec 17 17:42:38.153165]pfsd_open 539: open /nvme2n1/shared_data/pg_wal/000000010000000000000001 with inode 3, fd 0  
polar_basebackup: error: could not create directory "/nvme2n1/shared_data/base": No such file or directory  
polar_basebackup: removing data directory "/home/postgres/standby"  
polar_basebackup: removing data directory "/nvme2n1/shared_data"  
[PFSD_SDK INF Dec 17 17:42:38.210123]pfsd_rmdir 1370: rmdir /nvme2n1/shared_data/pg_wal/archive_status  
[PFSD_SDK INF Dec 17 17:42:38.211285]pfsd_unlink 952: unlink /nvme2n1/shared_data/pg_wal/000000010000000000000001  
[PFSD_SDK INF Dec 17 17:42:38.212522]pfsd_rmdir 1370: rmdir /nvme2n1/shared_data/pg_wal  
[PFSD_SDK INF Dec 17 17:42:38.213276]pfsd_rmdir 1370: rmdir /nvme2n1/shared_data
Creation failed, the environment has been cleared
$ sudo pfs -C disk ls /nvme2n1/  
  File  1     4194304           Wed Dec 18 09:58:16 2024  .pfs-paxos  
  File  1     1073741824        Wed Dec 18 09:58:17 2024  .pfs-journal  
total 2105344 (unit: 512Bytes)
How can I ensure that the necessary directories are created automatically, or what steps should I take to resolve this issue?
Asked by nan bai (1 rep)
Dec 24, 2024, 02:17 AM