<?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: Alvaro Nabangi</title>
    <description>The latest articles on DEV Community by Alvaro Nabangi (@nabangi).</description>
    <link>https://dev.to/nabangi</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%2F633969%2F81dad6c0-999d-42df-b52f-4eba309c7b87.jpg</url>
      <title>DEV Community: Alvaro Nabangi</title>
      <link>https://dev.to/nabangi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nabangi"/>
    <language>en</language>
    <item>
      <title>NetDevOps</title>
      <dc:creator>Alvaro Nabangi</dc:creator>
      <pubDate>Tue, 19 Jul 2022 20:51:44 +0000</pubDate>
      <link>https://dev.to/nabangi/netdevops-2ibp</link>
      <guid>https://dev.to/nabangi/netdevops-2ibp</guid>
      <description>&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--566lAguM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/nabangi"&gt;
        nabangi
      &lt;/a&gt; / &lt;a href="https://github.com/nabangi/NetDevOps"&gt;
        NetDevOps
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      SysAdmin | NetOps | Monitoring | Virtualization | Containers
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
NetDevOps | Bash | python | KVM&lt;/h1&gt;
&lt;h2&gt;
Infrastructure Automation &lt;br&gt;
&lt;/h2&gt;
&lt;h3&gt;
Linux Network Configuration Scripts &lt;br&gt;
&lt;/h3&gt;
&lt;h4&gt;
Network Monitoring and server Health related resources&lt;/h4&gt;
&lt;p&gt;&lt;code&gt;Troubleshooting&lt;/code&gt;&lt;/p&gt;
&lt;div class="snippet-clipboard-content notranslate position-relative overflow-auto"&gt;&lt;pre class="notranslate"&gt;&lt;code&gt;grep -i -E 'exception|unable|fail|invalid|leak|warn|error' &amp;lt;logfile&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;



&lt;/div&gt;
&lt;br&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/nabangi/NetDevOps"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;br&gt;


</description>
      <category>python</category>
      <category>linux</category>
      <category>opensource</category>
      <category>github</category>
    </item>
    <item>
      <title>MariaDB with Replication in Docker</title>
      <dc:creator>Alvaro Nabangi</dc:creator>
      <pubDate>Tue, 19 Jul 2022 20:46:00 +0000</pubDate>
      <link>https://dev.to/nabangi/mariadb-with-replication-in-docker-2oo</link>
      <guid>https://dev.to/nabangi/mariadb-with-replication-in-docker-2oo</guid>
      <description>&lt;p&gt;In this blog we are going to demonstrate how to replicate a MariaDB database that runs in a Docker container.&lt;/p&gt;

&lt;p&gt;Automatically deploy environment by;&lt;/p&gt;

&lt;p&gt;Running the deploy_config.sh after cloning this Repo &lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/nabangi" rel="noopener noreferrer"&gt;
        nabangi
      &lt;/a&gt; / &lt;a href="https://github.com/nabangi/MariaDB-in-Docker" rel="noopener noreferrer"&gt;
        MariaDB-in-Docker
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      SQL Database cluster deployment with Replication monitoring in Docker
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;MariaDB-in-Docker&lt;/h1&gt;
&lt;/div&gt;
&lt;p&gt;mariadb container master-slave replication with health Monitoring&lt;/p&gt;

&lt;div class="markdown-heading"&gt;
&lt;h3 class="heading-element"&gt;Automatically deploy environment by;&lt;/h3&gt;
&lt;/div&gt;

&lt;p&gt;Running the &lt;code&gt;deploy_config.sh&lt;/code&gt; after clonning the Repo to you Server.&lt;/p&gt;

&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Environment prep and manually deploy&lt;/h2&gt;
&lt;/div&gt;

&lt;div class="snippet-clipboard-content notranslate position-relative overflow-auto"&gt;&lt;pre class="notranslate"&gt;&lt;code&gt;sudo apt update
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h3 class="heading-element"&gt;Installing the Docker engine incase its not installed yet&lt;/h3&gt;

&lt;/div&gt;

&lt;div class="snippet-clipboard-content notranslate position-relative overflow-auto"&gt;&lt;pre class="notranslate"&gt;&lt;code&gt;sudo apt-get remove docker docker-engine docker.io

sudo apt install docker.io

sudo systemctl start docker

sudo systemctl enable docker
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h3 class="heading-element"&gt;logout then login again to enable user rights incase they don't apply immediately&lt;/h3&gt;

&lt;/div&gt;

&lt;div class="snippet-clipboard-content notranslate position-relative overflow-auto"&gt;&lt;pre class="notranslate"&gt;&lt;code&gt;sudo groupadd docker

sudo gpasswd -a "${USER}" docker

usermod -aG docker "${USER}"
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h3 class="heading-element"&gt;Create the database persistent volume to be mounted&lt;/h3&gt;

&lt;/div&gt;

&lt;div class="snippet-clipboard-content notranslate position-relative overflow-auto"&gt;&lt;pre class="notranslate"&gt;&lt;code&gt;mkdir -p /opt/mariadb/master-data
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h4 class="heading-element"&gt;Grant Permissions&lt;/h4&gt;

&lt;/div&gt;

&lt;div class="snippet-clipboard-content notranslate position-relative overflow-auto"&gt;&lt;pre class="notranslate"&gt;&lt;code&gt;sudo chown -R 1001:1001 /opt/mariadb/master-data/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Running containers in dettached mode but when you remove the "-d" it could help with debugging the running configs in the container!&lt;/p&gt;
&lt;div class="snippet-clipboard-content notranslate position-relative overflow-auto"&gt;&lt;pre class="notranslate"&gt;&lt;code&gt;docker run -d or docker-compose up -d 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h4 class="heading-element"&gt;To login to a container&lt;/h4&gt;

&lt;/div&gt;

&lt;div class="snippet-clipboard-content notranslate position-relative overflow-auto"&gt;&lt;pre class="notranslate"&gt;&lt;code&gt;docker exec -it $container_id bash
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;mariadb&lt;/h2&gt;

&lt;/div&gt;

&lt;div class="snippet-clipboard-content notranslate position-relative overflow-auto"&gt;&lt;pre class="notranslate"&gt;&lt;code&gt;$ mysql -u my_user -p
  #my_password
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h4 class="heading-element"&gt;after login check databases&lt;/h4&gt;…&lt;/div&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/nabangi/MariaDB-in-Docker" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
Environment prep and manually deploy&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

sudo apt update


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Installing the Docker engine incase its not installed yet&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

sudo apt-get remove docker docker-engine docker.io

sudo apt install docker.io

sudo systemctl start docker

sudo systemctl enable docker


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;logout then login again to enable user rights incase they don't apply immediately&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

sudo groupadd docker

sudo gpasswd -a "${USER}" docker

usermod -aG docker "${USER}"


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Create the database persistent volume to be mounted&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

mkdir -p /opt/mariadb/master-data


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Grant Permissions&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

sudo chown -R 1001:1001 /opt/mariadb/master-data/


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Running containers in dettached mode but when you remove the "-d" it could help with debugging the running configs in the container!&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

docker run -d or docker-compose up -d 


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;To login to a container&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

docker exec -it $container_id bash


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Mariadb&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

$ mysql -u my_user -p
  #my_password



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;after login check databases&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

show databases;
use my_databse;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;then create table form there&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

exit;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;check or configure replication&lt;/p&gt;

&lt;p&gt;login with root&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

$ mysql -u root -p
  #master_root_password


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;then&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

show master status;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;To import:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

docker exec -i adprcc3ms_mariadb-master_1 mysql -uroot -pmaster_root_password my_database &amp;lt; mariadb-master-dump.sql


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;To export:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

docker exec -i adprcc3ms_mariadb-master_1 mysqldump -uroot -pmaster_root_password my_database &amp;gt; mariadb-master-dump.sql



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Stop and backup the currently running container, Uncomment the following lines&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

docker stop $container_id


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

rsync -a /opt/mariadb/master-data /opt/mariadb/master-data.bkp.$(date +%Y%m%d-%H.%M.%S)


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;incase you want to scale up number of slaves or scale down&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

docker-compose up --detach --scale mariadb-master=1 --scale mariadb-slave=3


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;To clean up&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

docker stop $container_id

docker rm $container_id


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;You can also remove all images and stopped contaners using&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

docker prune -a


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Run the following to see if the cronjob you've defined actually runs.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

sudo grep CRON /var/log/syslog


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;VOILAA...!!!&lt;/p&gt;

</description>
      <category>sql</category>
      <category>docker</category>
      <category>tutorial</category>
      <category>bash</category>
    </item>
  </channel>
</rss>
