1. Installation planning

By the end of this chapter: You decide the setup type, server specifications, OS settings, disk layout, and items to bring in.

1.1 Setup types

Setup Flow Where to use it
Analytics setup (recommended) Operational database → built-in replication (PostgreSQL logical replication, publication → subscription), CDC, or ETL → GritDB → reports and BI tools (analytics session) The adoption model recommended for 1.1. The executables, data, and business applications of the operational database stay as they are
Single database Application → GritDB (both writes and queries) QuickStart installation setup, testing, and validation
  • In a single-database setup, each write to a registered table waits for confirmation that the GritDB engine received it. So it is not recommended for production write workloads.
  • In an analytics setup, the operational database side also has work to do. For wal_level, publication, replication account, pg_hba.conf, firewall, free space in pg_wal on the operational database, and max_slot_wal_keep_size, see 6.4.1 and 6.4.3. For monitoring, see 7.5.
  • While the GritDB of an analytics setup is stopped, the replication slot on the operational database holds WAL. So decide in advance how long GritDB can stay stopped and how much free disk space the operational database has (4.7).
  • Do not receive data through physical replication (streaming standby server) of the operational database. An analytics setup receives data through PostgreSQL logical replication, CDC, or ETL (6.4).
  • 1.1 does not offer GritDB redundancy (standby, HA), multiple nodes, or adding GritDB to a PostgreSQL already in use. The installation script creates a new data directory with initdb, so you cannot add GritDB to an existing PostgreSQL. For details, see 10.6.

1.2 Supported platforms

Item Requirement Check
CPU x86-64 with the cx16 and sse4_2 instructions (without them, GritDB does not start) QuickStart 2.4 checklist item 3
glibc At least min_glibc in the installation package’s manifest.json QuickStart 2.4 checklist item 4
OS Ubuntu 24.04 LTS grep PRETTY_NAME /etc/os-release
Virtual server Fine if the OS is the same —
PostgreSQL 17.11 (included in the installation package, so do not install it separately) Chapter 0, “Applicable version”
  • The supported OS is Ubuntu 24.04 LTS only. Other operating systems and containers are outside the supported environment. Even if installation and start succeed, there is no guarantee.
  • On RHEL 9 and Rocky Linux 9, glibc is older than min_glibc, so they fail the installation check (QuickStart 2.4 checklist item 4).
  • The installation script only prints a warning and continues the installation even if glibc or the CPU instructions fall short. If you see a warning below, stop the installation and go back to QuickStart 2.4 checklist items 3 and 4.
    • [WARN] Host glibc <version> is older than required <version>; binaries may not start.
    • [WARN] CPU may lack required flags (cx16, sse4.2); startup guard will refuse if so.
  • In a container, the GritDB engine sizes memory and vCPUs by the host values. It does not look at the container limits. If GritDB hits a limit, the OS forcibly ends a GritDB process, and all of GritDB stops (4.3).

Check the shared libraries before installation. Run the command in the extracted directory.

cd ~/pkg/gritdb-*/
ldd bin/postgres bin/grit_admin bin/grit_surfer_process bin/grit_catalog_process | grep 'not found'

No output is normal. If a library is missing, the installation finishes, but GritDB stops at start. In that case, install that library from an OS package, then check again.

1.3 Sizing

Item Value If it falls short
Minimum specification (subscription minimum specification) 16 vCPU, 64 GB of memory You still get installation and operation support. Support takes performance questions after you raise the server to the minimum specification (QuickStart 2.4 checklist item 5)
Minimum memory Total memory that the OS sees (total on the Mem: line of free -m) 8192 or more The GritDB engine does not start. The abort record log/GRIT_SURFER_ASSERT.log gets system memory too small and Required system memory >= 8192 MB (9.1)
Minimum disk space Size of the data to load + 200 GB (based on max_wal_size 64 GB) Use a separate data volume (1.5, 2.4, and QuickStart 2.4 checklist item 6)
  • A server sold as 8 GB usually shows a total smaller than 8192. The kernel and firmware reserve part of the memory. So it falls short of the minimum.
  • 1.1 has no setting that reduces the vCPUs or memory that GritDB uses. GritDB uses as much as the size of the server (virtual server). So decide the size when you choose the server.

Memory breakdown:

Share Size
GritDB engine storage Half of physical memory
GritDB engine queries The larger of 4 GB and 15% of physical memory
shared_buffers 25% of the memory left after the two engine shares (the PostgreSQL share). The installation script sets it (5.5)
Connections Per connected PostgreSQL session

Disk breakdown:

Location Why it grows
datafiles/pgdata Table and index data
datafiles/pgdata/pg_wal max_wal_size (64 GB by default) + WAL that the recovery replication slot (gritsurfer_slot, replication slot) holds
datafiles/cold_file cold files (files the GritDB engine stores by column for analytic queries). They include the share that keeps update and delete history (7.4)
datafiles/queue, datafiles/buffer_spill GritDB engine queue, data spilled when memory runs short
log/ GritDB logs and postgresql.log (9.3 and 9.4)
Core files Tens of GB each (9.6). kernel.core_pattern sets the location (1.4)

The number of rows that one transaction can write to registered tables (single-transaction size) has a limit. The limit depends on server memory, and no setting changes it. Check it with 6.8 after installation.

  • If an analytics setup receives a large table, or the operational database has large batches, contact support (chapter 0) before you choose the server.

Calculation example:

Share Server with 64 GB of memory and 100 GB of data Server with 128 GB of memory and 1 TB of data
GritDB engine storage About 32 GB About 64 GB
GritDB engine queries About 10 GB About 19 GB
shared_buffers 5 GB 10 GB
Remainder (OS, connections, file cache) About 17 GB About 35 GB
Minimum disk space 300 GB 1,200 GB
  • The minimum disk space is only a minimum. The size of cold files depends on the workload, so measure the trend from the start of operation (7.4).

1.4 OS settings

Item Check (gritdb) Normal Configure (root)
Service account id gritdb The account exists useradd -m gritdb (QuickStart 2.1)
Open file limit ulimit -n and ulimit -Hn Both 65536 or more ① below
Core files ulimit -c, ulimit -Hc, and cat /proc/sys/kernel/core_pattern The limit and location you chose (9.6) ② below
/dev/shm df -h /dev/shm Not reduced. The Ubuntu default is half of memory If it was reduced, restore it
Shared memory removal at logout (RemoveIPC) systemd-analyze cat-config systemd/logind.conf | grep -E '^RemoveIPC' RemoveIPC=no ⑤ below
Time synchronization timedatectl System clock synchronized: yes timedatectl set-ntp true
clocksource cat /sys/devices/system/clocksource/clocksource0/current_clocksource tsc ③ below
/tmp execute permission findmnt -n -o OPTIONS --target /tmp No noexec ④ below

① Open file limit — root adds two lines to /etc/security/limits.conf.

cat >> /etc/security/limits.conf <<'EOF'
gritdb soft nofile 65536
gritdb hard nofile 65536
EOF
  • To check again, run ulimit -n and ulimit -Hn in a new gritdb login shell. Both return 65536 or more.
  • QuickStart 2.1 (create the account) adds the same two lines. If you followed it as written, the limit is already raised, so only check it.
  • If you start GritDB as a service at server boot, this file does not apply. In that case, see LimitNOFILE in 4.6.

② Core files — The GritDB engine raises the core size limit up to the hard value. At a quick stop or an abnormal termination, one core file can be tens of GB (9.6).

  • Decide whether to keep core files and where to put them. The settings are the hard limit (the core line in /etc/security/limits.conf) and the location in kernel.core_pattern.
  • If kernel.core_pattern starts with | (Ubuntu default), the OS core collection program receives the core. In that case, check that program’s location and settings first (9.6).
  • The location is a place other than the data volume, with space for several core files (1.5).

③ clocksource — If it is not tsc, GritDB starts, but log/grit_admin_main.log gets a kernel clocksource is warning. root makes the change.

cat /sys/devices/system/clocksource/clocksource0/available_clocksource
echo tsc > /sys/devices/system/clocksource/clocksource0/current_clocksource
  • Change it only when the output of the first line contains tsc. If it does not, contact support (chapter 0).
  • To keep it after a reboot, add clocksource=tsc to the kernel command line.

④ Temporary directory (TMPDIR)

  • During installation, the installation script creates a script for each step in the temporary directory and runs it. If /tmp is noexec, every step can fail. In that case, give it a directory that allows execution.

    mkdir -p ~/tmp
    cd ~/pkg/gritdb-*/
    TMPDIR=~/tmp ./install_gritdb.sh
    
  • While running, the GritDB engine writes temporary files for cleanup work (__tkidx_spill_*.tmp). It writes them to the TMPDIR of the shell that started it (/tmp if it is not set). If /tmp is tmpfs or small, give a directory on the data volume when you start GritDB. Keep that directory outside datafiles/, and give the same value at every start.

    TMPDIR=<directory on the data volume> ~/gritdb1/bin/gritdb-start
    
  • With GritDB stopped (4.5), delete the temporary files left after an abnormal termination. For details, see 7.6. <temporary directory> is the TMPDIR you gave at start, or /tmp if you gave none.

    ls -l <temporary directory>/__tkidx_spill_*.tmp
    rm -f <temporary directory>/__tkidx_spill_*.tmp
    
    • If several installations use the same temporary directory, stop all of them, then delete the files (2.9).

⑤ RemoveIPC — By default, systemd on Ubuntu removes a regular account’s shared memory when its last login session ends. A service account created with useradd -m (QuickStart 2.1) is a regular account. So when you log in as gritdb and log out, systemd removes the shared memory of the running GritDB (/dev/shm, the 1.4 table). root turns this off as shown below.

mkdir -p /etc/systemd/logind.conf.d
printf '[Login]\nRemoveIPC=no\n' > /etc/systemd/logind.conf.d/gritdb.conf
systemctl restart systemd-logind
  • To check, run the check command in the table above. It returns RemoveIPC=no.
  • QuickStart 2.1 (create the account) runs the same three lines. If you followed it as written, the setting is already off, so only check it.
  • If you created the service account as a system account (useradd -r), systemd does not remove its shared memory. For the source, see systemd RemoveIPC.

Leave the huge page setting, PostgreSQL huge_pages, at the default (try). The GritDB engine does not allocate huge pages separately.

1.5 Disk layout

The recommended layout is to put all of datafiles/ on a dedicated data volume (--datafiles in 2.4). datafiles/ is one unit, so do not put only part of it on another volume.

~/gritdb1/                    installation directory (OS volume)
├── bin/ · lib/ · share/ …    installed files
├── config/                   GritDB engine configuration
├── log/                      logs
├── run/                      runtime state files
└── datafiles → /data/gritdb/datafiles  symlink

/data/                        dedicated data volume (mount point · owned by root)
└── gritdb/                   owned by the service account (reinitialization and restore rename directories in here)
    └── datafiles/
        ├── pgdata/           PostgreSQL data · WAL
        ├── checkpoint/       unify checkpoint (the WAL position up to which the GritDB engine has applied changes durably · not the PostgreSQL checkpoint)
        ├── queue/            GritDB engine queue
        ├── buffer_spill/     data spilled when memory runs short
        └── cold_file/        cold file

⚠ After installation, do not change the real path of datafiles/ (including the relocation target and the mount point)

  • Reason: If you start GritDB after the change, you lose the cold files. You cannot undo this.
  • Instead: Decide the data volume at the first installation (2.4). If the disk runs short, keep the path and only grow the volume. Restore to the same real path, too (8.1 and 10.5).
  • Give --datafiles a directory below the mount point, not the mount point itself (2.4). For example, if /data is the mount point, create /data/gritdb owned by the service account and give /data/gritdb/datafiles. Then reinitialization and restore only rename directories inside the same volume, in a place where the service account can write. If you give the mount point itself, reinitialization moves the old data to the parent file system. That file system can then fill up (3.1).
  • log/ is under the installation directory, and no option moves it. So leave room for logs on the volume of the installation directory. postgresql.log keeps growing unless you set up rotation (9.4).
  • Core files pile up in the location that kernel.core_pattern sets, so keep that location off the data volume (1.4 and 9.6).
  • To grow the disk, keep the path and only grow the volume (warning above).

1.6 Ports and network

Direction From To Port Use
Inbound Applications, reports, and BI tools GritDB server PostgreSQL port (default 5432) Queries and writes
Inbound CDC and ETL tools GritDB server PostgreSQL port Analytics setup (when you receive data with a tool, 6.4)
Outbound GritDB server Operational database Operational database port Analytics setup subscription (6.4.1 step 4)
  • The only port for inbound TCP connections is the PostgreSQL port. GritDB has no other TCP ports.
  • The Unix sockets are PostgreSQL /tmp/.s.PGSQL.<port> (unix_socket_directories) and the supervisor process ~/gritdb1/run/grit_admin.sock. The supervisor process socket is for the stop command (11.7).
  • GritDB does not communicate outward on its own. It has no license or statistics communication. The only outbound connection is the one that the analytics setup subscription opens to the operational database.
  • By default after installation, GritDB accepts connections only from localhost. For remote connections, see 11.4.

1.7 Bringing files into a network without internet access

Item to bring in Notes
Installation package (gritdb-<...>.tar.gz) Distribution media
SHA256SUMS Get it through a different channel from the installation package
jq OS package. Get it with its dependency packages from the OS installation media or your organization’s internal repository
  • Verify the delivered files by following QuickStart 2.3 as written (sha256sum -c SHA256SUMS → install_gritdb.sh --verify-only).
  • The installation script does not read SHA256SUMS, so do not skip sha256sum -c.
  • For automated checks, exit code 0 from --verify-only means a pass. If it is not 0, tell the cause apart by the text on the screen.
    • If jq is required to read the manifest appears, bring in jq (GDB-INSTALL-002).
    • If hash mismatch or dist verification FAILED appears, get the delivered files again (GDB-INSTALL-003).
  • For a patch or upgrade, verify the new installation package with the same procedure (3.4).

1.8 Character set, collation, and time zone

  • The database character set is UTF8, and the sort order (collation) is C. Character classification (ctype) is C.UTF-8. The installation sets them, and you cannot change them. They are fixed so that the GritDB engine and PostgreSQL give the same sort results.

    ~/gritdb1/bin/psql -p 5432 -d postgres -Atc "SELECT datname, pg_encoding_to_char(encoding), datcollate, datctype FROM pg_database;"
    

    It is normal if every database shows UTF8|C|C.UTF-8.

  • Sort results follow byte order. They differ from the ko_KR and en_US collations. For example, uppercase letters come first in ORDER BY, so B comes before a. Hangul (precomposed syllables) sorts in Korean alphabetical order.

  • Do not create databases with another collation or an ICU collation (10.3).

  • The server time zone is the OS time zone at installation (TimeZone). To check it, run SHOW timezone;. To change it, see 5.3.

  • Queries in an analytics session do not use the session time zone (SET timezone). So set the application’s time zone to match the server time zone (10.3). Analytics sessions compute with the OS time zone, so keep the server time zone equal to the OS time zone (5.3).

1.9 Installation planning checklist

# Decision Your value See
1 Setup <analytics setup · single database> 1.1
2 Server <vCPU · memory · OS> 1.2 and 1.3
3 Service account <account · default gritdb> 1.4
4 Installation directory <default ~/gritdb1 · 80 characters or fewer> 2.2
5 Data volume <--datafiles path · volume size> 1.5 and 2.4
6 Port and firewall <port · addresses to open for connections> 1.6, 2.5, and 11.4
7 Items to bring in Installation package, SHA256SUMS (different channel), and jq 1.7
8 Shared libraries No output from the ldd check 1.2
9 Open file limit soft and hard 65536 or more 1.4
10 TMPDIR <directory to use at installation and start> 1.4
11 core <limit · kernel.core_pattern location> 1.4 and 9.6
12 Backup location and interval <location that holds all of datafiles/ · interval = period of data you can afford to lose> 8.2, 8.3, and 8.4 (free space on the data volume for a restore)
13 Time zone <server time zone> (character set and collation are fixed) 1.8
14 Single-transaction size <row count of the largest load or batch> (compare with 6.8 after installation) 1.3 and 6.8
15 Operational database preparation for an analytics setup <wal_level · max_slot_wal_keep_size · free space in pg_wal on the operational database · how long GritDB can stay stopped> 1.1, 4.7, 6.4.1, and 6.4.3
16 OS settings (other items in the 1.4 table) RemoveIPC=no, System clock synchronized: yes, clocksource tsc, and /dev/shm unchanged 1.4
  • For the installation command, if items 4, 5, 6, and 10 all use the defaults, follow QuickStart 3.1 as written. If any of them differs, put those values in one command and give them at the first installation (“Examples of combined options” in 2.1).

    cd ~/pkg/gritdb-*/
    TMPDIR=<directory> ./install_gritdb.sh --datafiles /data/gritdb/datafiles --pgport 5433
    
    • You cannot change the installation directory or the data volume after installation (1.5, 2.2, and 2.4).
    • Check with QuickStart 3.2 and 3.3. Substitute only the path and port. Then go to 2.10.

If a problem occurs

  • If the installation fails, see the GDB-INSTALL entries in QuickStart, chapter 7, and TroubleShooting.

Learn more