Need Help on how it works

Hello everyone,
I have few questions since I’m newbie here :slight_smile:

  1. Is there a ready docker-compose file for a basic usage (as I know : 3 nodes type zone, 1 master with 2 joins, and read replicas ) to integrate with nodejs app
  2. Can we use it on production using just docker without any problem ?
  3. Let’s say we have 3 nodes, as I understand, when a client requests an api get / post, yugabyte will choose the best node for response same as load-balancers do ?
    Thank you :slight_smile:

Hi @bkfdev

We are glad you’ve started your YugabyteDB journey. I can help you answer the questions -

  1. Here are the docs link for getting started with docker -
  1. We generally don’t recommend running Docker-based deployments in production. There are a few users in the community who are doing so. We recommend deploying YugabyteDB on Kubernetes to run production container workloads. Open source Kubernetes using YugabyteDB operator | YugabyteDB Docs

Yes, in the simplest of explanations, your understanding is correct. YugabyteDB distributes(shards) the data in all the available nodes of the universe, so the app doesn’t need to know where the data is located and can send the query ( SELECT/INSERTs) to any node and apps will get the required data.

You can further explore the YugabyteDB data distribution here - Data distribution | YugabyteDB Docs

Let us know if you have any questions. Thanks

Thank you for quick reply,
Actually I’m using this setup below, everything is created, and I can access to 7000, 15433, and I’m able to use ysqlsh and create roles, databases ..etc, but nothing is shown on 15433 => http://localhost:15433/databases/tabYsql
Docker-compose :

db-1:
   image: yugabytedb/yugabyte:latest
   container_name: otlob-db-1
   command:
     [
       "bin/yugabyted",
       "start",
       "--listen=db-1",
       "--background=false",
       "--cloud_location=otlob.zone.a",
       "--fault_tolerance=zone",
       "--base_dir=/home/yugabyte/yb_data",
     ]
   ports:
     - "5433:5433"
     - "15433:15433"
     - "7000:7000"
     - "9000:9000"
   volumes:
     - ./data/db-1:/home/yugabyte/yb_data
   networks:
     - otlob-network

   healthcheck:
     test: ["CMD-SHELL", "yugabyted status && exit 0 || exit 1"]
     interval: 10s
     timeout: 5s
     retries: 5
     start_period: 20s

 db-2:
   image: yugabytedb/yugabyte:latest
   container_name: otlob-db-2
   command:
     [
       "bin/yugabyted",
       "start",
       "--listen=db-2",
       "--join=db-1",
       "--background=false",
       "--cloud_location=otlob.zone.b",
       "--fault_tolerance=zone",
       "--base_dir=/home/yugabyte/yb_data",
     ]
   ports:
     - "5434:5433"
     - "15434:15433"
   volumes:
     - ./data/db-2:/home/yugabyte/yb_data

   depends_on:
     db-1:
       condition: service_healthy
   networks:
     - otlob-network

 db-3:
   image: yugabytedb/yugabyte:latest
   container_name: otlob-db-3
   command:
     [
       "bin/yugabyted",
       "start",
       "--listen=db-3",
       "--join=db-1",
       "--background=false",
       "--cloud_location=otlob.zone.c",
       "--fault_tolerance=zone",
       "--base_dir=/home/yugabyte/yb_data",
     ]
   ports:
     - "5435:5433"
     - "15435:15433"
   volumes:
     - ./data/db-3:/home/yugabyte/yb_data
   networks:
     - otlob-network
   depends_on:
     db-1:
       condition: service_healthy
#Docker Networks
networks:
 otlob-network:
   driver: bridge

And when I try create database from nodejs, I get this error :
error: SELECT PG_ADVISORY_UNLOCK('1') as lock_status; - advisory locks feature is currently in preview

Are you using Prisma or Sequelize for connecting to YB? Can you pls send us the complete app log?

I’ve just tested the code mentioned here : nodejs with yugabytedb

Here’s the console log :

/home/bkf/Work/Otlob/node_modules/@yugabytedb/pg/lib/client.js:230
      throw new Error('Could not find a least loaded server.')
            ^

Error: Could not find a least loaded server.
    at Client.getLeastLoadedServer (/home/bkf/Work/Otlob/node_modules/@yugabytedb/pg/lib/client.js:230:13)
    at Client._connect (/home/bkf/Work/Otlob/node_modules/@yugabytedb/pg/lib/client.js:355:26)
    at /home/bkf/Work/Otlob/node_modules/@yugabytedb/pg/lib/client.js:711:12
    at new Promise (<anonymous>)
    at Client.nowConnect (/home/bkf/Work/Otlob/node_modules/@yugabytedb/pg/lib/client.js:710:12)
    at /home/bkf/Work/Otlob/node_modules/@yugabytedb/pg/lib/client.js:855:26
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)

And in my node app developed by AdonisJs,
I got this :

error: SELECT PG_ADVISORY_UNLOCK('1') as lock_status; - advisory locks feature is currently in preview
 

   ⁃ Parser.parseErrorMessage
     node_modules/pg-protocol/dist/parser.js:285
   ⁃ Parser.handlePacket
     node_modules/pg-protocol/dist/parser.js:122
   ⁃ Parser.parse
     node_modules/pg-protocol/dist/parser.js:35