4-node: mssql

Replaces PostgreSQL with a Microsoft SQL Server-compatible kernel using WiltonDB or Babelfish.

The mssql config template is based on full template. Which use the WiltonDB / Babelfish kernel to replace the vanilla PostgreSQL kernel, providing Microsoft SQL Server wire protocol level compatibility.

Check Babelfish (MSSQL) kernel description for more details


Overview

  • Conf Name: mssql
  • Node Count: 4-node, pigsty/vagrant/spec/full.rb
  • Description: Replaces PostgreSQL with a Microsoft SQL Server-compatible kernel using WiltonDB or Babelfish.
  • Content: pigsty/conf/mssql.yml
  • OS Distro: el7, el8, el9, u20, u22, u24
  • OS Arch: x86_64, aarch64
  • Related: full

Usage: configure with -c mssql:

./configure -c mssql

This is a 4-node template, you need to modify the IP address of the other 3 nodes after configure


Content

Source: pigsty/conf/mssql.yml

all: children: #----------------------------------# # infra: monitor, alert, repo, etc.. #----------------------------------# infra: { hosts: { 10.10.10.10: { infra_seq: 1 } } } #----------------------------------# # etcd cluster for HA postgres DCS #----------------------------------# etcd: { hosts: { 10.10.10.10: { etcd_seq: 1 } }, vars: { etcd_cluster: etcd } } #----------------------------------# # pgsql (singleton on current node) #----------------------------------# # this is an example single-node postgres cluster pg-meta: hosts: 10.10.10.10: { pg_seq: 1, pg_role: primary } # <---- primary instance with read-write capability vars: pg_cluster: pg-meta pg_users: # create MSSQL superuser - {name: dbuser_mssql ,password: DBUser.MSSQL ,superuser: true, pgbouncer: true ,roles: [dbrole_admin], comment: superuser & owner for babelfish } pg_databases: - name: mssql baseline: mssql.sql # init babelfish database & user extensions: - { name: uuid-ossp } - { name: babelfishpg_common } - { name: babelfishpg_tsql } - { name: babelfishpg_tds } - { name: babelfishpg_money } - { name: pg_hint_plan } - { name: system_stats } - { name: tds_fdw } owner: dbuser_mssql parameters: { 'babelfishpg_tsql.migration_mode' : 'multi-db' } comment: babelfish cluster, a MSSQL compatible pg cluster #----------------------------------# # pgsql (3-node pgsql/mssql cluster) #----------------------------------# pg-test: hosts: 10.10.10.11: { pg_seq: 1, pg_role: primary } 10.10.10.12: { pg_seq: 2, pg_role: replica } 10.10.10.13: { pg_seq: 3, pg_role: replica, pg_offline_query: true } vars: pg_cluster: pg-test pg_users: # create MSSQL superuser - {name: dbuser_mssql ,password: DBUser.MSSQL ,superuser: true, pgbouncer: true ,roles: [dbrole_admin], comment: superuser & owner for babelfish } pg_primary_db: mssql # use `mssql` as the primary sql server database pg_databases: - name: mssql baseline: mssql.sql # init babelfish database & user extensions: - { name: uuid-ossp } - { name: babelfishpg_common } - { name: babelfishpg_tsql } - { name: babelfishpg_tds } - { name: babelfishpg_money } - { name: pg_hint_plan } - { name: system_stats } - { name: tds_fdw } owner: dbuser_mssql parameters: { 'babelfishpg_tsql.migration_mode' : 'single-db' } comment: babelfish cluster, a MSSQL compatible pg cluster vars: #----------------------------------# # Meta Data #----------------------------------# version: v3.3.0 # pigsty version string admin_ip: 10.10.10.10 # admin node ip address region: default # upstream mirror region: default,china,europe node_tune: oltp # node tuning specs: oltp,olap,tiny,crit pg_conf: oltp.yml # pgsql tuning specs: {oltp,olap,tiny,crit}.yml infra_portal: # domain names and upstream servers home : { domain: h.pigsty } grafana : { domain: g.pigsty ,endpoint: "${admin_ip}:3000" , websocket: true } prometheus : { domain: p.pigsty ,endpoint: "${admin_ip}:9090" } alertmanager : { domain: a.pigsty ,endpoint: "${admin_ip}:9093" } blackbox : { endpoint: "${admin_ip}:9115" } loki : { endpoint: "${admin_ip}:3100" } #----------------------------------# # NODE, PGSQL, MSSQL #----------------------------------# pg_version: 15 # The current WiltonDB major version is 15 pg_packages: # install forked version of postgresql with babelfishpg support - wiltondb patroni pgbouncer pgbackrest pg_exporter pgbadger vip-manager pg_extensions: [ ] # do not install any vanilla postgresql extensions pg_mode: mssql # Microsoft SQL Server Compatible Mode pg_libs: 'babelfishpg_tds, pg_stat_statements, auto_explain' # add timescaledb to shared_preload_libraries pg_default_hba_rules: # overwrite default HBA rules for babelfish cluster - { user: '${dbsu}' ,db: all ,addr: local ,auth: ident ,title: 'dbsu access via local os user ident' } - { user: '${dbsu}' ,db: replication ,addr: local ,auth: ident ,title: 'dbsu replication from local os ident' } - { user: '${repl}' ,db: replication ,addr: localhost ,auth: pwd ,title: 'replicator replication from localhost' } - { user: '${repl}' ,db: replication ,addr: intra ,auth: pwd ,title: 'replicator replication from intranet' } - { user: '${repl}' ,db: postgres ,addr: intra ,auth: pwd ,title: 'replicator postgres db from intranet' } - { user: '${monitor}' ,db: all ,addr: localhost ,auth: pwd ,title: 'monitor from localhost with password' } - { user: '${monitor}' ,db: all ,addr: infra ,auth: pwd ,title: 'monitor from infra host with password' } - { user: '${admin}' ,db: all ,addr: infra ,auth: ssl ,title: 'admin @ infra nodes with pwd & ssl' } - { user: '${admin}' ,db: all ,addr: world ,auth: ssl ,title: 'admin @ everywhere with ssl & pwd' } - { user: dbuser_mssql ,db: mssql ,addr: intra ,auth: md5 ,title: 'allow mssql dbsu intranet access' } # <--- use md5 auth method for mssql user - { user: '+dbrole_readonly',db: all ,addr: localhost ,auth: pwd ,title: 'pgbouncer read/write via local socket' } - { user: '+dbrole_readonly',db: all ,addr: intra ,auth: pwd ,title: 'read/write biz user via password' } - { user: '+dbrole_offline' ,db: all ,addr: intra ,auth: pwd ,title: 'allow etl offline tasks from intranet' } pg_default_services: # route primary & replica service to mssql port 1433 - { name: primary ,port: 5433 ,dest: 1433 ,check: /primary ,selector: "[]" } - { name: replica ,port: 5434 ,dest: 1433 ,check: /read-only ,selector: "[]" , backup: "[? pg_role == `primary` || pg_role == `offline` ]" } - { name: default ,port: 5436 ,dest: postgres ,check: /primary ,selector: "[]" } - { name: offline ,port: 5438 ,dest: postgres ,check: /replica ,selector: "[? pg_role == `offline` || pg_offline_query ]" , backup: "[? pg_role == `replica` && !pg_offline_query]" } # download wiltondb instead of postgresql kernel repo_modules: node,pgsql,infra,mssql repo_packages: [ node-bootstrap, infra-package, infra-addons, node-package1, node-package2, pgsql-utility ] repo_extra_packages: [ wiltondb, sqlcmd ] # replace pgsql kernel with wiltondb/babelfish

Caveat

Beware that WiltonDB is only available on EL 7/8/9 and Ubuntu 20.04/22.04/24.04 systems, and Debian-based systems are not supported at the moment.

WiltonDB is compatible with PostgreSQL 15.


Last modified 2025-03-21: replace vonng to pgsty (75336f2)