DEV Community

mmllllzcn
mmllllzcn

Posted on

GBase Database Environment Pre-Check Script: One Command Before Installation

Before installing GBase Database(GBase 8s) on Linux, checking the server environment can save a lot of troubleshooting time.

In practice, many installation failures are not caused by the database package itself. Missing dependencies, insufficient memory, incorrect permissions, unavailable ports, and unsuitable kernel parameters can all cause problems during installation or instance creation.

This tutorial provides a simple GBase Database environment pre-check script that checks the main server requirements before you start the installation.

What Does the Script Check?

The script checks seven areas:

  1. Operating system
  2. CPU, memory, and disk space
  3. Required packages
  4. Database ports
  5. gbasedbt user
  6. Directory permissions
  7. Kernel parameters

The goal is not to replace the official installation requirements. Instead, it provides a quick first-level check before installing GBase Database.

Full Pre-Check Script

Save the following as gbase_precheck.sh:

#!/bin/bash

RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'

PASS=0
WARN=0
FAIL=0

check() {
    local desc="$1"
    local cmd="$2"

    if eval "$cmd" >/dev/null 2>&1; then
        echo -e "${GREEN}[PASS]${NC} $desc"
        ((PASS++))
    else
        echo -e "${RED}[FAIL]${NC} $desc"
        ((FAIL++))
    fi
}

check_warn() {
    local desc="$1"
    local cmd="$2"

    if eval "$cmd" >/dev/null 2>&1; then
        echo -e "${GREEN}[PASS]${NC} $desc"
        ((PASS++))
    else
        echo -e "${YELLOW}[WARN]${NC} $desc"
        ((WARN++))
    fi
}

echo "=========================================="
echo "  GBase Database Environment Pre-Check"
echo "=========================================="

echo ""
echo "=== 1. Operating System ==="
check "CentOS or Red Hat detected" \
    "grep -Eqi 'CentOS|Red Hat' /etc/redhat-release"

check_warn "Kernel version >= 3.10" \
    "uname -r | awk -F. '{if (\$1 >= 3 && \$2 >= 10) exit 0; exit 1}'"

echo ""
echo "=== 2. Hardware Resources ==="

check_warn "Memory >= 4GB" \
    "free -g | awk '/Mem:/{if (\$2 >= 4) exit 0; exit 1}'"

check_warn "CPU >= 2 cores" \
    "test \$(nproc) -ge 2"

check_warn "Disk space >= 100GB" \
    "df -BG /opt | awk 'NR==2{gsub(\"G\",\"\"); if (\$4 >= 100) exit 0; exit 1}'"

echo ""
echo "=== 3. Dependency Packages ==="

for pkg in unzip libaio libgcc libstdc++ ncurses-devel; do
    check "$pkg installed" "rpm -q $pkg"
done

echo ""
echo "=== 4. Port Check ==="

for port in 9088 9089 19088; do
    check_warn "Port $port available" \
        "! ss -lnt | awk '{print \$4}' | grep -qE ':${port}$'"
done

echo ""
echo "=== 5. User Check ==="

check "gbasedbt user exists" "id gbasedbt"

echo ""
echo "=== 6. Directory Check ==="

check "/opt/GBASE is writable" \
    "test -d /opt/GBASE && test -w /opt/GBASE"

check_warn "/tmp space >= 10GB" \
    "df -BG /tmp | awk 'NR==2{gsub(\"G\",\"\"); if (\$4 >= 10) exit 0; exit 1}'"

echo ""
echo "=== 7. Kernel Parameters ==="

check_warn "Semaphore values meet baseline" \
    "awk '{if (\$1 >= 250 && \$2 >= 1024000 && \$3 >= 100 && \$4 >= 128) exit 0; exit 1}' /proc/sys/kernel/sem"

echo ""
echo "=========================================="
echo "  Results: PASS=$PASS  WARN=$WARN  FAIL=$FAIL"
echo "=========================================="

if [ $FAIL -gt 0 ]; then
    echo -e "${RED}$FAIL critical issue(s) found.${NC}"
    echo "Please review them before installing GBase Database."
    exit 1
elif [ $WARN -gt 0 ]; then
    echo -e "${YELLOW}$WARN warning(s) found.${NC}"
    echo "Review the warnings before installation."
    exit 0
else
    echo -e "${GREEN}All checks passed. Environment is ready.${NC}"
    exit 0
fi
Enter fullscreen mode Exit fullscreen mode

How to Run It

Make the script executable:

chmod +x gbase_precheck.sh
Enter fullscreen mode Exit fullscreen mode

Then run it:

sudo bash gbase_precheck.sh
Enter fullscreen mode Exit fullscreen mode

A successful environment might produce output like:

==========================================
  GBase Database Environment Pre-Check
==========================================

=== 1. Operating System ===
[PASS] CentOS or Red Hat detected
[PASS] Kernel version >= 3.10

=== 2. Hardware Resources ===
[PASS] Memory >= 4GB
[PASS] CPU >= 2 cores
[PASS] Disk space >= 100GB

=== 3. Dependency Packages ===
[PASS] unzip installed
[PASS] libaio installed
[PASS] libgcc installed
[PASS] libstdc++ installed
[PASS] ncurses-devel installed

=== 4. Port Check ===
[PASS] Port 9088 available
[PASS] Port 9089 available
[PASS] Port 19088 available

==========================================
  Results: PASS=11  WARN=0  FAIL=0
==========================================

All checks passed. Environment is ready.
Enter fullscreen mode Exit fullscreen mode

If a required package is missing or a critical check fails, the script returns a non-zero exit code. That makes it useful not only for manual checks but also for automated deployment workflows.

Why Run a Pre-Check?

A pre-check separates environment problems from database installation problems.

For example, if ncurses-devel is missing, fixing the package dependency first is much easier than troubleshooting an installation failure later.

The same applies to:

  • Insufficient memory
  • Insufficient disk space
  • Missing gbasedbt user
  • Port conflicts
  • Incorrect directory permissions
  • Kernel configuration issues

Running one small script before installation gives you a much clearer starting point.

Integrate It with Ansible

If you are deploying GBase Database to multiple servers, the same script can be integrated into an Ansible workflow:

- name: GBase Database Environment Pre-Check
  hosts: gbase_servers

  tasks:
    - name: Upload pre-check script
      copy:
        src: gbase_precheck.sh
        dest: /tmp/gbase_precheck.sh
        mode: '0755'

    - name: Run pre-check
      command: bash /tmp/gbase_precheck.sh
      register: result

    - name: Display results
      debug:
        var: result.stdout_lines
Enter fullscreen mode Exit fullscreen mode

This allows you to validate the target servers before starting a batch GBase Database installation.

Final Thoughts

A few minutes of environment validation can prevent hours of installation troubleshooting.

The recommended workflow is:

Pre-check the server → Fix environment issues → Install GBase Database → Create the instance → Verify the database.

The script above is intended as a practical baseline rather than a replacement for version-specific GBase Database(GBase 8s) installation requirements. Always compare the checks with the requirements of the specific GBase Database release you are deploying.

For repeated deployments, combining this pre-check with Ansible can turn the manual installation process into a more consistent and repeatable workflow.

Top comments (0)