The data storage architecture is optimized to efficiently manage both real-time and historical data, leveraging Apache Druid for the ingestion and querying of time-series machine performance data. PostgreSQL is used to maintain structured data such as user information, alerts, and reports tables, ensuring reliable relational data storage. Additionally, MinIO is employed as the object storage solution for managing and archiving reports. This architecture ensures scalability, high availability, and optimal performance for data-intensive operations, seamlessly integrating diverse storage and query needs.
To clone the repository:
git clone -b database https://github.com/belgio99/smartfactory
cd smartfactory
To start the containers:
docker compose up -d
The next steps for initializing the database are outlined in the README file within the database folder:
cd database
The following Python modules are installed during the Docker image build process:
- pandas: Data analysis and manipulation library.
- psycopg2-binary: PostgreSQL database adapter for Python.
- hvac: Python client for HashiCorp Vault.
- minio: Python library for interacting with Minio object storage.
- dotenv: Loads environment variables from a
.envfile.
-
Prepare the Dataset Create an
uploadfolder inside thedruidsubdirectory:mkdir -p druid/uploadPlace then your dataset in the
druid/uploadfolder. Apache Druid can ingest denormalized data in JSON, CSV, TSV, or any custom delimited format. Support for PKL files has also been added. -
Build the Docker Image Build the initialization image using the following command:
docker build -t smartfactory-db-init .Note: If you modified the ports in the Docker Compose file, ensure that the ports in the
.envfiles are updated accordingly. -
Run the Image in a container Execute the following command to set up the database architecture:
docker run --rm --network host --name init -v ./druid/upload:/app/druid/upload smartfactory-db-initThe container will automatically remove itself once the process is complete.
-
Creates Object Storage in Minio:
Initializes the object storage in Minio to manage and archive reports, creating the necessary buckets forreportsandbackupsif they do not already exist. -
Creates Database Tables in PostgreSQL:
Sets up the database tables in PostgreSQL for structured data (tables for user information, alerts, and reports). -
Uploads Time-Series Data to Apache Druid:
Ingests the dataset placed in theobj_storagefolder into Apache Druid, creating a new datasource namedtimeseries.
