CLI Installation
CLI Installation
Section titled “CLI Installation”This guide covers installing and setting up the OstrichDB CLI on Unix-based systems (macOS and Linux). The CLI is written in Odin and provides a powerful terminal-based interface to OstrichDB.
Prerequisites
Section titled “Prerequisites”Before installing the OstrichDB CLI, ensure your system meets these requirements:
System Requirements
Section titled “System Requirements”- Operating System: Unix-based system (macOS or Linux)
- Memory: At least 512MB RAM available
- Storage: 100MB+ free disk space
- Terminal: Command-line interface access
Required Dependencies
Section titled “Required Dependencies”1. Go Programming Language
Section titled “1. Go Programming Language”The OstrichDB CLI requires Go to be installed and properly configured:
Installation:
- Visit https://go.dev/
- Download the appropriate version for your system
- Follow the installation instructions
- Recommended version:
go1.23.1
or later
Verify Installation:
go version# Should output: go version go1.23.1 [system] [arch]
PATH Configuration: Ensure Go is in your system PATH:
echo $PATH# Should include Go's bin directory (usually /usr/local/go/bin)
# If not in PATH, add to your shell profile (.bashrc, .zshrc, etc.):export PATH=$PATH:/usr/local/go/bin
2. Odin Programming Language
Section titled “2. Odin Programming Language”OstrichDB is written in Odin, so the Odin compiler is required:
Installation:
- Visit https://odin-lang.org/
- Follow the Odin Installation Guide
- Recommended version:
dev-2024-11:764c32fd3
or later
Quick Installation (Linux/macOS):
# Clone the Odin repositorygit clone https://github.com/odin-lang/Odin.gitcd Odin
# Build Odin (Linux)make release
# Build Odin (macOS)make release_native
# Move to system PATH locationsudo mv odin /usr/local/bin/
Verify Installation:
odin version# Should output version information
PATH Configuration: Ensure Odin is accessible from anywhere:
which odin# Should output: /usr/local/bin/odin (or similar)
# If not found, add Odin to your PATHexport PATH=$PATH:/path/to/odin
Installation Methods
Section titled “Installation Methods”Method 1: Local Build (Recommended)
Section titled “Method 1: Local Build (Recommended)”This method builds OstrichDB directly on your system for optimal performance.
Step 1: Clone the Repository
Section titled “Step 1: Clone the Repository”git clone https://github.com/Solitude-Software-Solutions/OstrichDB.gitcd OstrichDB
Step 2: Make Scripts Executable
Section titled “Step 2: Make Scripts Executable”chmod +x scripts/local_build_run.shchmod +x scripts/local_build.shchmod +x scripts/restart.sh
Step 3: Build and Run
Section titled “Step 3: Build and Run”# Build and immediately run OstrichDB./scripts/local_build_run.sh
Alternative: Build Only
# Just build without running./scripts/local_build.sh
# Then run manually./main.bin
Verify Local Installation
Section titled “Verify Local Installation”After building, you should see:
OstrichDB CLI v[version]Welcome to OstrichDB!Type 'HELP' for assistance.
OstrichDB>
Method 2: Docker Container
Section titled “Method 2: Docker Container”For isolated environments or systems where dependencies are difficult to install.
Prerequisites for Docker
Section titled “Prerequisites for Docker”- Install Docker: Visit https://docs.docker.com/engine/install/
- Verify Docker:
docker --version
Step 1: Navigate to Project
Section titled “Step 1: Navigate to Project”cd /path/to/OstrichDB
Step 2: Build Docker Container
Section titled “Step 2: Build Docker Container”# Build the containerdocker compose build
# Alternative: Build and run in detached modedocker compose up -d
Step 3: Run OstrichDB CLI
Section titled “Step 3: Run OstrichDB CLI”# Connect to the running container and start CLIdocker exec -it ostrichdb /app/main.bin
Docker Configuration
Section titled “Docker Configuration”Port Mapping:
The default Docker setup uses port 8080. To change this, edit docker-compose.yml
:
# Change from default 8080 to 8089ports: - "8089:8080"
Data Persistence:
OstrichDB data is stored in .ostrichdb/data
on your host machine, mapped to /data
in the container.
Verify Docker Installation
Section titled “Verify Docker Installation”You should see the OstrichDB CLI prompt inside the container:
OstrichDB CLI v[version]Welcome to OstrichDB!Type 'HELP' for assistance.
OstrichDB>
Post-Installation Setup
Section titled “Post-Installation Setup”Initial Configuration
Section titled “Initial Configuration”After successful installation, perform initial setup:
1. Create Your First User
Section titled “1. Create Your First User”# Start OstrichDB./main.bin
# Create a user accountOstrichDB> NEW USER# Follow the prompts to set up username and password
2. Test Basic Operations
Section titled “2. Test Basic Operations”# Create test dataOstrichDB> NEW test.sample.hello OF_TYPE STRING WITH "Hello, OstrichDB!"
# Fetch the dataOstrichDB> FETCH test.sample.hello
# View data structureOstrichDB> TREE
# Get helpOstrichDB> HELP
3. Configure Settings (Optional)
Section titled “3. Configure Settings (Optional)”# Enable verbose helpOstrichDB> SET CONFIG HELP_IS_VERBOSE TO true
# Configure auto-server startupOstrichDB> SET CONFIG AUTO_SERVE TO true
# Set session time limitsOstrichDB> SET CONFIG LIMIT_SESSION_TIME TO false
Environment Variables
Section titled “Environment Variables”Set up optional environment variables for easier access:
# Add to your shell profile (.bashrc, .zshrc, etc.)
# OstrichDB installation pathexport OSTRICHDB_HOME="/path/to/OstrichDB"
# Add OstrichDB to PATH for global accessexport PATH="$PATH:$OSTRICHDB_HOME"
# OstrichDB data directoryexport OSTRICHDB_DATA="$OSTRICHDB_HOME/.ostrichdb/data"
Reload your shell:
source ~/.bashrc # or ~/.zshrc
Directory Structure
Section titled “Directory Structure”After installation, your OstrichDB directory structure will look like:
OstrichDB/├── main.bin # Compiled executable├── scripts/│ ├── local_build.sh # Build script│ ├── local_build_run.sh # Build and run script│ └── restart.sh # Restart script├── .ostrichdb/│ ├── data/ # Database files (.ostrichdb)│ ├── logs/ # System logs│ ├── configs/ # Configuration files│ └── backups/ # Database backups├── src/ # Source code (Odin files)├── docker-compose.yml # Docker configuration└── README.md # Documentation
Troubleshooting Installation
Section titled “Troubleshooting Installation”Common Issues
Section titled “Common Issues”Go Not Found
Section titled “Go Not Found”# Error: go: command not found# Solution: Install Go and add to PATHwhich goecho $PATHexport PATH=$PATH:/usr/local/go/bin
Odin Not Found
Section titled “Odin Not Found”# Error: odin: command not found# Solution: Install Odin and add to PATHwhich odin# If not found, reinstall Odin or fix PATH
Permission Denied
Section titled “Permission Denied”# Error: Permission denied when running scripts# Solution: Make scripts executablechmod +x scripts/*.sh
Build Failures
Section titled “Build Failures”# Check dependencies are installedgo versionodin version
# Try rebuilding./scripts/local_build.sh
# Check for error messages in output
Docker Issues
Section titled “Docker Issues”# Docker daemon not runningsudo systemctl start docker # Linuxopen -a Docker # macOS
# Permission issuessudo docker compose build# Or add user to docker group (Linux)sudo usermod -aG docker $USER
System-Specific Issues
Section titled “System-Specific Issues”macOS Issues
Section titled “macOS Issues”Rosetta 2 (Apple Silicon):
# If running on Apple Silicon with Rosettaarch -x86_64 ./scripts/local_build.sh
Xcode Command Line Tools:
# Install if missingxcode-select --install
Linux Issues
Section titled “Linux Issues”Missing Development Tools:
# Ubuntu/Debiansudo apt updatesudo apt install build-essential git
# CentOS/RHEL/Fedorasudo yum groupinstall "Development Tools"# orsudo dnf groupinstall "Development Tools"
Library Dependencies:
# If you encounter library errorssudo apt install libc6-dev gcc # Ubuntu/Debiansudo yum install glibc-devel gcc # CentOS/RHEL
Performance Optimization
Section titled “Performance Optimization”For Development
Section titled “For Development”# Use the build-and-run script for frequent testing./scripts/local_build_run.sh
For Production
Section titled “For Production”# Build optimized version./scripts/local_build.sh
# Run with specific memory limits if neededulimit -m 1048576 # 1GB memory limit./main.bin
Getting Help
Section titled “Getting Help”If you encounter issues:
- Check Prerequisites: Ensure Go and Odin are properly installed
- Review Error Messages: Look for specific error details in output
- Check File Permissions: Ensure scripts are executable
- Verify System Resources: Ensure adequate memory and disk space
- Consult Documentation: Review the README and documentation
- Community Support: Join the OstrichDB community for help
Verification Checklist
Section titled “Verification Checklist”After installation, verify everything works:
- OstrichDB CLI starts without errors
- Can create users with
NEW USER
- Can create and fetch records
-
TREE
command shows data structure -
HELP
command provides information -
VERSION
shows correct version - Server mode works with
SERVE
(if needed)
Next Steps
Section titled “Next Steps”With OstrichDB CLI installed:
- Learn Query Structure - Understand the CLP system
- Explore Commands - Master all available operations
- Configure Your Setup - Customize OstrichDB settings
- Try Examples - Practice with real-world scenarios
You’re now ready to start using OstrichDB CLI for your database management needs!