<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>devops &#8211; abdulrahmanuk.com</title>
	<atom:link href="https://www.abdulrahmanuk.com/tag/devops/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.abdulrahmanuk.com</link>
	<description>All about Cloud and DevOps</description>
	<lastBuildDate>Mon, 23 Jun 2025 08:07:31 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://www.abdulrahmanuk.com/wp-content/uploads/2023/02/icons8-devops-60.png</url>
	<title>devops &#8211; abdulrahmanuk.com</title>
	<link>https://www.abdulrahmanuk.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>AKS Cluster Setup Using Azure CLI with OIDC &#038; Azure Key Vault Integration</title>
		<link>https://www.abdulrahmanuk.com/aks-cluster-setup-using-azure-cli-with-oidc-azure-key-vault-integration/</link>
					<comments>https://www.abdulrahmanuk.com/aks-cluster-setup-using-azure-cli-with-oidc-azure-key-vault-integration/#respond</comments>
		
		<dc:creator><![CDATA[Abdul Rahman UK]]></dc:creator>
		<pubDate>Mon, 23 Jun 2025 01:36:03 +0000</pubDate>
				<category><![CDATA[Azure]]></category>
		<category><![CDATA[Kubernetes]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[devops]]></category>
		<guid isPermaLink="false">https://www.abdulrahmanuk.com/?p=574</guid>

					<description><![CDATA[<p>If you&#8217;re more comfortable using the Azure CLI, here&#8217;s how to set up an AKS cluster with Azure Key Vault integration using the Secrets Store CSI Driver, along with OIDC (OpenID Connect) support and Workload Identity. This is especially useful for secure, production-grade Kubernetes deployments. ✅ Step 1: Create an Azure Resource Group This creates [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.abdulrahmanuk.com/aks-cluster-setup-using-azure-cli-with-oidc-azure-key-vault-integration/">AKS Cluster Setup Using Azure CLI with OIDC &amp; Azure Key Vault Integration</a> appeared first on <a rel="nofollow" href="https://www.abdulrahmanuk.com">abdulrahmanuk.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>If you&#8217;re more comfortable using the <strong>Azure CLI</strong>, here&#8217;s how to set up an <strong>AKS cluster with Azure Key Vault integration</strong> using the <strong>Secrets Store CSI Driver</strong>, along with <strong>OIDC (OpenID Connect) support</strong> and <strong>Workload Identity</strong>. This is especially useful for secure, production-grade Kubernetes deployments.</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h3 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Step 1: Create an Azure Resource Group</h3>



<pre class="wp-block-code"><code><code>az group create --name keyvault-demo --location eastus
</code></code></pre>



<p>This creates a logical container for your AKS resources.</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h3 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f680.png" alt="🚀" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Step 2: Create the AKS Cluster with Workload Identity and Azure Key Vault Integration</h3>



<pre class="wp-block-code"><code><code>az aks create \
  --name keyvault-demo-cluster \
  --resource-group keyvault-demo \
  --node-count 1 \
  --enable-addons azure-keyvault-secrets-provider \
  --enable-oidc-issuer \
  --enable-workload-identity
</code></code></pre>



<h4 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2699.png" alt="⚙" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Explanation of Flags:</h4>



<ul class="wp-block-list">
<li><code>--enable-addons azure-keyvault-secrets-provider</code>: Installs the CSI driver and Azure Key Vault provider addon.</li>



<li><code>--enable-oidc-issuer</code>: Enables the OIDC issuer URL for secure authentication with federated identity.</li>



<li><code>--enable-workload-identity</code>: Activates Azure Workload Identity (replacement for AAD Pod Identity).</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h3 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f510.png" alt="🔐" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Step 3: Get AKS Credentials for kubectl</h3>



<pre class="wp-block-code"><code><code>az aks get-credentials \
  --resource-group keyvault-demo \
  --name keyvault-demo-cluster
</code></code></pre>



<p>This updates your local kubeconfig so you can interact with the new cluster.</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h3 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f50d.png" alt="🔍" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Step 4: Verify CSI Driver and Azure Provider Pods</h3>



<p>Make sure everything is running correctly:</p>



<pre class="wp-block-code"><code><code>kubectl get pods -n kube-system -l 'app in (secrets-store-csi-driver,secrets-store-provider-azure)' -o wide
</code></code></pre>



<p>You should see pods like:</p>



<ul class="wp-block-list">
<li><code>secrets-store-csi-driver-*</code></li>



<li><code>secrets-store-provider-azure-*</code></li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f510.png" alt="🔐" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Bonus: Why Use Azure Key Vault with AKS?</h2>



<ul class="wp-block-list">
<li><strong>Centralized Secrets Management</strong></li>



<li><strong>Automatic Secret Rotation</strong></li>



<li><strong>No Secret Mounting in Code</strong></li>



<li><strong>Secure Identity Binding with Workload Identity</strong></li>
</ul>



<p>This setup is cloud-native, secure, and production-ready.</p>
<p>The post <a rel="nofollow" href="https://www.abdulrahmanuk.com/aks-cluster-setup-using-azure-cli-with-oidc-azure-key-vault-integration/">AKS Cluster Setup Using Azure CLI with OIDC &amp; Azure Key Vault Integration</a> appeared first on <a rel="nofollow" href="https://www.abdulrahmanuk.com">abdulrahmanuk.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.abdulrahmanuk.com/aks-cluster-setup-using-azure-cli-with-oidc-azure-key-vault-integration/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to Create an AKS Cluster Using PowerShell in Azure Portal</title>
		<link>https://www.abdulrahmanuk.com/how-to-create-an-aks-cluster-using-powershell-in-azure-portal/</link>
					<comments>https://www.abdulrahmanuk.com/how-to-create-an-aks-cluster-using-powershell-in-azure-portal/#respond</comments>
		
		<dc:creator><![CDATA[Abdul Rahman UK]]></dc:creator>
		<pubDate>Mon, 23 Jun 2025 01:20:54 +0000</pubDate>
				<category><![CDATA[Azure]]></category>
		<category><![CDATA[devops]]></category>
		<category><![CDATA[Kubernetes]]></category>
		<category><![CDATA[Powershell]]></category>
		<guid isPermaLink="false">https://www.abdulrahmanuk.com/?p=566</guid>

					<description><![CDATA[<p>In today’s DevOps-driven world, Kubernetes has become the cornerstone of modern cloud-native applications. Microsoft Azure provides a fully managed Kubernetes service called Azure Kubernetes Service (AKS), which helps you focus on deploying and managing containerized applications without worrying about the underlying infrastructure. In this guide, we’ll walk you through how to create an AKS cluster [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.abdulrahmanuk.com/how-to-create-an-aks-cluster-using-powershell-in-azure-portal/">How to Create an AKS Cluster Using PowerShell in Azure Portal</a> appeared first on <a rel="nofollow" href="https://www.abdulrahmanuk.com">abdulrahmanuk.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>In today’s DevOps-driven world, Kubernetes has become the cornerstone of modern cloud-native applications. Microsoft Azure provides a fully managed Kubernetes service called <strong>Azure Kubernetes Service (AKS)</strong>, which helps you focus on deploying and managing containerized applications without worrying about the underlying infrastructure.</p>



<p>In this guide, we’ll walk you through <strong>how to create an AKS cluster using PowerShell directly from the Azure Cloud Shell or your local PowerShell session</strong>. Whether you’re getting started or automating cluster provisioning, this tutorial will provide a clear, step-by-step approach.</p>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="1858" height="994" src="https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-2.png" alt="image 2" class="wp-image-568" title="How to Create an AKS Cluster Using PowerShell in Azure Portal 1" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-2.png 1858w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-2-768x411.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-2-1536x822.png 1536w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-2-150x80.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-2-300x160.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-2-696x372.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-2-1068x571.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/06/image-2-600x321.png 600w" sizes="(max-width: 1858px) 100vw, 1858px" /></figure>



<h3 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Prerequisites</h3>



<p>Before we begin, make sure you have the following:</p>



<ul class="wp-block-list">
<li>An active <a class="" href="https://portal.azure.com/" rel="nofollow noopener" target="_blank">Azure subscription</a></li>



<li>Azure PowerShell installed locally <strong>or</strong> use <a class="" href="https://shell.azure.com/" rel="nofollow noopener" target="_blank">Azure Cloud Shell</a></li>



<li>Azure CLI is optional but recommended for verification</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f527.png" alt="🔧" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Step 1: Log in to the Azure Account</h2>



<p>Open PowerShell and log in to your Azure account.</p>



<pre class="wp-block-code"><code><code>Connect-AzAccount
</code></code></pre>



<p>This command opens a sign-in window or browser-based prompt to authenticate your account.</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4c1.png" alt="📁" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Step 2: Set Your Subscription (If You Have Multiple)</h2>



<pre class="wp-block-code"><code><code>Get-AzSubscription
Set-AzContext -SubscriptionId "your-subscription-id"
</code></code></pre>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f3d7.png" alt="🏗" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Step 3: Create a Resource Group</h2>



<p>A resource group is a container that holds related resources for an Azure solution.</p>



<pre class="wp-block-code"><code><code>$resourceGroup = "AKS-ResourceGroup"
$location = "EastUS"

New-AzResourceGroup -Name $resourceGroup -Location $location
</code></code></pre>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f6e1.png" alt="🛡" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Step 4: Create an Azure AD Service Principal (Optional but recommended)</h2>



<p>This account will be used by AKS to interact with Azure resources.</p>



<pre class="wp-block-code"><code><code>$sp = New-AzADServicePrincipal -DisplayName "AKSServicePrincipal"
$spPassword = (New-AzADSpCredential -ServicePrincipalObjectId $sp.Id).SecretText
</code></code></pre>



<p>Store the AppId and Password for later use.</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f680.png" alt="🚀" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Step 5: Create the AKS Cluster</h2>



<pre class="wp-block-code"><code><code>$aksName = "MyAKSCluster"

New-AzAksCluster `
  -ResourceGroupName $resourceGroup `
  -Name $aksName `
  -KubernetesVersion "1.29.2" `
  -NodeCount 3 `
  -NodeVmSize "Standard_DS2_v2" `
  -GenerateSshKey `
  -Location $location `
  -EnableRBAC
</code></code></pre>



<p><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4a1.png" alt="💡" class="wp-smiley" style="height: 1em; max-height: 1em;" /> You can specify additional parameters such as <code>-ServicePrincipalId</code>, <code>-ClientSecret</code>, or <code>-NetworkPlugin azure</code> For more custom setups.</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f50d.png" alt="🔍" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Step 6: Verify the Cluster</h2>



<p>After creation, verify the AKS cluster status:</p>



<pre class="wp-block-code"><code><code>Get-AzAksCluster -ResourceGroupName $resourceGroup -Name $aksName
</code></code></pre>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4e6.png" alt="📦" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Step 7: Connect to the AKS Cluster Using <code>kubectl</code></h2>



<p>First, install <code>kubectl</code> if you haven&#8217;t already:</p>



<pre class="wp-block-code"><code><code>az aks install-cli
</code></code></pre>



<p>Then, get credentials:</p>



<pre class="wp-block-code"><code><code>az aks get-credentials --resource-group $resourceGroup --name $aksName
</code></code></pre>



<p>Verify connection:</p>



<pre class="wp-block-code"><code><code>kubectl get nodes
</code></code></pre>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Wrapping Up</h2>



<p>You’ve successfully created an <strong>AKS Cluster using PowerShell</strong> on Microsoft Azure! This process is ideal for automating infrastructure deployment.</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f3af.png" alt="🎯" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Bonus Tips</h2>



<ul class="wp-block-list">
<li>Use Azure Bicep or Terraform for infrastructure-as-code.</li>



<li>Integrate Azure Key Vault and Managed Identity for secure secrets management.</li>



<li>Enable monitoring with Azure Monitor and Log Analytics for production workloads.</li>
</ul>
<p>The post <a rel="nofollow" href="https://www.abdulrahmanuk.com/how-to-create-an-aks-cluster-using-powershell-in-azure-portal/">How to Create an AKS Cluster Using PowerShell in Azure Portal</a> appeared first on <a rel="nofollow" href="https://www.abdulrahmanuk.com">abdulrahmanuk.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.abdulrahmanuk.com/how-to-create-an-aks-cluster-using-powershell-in-azure-portal/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Kubernetes Resource Limits Simplified – From Beginner to Production Ready</title>
		<link>https://www.abdulrahmanuk.com/kubernetes-resource-limits-simplified-from-beginner-to-production-ready/</link>
					<comments>https://www.abdulrahmanuk.com/kubernetes-resource-limits-simplified-from-beginner-to-production-ready/#respond</comments>
		
		<dc:creator><![CDATA[Abdul Rahman UK]]></dc:creator>
		<pubDate>Sun, 15 Jun 2025 13:08:20 +0000</pubDate>
				<category><![CDATA[Kubernetes]]></category>
		<category><![CDATA[devops]]></category>
		<guid isPermaLink="false">https://www.abdulrahmanuk.com/?p=545</guid>

					<description><![CDATA[<p>In the world of Kubernetes, managing resources wisely is key to keeping your cluster healthy and your workloads running smoothly. Without proper controls, one application can easily consume more than its fair share of CPU, memory, or pods, leading to resource contention and system instability. Thankfully, Kubernetes provides powerful tools to enforce resource limits at [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.abdulrahmanuk.com/kubernetes-resource-limits-simplified-from-beginner-to-production-ready/">Kubernetes Resource Limits Simplified – From Beginner to Production Ready</a> appeared first on <a rel="nofollow" href="https://www.abdulrahmanuk.com">abdulrahmanuk.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>In the world of <strong>Kubernetes</strong>, managing resources wisely is key to keeping your cluster healthy and your workloads running smoothly. Without proper controls, one application can easily consume more than its fair share of CPU, memory, or pods, leading to resource contention and system instability.</p>



<p>Thankfully, Kubernetes provides powerful tools to enforce <strong>resource limits at the namespace level</strong>, allowing teams to share the cluster fairly. In this blog post, we’ll explore two important tools for namespace-level resource management:</p>



<ul class="wp-block-list">
<li><strong>Resource Quotas</strong></li>



<li><strong>Limit Ranges</strong></li>
</ul>



<p>Let’s dive in and see how they work, with practical examples to help you get started.</p>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f539.png" alt="🔹" class="wp-smiley" style="height: 1em; max-height: 1em;" /> What Are Resource Quotas in Kubernetes?</h2>



<p><strong>Resource Quotas</strong> let administrators cap the total amount of resources that a specific namespace can use. Think of it as setting a budget for pods, CPU, memory, and other compute resources.</p>



<h3 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4cc.png" alt="📌" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Why Use Resource Quotas?</h3>



<ul class="wp-block-list">
<li>Define clear usage boundaries per namespace.</li>



<li>Monitor and track resource usage in real-time.</li>



<li>Automatically block workloads that try to exceed their limits.</li>
</ul>



<h3 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f6e0.png" alt="🛠" class="wp-smiley" style="height: 1em; max-height: 1em;" /> How to Set a Resource Quota</h3>



<p>To apply a Resource Quota, create a YAML file and apply it to the relevant namespace.</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><textarea class="code-block-pro-copy-button-textarea" aria-hidden="true" readonly>apiVersion: v1
kind: ResourceQuota
metadata:
  name: resource-quota-example
  namespace: example-namespace
spec:
  hard:
    pods: &#8220;1&#8221;
    requests.cpu: &#8220;2&#8221;
    requests.memory: &#8220;5Gi&#8221;
    limits.cpu: &#8220;4&#8221;
    limits.memory: &#8220;10Gi&#8221;</textarea><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">apiVersion: v</span><span style="color: #5DE4C7">1</span></span>
<span class="line"><span style="color: #A6ACCD">kind: ResourceQuota</span></span>
<span class="line"><span style="color: #A6ACCD">metadata:</span></span>
<span class="line"><span style="color: #A6ACCD">  name: resource-quota-example</span></span>
<span class="line"><span style="color: #A6ACCD">  namespace: example-namespace</span></span>
<span class="line"><span style="color: #A6ACCD">spec:</span></span>
<span class="line"><span style="color: #A6ACCD">  hard:</span></span>
<span class="line"><span style="color: #A6ACCD">    pods: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">1</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">    requests.cpu: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">2</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">    requests.memory: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">5Gi</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">    limits.cpu: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">4</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">    limits.memory: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">10Gi</span><span style="color: #A6ACCD">&quot;</span></span></code></pre></div>



<p>Then apply it using:</p>



<pre class="wp-block-code"><code>kubectl apply -f resource-quota.yaml</code></pre>



<p><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4a1.png" alt="💡" class="wp-smiley" style="height: 1em; max-height: 1em;" /> This will limit the <code>example-namespace</code> to <strong>1 pod</strong>, <strong>2 CPU requests</strong>, <strong>5Gi of memory requests</strong>, and caps CPU and memory usage at <strong>4 CPUs</strong> and <strong>10Gi</strong>, respectively.</p>



<h3 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Verifying the Resource Quota</h3>



<p>Check if the quota has been successfully applied:</p>



<pre class="wp-block-code"><code>kubectl get resourcequota resource-quota-example -n example-namespace</code></pre>



<p>Or to get detailed info:</p>



<pre class="wp-block-code"><code>kubectl describe ns example-namespace</code></pre>



<p>Sample output:</p>



<pre class="wp-block-preformatted">Resource         Used  Hard<br>limits.cpu       0     4<br>limits.memory    0     10Gi<br>pods             0     1<br>requests.cpu     0     2<br>requests.memory  0     5Gi</pre>



<h3 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f50d.png" alt="🔍" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Testing Quota Enforcement</h3>



<p>Let’s try deploying more pods than allowed to see the quota in action.</p>



<p><strong>Deployment with 2 replicas (but the quota allows only 1):</strong></p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><textarea class="code-block-pro-copy-button-textarea" aria-hidden="true" readonly>apiVersion: apps/v1
kind: Deployment
metadata:
  name: quota-test
  namespace: example-namespace
  labels:
    app: deployment-label
spec:
  replicas: 2
  selector:
    matchLabels:
      app: deployment-label
  template:
    metadata:
      labels:
        app: deployment-label
    spec:
      containers:
      &#8211; name: nginx-deploy
        image: nginx:latest
        resources:
          requests:
            cpu: 100m
            memory: 100Mi
          limits:
            cpu: 100m
            memory: 100Mi</textarea><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">apiVersion: apps/v</span><span style="color: #5DE4C7">1</span></span>
<span class="line"><span style="color: #A6ACCD">kind: Deployment</span></span>
<span class="line"><span style="color: #A6ACCD">metadata:</span></span>
<span class="line"><span style="color: #A6ACCD">  name: quota-test</span></span>
<span class="line"><span style="color: #A6ACCD">  namespace: example-namespace</span></span>
<span class="line"><span style="color: #A6ACCD">  labels:</span></span>
<span class="line"><span style="color: #A6ACCD">    app: deployment-label</span></span>
<span class="line"><span style="color: #A6ACCD">spec:</span></span>
<span class="line"><span style="color: #A6ACCD">  replicas: </span><span style="color: #5DE4C7">2</span></span>
<span class="line"><span style="color: #A6ACCD">  selector:</span></span>
<span class="line"><span style="color: #A6ACCD">    matchLabels:</span></span>
<span class="line"><span style="color: #A6ACCD">      app: deployment-label</span></span>
<span class="line"><span style="color: #A6ACCD">  template:</span></span>
<span class="line"><span style="color: #A6ACCD">    metadata:</span></span>
<span class="line"><span style="color: #A6ACCD">      labels:</span></span>
<span class="line"><span style="color: #A6ACCD">        app: deployment-label</span></span>
<span class="line"><span style="color: #A6ACCD">    spec:</span></span>
<span class="line"><span style="color: #A6ACCD">      containers:</span></span>
<span class="line"><span style="color: #A6ACCD">      - name: nginx-deploy</span></span>
<span class="line"><span style="color: #A6ACCD">        image: nginx:latest</span></span>
<span class="line"><span style="color: #A6ACCD">        resources:</span></span>
<span class="line"><span style="color: #A6ACCD">          requests:</span></span>
<span class="line"><span style="color: #A6ACCD">            cpu: </span><span style="color: #5DE4C7">100</span><span style="color: #A6ACCD">m</span></span>
<span class="line"><span style="color: #A6ACCD">            memory: </span><span style="color: #5DE4C7">100</span><span style="color: #A6ACCD">Mi</span></span>
<span class="line"><span style="color: #A6ACCD">          limits:</span></span>
<span class="line"><span style="color: #A6ACCD">            cpu: </span><span style="color: #5DE4C7">100</span><span style="color: #A6ACCD">m</span></span>
<span class="line"><span style="color: #A6ACCD">            memory: </span><span style="color: #5DE4C7">100</span><span style="color: #A6ACCD">Mi</span></span></code></pre></div>



<p>Apply the deployment:</p>



<pre class="wp-block-preformatted">kubectl apply -f deploy.yaml<br></pre>



<p>Check the pod status:</p>



<pre class="wp-block-preformatted">kubectl get all -n example-namespace<br></pre>



<p>ou’ll see something like:</p>



<pre class="wp-block-preformatted">Warning  FailedCreate  pods "quota-test-xxxx" is forbidden: exceeded quota: resource-quota-example...</pre>



<p>The second pod fails to start—<strong>exactly what we want</strong>. The quota is working as intended!</p>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f539.png" alt="🔹" class="wp-smiley" style="height: 1em; max-height: 1em;" /> What Are Limit Ranges in Kubernetes?</h2>



<p>While Resource Quotas set overall namespace limits, <strong>Limit Ranges</strong> control the <strong>default and maximum/minimum resource limits for each pod, container, or PVC</strong>. This ensures no single pod or container hogs cluster resources.</p>



<h3 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4cc.png" alt="📌" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Why Use Limit Ranges?</h3>



<ul class="wp-block-list">
<li>Enforce consistent resource consumption across deployments.</li>



<li>Prevent resource abuse by setting sensible defaults.</li>



<li>Ensure all pods have a minimum allocation for healthy operation.</li>
</ul>



<h3 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f6e0.png" alt="🛠" class="wp-smiley" style="height: 1em; max-height: 1em;" /> How to Set a Limit Range</h3>



<p>Create a <code>limit-range.yaml</code> file:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><textarea class="code-block-pro-copy-button-textarea" aria-hidden="true" readonly>apiVersion: v1
kind: LimitRange
metadata:
  name: limit-range-example
  namespace: example-namespace
spec:
  limits:
  &#8211; type: Pod
    max:
      cpu: &#8220;2&#8221;
      memory: &#8220;4Gi&#8221;
    min:
      cpu: &#8220;200m&#8221;
      memory: &#8220;256Mi&#8221;
    maxLimitRequestRatio:
      cpu: &#8220;4&#8221;
      memory: &#8220;8&#8221;
  &#8211; type: Container
    default:
      cpu: &#8220;500m&#8221;
      memory: &#8220;512Mi&#8221;
    defaultRequest:
      cpu: &#8220;250m&#8221;
      memory: &#8220;256Mi&#8221;
    max:
      cpu: &#8220;1&#8221;
      memory: &#8220;1Gi&#8221;
    min:
      cpu: &#8220;100m&#8221;
      memory: &#8220;128Mi&#8221;
    maxLimitRequestRatio:
      cpu: &#8220;2&#8221;
      memory: &#8220;4&#8221;
  &#8211; type: PersistentVolumeClaim
    max:
      storage: &#8220;10Gi&#8221;
    min:
      storage: &#8220;1Gi&#8221;
    default:
      storage: &#8220;5Gi&#8221;
    defaultRequest:
      storage: &#8220;2Gi&#8221;
    maxLimitRequestRatio:
      storage: &#8220;2&#8221;</textarea><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">apiVersion: v</span><span style="color: #5DE4C7">1</span></span>
<span class="line"><span style="color: #A6ACCD">kind: LimitRange</span></span>
<span class="line"><span style="color: #A6ACCD">metadata:</span></span>
<span class="line"><span style="color: #A6ACCD">  name: limit-range-example</span></span>
<span class="line"><span style="color: #A6ACCD">  namespace: example-namespace</span></span>
<span class="line"><span style="color: #A6ACCD">spec:</span></span>
<span class="line"><span style="color: #A6ACCD">  limits:</span></span>
<span class="line"><span style="color: #A6ACCD">  - type: Pod</span></span>
<span class="line"><span style="color: #A6ACCD">    max:</span></span>
<span class="line"><span style="color: #A6ACCD">      cpu: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">2</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">      memory: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">4Gi</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">    min:</span></span>
<span class="line"><span style="color: #A6ACCD">      cpu: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">200m</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">      memory: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">256Mi</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">    maxLimitRequestRatio:</span></span>
<span class="line"><span style="color: #A6ACCD">      cpu: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">4</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">      memory: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">8</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">  - type: Container</span></span>
<span class="line"><span style="color: #A6ACCD">    default:</span></span>
<span class="line"><span style="color: #A6ACCD">      cpu: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">500m</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">      memory: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">512Mi</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">    defaultRequest:</span></span>
<span class="line"><span style="color: #A6ACCD">      cpu: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">250m</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">      memory: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">256Mi</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">    max:</span></span>
<span class="line"><span style="color: #A6ACCD">      cpu: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">1</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">      memory: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">1Gi</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">    min:</span></span>
<span class="line"><span style="color: #A6ACCD">      cpu: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">100m</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">      memory: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">128Mi</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">    maxLimitRequestRatio:</span></span>
<span class="line"><span style="color: #A6ACCD">      cpu: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">2</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">      memory: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">4</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">  - type: PersistentVolumeClaim</span></span>
<span class="line"><span style="color: #A6ACCD">    max:</span></span>
<span class="line"><span style="color: #A6ACCD">      storage: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">10Gi</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">    min:</span></span>
<span class="line"><span style="color: #A6ACCD">      storage: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">1Gi</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">    default:</span></span>
<span class="line"><span style="color: #A6ACCD">      storage: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">5Gi</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">    defaultRequest:</span></span>
<span class="line"><span style="color: #A6ACCD">      storage: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">2Gi</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">    maxLimitRequestRatio:</span></span>
<span class="line"><span style="color: #A6ACCD">      storage: </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">2</span><span style="color: #A6ACCD">&quot;</span></span></code></pre></div>



<p>Apply it:</p>



<pre class="wp-block-preformatted"><code>kubectl apply -f limit-range.yaml<br></code></pre>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f9e0.png" alt="🧠" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Limit Ranges apply defaults <em>automatically</em> to pods if you forget to specify them!</p>
</blockquote>



<h3 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Verifying the Limit Range</h3>



<p>Use the following commands:</p>



<pre class="wp-block-preformatted">kubectl describe limitrange limit-range-example -n example-namespace<br>kubectl describe ns example-namespace</pre>



<p>You’ll see something like:</p>



<pre class="wp-block-preformatted">Type                   Resource  Min    Max   Default Request  Default Limit  Max Limit/Request Ratio<br>Pod                    cpu       200m   2     -                -              4<br>Pod                    memory    256Mi  4Gi   -                -              8<br>Container              cpu       100m   1     250m             500m           2<br>Container              memory    128Mi  1Gi   256Mi            512Mi          4<br>PersistentVolumeClaim  storage   1Gi    10Gi  2Gi              5Gi            2</pre>



<h3 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f50d.png" alt="🔍" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Testing the Limit Range in Action</h3>



<p>Create a deployment <strong>without resource specs</strong> and watch the defaults kick in:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><textarea class="code-block-pro-copy-button-textarea" aria-hidden="true" readonly>apiVersion: apps/v1
kind: Deployment
metadata:
  name: limit-test
  namespace: example-namespace
  labels:
    app: deployment-label
spec:
  replicas: 1
  selector:
    matchLabels:
      app: deployment-label
  template:
    metadata:
      labels:
        app: deployment-label
    spec:
      containers:
      &#8211; name: nginx-deploy
        image: nginx:latest</textarea><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">apiVersion: apps/v</span><span style="color: #5DE4C7">1</span></span>
<span class="line"><span style="color: #A6ACCD">kind: Deployment</span></span>
<span class="line"><span style="color: #A6ACCD">metadata:</span></span>
<span class="line"><span style="color: #A6ACCD">  name: limit-test</span></span>
<span class="line"><span style="color: #A6ACCD">  namespace: example-namespace</span></span>
<span class="line"><span style="color: #A6ACCD">  labels:</span></span>
<span class="line"><span style="color: #A6ACCD">    app: deployment-label</span></span>
<span class="line"><span style="color: #A6ACCD">spec:</span></span>
<span class="line"><span style="color: #A6ACCD">  replicas: </span><span style="color: #5DE4C7">1</span></span>
<span class="line"><span style="color: #A6ACCD">  selector:</span></span>
<span class="line"><span style="color: #A6ACCD">    matchLabels:</span></span>
<span class="line"><span style="color: #A6ACCD">      app: deployment-label</span></span>
<span class="line"><span style="color: #A6ACCD">  template:</span></span>
<span class="line"><span style="color: #A6ACCD">    metadata:</span></span>
<span class="line"><span style="color: #A6ACCD">      labels:</span></span>
<span class="line"><span style="color: #A6ACCD">        app: deployment-label</span></span>
<span class="line"><span style="color: #A6ACCD">    spec:</span></span>
<span class="line"><span style="color: #A6ACCD">      containers:</span></span>
<span class="line"><span style="color: #A6ACCD">      - name: nginx-deploy</span></span>
<span class="line"><span style="color: #A6ACCD">        image: nginx:latest</span></span></code></pre></div>



<p>Apply it:</p>



<pre class="wp-block-preformatted"><code>kubectl apply -f deploy.yaml<br></code></pre>



<p>Now describe the pod and you&#8217;ll notice the resource requests and limits are automatically applied based on the LimitRange!</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f9e9.png" alt="🧩" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Final Thoughts</h2>



<p><strong>Namespace-level resource control</strong> in Kubernetes is not just a best practice—it’s a necessity for scalable and stable clusters.</p>



<p><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Use <strong>Resource Quotas</strong> to enforce overall limits per namespace.<br><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Use <strong>Limit Ranges</strong> to set smart defaults and enforce per-container or per-pod limits.</p>



<p>By combining both, you ensure fair resource distribution, avoid noisy neighbor problems, and maintain consistent workload performance across your Kubernetes environment.</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<p><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4ac.png" alt="💬" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Got questions about resource management in Kubernetes?<br><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4e9.png" alt="📩" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Drop a comment below or connect with me for more DevOps tips and Kubernetes best practices.</p>



<p>Happy Clustering! <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f680.png" alt="🚀" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>



<p></p>
<p>The post <a rel="nofollow" href="https://www.abdulrahmanuk.com/kubernetes-resource-limits-simplified-from-beginner-to-production-ready/">Kubernetes Resource Limits Simplified – From Beginner to Production Ready</a> appeared first on <a rel="nofollow" href="https://www.abdulrahmanuk.com">abdulrahmanuk.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.abdulrahmanuk.com/kubernetes-resource-limits-simplified-from-beginner-to-production-ready/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Creating a Highly Available MySQL InnoDB Cluster</title>
		<link>https://www.abdulrahmanuk.com/creating-a-highly-available-mysql-innodb-cluster/</link>
					<comments>https://www.abdulrahmanuk.com/creating-a-highly-available-mysql-innodb-cluster/#comments</comments>
		
		<dc:creator><![CDATA[Abdul Rahman UK]]></dc:creator>
		<pubDate>Thu, 17 Apr 2025 22:31:28 +0000</pubDate>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[devops]]></category>
		<guid isPermaLink="false">https://www.abdulrahmanuk.com/?p=517</guid>

					<description><![CDATA[<p>Setting up a highly available MySQL InnoDB Cluster with MySQL Router, group replication, automatic failover, and point-in-time recovery can be complex, but I’ll break everything down into step-by-step instructions with explanations, suitable for beginners. This guide summarizes my real-world setup journey for a production-ready MySQL cluster with a dedicated MySQL Router VM, backups, and failover [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.abdulrahmanuk.com/creating-a-highly-available-mysql-innodb-cluster/">Creating a Highly Available MySQL InnoDB Cluster</a> appeared first on <a rel="nofollow" href="https://www.abdulrahmanuk.com">abdulrahmanuk.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Setting up a <strong>highly available MySQL InnoDB Cluster</strong> with <strong>MySQL Router</strong>, <strong>group replication</strong>, <strong>automatic failover</strong>, and <strong>point-in-time recovery</strong> can be complex, but I’ll break everything down into <strong>step-by-step instructions with explanations</strong>, suitable for beginners. This guide summarizes my real-world setup journey for a production-ready MySQL cluster with a dedicated MySQL Router VM, backups, and failover handling.</p>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f9f1.png" alt="🧱" class="wp-smiley" style="height: 1em; max-height: 1em;" /> MySQL InnoDB Cluster Architecture</h2>



<ol class="wp-block-list">
<li><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f9e0.png" alt="🧠" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <strong>3 MySQL Nodes</strong>: 1 primary (writer) + 2 secondaries (readers)</li>



<li><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f501.png" alt="🔁" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <strong>Group Replication</strong> for HA</li>



<li><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f6aa.png" alt="🚪" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <strong>MySQL Router</strong> (deployed on a separate VM for better failover control)</li>



<li><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f6e1.png" alt="🛡" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <strong>Backups</strong> (dump + binary logs) for PITR</li>
</ol>



<p><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <strong>Pre-requisites</strong><br>Ubuntu VMs (each with at least 2 vCPUs and 4GB RAM recommended)<br>All VMs must be reachable via an internal network.<br>MySQL port (3306) and Group Replication ports (33061, 33062) must be open.</p>



<p>I had created 3 VMs on Azure Cloud to create the MySQL Cluster architecture</p>



<figure class="wp-block-image size-full"><img decoding="async" width="2560" height="1213" src="https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-9-scaled.png" alt="image 9 scaled" class="wp-image-527" title="Creating a Highly Available MySQL InnoDB Cluster 2" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-9-scaled.png 2560w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-9-768x364.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-9-1536x728.png 1536w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-9-2048x971.png 2048w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-9-150x71.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-9-300x142.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-9-696x330.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-9-1068x506.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-9-1920x910.png 1920w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-9-600x284.png 600w" sizes="(max-width: 2560px) 100vw, 2560px" /></figure>



<h5 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Step 1: Install MySQL on All Nodes</h5>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="sudo apt update &amp;&amp; sudo apt install mysql-server net-tools -y
wget https://repo.mysql.com//mysql-apt-config_0.8.34-1_all.deb
sudo dpkg -i mysql-apt-config_0.8.34-1_all.deb
sudo apt update &amp;&amp; sudo apt install mysql-shell -y
" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">sudo apt update &amp;&amp; sudo apt install mysql-server net-tools -y</span></span>
<span class="line"><span style="color: #A6ACCD">wget https:</span><span style="color: #767C9DB0; font-style: italic">//repo.mysql.com//mysql-apt-config_0.8.34-1_all.deb</span></span>
<span class="line"><span style="color: #A6ACCD">sudo dpkg -i mysql-apt-config_</span><span style="color: #5DE4C7">0.8</span><span style="color: #A6ACCD">.</span><span style="color: #5DE4C7">34-1</span><span style="color: #A6ACCD">_all.deb</span></span>
<span class="line"><span style="color: #A6ACCD">sudo apt update &amp;&amp; sudo apt install mysql-shell -y</span></span>
<span class="line"></span></code></pre></div>



<p>Check that MySQL is running and listening on 3306 on each node (especially node01):</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="sudo netstat -tulnp | grep 3306" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">sudo netstat -tulnp | grep </span><span style="color: #5DE4C7">3306</span></span></code></pre></div>



<pre class="wp-block-code"><code>#You should see something like:
**tcp &nbsp; 0&nbsp; 0 0.0.0.0:3306 &nbsp; 0.0.0.0:* &nbsp; LISTEN &nbsp; 1234/mysqld**</code></pre>



<pre class="wp-block-code"><code>If it only shows 127.0.0.1:3306, then MySQL is **not listening on external IPs**.
&#x1f449; **To fix that:**
Edit your mysqld.cnf (location: /etc/mysql/mysql.conf.d/mysqld.cnf):

**bind-address = 0.0.0.0**</code></pre>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
# Set bind-address to:
bind-address = 0.0.0.0
" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf</span></span>
<span class="line"><span style="color: #A6ACCD"># Set bind-address to:</span></span>
<span class="line"><span style="color: #A6ACCD">bind-address = </span><span style="color: #5DE4C7">0.0</span><span style="color: #A6ACCD">.</span><span style="color: #5DE4C7">0.0</span></span>
<span class="line"></span></code></pre></div>



<p>Then restart:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="sudo systemctl restart mysql" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">sudo systemctl restart mysql</span></span></code></pre></div>



<h5 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2699.png" alt="⚙" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Step 2: Configure Each MySQL Node</h5>



<p>Create a config file <code>/etc/mysql/mysql.conf.d/group_replication.cnf</code> on each node.<br><strong>Example (for node01):</strong></p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="[mysqld]
# Server identity (must be unique for each node)
server-id=1  # node01 = 1, node02 = 2, node03 = 3 (change accordingly)

# Enable binary logging
log_bin = mysql-bin
binlog_format = ROW
binlog_checksum = NONE
transaction_write_set_extraction = XXHASH64

# Enable GTID
gtid_mode = ON
enforce_gtid_consistency = ON

# Group Replication settings
loose-group_replication_group_name=&quot;aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee&quot;
loose-group_replication_start_on_boot=off
loose-group_replication_bootstrap_group=off
loose-group_replication_local_address=&quot;node01:33061&quot;  # Change per node
loose-group_replication_group_seeds=&quot;node01:33061,node02:33061,node03:33061&quot;
loose-group_replication_single_primary_mode=ON
loose-group_replication_enforce_update_everywhere_checks=OFF

# Networking
report_host=node01  # change for each node
bind-address=0.0.0.0
mysqlx-bind-address=0.0.0.0

# InnoDB settings
innodb_flush_log_at_trx_commit = 1
sync_binlog = 1
" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">[</span><span style="color: #D0679D">mysqld</span><span style="color: #A6ACCD">]</span></span>
<span class="line"><span style="color: #A6ACCD"># Server identity (must be unique for each node)</span></span>
<span class="line"><span style="color: #A6ACCD">server-id=</span><span style="color: #5DE4C7">1</span><span style="color: #A6ACCD">  # node</span><span style="color: #5DE4C7">01</span><span style="color: #A6ACCD"> = </span><span style="color: #5DE4C7">1</span><span style="color: #A6ACCD">, node</span><span style="color: #5DE4C7">02</span><span style="color: #A6ACCD"> = </span><span style="color: #5DE4C7">2</span><span style="color: #A6ACCD">, node</span><span style="color: #5DE4C7">03</span><span style="color: #A6ACCD"> = </span><span style="color: #5DE4C7">3</span><span style="color: #A6ACCD"> (change accordingly)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A6ACCD"># Enable binary logging</span></span>
<span class="line"><span style="color: #A6ACCD">log_bin = mysql-bin</span></span>
<span class="line"><span style="color: #A6ACCD">binlog_format = ROW</span></span>
<span class="line"><span style="color: #A6ACCD">binlog_checksum = NONE</span></span>
<span class="line"><span style="color: #A6ACCD">transaction_write_set_extraction = XXHASH</span><span style="color: #5DE4C7">64</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A6ACCD"># Enable GTID</span></span>
<span class="line"><span style="color: #A6ACCD">gtid_mode = ON</span></span>
<span class="line"><span style="color: #A6ACCD">enforce_gtid_consistency = ON</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A6ACCD"># Group Replication settings</span></span>
<span class="line"><span style="color: #A6ACCD">loose-group_replication_group_name=</span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">loose-group_replication_start_on_boot=off</span></span>
<span class="line"><span style="color: #A6ACCD">loose-group_replication_bootstrap_group=off</span></span>
<span class="line"><span style="color: #A6ACCD">loose-group_replication_local_address=</span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">node01:33061</span><span style="color: #A6ACCD">&quot;</span><span style="color: #A6ACCD">  # Change per node</span></span>
<span class="line"><span style="color: #A6ACCD">loose-group_replication_group_seeds=</span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">node01:33061,node02:33061,node03:33061</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">loose-group_replication_single_primary_mode=ON</span></span>
<span class="line"><span style="color: #A6ACCD">loose-group_replication_enforce_update_everywhere_checks=OFF</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A6ACCD"># Networking</span></span>
<span class="line"><span style="color: #A6ACCD">report_host=node</span><span style="color: #5DE4C7">01</span><span style="color: #A6ACCD">  # change for each node</span></span>
<span class="line"><span style="color: #A6ACCD">bind-address=</span><span style="color: #5DE4C7">0.0</span><span style="color: #A6ACCD">.</span><span style="color: #5DE4C7">0.0</span></span>
<span class="line"><span style="color: #A6ACCD">mysqlx-bind-address=</span><span style="color: #5DE4C7">0.0</span><span style="color: #A6ACCD">.</span><span style="color: #5DE4C7">0.0</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A6ACCD"># InnoDB settings</span></span>
<span class="line"><span style="color: #A6ACCD">innodb_flush_log_at_trx_commit = </span><span style="color: #5DE4C7">1</span></span>
<span class="line"><span style="color: #A6ACCD">sync_binlog = </span><span style="color: #5DE4C7">1</span></span>
<span class="line"></span></code></pre></div>



<p>Make sure each node has a <strong>unique <code>server-id</code></strong> and correct <code>report_host</code>.</p>



<h5 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f464.png" alt="👤" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Step 3: Create a Cluster Admin User</h5>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="CREATE USER 'clusteradmin'@'%' IDENTIFIED BY 'StrongPass!123';
GRANT ALL PRIVILEGES ON *.* TO 'clusteradmin'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">CREATE USER &#39;clusteradmin&#39;@&#39;%&#39; IDENTIFIED BY &#39;StrongPass!</span><span style="color: #5DE4C7">123</span><span style="color: #A6ACCD">&#39;;</span></span>
<span class="line"><span style="color: #A6ACCD">GRANT ALL PRIVILEGES ON *.* TO &#39;clusteradmin&#39;@&#39;%&#39; WITH GRANT OPTION;</span></span>
<span class="line"><span style="color: #A6ACCD">FLUSH PRIVILEGES;</span></span></code></pre></div>



<h5 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f310.png" alt="🌐" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Step 4: Configure InnoDB Cluster</h5>



<p>On <strong>node01</strong>, use MySQL Shell:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="mysqlsh --uri clusteradmin@localhost" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">mysqlsh --uri clusteradmin@localhost</span></span></code></pre></div>



<p>Please enter clusteradmin password &#8220;StrongPass!123&#8221; once it pops up on your terminal</p>



<figure class="wp-block-image size-full"><img decoding="async" width="2068" height="588" src="https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image.png" alt="image" class="wp-image-518" title="Creating a Highly Available MySQL InnoDB Cluster 3" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image.png 2068w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-768x218.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-1536x437.png 1536w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-2048x582.png 2048w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-150x43.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-300x85.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-696x198.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-1068x304.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-1920x546.png 1920w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-600x171.png 600w" sizes="(max-width: 2068px) 100vw, 2068px" /></figure>



<p>Then: Run the following command one by one on node01 </p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="dba.configureInstance('clusteradmin@node01')
dba.configureInstance('clusteradmin@node02')
dba.configureInstance('clusteradmin@node03')" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">dba.configureInstance(&#39;clusteradmin@node</span><span style="color: #5DE4C7">01</span><span style="color: #A6ACCD">&#39;)</span></span>
<span class="line"><span style="color: #A6ACCD">dba.configureInstance(&#39;clusteradmin@node</span><span style="color: #5DE4C7">02</span><span style="color: #A6ACCD">&#39;)</span></span>
<span class="line"><span style="color: #A6ACCD">dba.configureInstance(&#39;clusteradmin@node</span><span style="color: #5DE4C7">03</span><span style="color: #A6ACCD">&#39;)</span></span></code></pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="2276" height="720" src="https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-1.png" alt="image 1" class="wp-image-519" title="Creating a Highly Available MySQL InnoDB Cluster 4" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-1.png 2276w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-1-768x243.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-1-1536x486.png 1536w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-1-2048x648.png 2048w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-1-150x47.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-1-300x95.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-1-696x220.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-1-1068x338.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-1-1920x607.png 1920w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-1-600x190.png 600w" sizes="auto, (max-width: 2276px) 100vw, 2276px" /></figure>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="2196" height="1698" src="https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-2.png" alt="image 2" class="wp-image-520" title="Creating a Highly Available MySQL InnoDB Cluster 5" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-2.png 2196w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-2-768x594.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-2-1536x1188.png 1536w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-2-2048x1584.png 2048w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-2-150x116.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-2-300x232.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-2-696x538.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-2-1068x826.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-2-1920x1485.png 1920w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-2-600x464.png 600w" sizes="auto, (max-width: 2196px) 100vw, 2196px" /></figure>



<p>After once you have completed above command, then run following command on node01</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="var cluster = dba.createCluster('wordpressCluster')
cluster.addInstance('clusteradmin@node02')
cluster.addInstance('clusteradmin@node03')" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">var cluster = dba.createCluster(&#39;wordpressCluster&#39;)</span></span>
<span class="line"><span style="color: #A6ACCD">cluster.addInstance(&#39;clusteradmin@node</span><span style="color: #5DE4C7">02</span><span style="color: #A6ACCD">&#39;)</span></span>
<span class="line"><span style="color: #A6ACCD">cluster.addInstance(&#39;clusteradmin@node</span><span style="color: #5DE4C7">03</span><span style="color: #A6ACCD">&#39;)</span></span></code></pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="2260" height="634" src="https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-3.png" alt="image 3" class="wp-image-521" title="Creating a Highly Available MySQL InnoDB Cluster 6" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-3.png 2260w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-3-768x215.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-3-1536x431.png 1536w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-3-2048x575.png 2048w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-3-150x42.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-3-300x84.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-3-696x195.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-3-1068x300.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-3-1920x539.png 1920w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-3-600x168.png 600w" sizes="auto, (max-width: 2260px) 100vw, 2260px" /></figure>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="2560" height="1519" src="https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-5-scaled.png" alt="image 5 scaled" class="wp-image-523" title="Creating a Highly Available MySQL InnoDB Cluster 7" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-5-scaled.png 2560w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-5-768x456.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-5-1536x911.png 1536w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-5-2048x1215.png 2048w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-5-150x89.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-5-300x178.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-5-696x413.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-5-1068x634.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-5-1920x1139.png 1920w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-5-600x356.png 600w" sizes="auto, (max-width: 2560px) 100vw, 2560px" /></figure>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="2560" height="1491" src="https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-6-scaled.png" alt="image 6 scaled" class="wp-image-524" title="Creating a Highly Available MySQL InnoDB Cluster 8" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-6-scaled.png 2560w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-6-768x447.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-6-1536x895.png 1536w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-6-2048x1193.png 2048w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-6-150x87.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-6-300x175.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-6-696x405.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-6-1068x622.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-6-1920x1118.png 1920w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-6-600x350.png 600w" sizes="auto, (max-width: 2560px) 100vw, 2560px" /></figure>



<p>Finally, you can check the cluster status.  </p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="cluster.status()" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">cluster.status()</span></span></code></pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1732" height="1596" src="https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-7.png" alt="image 7" class="wp-image-525" title="Creating a Highly Available MySQL InnoDB Cluster 9" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-7.png 1732w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-7-768x708.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-7-1536x1415.png 1536w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-7-150x138.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-7-300x276.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-7-696x641.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-7-1068x984.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-7-600x553.png 600w" sizes="auto, (max-width: 1732px) 100vw, 1732px" /></figure>



<p><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> At this point, the cluster is formed, and MySQL group replication is working.<br><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <strong>Success!</strong> You now have a functional InnoDB Cluster <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f389.png" alt="🎉" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>



<h5 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <strong>Step 5: Setup <code>mysqldump</code> Cron Job for Daily Backups</strong></h5>



<p>Create a script <code>/usr/local/bin/mysql_backup.sh</code>:<br>You can mount a volume to this directory <strong>/mnt/mysql_backup.</strong> This way, you can make sure your backup will be safe if the server has any issues.</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="#!/bin/bash
DATE=$(date +%F_%H-%M)
mysqldump -u root --all-databases &gt; /mnt/mysql_backup/db_backup_$DATE.sql" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">#!/bin/bash</span></span>
<span class="line"><span style="color: #A6ACCD">DATE=$(date +%F_%H-%M)</span></span>
<span class="line"><span style="color: #A6ACCD">mysqldump -u root --all-databases &gt; /mnt/mysql_backup/db_backup_$DATE.sql</span></span></code></pre></div>



<p>Make it executable:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="chmod +x /usr/local/bin/mysql_backup.sh" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">chmod +x /usr/local/bin/mysql_backup.sh</span></span></code></pre></div>



<p>Add a cron job:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="crontab -e

0 2 * * * /usr/local/bin/mysql_backup.sh" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">crontab -e</span></span>
<span class="line"></span>
<span class="line"><span style="color: #5DE4C7">0</span><span style="color: #A6ACCD"> </span><span style="color: #5DE4C7">2</span><span style="color: #A6ACCD"> * * * /usr/local/bin/mysql_backup.sh</span></span></code></pre></div>



<p>This runs daily at 2 AM.</p>



<h5 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <strong>Step 6: Backup Binary Logs Every Minute</strong></h5>



<p>Use <code>mysqlbinlog</code> to extract binlog content every minute:<br>Create <code>/usr/local/bin/binlog_backup.sh</code>:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="#!/bin/bash
DATE=$(date +%F_%H-%M)
BINLOG_PATH=&quot;/mnt/mysql_binlog&quot;
DEST_PATH=&quot;/mnt/mysql_backup/binlogs&quot;
mkdir -p &quot;$DEST_PATH&quot;
cp $BINLOG_PATH/mysql-bin.* &quot;$DEST_PATH/binlog_$DATE&quot;" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">#!/bin/bash</span></span>
<span class="line"><span style="color: #A6ACCD">DATE=$(date +%F_%H-%M)</span></span>
<span class="line"><span style="color: #A6ACCD">BINLOG_PATH=</span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">/mnt/mysql_binlog</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">DEST_PATH=</span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">/mnt/mysql_backup/binlogs</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">mkdir -p </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">$DEST_PATH</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">cp $BINLOG_PATH/mysql-bin.* </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">$DEST_PATH/binlog_$DATE</span><span style="color: #A6ACCD">&quot;</span></span></code></pre></div>



<p>Add to crontab:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="* * * * * /usr/local/bin/binlog_backup.sh" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">* * * * * /usr/local/bin/binlog_backup.sh</span></span></code></pre></div>



<p>This ensures you can do <strong>point-in-time recovery</strong> using full dump + binlogs.</p>



<h3 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <strong>Important Concepts to Know </strong></h3>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th>Concept</th><th>Description</th></tr></thead><tbody><tr><td><strong>InnoDB Cluster</strong></td><td>A high-availability solution using Group Replication and MySQL Shell</td></tr><tr><td><strong>Group Replication</strong></td><td>Ensures all nodes are in sync using GTID-based replication</td></tr><tr><td><strong>MySQL Router</strong></td><td>Middle layer that routes read/write traffic to correct nodes</td></tr><tr><td><strong>Single Primary Mode</strong></td><td>Only one node accepts writes; automatic failover is supported</td></tr><tr><td><strong>Backup Strategy</strong></td><td><code>mysqldump</code> for full backups, <code>mysqlbinlog</code> for PITR</td></tr><tr><td><strong>GTID</strong></td><td>Global Transaction IDs used to track transactions in replication</td></tr><tr><td><strong>Failover</strong></td><td>If primary fails, a new primary is elected from secondaries</td></tr></tbody></table></figure>



<p><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f501.png" alt="🔁" class="wp-smiley" style="height: 1em; max-height: 1em;" /> MySQL Router – On a Dedicated VM<br>For better <strong>failover and load balancing</strong>, deploy MySQL Router separately:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="sudo apt install mysql-router -y
mysqlrouter --bootstrap clusteradmin@node01:3306 --directory /etc/mysqlrouter
sudo systemctl start mysqlrouter" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">sudo apt install mysql-router -y</span></span>
<span class="line"><span style="color: #A6ACCD">mysqlrouter --bootstrap clusteradmin@node</span><span style="color: #5DE4C7">01</span><span style="color: #A6ACCD">:</span><span style="color: #5DE4C7">3306</span><span style="color: #A6ACCD"> --directory /etc/mysqlrouter</span></span>
<span class="line"><span style="color: #A6ACCD">sudo systemctl start mysqlrouter</span></span></code></pre></div>



<p>It ensures connections always route to the right node. <strong>no manual switching needed</strong> <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f504.png" alt="🔄" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f9ea.png" alt="🧪" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Failover Test</h2>



<p>Try stopping MySQL on node01:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="sudo systemctl stop mysql" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">sudo systemctl stop mysql</span></span></code></pre></div>



<p>Once you stop MySQL services, to see the failover, you have to connect to the MySQL shell. For that, follow the commands below </p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="mysqlsh --uri clusteradmin@localhost

var cluster = dba.getCluster('wordpressCluster')

cluster.status()" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">mysqlsh --uri clusteradmin@localhost</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A6ACCD">var cluster = dba.getCluster(&#39;wordpressCluster&#39;)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A6ACCD">cluster.status()</span></span></code></pre></div>



<div style="height:10px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1906" height="1532" src="https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-8.png" alt="image 8" class="wp-image-526" title="Creating a Highly Available MySQL InnoDB Cluster 10" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-8.png 1906w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-8-768x617.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-8-1536x1235.png 1536w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-8-150x121.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-8-300x241.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-8-696x559.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-8-1068x858.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2025/04/image-8-600x482.png 600w" sizes="auto, (max-width: 1906px) 100vw, 1906px" /></figure>



<h3 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f51a.png" alt="🔚" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <strong>Wrapping Up</strong></h3>



<p>Setting up a MySQL InnoDB Cluster <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f6e0.png" alt="🛠" class="wp-smiley" style="height: 1em; max-height: 1em;" /> isn&#8217;t just about replication. It&#8217;s about building a resilient, production-ready database architecture with automatic failover, dedicated routing, and reliable backups. With 3 MySQL nodes, a separate MySQL Router VM, binary logs, and regular dumps, you&#8217;re all set for high availability and peace of mind. <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f680.png" alt="🚀" class="wp-smiley" style="height: 1em; max-height: 1em;" /><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4be.png" alt="💾" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p>The post <a rel="nofollow" href="https://www.abdulrahmanuk.com/creating-a-highly-available-mysql-innodb-cluster/">Creating a Highly Available MySQL InnoDB Cluster</a> appeared first on <a rel="nofollow" href="https://www.abdulrahmanuk.com">abdulrahmanuk.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.abdulrahmanuk.com/creating-a-highly-available-mysql-innodb-cluster/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Day 8 Task &#8211; Basics Of Git &#038; GitHub</title>
		<link>https://www.abdulrahmanuk.com/day-8-task-basics-of-git-github/</link>
		
		<dc:creator><![CDATA[Abdul Rahman UK]]></dc:creator>
		<pubDate>Sat, 03 Jun 2023 04:52:41 +0000</pubDate>
				<category><![CDATA[DevOps]]></category>
		<category><![CDATA[devops]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[github]]></category>
		<guid isPermaLink="false">https://www.abdulrahmanuk.com/?p=394</guid>

					<description><![CDATA[<p>#90DaysOfDevopsChallenge If you are working in Software Industry must hear about the two-term &#8220;Git and GitHub&#8221; but before jumping into git first, you have to understand what version control is and what issue the software industry was facing before git. What is Version Control System? A version control system is software that tracks changes to a [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.abdulrahmanuk.com/day-8-task-basics-of-git-github/">Day 8 Task &#8211; Basics Of Git &#038; GitHub</a> appeared first on <a rel="nofollow" href="https://www.abdulrahmanuk.com">abdulrahmanuk.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p><strong>#90DaysOfDevopsChallenge</strong></p>



<p>If you are working in Software Industry must hear about the two-term &#8220;<strong>Git and</strong> <strong>GitHub</strong>&#8221; but before jumping into git first, you have to understand what version control is and what issue the software industry was facing before git.</p>



<h3 class="wp-block-heading" id="heading-what-is-version-control-system"><strong><mark>What is Version Control System?</mark></strong></h3>



<p>A version control system is software that tracks changes to a file or set of files over time so that you can recall specific versions later. It also allows you to work together with other programmers.</p>



<p>The version control system is a collection of software tools that help a team to manage changes in a source code. It uses a special kind of database to keep track of every modification to the code.</p>



<p>Developers can compare earlier versions of the code with an older version to fix the mistakes.</p>



<h3 class="wp-block-heading" id="heading-benefits"><strong><mark>Benefits</mark></strong></h3>



<ul class="wp-block-list">
<li>Enhances the project development speed by providing efficient collaboration.</li>



<li>Reduce possibilities of errors and conflicts meanwhile project development through traceability to every small change.</li>



<li>Employees or contributors of the project can contribute from anywhere irrespective of the different geographical locations through this&nbsp;<strong>VCS</strong></li>



<li>For each different contributor to the project, a different working copy is maintained and not merged to the main file unless the working copy is validated.</li>



<li>Informs us about Who, What, When, and Why changes have been made.</li>



<li>Helps in recovery in case of any disaster situation</li>
</ul>



<h3 class="wp-block-heading" id="heading-types-of-vcs"><strong><mark>Types of VCS</mark></strong></h3>



<p>1. Centralized Version Control Systems</p>



<p>2. Distributed Version Control Systems</p>



<h3 class="wp-block-heading" id="heading-benefits"><strong><mark>Centralized Version Control Systems :</mark></strong></h3>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1508" height="968" src="https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-6.png" alt="image 6" class="wp-image-395" title="Day 8 Task - Basics Of Git &amp; GitHub 11" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-6.png 1508w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-6-768x493.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-6-150x96.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-6-300x193.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-6-696x447.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-6-1068x686.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-6-600x385.png 600w" sizes="auto, (max-width: 1508px) 100vw, 1508px" /></figure>



<h4 class="wp-block-heading" id="heading-benefits">Centralized version control systems contain just one repository globally and every user needs to commit for reflecting one’s changes in the repository. Others can see your changes by updating.<a href="https://tanaya.hashnode.dev/basics-of-git-github-day-8-task#heading-benefits" rel="nofollow noopener" target="_blank"></a></h4>



<h3 class="wp-block-heading" id="heading-cvcs-has-some-drawbacks-and-the-problem-was"><strong><mark>CVCS has some drawbacks and the problem was,</mark></strong></h3>



<p>a) It is not locally available, meaning you always need to be connected to a network to perform any actions.</p>



<p>b) Since everything is centralized, if Central Server gets failed, you will lose the entire data.</p>



<p>Central Repository or Central Server means,it is a kind of storage or folder in a remote server, where you or anyone can keep your code and can see that code or can access it.</p>



<h3 class="wp-block-heading" id="heading-distributed-version-control-systems"><strong><mark>Distributed Version Control Systems</mark></strong><br><a href="https://tanaya.hashnode.dev/basics-of-git-github-day-8-task#heading-distributed-version-control-systems" rel="nofollow noopener" target="_blank"></a></h3>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1504" height="1066" src="https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-7.png" alt="image 7" class="wp-image-396" title="Day 8 Task - Basics Of Git &amp; GitHub 12" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-7.png 1504w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-7-768x544.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-7-150x106.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-7-300x213.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-7-696x493.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-7-1068x757.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-7-600x425.png 600w" sizes="auto, (max-width: 1504px) 100vw, 1504px" /></figure>



<ol class="wp-block-list">
<li>In a DVCS, every developer has a full copy of the repository, including the entire history of all changes. This makes it easier for developers to work together, as they don&#8217;t have to constantly communicate with a central server to commit their changes or to see the changes made by others.</li>



<li>Because developers have a local copy of the repository, they can commit their changes and perform other version control actions faster, as they don&#8217;t have to communicate with a central server.</li>



<li>With a DVCS, developers can work offline and commit their changes later when they do have an internet connection. They can also choose to share their changes with only a subset of the team, rather than pushing all of their changes to a central server.</li>



<li>In a DVCS, the repository history is stored on multiple servers and computers, which makes it more resistant to data loss.</li>
</ol>



<p><strong><mark>Git is an example of DVCS.</mark></strong></p>



<h3 class="wp-block-heading" id="heading-difference-between-cvcs-and-dvcs"><a href="https://tanaya.hashnode.dev/basics-of-git-github-day-8-task#heading-difference-between-cvcs-and-dvcs" rel="nofollow noopener" target="_blank"></a><strong><mark>Difference between CVCS and DVCS</mark></strong></h3>



<p>1. In CVCS, a client need to get a local copy of the source from the server, do the changes and commit those changes to the central source on the server, while in DVCS each client can have a local branch or repository as well and have a complete history on it. The client needs to push the changes to the branch which will then be pushed to the server repository.</p>



<p>2. CVCS systems are easy to learn and set up, and DVCS systems are difficult for beginners. Multiple commands need to be remembered.</p>



<p>3. Working on branches is difficult in CVCS, Developer often faces Merge Conflict. Working on branches is easier in DVCS, developers face less conflict.</p>



<p>4. CVCS systems do not provide offline access. DVCS systems are working fine in offline mode as a client copies the entire repository on their local machine.</p>



<p>5. CVCS is slower as every command needs to communicate with the server. while DVCS is faster as most user deals with a local copy without hitting the server every time.</p>



<p>6. If the CVCS server goes down, the developer is not able to do the work. But if the DVCS server is down, developers can work using their local copies.</p>



<h3 class="wp-block-heading" id="heading-github"><strong><mark>GitHub</mark></strong></h3>



<p>Git and GitHub are not the same things, Git mainly works on local systems. Github is used to store code that is remotely centralized and most Developers use this to store their code. GitHub is the largest host of source code in the world and has been owned by Microsoft since 2018.</p>



<h3 class="wp-block-heading" id="heading-git"><a href="https://tanaya.hashnode.dev/basics-of-git-github-day-8-task#heading-git" rel="nofollow noopener" target="_blank"></a><strong><mark>Git</mark></strong></h3>



<p>Git is a Distributed Version Control System and was launched by&nbsp;<strong>Linus Torvald</strong>&nbsp;&amp; this person also introduced Linux. Git is a software tool.</p>



<p>It is used for:</p>



<ul class="wp-block-list">
<li>Tracking code changes</li>



<li>Tracking who made changes</li>



<li>Coding collaboration</li>
</ul>



<h3 class="wp-block-heading" id="heading-what-does-git-do"><a href="https://tanaya.hashnode.dev/basics-of-git-github-day-8-task#heading-what-does-git-do" rel="nofollow noopener" target="_blank"></a>What does Git do?</h3>



<ul class="wp-block-list">
<li>Manage projects with&nbsp;<strong>Repositories</strong></li>



<li><strong>Clone</strong>&nbsp;a project to work on a local copy</li>



<li>Control and track changes with&nbsp;<strong>Staging</strong>&nbsp;and&nbsp;<strong>Committing</strong></li>



<li><strong>Branch</strong>&nbsp;and&nbsp;<strong>Merge</strong>&nbsp;to allow for work on different parts and versions of a project</li>



<li><strong>Pull</strong>&nbsp;the latest version of the project to a local copy</li>



<li><strong>Push</strong>&nbsp;local updates to the main project</li>
</ul>



<p><strong><mark>Actual Workflow of Git</mark></strong></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1752" height="1240" src="https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-8.png" alt="image 8" class="wp-image-397" title="Day 8 Task - Basics Of Git &amp; GitHub 13" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-8.png 1752w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-8-768x544.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-8-1536x1087.png 1536w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-8-150x106.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-8-300x212.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-8-696x493.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-8-1068x756.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-8-600x425.png 600w" sizes="auto, (max-width: 1752px) 100vw, 1752px" /></figure>



<ol class="wp-block-list">
<li>Initialize Git on a folder, making it a local <strong>Repository</strong> by the <strong><mark>git init </mark>command.</strong> A hidden folder will create named <strong><mark>.git</mark></strong></li>



<li><strong>Clone</strong>&nbsp;a project to work on a local copy</li>



<li><strong><mark>Working directory and Staging area</mark></strong><mark>:</mark>&nbsp;this is where you see files physically and do modifications. At a time you can work on a particular branch. When we send our code to the staging area to finalize our code from the working space, this procedure is known as&nbsp;<strong><mark>Add</mark></strong>In other CVCS, developers generally make modifications and commit their changes directly to the Repository (central). But Git uses a different strategy. Git does not track every modified file. Whenever you do commit an operation, Git looks for the files present in the staging area. Only those files present in the staging area are considered for commit and not all the modified files.</li>



<li><strong><mark>Commit</mark></strong><mark>:</mark>&nbsp;From the staging area when we send our codes to the local Repository this process will be known as Commit (save/snapshot). After saving the code, a commit id will be created &amp; this is unique.<strong><mark>Commit Id</mark>:</strong>&nbsp;So if anyone needs to check any code later time, then they can check it through that commit id. Commit-ID is 40 alpha-numeric characters. It mainly uses the&nbsp;<strong>SHA-1</strong>&nbsp;checksum concept. Even if you change one dot, the commit-id will get changed. It helps you to track the changes. Commit is also known as SHA-Hash.</li>



<li><strong><mark>Snapshot</mark></strong><mark>:</mark>&nbsp;It is that when you keep the codes into a file &amp; when you change some code, eg:you change into 4-5 lines then when you take a snapshot of that file, the snapshot will copy only that 4-5 lines of code in another file, not the entire code. So this helps to save less storage of a file.Snapshot is incremental i.e. it will copy or save only the changed data.</li>



<li><strong><mark>Push</mark></strong><mark>:</mark>&nbsp;Push operation copies changes from a local Repository instance to a Remote or Central Repo(<strong>GitHub</strong>). This is used to store the changes permanently in the Git Repo.</li>



<li><strong><mark>Pull:&nbsp;</mark></strong>Pull Operation copies the changes from a Remote Repo to a local machine. The pull operation is used for synchronization between two repo.</li>



<li><strong><mark>Branch:</mark></strong> There is an important concept of the branch&#8230;</li>
</ol>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1624" height="850" src="https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-9.png" alt="image 9" class="wp-image-398" title="Day 8 Task - Basics Of Git &amp; GitHub 14" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-9.png 1624w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-9-768x402.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-9-1536x804.png 1536w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-9-150x79.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-9-300x157.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-9-696x364.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-9-1068x559.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-9-600x314.png 600w" sizes="auto, (max-width: 1624px) 100vw, 1624px" /></figure>



<p>The diagram above visualizes a repository with two isolated lines of development. By developing them as branches, it&#8217;s not only possible to work on both of them in parallel, but it also keeps the main&nbsp;<strong><mark>Master (default branch)&nbsp;</mark></strong>free from error.</p>



<ul class="wp-block-list">
<li>Each task has one separate branch.</li>



<li>After done with the code,&nbsp;<strong><mark>Merge other Branches with the Master.</mark></strong></li>



<li>This concept is useful for parallel development means at times many persons can work on their branch and that won&#8217;t reflect on the main branch.</li>



<li>you can create any number of branches.</li>



<li>Changes are personal to that particular branch.</li>



<li><mark>The default branch is Master.</mark></li>



<li><mark>Files created in Workspace will be visible in any of the branch workspaces until you commit. Once you commit, then that file belongs to that particular branch.</mark></li>



<li><mark>When creating a new branch, data from the existing Branch is copied to the new branch (only one time when the branch is created).</mark></li>
</ul>



<h3 class="wp-block-heading" id="heading-tasks"><strong><mark>Tasks</mark></strong></h3>



<h3 class="wp-block-heading" id="heading-1-install-git-on-your-system"><a href="https://tanaya.hashnode.dev/basics-of-git-github-day-8-task#heading-1-install-git-on-your-system" rel="nofollow noopener" target="_blank"></a><strong>1. Install git on your system</strong></h3>



<p>As am using Linux OS(Ubuntu ) so by default git is already installed in it ( Aws instance). My git version is&nbsp;<strong>2.34.1</strong></p>



<h3 class="wp-block-heading" id="heading-2-create-a-free-account-in-github"><a href="https://tanaya.hashnode.dev/basics-of-git-github-day-8-task#heading-2-create-a-free-account-in-github" rel="nofollow noopener" target="_blank"></a><strong>2. Create a free account in GitHub.</strong></h3>



<p>You can create a free account in GitHub by Signing up&nbsp;<a target="_blank" href="https://github.com/" rel="noreferrer noopener nofollow"><strong></strong></a><strong><a href="https://github.com/" target="_blank" rel="noreferrer noopener nofollow">github.com</a></strong>&nbsp;(use this link).</p>



<h3 class="wp-block-heading" id="heading-3-make-a-directory-and-make-it-a-local-repository-by-git-init-command"><a href="https://tanaya.hashnode.dev/basics-of-git-github-day-8-task#heading-3-make-a-directory-and-make-it-a-local-repository-by-git-init-command" rel="nofollow noopener" target="_blank"></a><strong>3. Make a directory and make it a local repository by the git init command</strong></h3>



<p>Created one directory as <strong>test-repository</strong> then changed the directory to it. Then made it a git repository with <strong><mark>git init</mark> command.</strong>A .git folder will be created that is hidden</p>



<h3 class="wp-block-heading" id="heading-4-create-a-new-repository-on-github-and-clone-it-to-your-local-machine"><a href="https://tanaya.hashnode.dev/basics-of-git-github-day-8-task#heading-4-create-a-new-repository-on-github-and-clone-it-to-your-local-machine" rel="nofollow noopener" target="_blank"></a><strong>4. Create a new repository on GitHub and clone it to your local machine</strong></h3>



<p>Created one repository in GitHub named&nbsp;<strong>Task-Repo and</strong>&nbsp;cloned it to my machine.</p>



<h3 class="wp-block-heading" id="heading-5-make-some-changes-to-a-file-in-the-repository-and-commit-them-to-the-repository-using-git"><a href="https://tanaya.hashnode.dev/basics-of-git-github-day-8-task#heading-5-make-some-changes-to-a-file-in-the-repository-and-commit-them-to-the-repository-using-git" rel="nofollow noopener" target="_blank"></a><strong>5. Make some changes to a file in the repository and commit them to the repository using Git</strong></h3>



<p>Cloned the repository that I created in GitHub by the url in my machine.</p>



<p>configured git with git config &#8211;global user.name and user.email (this will help to check who is committed by name and mail id) command.</p>



<p>Now chnaged to the repository that I cloned. Then created a file called devops.txt.</p>



<p>add the file by <strong><mark>git add &lt;filename> </mark></strong>command and check the git status. This file is now <strong>staged</strong>. Now commit the file by the <strong><mark>git commit command.</mark></strong></p>



<h3 class="wp-block-heading" id="heading-6-push-the-changes-back-to-the-repository-on-github">6.&nbsp;<strong>Push the changes back to the repository on GitHub</strong></h3>



<p>Now add the repository by the command <strong><mark>git remote add origin</mark> &lt;url of GitHub repo</strong>></p>



<p>Then I pushed the committed file into GitHub by the command&nbsp;<strong><mark>git push origin main (as my default branch is main here, it can be master sometimes too).</mark></strong></p>



<p><strong><mark>While pushing the file into github have to enter the GitHub username and Personal access token ( go to Developers settings in GitHub -&gt; personal access token-&gt;generate token)</mark></strong></p>
<p>The post <a rel="nofollow" href="https://www.abdulrahmanuk.com/day-8-task-basics-of-git-github/">Day 8 Task &#8211; Basics Of Git &#038; GitHub</a> appeared first on <a rel="nofollow" href="https://www.abdulrahmanuk.com">abdulrahmanuk.com</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Day 7 Task &#8211; Understanding package manager and systemctl</title>
		<link>https://www.abdulrahmanuk.com/day-7-task-understanding-package-manager-and-systemctl/</link>
					<comments>https://www.abdulrahmanuk.com/day-7-task-understanding-package-manager-and-systemctl/#respond</comments>
		
		<dc:creator><![CDATA[Abdul Rahman UK]]></dc:creator>
		<pubDate>Fri, 02 Jun 2023 19:16:53 +0000</pubDate>
				<category><![CDATA[90DaysOfDevOps]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[devops]]></category>
		<guid isPermaLink="false">https://www.abdulrahmanuk.com/?p=385</guid>

					<description><![CDATA[<p>#90DaysOfDevopsChallenge 1. Pacakage Manager A package manager is a tool that allows users to install, remove, upgrade, configure and manage software packages on an operating system. The package manager can be a graphical application like a software center or a command lines tool like&#160;apt-get&#160;or&#160;Pacman. What is a Package? A package is usually referred to an [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.abdulrahmanuk.com/day-7-task-understanding-package-manager-and-systemctl/">Day 7 Task &#8211; Understanding package manager and systemctl</a> appeared first on <a rel="nofollow" href="https://www.abdulrahmanuk.com">abdulrahmanuk.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p><span style="background-color:#cdfe00" class="td_text_highlight_marker">#90DaysOfDevopsChallenge</span></p>



<p><mark><strong>1. Pacakage Manager</strong></mark></p>



<p>A package manager is a tool that allows users to install, remove, upgrade, configure and manage software packages on an operating system. The package manager can be a graphical application like a software center or a command lines tool like&nbsp;apt-get&nbsp;or&nbsp;Pacman.</p>



<h2 class="wp-block-heading" id="heading-what-is-a-package"><strong><mark>What is a Package?</mark></strong></h2>



<p>A package is usually referred to an application but it could be a GUI application, command line tool or a software library (required by other software programs). A package is essentially an archive file containing the binary executable, configuration file and sometimes information about the dependencies.</p>



<h2 class="wp-block-heading" id="heading-how-does-the-package-manager-work"><mark>How does the package manager work?</mark></h2>



<p>The package manager is a generic concept and it’s not exclusive to Linux. You’ll often find package managers for different software or programming languages. There is a PIP package manager just for Python packages.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1522" height="480" src="https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image.png" alt="image" class="wp-image-386" title="Day 7 Task - Understanding package manager and systemctl 15" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image.png 1522w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-768x242.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-150x47.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-300x95.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-696x220.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-1068x337.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-600x189.png 600w" sizes="auto, (max-width: 1522px) 100vw, 1522px" /></figure>



<p>Almost all Linux distributions have software repositories which is a collections of software packages. Yes, there could be more than one repository. The repositories contain software packages of a different kinds.</p>



<p>Repositories also have metadata files that contain information about the packages such as the name of the package, version number, description of the package and the repository name etc. This is what you see if you use the&nbsp;<strong>apt show command</strong>&nbsp;in Ubuntu/Debian.</p>



<p>Your system’s package manager first interacts with the metadata. The package manager creates a local cache of metadata on your system. When you run the update option of the package manager (for example apt update), it updates this local cache of metadata by referring to metadata from the repository.</p>



<p>When you run the installation command of your package manager (for example apt install package_name), the package manager refers to this cache. If it finds the package information in the cache, it uses the internet connection to connect to the appropriate repository and downloads the package first before installing on your system.</p>



<p>A package may have dependencies. Meaning that it may require other packages to be installed. The package manager often takes care of the dependencies and installs it automatically along with the package you are installing.</p>



<p><strong><mark>Types of Package Managers:</mark></strong></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1268" height="794" src="https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-1.png" alt="image 1" class="wp-image-387" title="Day 7 Task - Understanding package manager and systemctl 16" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-1.png 1268w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-1-768x481.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-1-150x94.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-1-300x188.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-1-696x436.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-1-1068x669.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-1-600x376.png 600w" sizes="auto, (max-width: 1268px) 100vw, 1268px" /></figure>



<ul class="wp-block-list">
<li><strong>1. DPKG – Debian Package Management System</strong></li>



<li><a href="https://tanaya.hashnode.dev/understanding-package-manager-and-systemctlday-7-task#heading-apt-advanced-packaging-tool" rel="nofollow noopener" target="_blank"></a><strong>APT (Advanced Packaging Tool) :</strong><a href="https://tanaya.hashnode.dev/understanding-package-manager-and-systemctlday-7-task#heading-it-is-a-very-popular-free-powerful-and-more-so-useful-command-line-package-management-system-that-is-a-front-end-for-the-dpkg-package-management-system" rel="nofollow noopener" target="_blank"></a>It is a very popular, free, powerful, and more so, useful command line package management system that is a front end for the dpkg package management system.Users of Debian or its derivatives such as Ubuntu and Linux Mint should be familiar with this package management tool.</li>



<li><a href="https://tanaya.hashnode.dev/understanding-package-manager-and-systemctlday-7-task#heading-aptitude-package-manager" rel="nofollow noopener" target="_blank"></a><strong>Aptitude Package Manager</strong>This is also a popular command line front-end package management tool for the&nbsp;<strong>Debian</strong>&nbsp;Linux family, it works similarly to&nbsp;<strong>APT</strong>&nbsp;. It was initially built for Debian and its derivatives but now its functionality stretches to the&nbsp;<strong>RHEL</strong>&nbsp;family.</li>



<li><strong>2. RPM (Red Hat Package Manager)</strong></li>



<li><a href="https://tanaya.hashnode.dev/understanding-package-manager-and-systemctlday-7-task#heading-yum-yellowdog-updater-modified" rel="nofollow noopener" target="_blank"></a><strong>YUM (Yellowdog Updater, Modified)</strong>It is an open-source and popular command line package manager that works as an interface for users to RPM. You can compare it to&nbsp;<strong>APT</strong>&nbsp;under Debian Linux systems, it incorporates the common functionalities that APT has.</li>



<li><strong>3.</strong>&nbsp;<strong>Pacman Package Manager – Arch Linux</strong></li>



<li><strong>4.</strong>&nbsp;<strong>Zypper Package Manager – openSUSE</strong></li>



<li><strong>5. Portage Package Manager – Gentoo</strong></li>
</ul>



<p><strong>2. You have to install docker and Jenkins in your system from your terminal using package managers</strong></p>



<p><strong><mark>Jenkins:</mark></strong></p>



<p>To install Jenkins you first have to install&nbsp;<strong><mark>java</mark></strong>. So this is some steps to install java:</p>



<p>Initially update all packages used in the below command. <span style="background-color:#0ea3e6" class="td_text_highlight_marker">NOTE: I&#8217;m showing here for Ubuntu operating system.</span></p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>sudo apt update</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">sudo apt update</span></span></code></pre></div>



<p>Depending on which Java version you want to install, Java 8 or 11, run one of the following commands:</p>



<p>To install OpenJDK 8, run:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>sudo apt install openjdk-8-jdk -y</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">sudo apt install openjdk</span><span style="color: #5DE4C7">-8</span><span style="color: #A6ACCD">-jdk -y</span></span></code></pre></div>



<p>To install OpenJDK 11, run:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>sudo apt install openjdk-11-jdk -y</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">sudo apt install openjdk</span><span style="color: #5DE4C7">-11</span><span style="color: #A6ACCD">-jdk -y</span></span></code></pre></div>



<p><strong>Add Jenkins Repository</strong></p>



<p>The version of Jenkins included with the default Ubuntu packages is often behind the latest available version from the project itself. To ensure you have the latest fixes and features, use the project-maintained packages to install Jenkins.</p>



<p>First, add the repository key to your system:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key |sudo gpg --dearmor -o /usr/share/keyrings/jenkins.gpg</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">wget -q -O - https:</span><span style="color: #767C9DB0; font-style: italic">//pkg.jenkins.io/debian-stable/jenkins.io.key |sudo gpg --dearmor -o /usr/share/keyrings/jenkins.gpg</span></span></code></pre></div>



<p>The&nbsp;<code>gpg --dearmor</code>&nbsp;command is used to convert the key into a format that&nbsp;<code>apt</code>&nbsp;recognizes.</p>



<p>Next, let’s append the Debian package repository address to the server’s&nbsp;<code>sources.list</code>:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>sudo sh -c 'echo deb [signed-by=/usr/share/keyrings/jenkins.gpg] http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">sudo sh -c &#39;echo deb [</span><span style="color: #D0679D">signed-by=/usr/share/keyrings/jenkins.gpg</span><span style="color: #A6ACCD">] http:</span><span style="color: #767C9DB0; font-style: italic">//pkg.jenkins.io/debian-stable binary/ &gt; /etc/apt/sources.list.d/jenkins.list&#39;</span></span></code></pre></div>



<p>The&nbsp;<code>[signed-by=/usr/share/keyrings/jenkins.gpg]</code>&nbsp;portion of the line ensures that&nbsp;<code>apt</code>&nbsp;will verify files in the repository using the GPG key that you just downloaded.</p>



<p>After both commands have been entered, run&nbsp;<code>apt update</code>&nbsp;so that&nbsp;<code>apt</code>&nbsp;will use the new repository.</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>sudo apt update</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">sudo apt update</span></span></code></pre></div>



<p>Finally, install Jenkins and its dependencies:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>sudo apt install jenkins</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">sudo apt install jenkins</span></span></code></pre></div>



<p>Now that Jenkins and its dependencies are in place, we’ll start the Jenkins server.</p>



<p><strong>Starting Jenkins</strong></p>



<p>now that Jenkins is installed, start it by using&nbsp;<code>systemctl</code>:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>sudo systemctl start jenkins.service</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">sudo systemctl start jenkins.service</span></span></code></pre></div>



<p>Since&nbsp;<code>systemctl</code>&nbsp;doesn’t display status output, we’ll use the&nbsp;<code>status</code>&nbsp;command to verify that Jenkins started successfully:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#a6accd;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>sudo systemctl status jenkins</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28" tabindex="0"><code><span class="line"><span style="color: #A6ACCD">sudo systemctl status jenkins</span></span></code></pre></div>



<p>If everything went well, the beginning of the status output shows that the service is active and configured to start at boot:</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1504" height="802" src="https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-2.png" alt="image 2" class="wp-image-388" title="Day 7 Task - Understanding package manager and systemctl 17" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-2.png 1504w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-2-768x410.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-2-150x80.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-2-300x160.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-2-696x371.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-2-1068x570.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-2-600x320.png 600w" sizes="auto, (max-width: 1504px) 100vw, 1504px" /></figure>



<p>you have completed the installation stage and can continue with configuring Jenkins.</p>



<p><strong><mark>Docker installation:</mark></strong></p>



<p><strong><mark>step 1: sudo apt update -y</mark></strong></p>



<p><strong><mark>step 2: sudo apt install&nbsp;docker.io&nbsp;-y</mark></strong></p>



<p><strong><mark>step 3: docker &#8211;version</mark></strong></p>



<p><strong><mark>step 4: systemctl status docker [ to check if docker is in the active state]</mark></strong></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1612" height="854" src="https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-3.png" alt="image 3" class="wp-image-389" title="Day 7 Task - Understanding package manager and systemctl 18" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-3.png 1612w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-3-768x407.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-3-1536x814.png 1536w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-3-150x79.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-3-300x159.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-3-696x369.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-3-1068x566.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-3-600x318.png 600w" sizes="auto, (max-width: 1612px) 100vw, 1612px" /></figure>



<h3 class="wp-block-heading" id="heading-3-systemctl-and-systemd"><strong><mark>systemctl and systemd</mark></strong></h3>



<p><strong><mark>systemctl</mark></strong>&nbsp;is used to examine and control the state of the “<strong><mark>systemd”</mark></strong>&nbsp;system and service manager.</p>



<p><strong><mark>systemd&nbsp;</mark></strong>is a system and service manager for Unix-like operating systems(most of the distributions, not all).</p>



<h3 class="wp-block-heading" id="heading-4-stop-the-service-jenkins-and-post-before-and-after-screenshots"><a href="https://tanaya.hashnode.dev/understanding-package-manager-and-systemctlday-7-task#heading-4-stop-the-service-jenkins-and-post-before-and-after-screenshots" rel="nofollow noopener" target="_blank"></a><strong>4. stop the service Jenkins and post before and after screenshots</strong></h3>



<p><strong><mark>Jenkins active status Screenshot:</mark></strong></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1408" height="762" src="https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-4.png" alt="image 4" class="wp-image-390" title="Day 7 Task - Understanding package manager and systemctl 19" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-4.png 1408w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-4-768x416.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-4-150x81.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-4-300x162.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-4-696x377.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-4-1068x578.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-4-600x325.png 600w" sizes="auto, (max-width: 1408px) 100vw, 1408px" /></figure>



<p><strong><mark>Jenkins stop Screenshot :</mark></strong></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1372" height="612" src="https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-5.png" alt="image 5" class="wp-image-391" title="Day 7 Task - Understanding package manager and systemctl 20" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-5.png 1372w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-5-768x343.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-5-150x67.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-5-300x134.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-5-696x310.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-5-1068x476.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/06/image-5-600x268.png 600w" sizes="auto, (max-width: 1372px) 100vw, 1372px" /></figure>



<h3 class="wp-block-heading" id="heading-5-read-about-the-commands-systemctl-vs-service"><strong>Read about the commands systemctl vs service</strong></h3>



<p>The&nbsp;<strong><mark>Service command</mark></strong>&nbsp;looks up the script to run at the path /etc/init.d/SCRIPT. It then runs the script, passing the COMMAND unchanged as the arguments. The&nbsp;<em>service</em>&nbsp;command guarantees a predictable running environment by removing most of the variables and setting the root path as the current working directory.</p>



<p><strong><mark>eg: sudo service jenkins start</mark></strong></p>



<p>The&nbsp;<strong><em><mark>systemctl</mark></em>&nbsp;<mark>command</mark></strong>&nbsp;interacts with the SystemD service manager to manage the services. Contrary to the&nbsp;<em>service</em>&nbsp;command, it manages the services by interacting with the SystemD process instead of running the init script.</p>



<p>To start, stop, and restart a process, we can run the commands with&nbsp;<em>systemctl</em>&nbsp;.</p>



<p><strong><mark>eg: sudo systemctl start docker</mark></strong></p>
<p>The post <a rel="nofollow" href="https://www.abdulrahmanuk.com/day-7-task-understanding-package-manager-and-systemctl/">Day 7 Task &#8211; Understanding package manager and systemctl</a> appeared first on <a rel="nofollow" href="https://www.abdulrahmanuk.com">abdulrahmanuk.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.abdulrahmanuk.com/day-7-task-understanding-package-manager-and-systemctl/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Day 6 &#8211; Linux File Permissions and Access Control Lists</title>
		<link>https://www.abdulrahmanuk.com/day-6-linux-file-permissions-and-access-control-lists/</link>
					<comments>https://www.abdulrahmanuk.com/day-6-linux-file-permissions-and-access-control-lists/#comments</comments>
		
		<dc:creator><![CDATA[Abdul Rahman UK]]></dc:creator>
		<pubDate>Wed, 31 May 2023 13:54:07 +0000</pubDate>
				<category><![CDATA[90DaysOfDevOps]]></category>
		<category><![CDATA[devops]]></category>
		<category><![CDATA[linux]]></category>
		<guid isPermaLink="false">https://www.abdulrahmanuk.com/?p=378</guid>

					<description><![CDATA[<p>1. About File Permissions: File permissions are core to the security model used by Linux systems. They determine who can access files and directories on a system and how. To check a file permission as : ls -l &#60;file-name> Permission Descriptions: Owner (u):&#160;Permissions used for the Owner of the file. Group(g):&#160;Permissions used by members of [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.abdulrahmanuk.com/day-6-linux-file-permissions-and-access-control-lists/">Day 6 &#8211; Linux File Permissions and Access Control Lists</a> appeared first on <a rel="nofollow" href="https://www.abdulrahmanuk.com">abdulrahmanuk.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading" id="heading-1-about-file-permissions"><strong><mark>1. About File Permissions:</mark></strong></h2>



<p>File permissions are core to the security model used by Linux systems. They determine who can access files and directories on a system and how.</p>



<p>To check a file permission as :</p>



<p><strong><mark>ls -l &lt;file-name></mark></strong></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1542" height="288" src="https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-16.png" alt="image 16" class="wp-image-379" title="Day 6 - Linux File Permissions and Access Control Lists 21" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-16.png 1542w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-16-768x143.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-16-1536x287.png 1536w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-16-150x28.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-16-300x56.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-16-696x130.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-16-1068x199.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-16-600x112.png 600w" sizes="auto, (max-width: 1542px) 100vw, 1542px" /></figure>



<p><strong><mark>Permission Descriptions:</mark></strong></p>



<ol class="wp-block-list">
<li><strong>Read (r):</strong>&nbsp;The read permission allows you to open and read the content of a file. But you can&#8217;t do any editing or modification in the file.</li>



<li><strong>Write (w):</strong>&nbsp;The write permission allows you to edit, remove or rename a file. For instance, if a file is present in a directory, and write permission is set on the file but not on the directory, then you can edit the content of the file but can&#8217;t remove, or rename it.</li>



<li><strong>Execute (x):</strong>&nbsp;In Unix type system, you can&#8217;t run or execute a program unless execute permission is set. But in Windows, there is no such permission available.</li>
</ol>



<p><strong><mark>Owner (u):</mark></strong>&nbsp;Permissions used for the Owner of the file.</p>



<p><strong><mark>Group(g):</mark></strong>&nbsp;Permissions used by members of the group.</p>



<p><strong><mark>Other(o):</mark></strong>&nbsp;Permissions used by all other users.</p>



<p><strong><mark>Permission Set:</mark></strong></p>



<figure class="wp-block-table"><table><thead><tr><td>permission</td><td>on a file</td><td>on a directory</td></tr></thead><tbody><tr><td>r (read)</td><td>read file content (cat)</td><td>read directory content (ls)</td></tr><tr><td>w (write)</td><td>change file content (vi)</td><td>create a file in the directory (touch)</td></tr><tr><td>x (execute)</td><td>execute the file</td><td>enter the directory (cd)</td></tr></tbody></table></figure>



<p><strong><mark>Permissions in detail:</mark></strong></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1484" height="926" src="https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-17.png" alt="image 17" class="wp-image-380" title="Day 6 - Linux File Permissions and Access Control Lists 22" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-17.png 1484w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-17-768x479.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-17-150x94.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-17-300x187.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-17-696x434.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-17-1068x666.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-17-600x374.png 600w" sizes="auto, (max-width: 1484px) 100vw, 1484px" /></figure>



<p><strong><mark>Change File Permissions:</mark></strong></p>



<p>a)&nbsp;<strong><mark>chmod</mark></strong>: Change file access permissions.</p>



<p><strong>Description:</strong>&nbsp;This command is used to change the file permissions. These permissions read, write and execute permission for the owner, group, and others.</p>



<p><strong>Syntax (symbolic mode)</strong>:&nbsp;<em><mark>chmod [ugoa][[+-=][mode]] file</mark></em></p>



<p>The first optional parameter indicates who – this can be (u)ser, (g)roup, (o)there, or (a)ll.</p>



<p>The second optional parameter indicates opcode – this can be for adding (+), removing (-), or assigning (=) permission.</p>



<p>The third optional parameter indicates the mode – this can be (r)ead, (w)rite, or e(x) acute.</p>



<p><strong>Example</strong>: Add writes permission for user, group, and others for file1.</p>



<p><strong><em><mark>$ chmod ugo+w file1</mark></em></strong></p>



<p>There is another way to change file permissions by numeric symbol:</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1114" height="458" src="https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-18.png" alt="image 18" class="wp-image-381" title="Day 6 - Linux File Permissions and Access Control Lists 23" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-18.png 1114w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-18-768x316.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-18-150x62.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-18-300x123.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-18-696x286.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-18-1068x439.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-18-600x247.png 600w" sizes="auto, (max-width: 1114px) 100vw, 1114px" /></figure>



<p><strong>Example</strong>: Give read/write/execute permission to the user, read/execute permission to the group, and execute permission to others.</p>



<p><strong><em><mark>$ chmod 751 file1</mark></em></strong></p>



<p>b)&nbsp;<strong><mark>chown</mark></strong>: Change ownership of the file.</p>



<p><strong>Description</strong>: Only the owner of the file has the right to change the file ownership.</p>



<p><strong>Syntax</strong>: chown [owner] [file]</p>



<p><strong>Example</strong>: Change the owner of file1 to user2 assuming it is currently owned by the current user</p>



<p><strong><em><mark>$ chown user2 file1</mark></em></strong></p>



<p>c)&nbsp;<strong><mark>chgrp</mark></strong>: Change the group ownership of the file</p>



<p><strong>Description</strong>: Only the owner of the file has the right to change the file ownership</p>



<p><strong>Syntax</strong>: chgrp [group] [file]</p>



<p><strong>Example</strong>: Change group of file1 to group2 assuming it is currently owned by the current user</p>



<p><strong><em><mark>$ chgrp group2 file1</mark></em></strong></p>



<p><strong>2. Create a simple file and check the details of the file:</strong></p>



<p>Here I created one file by using <strong><mark>the touch command</mark></strong> and then check the details of the file by using the <strong><mark>ls -l command </mark></strong>and then change the file permissions to <strong>766</strong> [all owner permissions, read and write permissions to group and others].<br></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1184" height="348" src="https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-19.png" alt="image 19" class="wp-image-382" title="Day 6 - Linux File Permissions and Access Control Lists 24" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-19.png 1184w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-19-768x226.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-19-150x44.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-19-300x88.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-19-696x205.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-19-1068x314.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-19-600x176.png 600w" sizes="auto, (max-width: 1184px) 100vw, 1184px" /></figure>



<p><strong>3 . Read about ACL and try out the commands getfacl and setfacl</strong></p>



<p>Access control list (ACL) provides an additional, more flexible permission mechanism for file systems. It is designed to assist with UNIX file permissions. ACL allows you to give permissions for any user or group to any disc resource.</p>



<p><strong>Use Of ACL:</strong>&nbsp;Think of a scenario in which a particular user is not a member of a group created by you but still you want to give some read or write access, how can you do it without making the user a member of the group, here comes in picture Access Control Lists, ACL helps us to do this trick.</p>



<p>ACLs are used to make a flexible permission mechanism in Linux.</p>



<p>From Linux man pages, ACLs are used to define more fine-grained discretionary access rights for files and directories.</p>



<p><strong><mark>setfacl and getfacl command:</mark></strong></p>



<p>The command&nbsp;<mark>&#8220;setfacl&#8221;</mark>&nbsp;refers to Set File Access Control Lists and&nbsp;<mark>&#8220;getfacl&#8221;</mark>&nbsp;refers to Get File Access Control List.</p>



<p>Example:</p>



<p><strong>getfacl &lt;file or directory name&gt;</strong></p>



<p>1. To add permission for user</p>



<p><strong>setfacl -m &#8220;u:user: permissions&#8221; /path/to/file</strong></p>



<p>setfacl -m u:tanaya:rwx test/declarations.h</p>



<p>2. To add permissions for a group</p>



<p><strong>setfacl -m &#8220;g:group: permissions&#8221; /path/to/file</strong></p>



<p>3. To remove ACL permission of user:</p>



<p><strong>setfacl -x &#8220;u:user: permissions&#8221; /path/to/file</strong></p>



<p>4. To remove ACL permission of group:</p>



<p><strong>setfacl -x &#8220;g:group: permissions&#8221; /path/to/file</strong></p>



<p></p>
<p>The post <a rel="nofollow" href="https://www.abdulrahmanuk.com/day-6-linux-file-permissions-and-access-control-lists/">Day 6 &#8211; Linux File Permissions and Access Control Lists</a> appeared first on <a rel="nofollow" href="https://www.abdulrahmanuk.com">abdulrahmanuk.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.abdulrahmanuk.com/day-6-linux-file-permissions-and-access-control-lists/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>Day-5 Task &#8211; Advanced Linux Shell Scripting for DevOps Engineers with User Management</title>
		<link>https://www.abdulrahmanuk.com/day-5-task-advanced-linux-shell-scripting-for-devops-engineers-with-user-management/</link>
					<comments>https://www.abdulrahmanuk.com/day-5-task-advanced-linux-shell-scripting-for-devops-engineers-with-user-management/#respond</comments>
		
		<dc:creator><![CDATA[Abdul Rahman UK]]></dc:creator>
		<pubDate>Wed, 31 May 2023 13:38:21 +0000</pubDate>
				<category><![CDATA[90DaysOfDevOps]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[devops]]></category>
		<guid isPermaLink="false">https://www.abdulrahmanuk.com/?p=370</guid>

					<description><![CDATA[<p>Challenge: If you noticed that there are total 90 sub directories in the directory &#8216;2023&#8217; of this repository. What did you think, how did I create 90 directories. Manually one by one or using a script, or a command ? All 90 directories within seconds using a simple command. mkdir day{1..90} Tasks So Write a [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.abdulrahmanuk.com/day-5-task-advanced-linux-shell-scripting-for-devops-engineers-with-user-management/">Day-5 Task &#8211; Advanced Linux Shell Scripting for DevOps Engineers with User Management</a> appeared first on <a rel="nofollow" href="https://www.abdulrahmanuk.com">abdulrahmanuk.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Challenge:</p>



<p>If you noticed that there are total 90 sub directories in the directory &#8216;2023&#8217; of this repository. What did you think, how did I create 90 directories. Manually one by one or using a script, or a command ?</p>



<p>All 90 directories within seconds using a simple command.</p>



<p><code>mkdir day{1..90}</code></p>



<h3 class="wp-block-heading"><a href="https://github.com/abdulrahman911/90DaysOfDevOps/blob/master/2023/day05/tasks.md#tasks" rel="nofollow noopener" target="_blank"></a>Tasks</h3>



<ol class="wp-block-list">
<li>You have to do the same using Shell Script i.e using either Loops or command with start day and end day variables using arguments &#8211;</li>
</ol>



<p>So Write a bash script createDirectories.sh that when the script is executed with three given arguments (one is directory name and second is start number of directories and third is the end number of directories ) it creates specified number of directories with a dynamic directory name.</p>



<p>Example 1: When the script is executed as</p>



<p><code>./createDirectories.sh day 1 90</code></p>



<p>then it creates 90 directories as&nbsp;<code>day1 day2 day3 .... day90</code></p>



<p>Example 2: When the script is executed as</p>



<p><code>./createDirectories.sh Movie 20 50</code> then it creates 50 directories as <code>Movie20 Movie21 Movie23 ...Movie50</code></p>



<p>As we know that if we want to pass any argument at the time of bash script execution we used to denote it as like&nbsp;<mark>$1(first arg),$2(2nd arg)</mark>&nbsp;etc&#8230;So here we will do the same thing in a bash script like :</p>



<p>name of the file as&nbsp;<strong><mark><a href="http://createdirectories.sh/" target="_blank" rel="noreferrer noopener nofollow">createDirectories.sh</a></mark></strong></p>



<p><strong><mark>start_day as $2 and end_day as $3 and day as $1</mark></strong></p>



<p><strong><mark>Execute as ./<a href="http://createdirectories.sh/" target="_blank" rel="noreferrer noopener nofollow">createDirectories.sh</a> day 1 90</mark></strong></p>



<p></p>



<p><strong><mark>Output</mark></strong></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="2642" height="554" src="https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-11.png" alt="image 11" class="wp-image-371" title="Day-5 Task - Advanced Linux Shell Scripting for DevOps Engineers with User Management 25" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-11.png 2642w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-11-768x161.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-11-1536x322.png 1536w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-11-2048x429.png 2048w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-11-150x31.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-11-300x63.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-11-696x146.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-11-1068x224.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-11-1920x403.png 1920w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-11-600x126.png 600w" sizes="auto, (max-width: 2642px) 100vw, 2642px" /></figure>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" style="font-size:.875rem;--cbp-line-number-color:#a6accd;--cbp-line-number-width:17.8046875px;line-height:1.25rem"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="#!/bin/bash

if [ $# != 3 ]
then
	echo &quot;Can't proceed \n Please give three arguments to continue&quot;
	exit 1

fi

echo &quot;Creating directory as per your requirement&quot;
start_day=$2
end_day=$3

for (( i=start_day; i&lt;=end_day; i++ ))
do
	mkdir $1$i
done	

echo &quot;Here are your directories:&quot;
ls
" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28"><code><span class="line"><span style="color: #A6ACCD">#!/bin/bash</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A6ACCD">if [ </span><span style="color: #D0679D">$#</span><span style="color: #A6ACCD"> </span><span style="color: #D0679D">!=</span><span style="color: #A6ACCD"> </span><span style="color: #5DE4C7">3</span><span style="color: #A6ACCD"> ]</span></span>
<span class="line"><span style="color: #A6ACCD">then</span></span>
<span class="line"><span style="color: #A6ACCD">	echo </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">Can&#39;t proceed </span><span style="color: #5FB3A1">\n</span><span style="color: #5DE4C7"> Please give three arguments to continue</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">	exit </span><span style="color: #5DE4C7">1</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A6ACCD">fi</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A6ACCD">echo </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">Creating directory as per your requirement</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">start_day=$</span><span style="color: #5DE4C7">2</span></span>
<span class="line"><span style="color: #A6ACCD">end_day=$</span><span style="color: #5DE4C7">3</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A6ACCD">for (( i=start_day; i&lt;=end_day; i++ ))</span></span>
<span class="line"><span style="color: #A6ACCD">do</span></span>
<span class="line"><span style="color: #A6ACCD">	mkdir $</span><span style="color: #5DE4C7">1</span><span style="color: #A6ACCD">$i</span></span>
<span class="line"><span style="color: #A6ACCD">done	</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A6ACCD">echo </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">Here are your directories:</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">ls</span></span>
<span class="line"></span></code></pre></div>



<p><strong>2. Create a Script to back up all your work done till now.</strong></p>



<p>Backups are an important part of DevOps Engineers&#8217; day to Day activities. Usually, when we create any backup of a file we used to create a zip file by using the tar command:&nbsp;<strong>tar -czvf file.tar.gz directory_name</strong></p>



<p>Here is a simple shell script to take a backup of recent work:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" style="font-size:.875rem;--cbp-line-number-color:#a6accd;--cbp-line-number-width:17.8046875px;line-height:1.25rem"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="#!/bin/bash

src_directory=/var/www/my-blog

BACKUP_FILENAME=&quot;backup_$(date +%Y-%m-%d).tar.gz&quot;
TARGET_DIRECTORY=&quot;/home/ubuntu/backup/&quot;

#Create backup archive
tar -czvf $TARGET_DIRECTORY/$BACKUP_FILENAME $src_directory

if [ $? -eq 0 ]; then
	echo &quot;Backup successful!&quot;
else
	echo &quot;Backup failed.&quot;
fi

" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28"><code><span class="line"><span style="color: #A6ACCD">#!/bin/bash</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A6ACCD">src_directory=/var/www/my-blog</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A6ACCD">BACKUP_FILENAME=</span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">backup_$(date +%Y-%m-%d).tar.gz</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">TARGET_DIRECTORY=</span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">/home/ubuntu/backup/</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A6ACCD">#Create backup archive</span></span>
<span class="line"><span style="color: #A6ACCD">tar -czvf $TARGET_DIRECTORY/$BACKUP_FILENAME $src_directory</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A6ACCD">if [ </span><span style="color: #D0679D">$?</span><span style="color: #A6ACCD"> </span><span style="color: #D0679D">-eq</span><span style="color: #A6ACCD"> </span><span style="color: #5DE4C7">0</span><span style="color: #A6ACCD"> ]; then</span></span>
<span class="line"><span style="color: #A6ACCD">	echo </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">Backup successful!</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">else</span></span>
<span class="line"><span style="color: #A6ACCD">	echo </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">Backup failed.</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">fi</span></span>
<span class="line"></span>
<span class="line"></span></code></pre></div>



<p><strong>3. Read About Cron and Crontab, to automate the backup Script</strong></p>



<p>Cron is a system process that will automatically perform tasks as per the specific schedule. It is a set of commands that are used for running regular scheduling tasks. Crontab stands for “<mark>cron table</mark>”. It allows using a job scheduler, which is known as cron to execute tasks.</p>



<p>Crontab is also the name of the program, which is used to edit that schedule. It is driven by a crontab file, a config file that indicates shell commands to run periodically for the specific schedule.</p>



<p><strong><mark>Reasons for using Cron jobs:</mark></strong></p>



<ul class="wp-block-list">
<li>Helps OS to take a scheduled backup of log files or database.</li>



<li>Delete old log files</li>



<li>Archive and purge database tables</li>



<li>Send out any notification email such as Newsletters, Password expiration email</li>



<li>Regular clean-up of cached data</li>



<li>Crontab is an ideal option to automate Unix jobs.</li>



<li>It is used to automate system maintenance</li>
</ul>



<p><strong>Crontab syntax:</strong></p>



<p><strong><mark>MIN HOUR DOM MON DOW CMD</mark></strong></p>



<p><strong>Ranges :</strong></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1262" height="516" src="https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-13.png" alt="image 13" class="wp-image-373" title="Day-5 Task - Advanced Linux Shell Scripting for DevOps Engineers with User Management 26" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-13.png 1262w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-13-768x314.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-13-150x61.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-13-300x123.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-13-696x285.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-13-1068x437.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-13-600x245.png 600w" sizes="auto, (max-width: 1262px) 100vw, 1262px" /></figure>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="996" height="466" src="https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-14.png" alt="image 14" class="wp-image-374" title="Day-5 Task - Advanced Linux Shell Scripting for DevOps Engineers with User Management 27" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-14.png 996w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-14-768x359.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-14-150x70.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-14-300x140.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-14-696x326.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-14-600x281.png 600w" sizes="auto, (max-width: 996px) 100vw, 996px" /></figure>



<p><strong>4. Read about User Management</strong></p>



<p>User management includes everything from creating a user to deleting a user on your system.</p>



<h3 class="wp-block-heading" id="heading-root"><a href="https://tanaya.hashnode.dev/advanced-linux-shell-scripting-for-devops-engineers-with-user-management-day-5-task#heading-root" rel="nofollow noopener" target="_blank"></a><strong>root</strong></h3>



<p>The root user is the superuser and has all the powers for creating a user, deleting a user and can even login in with the other user&#8217;s account. The root user always has userid 0.</p>



<h3 class="wp-block-heading" id="heading-useradd"><a href="https://tanaya.hashnode.dev/advanced-linux-shell-scripting-for-devops-engineers-with-user-management-day-5-task#heading-useradd" rel="nofollow noopener" target="_blank"></a><strong>useradd</strong></h3>



<p>1. With useradd command, you can add a user.</p>



<p>Syntax:&nbsp;<strong><mark>sudo adduser username [you should have the super user power to add a user]</mark></strong></p>



<p><strong>Then</strong>&nbsp;<mark>Enter the password for the new account and confirm</mark></p>



<p>You can check the newly added user from the file&nbsp;<strong><mark>/etc/passwd</mark></strong></p>



<p>Command:&nbsp;<strong>cat /etc/passwd</strong></p>



<p>2.&nbsp;<strong>For disabling an account using Terminal, remove the password set on the account.</strong></p>



<p><strong><mark>sudo passwd -l &#8216;username&#8217;</mark></strong></p>



<p>3. To delete an account, use the command –</p>



<p><strong><mark>sudo userdel -r &#8216;username</mark></strong></p>



<h2 class="wp-block-heading" id="heading-5-create-2-users-and-just-display-their-usernames"><strong>5. Create 2 users and just display their Usernames</strong></h2>



<p>Added two users by using the useradd command :</p>



<p>$ sudo useradd Sam</p>



<p>$ sudo useradd Vinod</p>



<p>To display their name use <strong>cat /etc/passwd</strong> and redirected the output to the <strong>tail</strong> command to see only the last two lines from the file :</p>



<p>To display their name use <strong>cat /etc/passwd</strong> and redirected the output to the <strong>tail</strong> command to see only the last two lines from the file :</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1606" height="356" src="https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-15.png" alt="image 15" class="wp-image-375" title="Day-5 Task - Advanced Linux Shell Scripting for DevOps Engineers with User Management 28" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-15.png 1606w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-15-768x170.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-15-1536x340.png 1536w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-15-150x33.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-15-300x67.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-15-696x154.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-15-1068x237.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-15-600x133.png 600w" sizes="auto, (max-width: 1606px) 100vw, 1606px" /></figure>



<h2 class="wp-block-heading" id="heading-5-create-2-users-and-just-display-their-usernames"><a href="https://tanaya.hashnode.dev/advanced-linux-shell-scripting-for-devops-engineers-with-user-management-day-5-task#heading-5-create-2-users-and-just-display-their-usernames" rel="nofollow noopener" target="_blank"></a></h2>
<p>The post <a rel="nofollow" href="https://www.abdulrahmanuk.com/day-5-task-advanced-linux-shell-scripting-for-devops-engineers-with-user-management/">Day-5 Task &#8211; Advanced Linux Shell Scripting for DevOps Engineers with User Management</a> appeared first on <a rel="nofollow" href="https://www.abdulrahmanuk.com">abdulrahmanuk.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.abdulrahmanuk.com/day-5-task-advanced-linux-shell-scripting-for-devops-engineers-with-user-management/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Day 4 &#8211; Basic Linux Shell Scripting for DevOps Engineer</title>
		<link>https://www.abdulrahmanuk.com/day-4-basic-linux-shell-scripting-for-devops-engineer/</link>
					<comments>https://www.abdulrahmanuk.com/day-4-basic-linux-shell-scripting-for-devops-engineer/#respond</comments>
		
		<dc:creator><![CDATA[Abdul Rahman UK]]></dc:creator>
		<pubDate>Wed, 31 May 2023 09:24:53 +0000</pubDate>
				<category><![CDATA[90DaysOfDevOps]]></category>
		<category><![CDATA[devops]]></category>
		<category><![CDATA[linux]]></category>
		<guid isPermaLink="false">https://www.abdulrahmanuk.com/?p=357</guid>

					<description><![CDATA[<p>What is Kernel A kernel is a central component of an operating system that manages system resources and provides a bridge between software applications and the computer&#8217;s hardware. Kernel Allows programs to interact with the computer&#8217;s resources such as the CPU, memory, disk drives, and input/output devices. What is Shell Shell is a special program [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.abdulrahmanuk.com/day-4-basic-linux-shell-scripting-for-devops-engineer/">Day 4 &#8211; Basic Linux Shell Scripting for DevOps Engineer</a> appeared first on <a rel="nofollow" href="https://www.abdulrahmanuk.com">abdulrahmanuk.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p><strong>What is Kernel</strong></p>



<p>A kernel is a central component of an operating system that manages system resources and provides a bridge between software applications and the computer&#8217;s hardware. Kernel Allows programs to interact with the computer&#8217;s resources such as the CPU, memory, disk drives, and input/output devices.</p>



<h4 class="wp-block-heading" id="heading-what-is-shell"><strong>What is Shell</strong></h4>



<p>Shell is a special program that provides a command-line interface (CLI)/ terminal so that users can interact with the operating system through special text commands. A shell allows users to run commands, execute programs, and manipulate files and directories on the system.</p>



<h4 class="wp-block-heading" id="heading-what-is-linux-shell-scripting">What is Linux Shell Scripting</h4>



<p>It&#8217;s a way of writing commands or a set of instructions in a text file to run in a Linux shell/ terminal. For writing shell scripts we can use different scripting languages such as Bash, Zsh, Csh, Ksh, Fish, etc.</p>



<p>Bash: Bash is the default shell in most Linux distributions and is widely used for writing shell scripts.</p>



<h3 class="wp-block-heading" id="heading-what-is-shell-scripting-for-devops">What is Shell Scripting for DevOps</h3>



<p>Shell scripting is used in DevOps to automate tasks and processes for managing the development and deployment of software applications in a fast-paced and dynamic environment.</p>



<p>Here are some examples of how shell scripting is used in DevOps:</p>



<ul class="wp-block-list">
<li>Deployment automation: DevOps teams use shell scripts to automate the deployment of software applications to production, testing, and staging environments. These scripts can automate tasks such as copying files, installing dependencies, setting up servers, configuring databases, and more.</li>



<li>Infrastructure management: DevOps teams use shell scripts to manage infrastructure as code, which allows them to treat infrastructure as if it were software. Shell scripts can be used to automate the provisioning and configuration of servers, load balancers, databases, and other infrastructure components.</li>



<li>Continuous Integration and Continuous Delivery (CI/CD): Shell scripting is used to automate the build, test, and deployment stages of the CI/CD pipeline. This ensures that code changes are thoroughly tested and deployed to production quickly and reliably.</li>



<li>Monitoring and logging: DevOps teams use shell scripts to automate the monitoring and logging of software applications and infrastructure. These scripts can be used to collect performance metrics, log files, and other data that can be used to troubleshoot issues and improve system performance.</li>
</ul>



<p>Overall, shell scripting is a powerful tool to automate repetitive tasks, manage infrastructure as code, and streamline the software development and deployment process</p>



<h3 class="wp-block-heading" id="heading-what-is-binbash">What is #!/bin/bash?</h3>



<p>#!/bin/bash is the shebang line and it is written first at the beginning of the script. It is nothing but the absolute path to the bash interpreter. This line is used to specify the interpreter with which the given script will be run by default.</p>



<p>Syntax of shebang line is #!/bin/&lt;shell_interpreter&gt;</p>



<h3 class="wp-block-heading" id="heading-can-we-write-binsh-as-well">Can we write #!/bin/sh as well?</h3>



<p>Answer is YES</p>



<p>Some of the most common shell interpreters include:</p>



<ul class="wp-block-list">
<li>Bash (Bourne-Again SHell)</li>



<li>sh (Bourne Shell)</li>



<li>csh (C Shell)</li>



<li>tcsh (TENEX C Shell)</li>



<li>zsh (Z Shell)</li>



<li>ksh (KornShell)</li>



<li>fish (Friendly Interactive SHell)</li>
</ul>



<p>Each shell interpreter has its own syntax, features, and capabilities. Bash is a popular shell interpreter in Linux environments and is known for its powerful scripting capabilities.</p>



<h4 class="wp-block-heading" id="heading-write-a-shell-script-that-prints-i-will-complete-the-90daysoofdevops-challenge">Write a Shell Script that prints I will complete the #90DaysOfDevOps challenge</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1430" height="176" src="https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-5.png" alt="image 5" class="wp-image-358" title="Day 4 - Basic Linux Shell Scripting for DevOps Engineer 29" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-5.png 1430w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-5-768x95.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-5-150x18.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-5-300x37.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-5-696x86.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-5-1068x131.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-5-600x74.png 600w" sizes="auto, (max-width: 1430px) 100vw, 1430px" /></figure>



<h4 class="wp-block-heading" id="heading-write-a-shell-script-that-prints-i-will-complete-the-90daysoofdevops-challenge">Write a Shell Script to take user input, input from arguments, and print the variables.<a href="https://90daysofdevopschallenge.hashnode.dev/day04-90daysofdevops-challenge-tws#heading-write-a-shell-script-that-prints-i-will-complete-the-90daysoofdevops-challenge" rel="nofollow noopener" target="_blank"></a></h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1732" height="342" src="https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-6.png" alt="image 6" class="wp-image-359" title="Day 4 - Basic Linux Shell Scripting for DevOps Engineer 30" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-6.png 1732w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-6-768x152.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-6-1536x303.png 1536w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-6-150x30.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-6-300x59.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-6-696x137.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-6-1068x211.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-6-600x118.png 600w" sizes="auto, (max-width: 1732px) 100vw, 1732px" /></figure>



<h4 class="wp-block-heading" id="heading-what-is-binbash">Write an example of If else in Shell Scripting for comparing 2 numbers</h4>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" style="font-size:.875rem;--cbp-line-number-color:#a6accd;--cbp-line-number-width:17.8046875px;line-height:1.25rem"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="#!/bin/bash 
echo &quot;Just you and Computer number Guess Game!!!&quot;
echo &quot;Please enter your number&quot;
read number

computer=$((1 + RANDOM % 100))
echo &quot;The computer Guess is $computer&quot;

echo &quot;Your choice is $number&quot;

if [ $computer -ge $number ]
then
	echo &quot;Computer won the game&quot;
else 
	echo &quot;You won the GAME!!!&quot;
fi " style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28"><code><span class="line"><span style="color: #A6ACCD">#!/bin/bash </span></span>
<span class="line"><span style="color: #A6ACCD">echo </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">Just you and Computer number Guess Game!!!</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">echo </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">Please enter your number</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">read number</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A6ACCD">computer=$((</span><span style="color: #5DE4C7">1</span><span style="color: #A6ACCD"> + RANDOM % </span><span style="color: #5DE4C7">100</span><span style="color: #A6ACCD">))</span></span>
<span class="line"><span style="color: #A6ACCD">echo </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">The computer Guess is $computer</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A6ACCD">echo </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">Your choice is $number</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A6ACCD">if [ </span><span style="color: #D0679D">$computer</span><span style="color: #A6ACCD"> </span><span style="color: #D0679D">-ge</span><span style="color: #A6ACCD"> </span><span style="color: #D0679D">$number</span><span style="color: #A6ACCD"> ]</span></span>
<span class="line"><span style="color: #A6ACCD">then</span></span>
<span class="line"><span style="color: #A6ACCD">	echo </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">Computer won the game</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">else </span></span>
<span class="line"><span style="color: #A6ACCD">	echo </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">You won the GAME!!!</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">fi </span></span></code></pre></div>



<p></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1532" height="618" src="https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-8.png" alt="image 8" class="wp-image-361" title="Day 4 - Basic Linux Shell Scripting for DevOps Engineer 31" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-8.png 1532w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-8-768x310.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-8-150x61.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-8-300x121.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-8-696x281.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-8-1068x431.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-8-600x242.png 600w" sizes="auto, (max-width: 1532px) 100vw, 1532px" /></figure>



<p></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1886" height="354" src="https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-7.png" alt="image 7" class="wp-image-360" title="Day 4 - Basic Linux Shell Scripting for DevOps Engineer 32" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-7.png 1886w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-7-768x144.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-7-1536x288.png 1536w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-7-150x28.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-7-300x56.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-7-696x131.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-7-1068x200.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-7-600x113.png 600w" sizes="auto, (max-width: 1886px) 100vw, 1886px" /></figure>



<h4 class="wp-block-heading" id="heading-what-is-binbash">Improve the above script to handle multiple conditions and invalid inputs by the users [ Use if-elif-else-fi ]</h4>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" style="font-size:.875rem;--cbp-line-number-color:#a6accd;--cbp-line-number-width:17.8046875px;line-height:1.25rem"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1b1e28"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="#!/bin/bash 
echo &quot;Just you and Computer number Guess Game!!!&quot;

echo &quot;Please enter your number&quot;
read number

if ! [[ $number =~ ^[1-9][0-9]?$|^100$ ]]; then
	echo &quot;enter valid number from 1 to 100 only&quot;
	exit 1
fi

computer=$((1 + RANDOM % 100))
echo &quot;The computer Guess is $computer&quot;

echo &quot;Your choice is $number&quot;

if [ $computer -gt $number ]
then
	echo &quot;Computer won the game&quot;
elif [ $number -gt $computer ]; then
	echo &quot;You won the GAME!!!&quot;
else 
	echo &quot;You both are guess same number!!!GREAT!!!&quot;
fi" style="color:#a6accd;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki poimandres" style="background-color: #1b1e28"><code><span class="line"><span style="color: #A6ACCD">#!/bin/bash </span></span>
<span class="line"><span style="color: #A6ACCD">echo </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">Just you and Computer number Guess Game!!!</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A6ACCD">echo </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">Please enter your number</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">read number</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A6ACCD">if ! [[ </span><span style="color: #D0679D">$number</span><span style="color: #A6ACCD"> </span><span style="color: #D0679D">=~</span><span style="color: #A6ACCD"> </span><span style="color: #D0679D">^</span><span style="color: #A6ACCD">[</span><span style="color: #5DE4C7">1-9</span><span style="color: #A6ACCD">][</span><span style="color: #5DE4C7">0-9</span><span style="color: #A6ACCD">]</span><span style="color: #D0679D">?$|^</span><span style="color: #5DE4C7">100</span><span style="color: #D0679D">$</span><span style="color: #A6ACCD"> ]]; then</span></span>
<span class="line"><span style="color: #A6ACCD">	echo </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">enter valid number from 1 to 100 only</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">	exit </span><span style="color: #5DE4C7">1</span></span>
<span class="line"><span style="color: #A6ACCD">fi</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A6ACCD">computer=$((</span><span style="color: #5DE4C7">1</span><span style="color: #A6ACCD"> + RANDOM % </span><span style="color: #5DE4C7">100</span><span style="color: #A6ACCD">))</span></span>
<span class="line"><span style="color: #A6ACCD">echo </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">The computer Guess is $computer</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A6ACCD">echo </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">Your choice is $number</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A6ACCD">if [ </span><span style="color: #D0679D">$computer</span><span style="color: #A6ACCD"> </span><span style="color: #D0679D">-gt</span><span style="color: #A6ACCD"> </span><span style="color: #D0679D">$number</span><span style="color: #A6ACCD"> ]</span></span>
<span class="line"><span style="color: #A6ACCD">then</span></span>
<span class="line"><span style="color: #A6ACCD">	echo </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">Computer won the game</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">elif [ </span><span style="color: #D0679D">$number</span><span style="color: #A6ACCD"> </span><span style="color: #D0679D">-gt</span><span style="color: #A6ACCD"> </span><span style="color: #D0679D">$computer</span><span style="color: #A6ACCD"> ]; then</span></span>
<span class="line"><span style="color: #A6ACCD">	echo </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">You won the GAME!!!</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">else </span></span>
<span class="line"><span style="color: #A6ACCD">	echo </span><span style="color: #A6ACCD">&quot;</span><span style="color: #5DE4C7">You both are guess same number!!!GREAT!!!</span><span style="color: #A6ACCD">&quot;</span></span>
<span class="line"><span style="color: #A6ACCD">fi</span></span></code></pre></div>



<p></p>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" src="https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-10.png" alt="image 10" class="wp-image-363" width="703" height="404" title="Day 4 - Basic Linux Shell Scripting for DevOps Engineer 33" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-10.png 1546w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-10-768x442.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-10-1536x884.png 1536w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-10-150x86.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-10-300x173.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-10-696x401.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-10-1068x615.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-10-600x345.png 600w" sizes="auto, (max-width: 703px) 100vw, 703px" /></figure>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1938" height="512" src="https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-9.png" alt="image 9" class="wp-image-362" title="Day 4 - Basic Linux Shell Scripting for DevOps Engineer 34" srcset="https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-9.png 1938w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-9-768x203.png 768w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-9-1536x406.png 1536w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-9-150x40.png 150w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-9-300x79.png 300w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-9-696x184.png 696w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-9-1068x282.png 1068w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-9-1920x507.png 1920w, https://www.abdulrahmanuk.com/wp-content/uploads/2023/05/image-9-600x159.png 600w" sizes="auto, (max-width: 1938px) 100vw, 1938px" /></figure>



<h4 class="wp-block-heading" id="heading-what-is-binbash">Hope the blog helps you, &nbsp;Follow me for more content on Cloud and DevOps. Thank you! <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f64f.png" alt="🙏" class="wp-smiley" style="height: 1em; max-height: 1em;" /><a href="https://90daysofdevopschallenge.hashnode.dev/day04-90daysofdevops-challenge-tws#heading-what-is-binbash" rel="nofollow noopener" target="_blank"></a></h4>
<p>The post <a rel="nofollow" href="https://www.abdulrahmanuk.com/day-4-basic-linux-shell-scripting-for-devops-engineer/">Day 4 &#8211; Basic Linux Shell Scripting for DevOps Engineer</a> appeared first on <a rel="nofollow" href="https://www.abdulrahmanuk.com">abdulrahmanuk.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.abdulrahmanuk.com/day-4-basic-linux-shell-scripting-for-devops-engineer/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Top 50+ Linux Commands You MUST Know</title>
		<link>https://www.abdulrahmanuk.com/top-50-linux-commands-you-must-know/</link>
					<comments>https://www.abdulrahmanuk.com/top-50-linux-commands-you-must-know/#respond</comments>
		
		<dc:creator><![CDATA[Abdul Rahman UK]]></dc:creator>
		<pubDate>Wed, 31 May 2023 06:53:19 +0000</pubDate>
				<category><![CDATA[DevOps]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[devops]]></category>
		<category><![CDATA[linux]]></category>
		<guid isPermaLink="false">https://www.abdulrahmanuk.com/?p=354</guid>

					<description><![CDATA[<p>Using Linux commands on a regular basis? Today we’ll look at 50+ Linux commands you must know! The commands listed below are some of the most useful and most frequently used Linux commands. Let’s get right into it!</p>
<p>The post <a rel="nofollow" href="https://www.abdulrahmanuk.com/top-50-linux-commands-you-must-know/">Top 50+ Linux Commands You MUST Know</a> appeared first on <a rel="nofollow" href="https://www.abdulrahmanuk.com">abdulrahmanuk.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Using Linux commands on a regular basis? Today we’ll look at 50+ <strong>Linux commands you must know</strong>! The commands listed below are some of the most useful and most frequently used Linux commands. Let’s get right into it!</p>



<ol class="wp-block-list">
<li><strong>ls</strong>&nbsp;&#8211; The most frequently used command in Linux to list directories</li>



<li><strong>pwd</strong>&nbsp;&#8211; Print working directory command in Linux</li>



<li><strong>cd</strong>&nbsp;&#8211; Linux command to navigate through directories</li>



<li><strong>mkdir</strong>&nbsp;&#8211; Command used to create directories in Linux</li>



<li><strong>mv</strong>&nbsp;&#8211; Move or rename files in Linux</li>



<li><strong>cp</strong>&nbsp;&#8211; Similar usage as mv but for copying files in Linux</li>



<li><strong>rm</strong>&nbsp;&#8211; Delete files or directories</li>



<li><strong>touch</strong>&nbsp;&#8211; Create blank/empty files</li>



<li><strong>ln</strong>&nbsp;&#8211; Create symbolic links (shortcuts) to other files</li>



<li><strong>cat</strong>&nbsp;&#8211; Display file contents on the terminal</li>



<li><strong>clear</strong>&nbsp;&#8211; Clear the terminal display</li>



<li><strong>echo</strong>&nbsp;&#8211; Print any text that follows the command</li>



<li><strong>less</strong>&nbsp;&#8211; Linux command to display paged outputs in the terminal</li>



<li><strong>man</strong>&nbsp;&#8211; Access manual pages for all Linux commands</li>



<li><strong>uname</strong>&nbsp;&#8211; Linux command to get basic information about the OS</li>



<li><strong>whoami</strong>&nbsp;&#8211; Get the active username</li>



<li><strong>tar</strong>&nbsp;&#8211; Command to extract and compress files in Linux</li>



<li><strong>grep</strong>&nbsp;&#8211; Search for a string within an output</li>



<li><strong>head</strong>&nbsp;&#8211; Return the specified number of lines from the top</li>



<li><strong>tail</strong>&nbsp;&#8211; Return the specified number of lines from the bottom</li>



<li><strong>diff</strong>&nbsp;&#8211; Find the difference between two files</li>



<li><strong>cmp</strong>&nbsp;&#8211; Allows you to check if two files are identical</li>



<li><strong>comm</strong>&nbsp;&#8211; Combines the functionality of diff and cmp</li>



<li><strong>sort</strong>&nbsp;&#8211; Linux command to sort the content of a file while outputting</li>



<li><strong>export</strong>&nbsp;&#8211; Export environment variables in Linux</li>



<li><strong>zip</strong>&nbsp;&#8211; Zip files in Linux</li>



<li><strong>unzip</strong>&nbsp;&#8211; Unzip files in Linux</li>



<li><strong>ssh</strong>&nbsp;&#8211; Secure Shell command in Linux</li>



<li><strong>service</strong>&nbsp;&#8211; Linux command to start and stop services</li>



<li><strong>ps</strong>&nbsp;&#8211; Display active processes</li>



<li><strong>kill and killall</strong>&nbsp;&#8211; Kill active processes by process ID or name</li>



<li><strong>df</strong>&nbsp;&#8211; Display disk filesystem information</li>



<li><strong>mount</strong>&nbsp;&#8211; Mount file systems in Linux</li>



<li><strong>chmod</strong>&nbsp;&#8211; Command to change file permissions</li>



<li><strong>chown</strong>&nbsp;&#8211; Command for granting ownership of files or folders</li>



<li><strong>ifconfig</strong>&nbsp;&#8211; Display network interfaces and IP addresses</li>



<li><strong>traceroute</strong>&nbsp;&#8211; Trace all the network hops to reach the destination</li>



<li><strong>wget</strong>&nbsp;&#8211; Direct download files from the internet</li>



<li><strong>ufw</strong>&nbsp;&#8211; Firewall command</li>



<li><strong>iptables</strong>&nbsp;&#8211; Base firewall for all other firewall utilities to interface with</li>



<li><strong>apt, pacman, yum, rpm</strong>&nbsp;&#8211; Package managers depending on the distro</li>



<li><strong>sudo</strong>&nbsp;&#8211; Command to escalate privileges in Linux</li>



<li><strong>cal</strong>&nbsp;&#8211; View a command-line calendar</li>



<li><strong>alias &#8211;</strong>&nbsp;Create custom shortcuts for your regularly used commands</li>



<li><strong>dd</strong>&nbsp;&#8211; Majorly used for creating bootable USB sticks</li>



<li><strong>whereis</strong>&nbsp;&#8211; Locate the binary, source, and manual pages for a command</li>



<li><strong>whatis</strong>&nbsp;&#8211; Find what a command is used for</li>



<li><strong>top</strong>&nbsp;&#8211; View active processes live with their system usage</li>



<li><strong>useradd and usermod</strong>&nbsp;&#8211; Add new user or change existing users data</li>



<li><strong>passwd</strong>&nbsp;&#8211; Create or update passwords for existing users</li>
</ol>
<p>The post <a rel="nofollow" href="https://www.abdulrahmanuk.com/top-50-linux-commands-you-must-know/">Top 50+ Linux Commands You MUST Know</a> appeared first on <a rel="nofollow" href="https://www.abdulrahmanuk.com">abdulrahmanuk.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.abdulrahmanuk.com/top-50-linux-commands-you-must-know/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
