圈子推荐
查看所有吧>>
活跃用户
    ​vastbase的主备切换

    1,连接主库,确认主备正常同步。

    cat  /etc/hosts

    192.168.192.133     node2   primary

    192.168.192.134     node3   standby

    [vastbase@node2 ~]$ vb_ctl query

     vb_ctl query ,datadir is /data/vastbase 

     HA state:           

    local_role                     : Primary

    static_connections             : 1

    db_state                       : Normal

    detail_information             : Normal


     Senders info:       

    sender_pid                     : 11815

    local_role                     : Primary

    peer_role                      : Standby

    peer_state                     : Normal

    state                          : Streaming

    sender_sent_location           : 0/10007A18

    sender_write_location          : 0/10007A18

    sender_flush_location          : 0/10007A18

    sender_replay_location         : 0/10007A18

    receiver_received_location     : 0/10007A18

    receiver_write_location        : 0/10007A18

    receiver_flush_location        : 0/10007A18

    receiver_replay_location       : 0/10007A18

    sync_percent                   : 100%

    sync_state                     : Sync

    sync_priority                  : 1

    sync_most_available            : Off

    channel                        : 192.168.192.133:26002-->192.168.192.134:45642


     Receiver info:      

    No information

    2,连接备库,确认主备正常同步。

     vb_ctl query ,datadir is /data/vastbase 

     HA state:           

    local_role                     : Standby

    static_connections             : 1

    db_state                       : Normal

    detail_information             : Normal


     Senders info:       

    No information 

     Receiver info:      

    receiver_pid                   : 12304

    local_role                     : Standby

    peer_role                      : Primary

    peer_state                     : Normal

    state                          : Normal

    sender_sent_location           : 0/10007C28

    sender_write_location          : 0/10007C28

    sender_flush_location          : 0/10007C28

    sender_replay_location         : 0/10007C28

    receiver_received_location     : 0/10007C28

    receiver_write_location        : 0/10007C28

    receiver_flush_location        : 0/10007C28

    receiver_replay_location       : 0/10007C28

    sync_percent                   : 100%

    channel                        : 192.168.192.134:45642vb_ctl stopped ,datadir is /data/vastbase 

    waiting for server to shut down............. done

    server stopped

    6、备库停止,启动为主库

    [vastbase@node3 ~]$ vb_ctl stop

    [2021-01-26 11:20:31.689][13723][][vb_ctl]: vb_ctl stopped ,datadir is /data/vastbase 

    waiting for server to shut down..... done

    server stopped

    [vastbase@node3 ~]$ vb_ctl -M primary start

    [2021-01-26 11:20:43.395][13728][][vb_ctl]: vb_ctl started,datadir is /data/vastbase 

    [2021-01-26 11:20:43.485][13728][][vb_ctl]: waiting for server to start...

    .0 LOG:  The core dump path in core_pattern is an invalid directory.

    0 [BACKEND] LOG:  Begin to start Vastbase Database.

    2021-01-26 11:20:43.644 600f8a8b.1 [unknown] 140590438802816 [unknown] 0 vastbasedb DB001 0 [REDO] LOG:  Recovery paralleli***, cpu count = 1, max = 4, actual = 1

    2021-01-26 11:20:43.644 600f8a8b.1 [unknown] 140590438802816 [unknown] 0 vastbasedb DB001 0 [REDO] LOG:  ConfigRecoveryParalleli***, true_max_recovery_paralleli***:4, max_recovery_paralleli***:4

    2021-01-26 11:20:43.644 600f8a8b.1 [unknown] 140590438802816 [unknown] 0 vastbasedb 00000 0 [BACKEND] LOG:  when starting as multi_standby mode, we couldn't support data replicaton.

    2021-01-26 11:20:43.644 600f8a8b.1 [unknown] 140590438802816 [unknown] 0 vastbasedb 00000 0 [BACKEND] LOG:  Transparent encryption disabled.

    2021-01-26 11:20:43.650 600f8a8b.1 [unknown] 140590438802816 [unknown] 0 vastbasedb 00000 0 [BACKEND] LOG:  loaded library "security_plugin"

    2021-01-26 11:20:43.655 600f8a8b.1 [unknown] 140590438802816 [unknown] 0 vastbasedb 01000 0 [BACKEND] WARNING:  No explicit IP is configured for listen_addresses GUC.

    2021-01-26 11:20:43.655 600f8a8b.1 [unknown] 140590438802816 [unknown] 0 vastbasedb 00000 0 [BACKEND] LOG:  InitNuma numaNodeNum: 1 numa_distribute_mode: none inheritThreadPool: 0.

    2021-01-26 11:20:43.656 600f8a8b.1 [unknown] 140590438802816 [unknown] 0 vastbasedb 00000 0 [BACKEND] LOG:  shared memory 3103 Mbytes, memory context 8672 Mbytes, max process memory 12288 Mbytes

    2021-01-26 11:20:43.656 600f8a8b.1 [unknown] 140590438802816 [unknown] 0 vastbasedb 00000 0 [BACKEND] LOG:  Initilize the memory protect with Process Chunks number 8672, change bits 20

    2021-01-26 11:20:43.726 600f8a8b.1 [unknown] 140590438802816 [unknown] 0 vastbasedb 00000 0 [CACHE] LOG:  set data cache  size(402653184)

    2021-01-26 11:20:43.740 600f8a8b.1 [unknown] 140590438802816 [unknown] 0 vastbasedb 00000 0 [CACHE] LOG:  set metadata cache  size(134217728)

    2021-01-26 11:20:44.293 600f8a8b.1 [unknown] 140590438802816 [unknown] 0 vastbasedb 00000 0 [BACKEND] LOG:  vastbase: fsync file "/data/vastbase/gaussdb.state.temp" success

    2021-01-26 11:20:44.293 600f8a8b.1 [unknown] 140590438802816 [unknown] 0 vastbasedb 00000 0 [BACKEND] LOG:  create gaussdb state file success: db state(STARTING_STATE), server mode(Primary)

    2021-01-26 11:20:44.294 600f8a8b.1 [unknown] 140590438802816 [unknown] 0 vastbasedb 00000 0 [BACKEND] LOG:  max_safe_fds = 975, usable_fds = 1000, already_open = 15

    2021-01-26 11:20:44.294 600f8a8b.1 [unknown] 140590438802816 [unknown] 0 vastbasedb 00000 0 [BACKEND] LOG:  The core dump path in core_pattern is an invalid directory.

    2021-01-26 11:20:44.296 600f8a8b.1 [unknown] 140590438802816 [unknown] 0 vastbasedb 00000 0 [BACKEND] LOG:  Success to start Vastbase Database, please press any key to exit...

    .

    [2021-01-26 11:20:50.512][13728][][vb_ctl]:  done

    [2021-01-26 11:20:50.512][13728][][vb_ctl]: server started (/data/vastbase)

    [vastbase@node3 ~]$ pg_controldata | grep "Database cluster state"

    Database cluster state:               in production

    7、将源主库切换为新备库:

    [vastbase@node2 ~]$ vb_ctl -M standby start

    [2021-01-26 11:22:11.680][12486][][vb_ctl]: vb_ctl started,datadir is /data/vastbase 

    [2021-01-26 11:22:11.765][12486][][vb_ctl]: waiting for server to start...

    .0 LOG:  The core dump path in core_pattern is an invalid directory.

    0 [BACKEND] LOG:  Begin to start Vastbase Database.

    2021-01-26 11:22:11.946 600f8ae3.1 [unknown] 140137077466496 [unknown] 0 vastbasedb DB001 0 [REDO] LOG:  Recovery paralleli***, cpu count = 1, max = 4, actual = 1

    2021-01-26 11:22:11.947 600f8ae3.1 [unknown] 140137077466496 [unknown] 0 vastbasedb DB001 0 [REDO] LOG:  ConfigRecoveryParalleli***, true_max_recovery_paralleli***:4, max_recovery_paralleli***:4

    2021-01-26 11:22:11.947 600f8ae3.1 [unknown] 140137077466496 [unknown] 0 vastbasedb 00000 0 [BACKEND] LOG:  when starting as multi_standby mode, we couldn't support data replicaton.

    2021-01-26 11:22:11.947 600f8ae3.1 [unknown] 140137077466496 [unknown] 0 vastbasedb 00000 0 [BACKEND] LOG:  Transparent encryption disabled.

    2021-01-26 11:22:11.953 600f8ae3.1 [unknown] 140137077466496 [unknown] 0 vastbasedb 00000 0 [BACKEND] LOG:  loaded library "security_plugin"

    2021-01-26 11:22:11.956 600f8ae3.1 [unknown] 140137077466496 [unknown] 0 vastbasedb 01000 0 [BACKEND] WARNING:  No explicit IP is configured for listen_addresses GUC.

    2021-01-26 11:22:11.956 600f8ae3.1 [unknown] 140137077466496 [unknown] 0 vastbasedb 00000 0 [BACKEND] LOG:  InitNuma numaNodeNum: 1 numa_distribute_mode: none inheritThreadPool: 0.

    2021-01-26 11:22:11.956 600f8ae3.1 [unknown] 140137077466496 [unknown] 0 vastbasedb 00000 0 [BACKEND] LOG:  shared memory 3103 Mbytes, memory context 8672 Mbytes, max process memory 12288 Mbytes

    2021-01-26 11:22:11.956 600f8ae3.1 [unknown] 140137077466496 [unknown] 0 vastbasedb 00000 0 [BACKEND] LOG:  Initilize the memory protect with Process Chunks number 8672, change bits 20

    2021-01-26 11:22:12.024 600f8ae3.1 [unknown] 140137077466496 [unknown] 0 vastbasedb 00000 0 [CACHE] LOG:  set data cache  size(402653184)

    2021-01-26 11:22:12.038 600f8ae3.1 [unknown] 140137077466496 [unknown] 0 vastbasedb 00000 0 [CACHE] LOG:  set metadata cache  size(134217728)

    2021-01-26 11:22:12.159 600f8ae3.1 [unknown] 140137077466496 [unknown] 0 vastbasedb 00000 0 [BACKEND] LOG:  vastbase: fsync file "/data/vastbase/gaussdb.state.temp" success

    2021-01-26 11:22:12.159 600f8ae3.1 [unknown] 140137077466496 [unknown] 0 vastbasedb 00000 0 [BACKEND] LOG:  create gaussdb state file success: db state(STARTING_STATE), server mode(Standby)

    2021-01-26 11:22:12.159 600f8ae3.1 [unknown] 140137077466496 [unknown] 0 vastbasedb 00000 0 [BACKEND] LOG:  max_safe_fds = 975, usable_fds = 1000, already_open = 15

    2021-01-26 11:22:12.160 600f8ae3.1 [unknown] 140137077466496 [unknown] 0 vastbasedb 00000 0 [BACKEND] LOG:  The core dump path in core_pattern is an invalid directory.

    2021-01-26 11:22:12.162 600f8ae3.1 [unknown] 140137077466496 [unknown] 0 vastbasedb 00000 0 [BACKEND] LOG:  Success to start Vastbase Database, please press any key to exit...


    [2021-01-26 11:22:12.892][12486][][vb_ctl]:  done

    [2021-01-26 11:22:12.892][12486][][vb_ctl]: server started (/data/vastbase)

    8、查看主备库的状态。

    [vastbase@node3 ~]$ vb_ctl query

    [2021-01-26 11:28:58.045][13906][][vb_ctl]: vb_ctl query ,datadir is /data/vastbase 

     HA state:           

    local_role                     : Primary

    static_connections             : 1

    db_state                       : Normal

    detail_information             : Normal


     Senders info:       

    sender_pid                     : 13806

    local_role                     : Primary

    peer_role                      : Standby

    peer_state                     : Normal

    state                          : Streaming

    sender_sent_location           : 0/100099D8

    sender_write_location          : 0/100099D8

    sender_flush_location          : 0/100099D8

    sender_replay_location         : 0/100099D8

    receiver_received_location     : 0/100099D8

    receiver_write_location        : 0/100099D8

    receiver_flush_location        : 0/100099D8

    receiver_replay_location       : 0/100099D8

    sync_percent                   : 100%

    sync_state                     : Sync

    sync_priority                  : 1

    sync_most_available            : Off

    channel                        : 192.168.192.134:26002-->192.168.192.133:40606


     Receiver info:      

    No information

    原来的主库变成备库的状态:

    [vastbase@node2 ~]$ vb_ctl query

    [2021-01-26 11:29:23.804][12771][][vb_ctl]: vb_ctl query ,datadir is /data/vastbase 

     HA state:           

    local_role                     : Standby

    static_connections             : 1

    db_state                       : Normal

    detail_information             : Normal


     Senders info:       

    No information 

     Receiver info:      

    receiver_pid                   : 12538

    local_role                     : Standby

    peer_role                      : Primary

    peer_state                     : Normal

    state                          : Normal

    sender_sent_location           : 0/10009AE0

    sender_write_location          : 0/10009AE0

    sender_flush_location          : 0/10009AE0

    sender_replay_location         : 0/10009AE0

    receiver_received_location     : 0/10009AE0

    receiver_write_location        : 0/10009AE0

    receiver_flush_location        : 0/10009AE0

    receiver_replay_location       : 0/10009AE0

    sync_percent                   : 100%

    channel                        : 192.168.192.133:40606

    • 分享到:
    排序方式:回复时间 共有0条评论