<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Shawn Sherwood</title>
    <description>The latest articles on DEV Community by Shawn Sherwood (@ssherwood).</description>
    <link>https://dev.to/ssherwood</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F796852%2F75e13523-b612-4ca9-a3e0-2b86deb41740.jpeg</url>
      <title>DEV Community: Shawn Sherwood</title>
      <link>https://dev.to/ssherwood</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ssherwood"/>
    <language>en</language>
    <item>
      <title>Getting Started with YugabyteDB and Docker</title>
      <dc:creator>Shawn Sherwood</dc:creator>
      <pubDate>Wed, 19 Jan 2022 23:18:24 +0000</pubDate>
      <link>https://dev.to/yugabyte/getting-started-with-yugabytedb-and-docker-5263</link>
      <guid>https://dev.to/yugabyte/getting-started-with-yugabytedb-and-docker-5263</guid>
      <description>&lt;p&gt;When developing modern applications, it is important to maintain &lt;a href="https://12factor.net/dev-prod-parity" rel="noopener noreferrer"&gt;dev/prod parity&lt;/a&gt; (that is, keep development, staging, and production as similar as possible).  This should also extend to the local development environment.  Containerization makes it easy to achieve consistency across all environments, even with more complicated components such as databases.&lt;/p&gt;

&lt;p&gt;YugabyteDB is a cloud-native, &lt;a href="https://blog.yugabyte.com/what-is-distributed-sql/" rel="noopener noreferrer"&gt;distributed SQL database&lt;/a&gt; that is also &lt;a href="https://blog.yugabyte.com/is-your-distributed-database-postgresql-compatible/" rel="noopener noreferrer"&gt;PostgreSQL compatible&lt;/a&gt;.  This interoperability makes it possible for developers to leverage existing tools, languages, and frameworks to quickly become productive with a modern distributed RDBMS.&lt;/p&gt;

&lt;p&gt;In this blog post, we’ll show you how to run YugabyteDB on your local machine with the convenience of a Docker container and not require manual installation.  It is useful to have a fully working database running locally to explore YugabyteDB features and for application development.&lt;/p&gt;

&lt;h2&gt;
  
  
  Download Options
&lt;/h2&gt;

&lt;p&gt;YugabyteDB can be &lt;a href="https://download.yugabyte.com/" rel="noopener noreferrer"&gt;downloaded and installed manually&lt;/a&gt;, but for many scenarios, it is easier to use an OCI compliant Docker container on Mac, Linux or the Windows Subsystem for Linux (WSL).&lt;/p&gt;

&lt;p&gt;As a convenience, this guide uses &lt;a href="https://podman.io/" rel="noopener noreferrer"&gt;podman&lt;/a&gt; as a replacement for the Docker CLI.  Podman has the distinct advantage of being a daemonless container engine that can run without requiring root privilege escalation.  It is still possible to use the Docker CLI with this guide by replacing the Podman command "podman" with "docker".&lt;/p&gt;

&lt;h3&gt;
  
  
  Downloading the YugabyteDB OCI Docker Image
&lt;/h3&gt;

&lt;p&gt;To review available YugabyteDB versions, use the "Filter Tags" feature on the DockerHub &lt;a href="https://hub.docker.com/r/yugabytedb/yugabyte/tags" rel="noopener noreferrer"&gt;tags&lt;/a&gt; page to find the specific version tag desired.  It is also possible to use the DockerHub API directly (if on Linux or Mac):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;curl &lt;span class="nt"&gt;-L&lt;/span&gt; &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s1"&gt;'https://registry.hub.docker.com/v2/repositories/yugabytedb/yugabyte/tags?page_size=5'&lt;/span&gt; | jq &lt;span class="s1"&gt;'."results"[]["name"]'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command fetches all the images tag metadata and limits the result to the first 5. If you don’t already have jq installed, please refer to the &lt;a href="https://stedolan.github.io/jq/download/" rel="noopener noreferrer"&gt;installation documentation&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In most cases, it is desirable to use a specific version of the database and not rely on the &lt;em&gt;latest&lt;/em&gt; tag.  For example, to download the 2.8.0 release use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;podman pull yugabytedb/yugabyte:2.8.0.0-b37
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;YugabyteDB stable releases use an even numbered minor version (e.g. 2.6, 2.8, etc.).  Odd numbered minor versions are considered more experimental.  Read more about &lt;a href="https://docs.yugabyte.com/latest/releases/versioning/" rel="noopener noreferrer"&gt;YugabyeDB Release Versioning&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Running the YugabyteDB Container
&lt;/h2&gt;

&lt;p&gt;Once the YugabteDB image is local, run it using this command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;podman run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;--name&lt;/span&gt; yugabyte-2.8.0 &lt;span class="nt"&gt;-p7000&lt;/span&gt;:7000 &lt;span class="nt"&gt;-p9000&lt;/span&gt;:9000 &lt;span class="nt"&gt;-p5433&lt;/span&gt;:5433 &lt;span class="nt"&gt;-p9042&lt;/span&gt;:9042 yugabytedb/yugabyte:2.8.0.0-b37 bin/yugabyted start &lt;span class="nt"&gt;--base_dir&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/home/yugabyte/yb_data &lt;span class="nt"&gt;--daemon&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;false&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Below is a breakdown of the options:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;-d&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The detach option runs the container as a background process and displays the container ID.  This option is needed to regain control of the shell since the yugabyted process is intended to be long-lived.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;--name yugabyte-2.8.0&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This option gives the container a user-friendly name that can be used later.  Adding the version to the name makes it easier to keep track of different versions of the database.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;-p7000:7000 -p9000:9000 -p5433:5433 -p9042:9042&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;These options expose internal ports to the host so they can be interacted with from outside the container.  These are YugabyteDB &lt;a href="https://docs.yugabyte.com/latest/reference/configuration/default-ports/" rel="noopener noreferrer"&gt;significant ports&lt;/a&gt; and will be discussed later. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;yugabytedb/yugabyte:2.8.0.0-b37&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This is the container image and version (tag) to run.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;bin/yugabyted start --base_dir=/home/yugabyte/yb_data --daemon=false&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This command starts &lt;a href="https://docs.yugabyte.com/latest/reference/configuration/yugabyted/" rel="noopener noreferrer"&gt;yugabyted&lt;/a&gt;, the parent process for YugabyteDB and passes additional options to set the base directory for the YugabyteDB data folder and directs the process to not run in the background (the default behavior which would cause the container to stop).&lt;/p&gt;

&lt;p&gt;It is important to note that YugabyteDB is a distributed SQL database and that the image used is only a single node deployment (i.e. a &lt;a href="https://docs.yugabyte.com/latest/architecture/docdb-replication/replication/#replication-factor" rel="noopener noreferrer"&gt;replication factor&lt;/a&gt; of 1).  This is not typical for a production environment which would usually be RF=3 or even RF=5.  Running a multi-node environment locally is possible but beyond the scope of this guide.&lt;/p&gt;

&lt;h2&gt;
  
  
  Testing the YugabyteDB Container
&lt;/h2&gt;

&lt;p&gt;Next, validate that the container process is running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;podman ps
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output should look like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbu5gqvq1l620vy7zdn7k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbu5gqvq1l620vy7zdn7k.png" alt="Bash shell with podman ps output" width="800" height="135"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If not, it likely errored due to a port conflict with another process.  Review any local running processes and ports, stopping anything that conflicts and try again.&lt;/p&gt;

&lt;p&gt;Next, exec a Bash session on the container:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;podman &lt;span class="nb"&gt;exec&lt;/span&gt; &lt;span class="nt"&gt;-it&lt;/span&gt; yugabyte-2.8.0 bash 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The default starting directory should be &lt;code&gt;/home/yugabyte&lt;/code&gt;.  This folder contains the YugabyteDB installation as well as the &lt;code&gt;yb_data&lt;/code&gt; directory (from the &lt;code&gt;--base_dir&lt;/code&gt; option).  This directory contains all the runtime data and logs from the YugabyteDB processes, specifically in three sub directories:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ ls -ls yb_data/
total 12
4 drwxr-xr-x 2 root root 4096 Nov 17 20:38 conf
4 drwxr-xr-x 4 root root 4096 Nov 17 20:39 data
4 drwxr-xr-x 2 root root 4096 Nov 17 20:30 logs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The conf directory contains the &lt;code&gt;yugabyted.conf&lt;/code&gt; file that can be used to customize the behavior of the system via various settings called &lt;a href="https://docs.yugabyte.com/latest/reference/configuration/yb-tserver/" rel="noopener noreferrer"&gt;"GFlags"&lt;/a&gt;.  This configuration file will be important later to enable YSQL logging.&lt;/p&gt;

&lt;p&gt;The data and logs directories respectively contain the database data files and process logs.  To view the current Postgres logs, use this command from the &lt;code&gt;yb_data&lt;/code&gt; directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;tail&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; &lt;span class="sb"&gt;`&lt;/span&gt;&lt;span class="nb"&gt;cat &lt;/span&gt;data/pg_data/current_logfiles | &lt;span class="nb"&gt;cut&lt;/span&gt; &lt;span class="nt"&gt;-c7-&lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Postgres process frequently rotates its log but the &lt;code&gt;current_logfiles&lt;/code&gt; file contains the name of the current one.  It is also possible to navigate directly to the log file under &lt;code&gt;/home/yugabyte/yb_data/data/yb-data/tserver/logs/&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Alternatively, it is possible to bind mount a volume into the container and map it to a local directory (e.g. &lt;code&gt;-v ~/yb_data:/home/yugabyte/yb_data&lt;/code&gt;).  This option can be added to the original command to run the container.  This option is useful if you want to use native desktop tools to edit or view the config or log files or reuse an existing database across multiple versions of the YugabyteDB container.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reviewing the YugabyteDB Admin UIs
&lt;/h2&gt;

&lt;p&gt;YugabyteDB is made up of several distinct processes including the &lt;a href="https://docs.yugabyte.com/latest/architecture/concepts/yb-master/" rel="noopener noreferrer"&gt;YB-Master&lt;/a&gt; and &lt;a href="https://docs.yugabyte.com/latest/architecture/concepts/yb-tserver/" rel="noopener noreferrer"&gt;YB-TServer&lt;/a&gt;.  Once started, these processes each have an administrative UI exposed at &lt;a href="http://localhost:7000" rel="noopener noreferrer"&gt;http://localhost:7000&lt;/a&gt; and &lt;a href="http://localhost:9000" rel="noopener noreferrer"&gt;http://localhost:9000&lt;/a&gt; respectively.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyt5epce9u0yp2h2fdhmp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyt5epce9u0yp2h2fdhmp.png" alt="YugabyteDB Admin UI" width="800" height="641"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;These views provide a comprehensive overview of the database that was just deployed.  Feel free to explore both servers, but now let’s focus on interacting with the database via command line interface.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using the Yugabyte YSQL Command
&lt;/h2&gt;

&lt;p&gt;From the Bash prompt, type &lt;code&gt;ysqlsh&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;root@05a7aef6fd68 yugabyte]# ysqlsh
ysqlsh &lt;span class="o"&gt;(&lt;/span&gt;11.2-YB-2.8.0.0-b0&lt;span class="o"&gt;)&lt;/span&gt;
Type &lt;span class="s2"&gt;"help"&lt;/span&gt; &lt;span class="k"&gt;for &lt;/span&gt;help.

&lt;span class="nv"&gt;yugabyte&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="c"&gt;#&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;ysqlsh&lt;/code&gt; command is similar to the Postgres psql command and most commands will be exactly the same.  This CLI will mainly be used to issue DDL statements to the database or experiment with query performance using the explain command.&lt;/p&gt;

&lt;p&gt;To quit &lt;code&gt;ysqlsh&lt;/code&gt;, type backslash q (e.g. &lt;code&gt;\q&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;Note, it is possible to execute the &lt;code&gt;ysqlsh&lt;/code&gt; command directly from podman and skip the Bash shell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;podman &lt;span class="nb"&gt;exec&lt;/span&gt; &lt;span class="nt"&gt;-it&lt;/span&gt; yugabyte-2.8.0 ysqlsh
ysqlsh &lt;span class="o"&gt;(&lt;/span&gt;11.2-YB-2.8.0.0-b0&lt;span class="o"&gt;)&lt;/span&gt;
Type &lt;span class="s2"&gt;"help"&lt;/span&gt; &lt;span class="k"&gt;for &lt;/span&gt;help.

&lt;span class="nv"&gt;yugabyte&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="c"&gt;#&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Using the Yugabyte YCQL Command
&lt;/h2&gt;

&lt;p&gt;From the container’s Bash prompt, type &lt;code&gt;ycqlsh&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;root@05a7aef6fd68 yugabyte]# ycqlsh
Connected to &lt;span class="nb"&gt;local &lt;/span&gt;cluster at 127.0.0.1:9042.
&lt;span class="o"&gt;[&lt;/span&gt;ycqlsh 5.0.1 | Cassandra 3.9-SNAPSHOT | CQL spec 3.4.2 | Native protocol v4]
Use HELP &lt;span class="k"&gt;for &lt;/span&gt;help.
ycqlsh&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;a href="https://docs.yugabyte.com/latest/admin/ycqlsh/" rel="noopener noreferrer"&gt;ycqlsh&lt;/a&gt; command is equivalent to &lt;code&gt;cqlsh&lt;/code&gt; from which it is derived.&lt;/p&gt;

&lt;h2&gt;
  
  
  Enable YSQL Logging
&lt;/h2&gt;

&lt;p&gt;To enable the YSQL Postgres query logging, edit the &lt;code&gt;yugabyted.conf&lt;/code&gt; file (using vi) and add the &lt;code&gt;ysql_log_statement=all&lt;/code&gt; GFlag.  Editing config files may be unusual for immutable containers, but it is useful for debugging in development.&lt;/p&gt;

&lt;p&gt;Go to the &lt;code&gt;/home/yugabyte/yb_data/conf&lt;/code&gt; directory and open the &lt;code&gt;yugabyted.conf&lt;/code&gt; file, it should look something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"tserver_webserver_port"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;9000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"master_rpc_port"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;7100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"universe_uuid"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"099c3df0-011b-47c5-83e3-4a1e286986bb"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"webserver_port"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;7200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"ysql_enable_auth"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"ycql_port"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;9042&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"data_dir"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"/home/yugabyte/yb_data/data"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"tserver_uuid"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"767e00774ade4e9f90728eaf6fb3a13e"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"use_cassandra_authentication"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"log_dir"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"/home/yugabyte/yb_data/logs"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"polling_interval"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"5"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"listen"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"0.0.0.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"callhome"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"master_webserver_port"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;7000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"master_uuid"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"587434752fc74cba85ea27fea81164bd"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"master_flags"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"node_uuid"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"1be46681-4047-4278-b6c4-040ff1f5897c"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"join"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"ysql_port"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;5433&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"tserver_flags"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"tserver_rpc_port"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;9100&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This configuration file can be edited to modify the behavior of YugabyteDB as well as the YB-Master and YB-TServer process individually.&lt;/p&gt;

&lt;p&gt;Add the log parameter to the &lt;code&gt;tsever_flags&lt;/code&gt; as shown:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"tserver_flags": "ysql_log_statement=all"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This parameter accepts &lt;code&gt;none&lt;/code&gt; (default), &lt;code&gt;ddl&lt;/code&gt;, or &lt;code&gt;all&lt;/code&gt;.  With the value set to &lt;code&gt;all&lt;/code&gt;, the Postgres logs will contain every SQL statement that is executed by the database.  This is particularly helpful when using a higher level database abstraction (e.g. ORM) that generates SQL statements or manages transactional elements in an application.&lt;/p&gt;

&lt;p&gt;Once modified, the configuration change won’t take place without exiting and restarting the container.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;podman restart yugabyte-2.8.0 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After the restart, execute another Bash command on the image:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;podman &lt;span class="nb"&gt;exec&lt;/span&gt; &lt;span class="nt"&gt;-it&lt;/span&gt; yugabyte-2.8.0 bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then &lt;code&gt;tail&lt;/code&gt; the logs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;tail&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; &lt;span class="sb"&gt;`&lt;/span&gt;&lt;span class="nb"&gt;cat &lt;/span&gt;yb_data/data/pg_data/current_logfiles | &lt;span class="nb"&gt;cut&lt;/span&gt; &lt;span class="nt"&gt;-c7-&lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use any program that can connect to the database and execute a few SQL commands, the statements should start showing up in the logs (e.g.):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2021-11-01 17:58:26.591 UTC [50477] LOG:  statement: select 1;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  How-to: Connect with a Data Tool
&lt;/h2&gt;

&lt;p&gt;If you have a favorite DB client like DBeaver or DataGrip, you can establish a connection to the database now using the exposed ports (just remember that 5433 is the default for the YSQL / Postgres interface).&lt;/p&gt;

&lt;h3&gt;
  
  
  Using DBeaver
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://dbeaver.io/" rel="noopener noreferrer"&gt;DBeaver (Community Edition)&lt;/a&gt; is a free database tool that can be used with Yugabyte YSQL (for YCQL consider using &lt;a href="https://www.tableplus.io/" rel="noopener noreferrer"&gt;TablePlus&lt;/a&gt;).  Once DBeaver is installed, select the "New Database Connection" option and in the filter field, type "yuga" and it will filter out the other database drivers.&lt;/p&gt;

&lt;p&gt;Select the "YugabyteDB" tile and click Next.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiojret4sbcxgrmt5calc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiojret4sbcxgrmt5calc.png" alt="DBeaver UI" width="800" height="732"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The default settings will set localhost and port &lt;code&gt;5433&lt;/code&gt; correctly.  No other configuration changes are required.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fef6396etg16tyk9zzts9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fef6396etg16tyk9zzts9.png" alt="DBeaver UI" width="800" height="732"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click "Test Connection..." to validate the connection as configured.  A message should appear that displays relevant information about the connection.  If it connects successfully, select "Finish".&lt;/p&gt;

&lt;p&gt;In DBeaver, it is advisable to rename the connection to be relevant to the use case (e.g. "yugabyte-ysql-local").&lt;/p&gt;

&lt;h3&gt;
  
  
  Using IntelliJ
&lt;/h3&gt;

&lt;p&gt;Both the commercial version of &lt;a href="https://www.jetbrains.com/idea/" rel="noopener noreferrer"&gt;IntelliJ&lt;/a&gt; and the stand-alone product &lt;a href="https://www.jetbrains.com/datagrip/" rel="noopener noreferrer"&gt;DataGrip&lt;/a&gt; can be used to connect to YugabyteDB.&lt;/p&gt;

&lt;p&gt;Open the Database tab and select "New" &amp;gt; "Datasource". &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsm7vcwemf92m72ti0ldr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsm7vcwemf92m72ti0ldr.png" alt="IntelliJ UI" width="518" height="288"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Pick the PostgreSQL driver.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7ahjjt2yryfj7q6p0y0q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7ahjjt2yryfj7q6p0y0q.png" alt="IntelliJ UI" width="800" height="494"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Feel free to name the datasource appropriately to the use case and change the Port to &lt;code&gt;5433&lt;/code&gt;, User and Database to &lt;code&gt;yugabyte&lt;/code&gt;.  Use the "Test Connection" to validate the configuration and then Okay. &lt;/p&gt;

&lt;p&gt;If this error appears:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ERROR: System column with id -3 is not supported yet.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Edit the configuration and go to the Advanced tab.  Check the "Other: Introspect with JDBC metadata" option and click Apply and then refresh.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvfdaen0rzwak57e3kohf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvfdaen0rzwak57e3kohf.png" alt="IntelliJ UI" width="800" height="494"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;This should be enough information to get started using YugabyteDB locally in a Docker container.&lt;/p&gt;

&lt;p&gt;Using YugabyteDB locally can help streamline all phases of the application development process and help ensure dev/prod parity.  It is also a great way to experiment with new versions and features as they become available.&lt;/p&gt;

</description>
      <category>yugabytedb</category>
      <category>docker</category>
    </item>
  </channel>
</rss>
