KingbaseES V8R6集群运维案例之---数据库实例initdb后配置

案例说明:
KingbaseES V8R6集群在数据库实例启动时需加载repmgr插件,并且具有集群管理的用户esrep和存储元数据的数据库esrep库;但在手工initdb新的实例后,默认的实例将不包含repmgr extension及esrep库和esrep用户,需要手工配置,完善集群管理应用。

适用版本: KingbaseES V8R6

一、默认repmgr集群管理配置

如下图所示,需要在kingbase.conf中配置repmgr extension的加载:

如下所示,集群管理需要创建esrep用户、esrep库及repmgr插件:

test=# \l esrep
                             List of databases
 Name  | Owner  | Encoding |   Collate   |    Ctype    | Access privileges
-------+--------+----------+-------------+-------------+-------------------
 esrep | system | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
(1 row)


test=# \du esrep
           List of roles
 Role name | Attributes | Member of
-----------+------------+-----------
 esrep     | Superuser  | {}

esrep=# \dx repmgr
                 List of installed extensions
  Name  | Version | Schema |           Description
--------+---------+--------+----------------------------------
 repmgr | 5.1     | repmgr | Replication manager for Kingbase

二、执行initdb初始化实例

1、initdb初始化实例[kingbase@node101 bin]$ ./initdb -U system -W -E utf8 --enable-ci -D /data/kingbase/has/data

2、查看初始化实例extension配置
如下所示,在shared_preload_libraries配置中,默认无repmgr的加载:

[kingbase@node101 bin]$ cat /data/kingbase/has/data/kingbase.conf|grep -i shared_

shared_preload_libraries = 'liboracle_parser, synonym, plsql, force_view, kdb_flashback,plugin_debugger, plsql_plugin_debugger, plsql_plprofiler, ora_commands,
kdb_ora_expr, sepapower, dblink, sys_kwr, sys_ksh, sys_spacequota, sys_stat_statements, backtrace, kdb_utils_function, auto_bmr, sys_squeeze, src_restrict'

3、查看esrep和resrep库信息

如下所示,默认创建新实例后,并不包含esrep用户和esrep库:

prod=# \l esrep
                             List of databases
 Name  | Owner  | Encoding |   Collate   |    Ctype    | Access privileges
-------+--------+----------+-------------+-------------+-------------------

(0 row)

prod=# \du esrep
           List of roles
 Role name | Attributes | Member of
-----------+------------+-----------

三、配置repmgr extension及esrep用户和库

1、加载repmgr extension

2、创建esrep库和esrep用户

test=# create database esrep;
CREATE DATABASE
test=# create user esrep with superuser password 'Kingbaseha110';
CREATE ROLE
##注意:esrep用户的密码和.encpwd文件中用户密码要匹配

test=# alter user esrep with superuser;
ALTER ROLE
test=# \du esrep
           List of roles
 Role name | Attributes | Member of
-----------+------------+-----------
 esrep     | Superuser  | {}

3、创建repmgr extension

test=# \c esrep
You are now connected to database "esrep" as user "system".
esrep=# create extension repmgr;
CREATE EXTENSION

4、查看repmgr schema下的对象

如下所示,在创建repmgr extension后,自动创建repmgr schema及集群元数据存储对象:

esrep=# \d repmgr.*
                Table "repmgr.conf"
 Column  |  Type   | Collation | Nullable | Default
---------+---------+-----------+----------+---------
 node_id | integer |           | not null |
 key     | text    |           | not null |
 value   | text    |           | not null |

                                 Table "repmgr.events"
     Column      |           Type           | Collation | Nullable |      Default
-----------------+--------------------------+-----------+----------+-------------------
 node_id         | integer                  |           | not null |
 event           | text                     |           | not null |
 successful      | boolean                  |           | not null | true
 event_timestamp | timestamp with time zone |           | not null | CURRENT_TIMESTAMP
 details         | text                     |           |          |

               Index "repmgr.idx_monitoring_history_time"
      Column       |           Type           | Key? |    Definition
-------------------+--------------------------+------+-------------------
 last_monitor_time | timestamp with time zone | yes  | last_monitor_time
 standby_node_id   | integer                  | yes  | standby_node_id
btree, for table "repmgr.monitoring_history"

                           Table "repmgr.monitoring_history"
          Column           |           Type           | Collation | Nullable | Default
---------------------------+--------------------------+-----------+----------+---------
 primary_node_id           | integer                  |           | not null |
 standby_node_id           | integer                  |           | not null |
 last_monitor_time         | timestamp with time zone |           | not null |
 last_apply_time           | timestamp with time zone |           |          |
 last_wal_primary_location | pg_lsn                   |           | not null |
 last_wal_standby_location | pg_lsn                   |           |          |
 replication_lag           | bigint                   |           | not null |
 apply_lag                 | bigint                   |           | not null |
Indexes:
    "idx_monitoring_history_time" btree (last_monitor_time, standby_node_id)

                                  Table "repmgr.nodes"
      Column      |            Type            | Collation | Nullable |     Default
------------------+----------------------------+-----------+----------+-----------------
 node_id          | integer                    |           | not null |
 upstream_node_id | integer                    |           |          |
 active           | boolean                    |           | not null | true
 node_name        | text                       |           | not null |
 type             | text                       |           | not null |
 location         | text                       |           | not null | 'default'::text
 priority         | integer                    |           | not null | 100
 conninfo         | text                       |           | not null |
 repluser         | character varying(63 char) |           | not null |
 slot_name        | text                       |           |          |
 config_file      | text                       |           | not null |
 primary_seen     | boolean                    |           |          |
 lsn              | pg_lsn                     |           |          |
Indexes:
    "nodes_pkey" PRIMARY KEY, btree (node_id)
Check constraints:
    "nodes_type_check" CHECK (type = ANY (ARRAY['primary'::text, 'standby'::text, 'witness'::text, 'bdr'::text]))
Foreign-key constraints:
    "nodes_upstream_node_id_fkey" FOREIGN KEY (upstream_node_id) REFERENCES repmgr.nodes(node_id) DEFERRABLE
Referenced by:
    TABLE "repmgr.nodes" CONSTRAINT "nodes_upstream_node_id_fkey" FOREIGN KEY (upstream_node_id) REFERENCES repmgr.nodes(node_id) DEFERRABLE

       Index "repmgr.nodes_pkey"
 Column  |  Type   | Key? | Definition
---------+---------+------+------------
 node_id | integer | yes  | node_id
primary key, btree, for table "repmgr.nodes"

                           View "repmgr.replication_status"
          Column           |           Type           | Collation | Nullable | Default
---------------------------+--------------------------+-----------+----------+---------
 primary_node_id           | integer                  |           |          |
 standby_node_id           | integer                  |           |          |
 standby_name              | text                     |           |          |
 node_type                 | text                     |           |          |
 active                    | boolean                  |           |          |
 last_monitor_time         | timestamp with time zone |           |          |
 last_wal_primary_location | pg_lsn                   |           |          |
 last_wal_standby_location | pg_lsn                   |           |          |
 replication_lag           | text                     |           |          |
 replication_time_lag      | pg_catalog.interval      |           |          |
 apply_lag                 | text                     |           |          |
 communication_time_lag    | pg_catalog.interval      |           |          |

                   View "repmgr.show_nodes"
       Column       |  Type   | Collation | Nullable | Default
--------------------+---------+-----------+----------+---------
 node_id            | integer |           |          |
 node_name          | text    |           |          |
 active             | boolean |           |          |
 upstream_node_id   | integer |           |          |
 upstream_node_name | text    |           |          |
 type               | text    |           |          |
 priority           | integer |           |          |
 conninfo           | text    |           |          |

            Table "repmgr.voting_term"
 Column |  Type   | Collation | Nullable | Default
--------+---------+-----------+----------+---------
 term   | integer |           | not null |
Indexes:
    "voting_term_restrict" UNIQUE, btree ((true))
Rules:
    voting_term_delete AS
    ON DELETE TO repmgr.voting_term DO INSTEAD NOTHING

 Index "repmgr.voting_term_restrict"
 Column |  Type   | Key? | Definition
--------+---------+------+------------
 bool   | boolean | yes  | (true)
unique, btree, for table "repmgr.voting_term"

四、总结
KingbaseES V8R6集群管理需要加载repmgr插件及创建集群管理的数据库esrep和esrep用户,在集群重新初始化实例后,并不包含以上对象,需要配置后,才能用于集群管理。

  • 4
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
KingbaseES V8是一种基于开源PostgreSQL数据库的企业级数据库管理系统。它被开发为一个高度可扩展和安全的解决方案,适用于各种规模的企业数据处理需求。 KingbaseES V8数据库技术白皮书详细介绍了该数据库系统的特点和优势。下面是一些关键内容: 1. 安全性:KingbaseES V8采用了严格的安全机制来保护数据的机密性和完整性。它支持数据加密、访问控制和安全审计等功能,确保敏感数据不会被未经授权的人员访问。 2. 高可靠性:KingbaseES V8通过提供数据库事务和持久性来确保数据的可靠性。它支持ACID(原子性、一致性、隔离性和持久性)属性,使得数据库在发生故障或中断时能够进行恢复并保持数据的一致性。 3. 高扩展性:KingbaseES V8支持水平和垂直扩展,可以根据业务需求进行灵活的扩展。它能够处理大规模的数据存储和查询,并提供了分布式数据库集群部署选项。 4. 大数据处理:KingbaseES V8具备处理大数据的能力,通过支持多种数据压缩和索引技术来提高数据存储和查询的效率。同时,它还提供了强大的数据备份和恢复机制,确保在数据发生意外故障时能够及时进行数据恢复。 5. 兼容性:KingbaseES V8与主流数据库标准兼容,可以实现与Oracle、SQL Server等数据库的互通和迁移。这样一来,企业在将原有数据库迁移到KingbaseES V8上时,可以事半功倍地减少迁移成本和风险。 总的来说,KingbaseES V8数据库技术白皮书详细介绍了其作为一种可靠、高效和安全的企业级数据库管理系统的优势和功能。这些特点使得KingbaseES V8成为适用于各种企业规模和数据处理需求的理想选择。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值