I think ... - Linuxhttps://blog.kmonsoor.com/2021-03-31T00:00:00+06:00Pimping up My Linux Terminal2021-03-31T00:00:00+06:002021-03-31T00:00:00+06:00Khaled Monsoortag:blog.kmonsoor.com,2021-03-31:/pimp-up-my-terminal/<p>How do I pimp up my Linux terminal? A quick trip through Zsh, Oh-my-zsh, and other power tools to make the command-line-based workflow smooth and&nbsp;cool.</p><p>The purpose of this post is to be my quick, copy-paste source of the commands that I use to set up my terminal on a new *nix system. However, if someone else finds it useful, that&rsquo;d be some cherries on&nbsp;top.</p> <p>This command prompt in the below image is the end&nbsp;goal.</p> <p><img alt="The end goal of this post" src="https://i.imgur.com/oZahIog.png"></p> <p>Assuming, I&rsquo;m on a standard pc/server with Ubuntu Linux and I have <span class="caps">CLI</span> access with <code>sudo</code>. For other Linux distros or <em>MacOS</em>, some commands might be slightly&nbsp;different.</p> <h2 id="step-1-confirm-that-zsh-is-up-to-date">Step-1: Confirm that Zsh is up-to-date<a class="headerlink" href="#step-1-confirm-that-zsh-is-up-to-date" title="Permanent link">&para;</a></h2> <p>While on most of the Linux systems Zsh is present by default, on others that&rsquo;s not the case. So, let&rsquo;s make sure about&nbsp;it.</p> <div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span><span class="gp">$ </span>sudo apt install zsh </code></pre></div> <p>Confirm the version. <code>Oh-my-zsh</code> recommends Zsh to be <code>5.0.8</code> or&nbsp;higher.</p> <div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span><span class="gp">$ </span>zsh --version <span class="linenos" data-linenos="2 "></span><span class="go">zsh 5.8 (x86_64-ubuntu-linux-gnu)</span> </code></pre></div> <p>Also, you gotta make sure that <code>git</code> (recommended v2.4.11 or higher) is also installed on the&nbsp;system.</p> <h2 id="step-2-install-oh-my-zsh-the-fun-configuration-framework">Step-2: Install Oh-my-zsh, the fun &ldquo;configuration&rdquo; framework<a class="headerlink" href="#step-2-install-oh-my-zsh-the-fun-configuration-framework" title="Permanent link">&para;</a></h2> <p>Install directly from the&nbsp;source.</p> <div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span><span class="gp">$ </span>sh -c <span class="s2">&quot;</span><span class="k">$(</span>curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh<span class="k">)</span><span class="s2">&quot;</span> </code></pre></div> <p>In the last step of this installation, it will ask to set Zsh as <span class="caps">THE</span> shell. Go&nbsp;ahead.</p> <p>Now we have the default prompt from <code>Oh-my-zsh</code>. </p> <p><img alt="After successful installation of Oh-my-zsh" src="https://i.imgur.com/HOVqqvi.png"></p> <p>Now, let&rsquo;s pimp up the prompt. Shall&nbsp;we?</p> <h2 id="step-3-install-powerlevel10k-a-powerful-prompt-theme">Step-3: Install <code>powerlevel10k</code>, a powerful prompt theme<a class="headerlink" href="#step-3-install-powerlevel10k-a-powerful-prompt-theme" title="Permanent link">&para;</a></h2> <p>I love the powerful Zsh theme <code>powerlevel10k</code>. More on <a href="https://github.com/romkatv/powerlevel10k#features">why this theme</a> is&nbsp;awesome.</p> <p>Let&rsquo;s install it on top of <code>oh-my-zsh</code>.</p> <div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span><span class="gp">$ </span>git clone --depth<span class="o">=</span><span class="m">1</span> <span class="se">\</span> <span class="linenos" data-linenos="2 "></span> https://github.com/romkatv/powerlevel10k.git <span class="se">\</span> <span class="linenos" data-linenos="3 "></span><span class="gp"> $</span><span class="o">{</span>ZSH_CUSTOM:-<span class="nv">$HOME</span>/.oh-my-zsh/custom<span class="o">}</span>/themes/powerlevel10k </code></pre></div> <p>Now, gotta set <code>ZSH_THEME="powerlevel10k/powerlevel10k"</code> in <code>~/.zshrc</code> by adding that manually in the&nbsp;file.</p> <h2 id="step-4-make-sure-the-prompt-looks-like-as-you-want">Step-4: Make sure the prompt looks like as you want<a class="headerlink" href="#step-4-make-sure-the-prompt-looks-like-as-you-want" title="Permanent link">&para;</a></h2> <p>In this step, I&rsquo;m gonna bring in my already open-sourced Zsh config file aka <code>.zshrc</code>. </p> <div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span><span class="gp"># </span>deleting the current one <span class="p">&amp;</span> get my personal one from GitHub <span class="linenos" data-linenos="2 "></span><span class="gp">$ </span>rm .zshrc <span class="linenos" data-linenos="3 "></span><span class="gp">$</span> <span class="linenos" data-linenos="4 "></span><span class="gp">$ </span>wget https://raw.githubusercontent.com/kmonsoor/dot-files/master/.zshrc </code></pre></div> <p>I kept the powerlevel10k configs as comments so that Zsh doesn&rsquo;t complain if I use the config file early. Have to set <code>ZSH_THEME="powerlevel10k/powerlevel10k"</code> in the <code>~/.zshrc</code> as&nbsp;well.</p> <p>Otherwise, once the <code>powerlevel10k</code> theme will run for the first time by Zsh, a very friendly step-by-step prompt will run you through towards a desirable prompt for you. Also, whenever you want, you can invoke the config-wizard by executing <code>p10k configure</code> on the&nbsp;shell.</p> <p>Now is the time to enable the changes by restarting Zsh and enjoy the new config and the powerful&nbsp;prompt.</p> <div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span><span class="gp">$ </span><span class="nb">exec</span> zsh </code></pre></div> <h2 id="optional">Optional<a class="headerlink" href="#optional" title="Permanent link">&para;</a></h2> <p>Also, I usually install this very useful, but external plugin <code>zsh-syntax-highlighting</code> for&nbsp;oh-my-zsh.</p> <p><div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span><span class="gp">$ </span>git clone https://github.com/zsh-users/zsh-syntax-highlighting.git <span class="si">${</span><span class="nv">ZSH_CUSTOM</span><span class="k">:-</span><span class="p">~/.oh-my-zsh/custom</span><span class="si">}</span>/plugins/zsh-syntax-highlighting </code></pre></div> Don&rsquo;t forget to activate the plugin by including it in ~/.zshrc. For that, add <code>zsh-syntax-highlighting</code> inside the list of other&nbsp;plugins.</p> <p>plugins=( plugin_a plugin_b&nbsp;zsh-syntax-highlighting)</p>Install the latest Zsh on CentOS2020-10-20T00:00:00+06:002020-10-20T00:00:00+06:00Khaled Monsoortag:blog.kmonsoor.com,2020-10-20:/install-latest-Zsh-on-CentOS/<p>If you&rsquo;re trying to install the latest version of Zsh instead of the default old one, here you&nbsp;go.</p><p>As the <strong>default</strong> Zsh on CentOS is usually an older version, many cool things are not possible on this version of Zsh, like installing <a href="https://ohmyz.sh/">oh-my-zsh</a> or using awesome <a href="https://github.com/romkatv/powerlevel10k">powerlevel10k</a> prompt system, it&rsquo;s understandable if you&rsquo;d like to have the latest Zsh on your system. Easy peasy&nbsp;!! </p> <p><strong>Note</strong>: Please remember to remove the <code>sudo</code> from the commands if you are already in &ldquo;root&rdquo; or sudo-er&nbsp;mode </p> <p>We&rsquo;ll be following these&nbsp;steps:</p> <div class="toc"> <ul> <li><a href="#install-the-pre-requisites">Install the&nbsp;pre-requisites</a></li> <li><a href="#download-the-latest-source">Download the latest&nbsp;source</a></li> <li><a href="#build-install">Build <span class="amp">&amp;</span>&nbsp;Install</a></li> <li><a href="#final-steps">Final&nbsp;steps</a></li> <li><a href="#related">Related</a></li> </ul> </div> <h1 id="install-the-pre-requisites">Install the pre-requisites<a class="headerlink" href="#install-the-pre-requisites" title="Permanent link">&para;</a></h1> <p>We need <span class="caps">GCC</span> (C++ compiler) and other related stuffs for building Zsh from the source&nbsp;code. </p> <div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span><span class="gp">$ </span>sudo yum groupinstall <span class="s2">&quot;Development tools&quot;</span> <span class="linenos" data-linenos="2 "></span><span class="gp">$ </span>sudo yum install ncurses-devel </code></pre></div> <p>Now, check if <span class="caps">GCC</span> is installed properly, by<br> <div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span><span class="gp">$ </span>gcc -v </code></pre></div></p> <h1 id="download-the-latest-source">Download the latest source<a class="headerlink" href="#download-the-latest-source" title="Permanent link">&para;</a></h1> <p>Now, we gonna get the latest code of Zsh.<br> Please update the link (in the shown command) with the latest by checking <a href="https://www.zsh.org/pub/">this web-folder</a>.<br> Don&rsquo;t forget to update the filename as well, if&nbsp;needed.</p> <div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span><span class="gp">$ </span><span class="nb">cd</span> /usr/local/src <span class="linenos" data-linenos="2 "></span><span class="gp">$ </span>sudo curl -L https://www.zsh.org/pub/zsh-5.8.tar.xz <span class="se">\</span> <span class="linenos" data-linenos="3 "></span>-o zsh-5.8.tar.xz </code></pre></div> <h1 id="build-install">Build <span class="amp">&amp;</span> Install<a class="headerlink" href="#build-install" title="Permanent link">&para;</a></h1> <p>Unzip the file, &ldquo;dig in&rdquo; to the folder, and build <span class="amp">&amp;</span> install from the&nbsp;source. </p> <div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span><span class="gp">$ </span>sudo tar -xf zsh-5.8.tar.xz <span class="c1"># the actual version of the downloaded file might be different</span> <span class="linenos" data-linenos="2 "></span><span class="gp">$ </span><span class="nb">cd</span> zsh-5.8 <span class="linenos" data-linenos="3 "></span><span class="gp">$ </span>sudo ./configure <span class="o">&amp;&amp;</span> sudo make <span class="o">&amp;&amp;</span> sudo make install </code></pre></div> <h1 id="final-steps">Final steps<a class="headerlink" href="#final-steps" title="Permanent link">&para;</a></h1> <p>Add Zsh to the login shells by adding &lsquo;/usr/local/bin/zsh&rsquo; on the last line of the config file, <code>/etc/shells</code> </p> <div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span><span class="gp">$ </span>sudo -e /etc/shells <span class="linenos" data-linenos="2 "></span><span class="gp">$ </span>sudo chsh <span class="nv">$USER</span> </code></pre></div> <p>Update the system&rsquo;s default symlink to the new Zsh version.<br> <div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span><span class="gp">$ </span>sudo ln -sf /usr/local/bin/zsh /bin/zsh <span class="linenos" data-linenos="2 "></span><span class="gp">$ </span>zsh --version </code></pre></div></p> <p>It&rsquo;s always a good habit to clean up after doing stuffs. ;) <div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span><span class="gp">$ </span>sudo make clean </code></pre></div></p> <p>That&rsquo;s it&nbsp;!</p> <p><img alt="voila" class="noZoom" src="https://i.imgur.com/BEFIOXfm.jpg"></p> <h1 id="related">Related<a class="headerlink" href="#related" title="Permanent link">&para;</a></h1> <p>Want to have a super, cool-looking command shell? Gotcha, fam. Check out my blog on <strong><a href="https://blog.kmonsoor.com/pimp-up-my-terminal/">Pimping up My Linux Terminal</a></strong>.</p> <hr> <p>If you find this post helpful, you can show your support <a href="https://www.patreon.com/kmonsoor">through Patreon</a> or <a href="https://paypal.me/KhaledMonsoor/">Paypal</a> or by <a href="https://ko-fi.com/kmonsoor">buying me a coffee</a>. <em>Thanks!</em></p>Install latest Python 3 on Linux CentOS 72018-07-07T00:00:00+06:002018-07-07T00:00:00+06:00Khaled Monsoortag:blog.kmonsoor.com,2018-07-07:/install-latest-python3-on-centos-7/<p>Install the latest and greatest Python 3 on CentOS 7&nbsp;systems</p><h2 id="why">Why<a class="headerlink" href="#why" title="Permanent link">&para;</a></h2> <p>Not all distro created equal. <br> Some are created to join the space race, some are to hold unto the leagcy, some are cutting-edge, some are cutting edge. Some are born to boot-up IoT devices some are to push out heavy&nbsp;graphics.</p> <p>That&rsquo;s the fun (albeit, power) of&nbsp;Linux.</p> <p><img alt="CentOS 7 logo" class="noZoom" src="https://i.imgur.com/6ZFCdoM.jpg"></p> <p>CentOS 7 is a powerful and stable distro that runs on thousands (probably, millions) production-grade servers.<br> In the matter of stability, it&rsquo;s a beast. However, it doesn&rsquo;t ship with Python 3, by default. You can install it via <span class="caps">EPEL</span> repository, or the below simple&nbsp;steps.</p> <p>Also, take a note. The Python <strong>2</strong> comes with the system, which is probably 2.7.5, do <strong><span class="caps">NOT</span></strong> mess with it. Many system components rely on that specific version. If you need the latest versions of 2, use <code>virtualenv</code> or <code>pipenv</code>.</p> <h3 id="prepare-your-system">Prepare your system<a class="headerlink" href="#prepare-your-system" title="Permanent link">&para;</a></h3> <p>Start with installing pre-requisite utilities for compilation and development&nbsp;support.</p> <div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span>$ sudo yum update <span class="o">&amp;&amp;</span> sudo yum groupinstall -y <span class="s2">&quot;development tools&quot;</span> <span class="linenos" data-linenos="2 "></span>$ sudo yum install -y zlib-devel bzip2-devel openssl-devel ncurses-devel <span class="se">\</span> <span class="linenos" data-linenos="3 "></span> sqlite-devel readline-devel tk-devel gdbm-devel <span class="se">\</span> <span class="linenos" data-linenos="4 "></span> db4-devel libpcap-devel xz-devel expat-devel </code></pre></div> <h3 id="download-latest-python-source-code-from-pythonorg">Download latest Python source code from Python.org<a class="headerlink" href="#download-latest-python-source-code-from-pythonorg" title="Permanent link">&para;</a></h3> <div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span>$ wget https://www.python.org/ftp/python/3.6.6/Python-3.6.6.tar.xz <span class="linenos" data-linenos="2 "></span>$ tar xf Python-3.6.6.tar.xz <span class="linenos" data-linenos="3 "></span>$ <span class="nb">cd</span> Python-3.6.6 </code></pre></div> <h3 id="enable-performance-optimizations-optional-but-highly-recommended">Enable performance optimizations (optional, but highly recommended)<a class="headerlink" href="#enable-performance-optimizations-optional-but-highly-recommended" title="Permanent link">&para;</a></h3> <div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span>$ ./configure --prefix<span class="o">=</span>/usr/local --enable-shared <span class="nv">LDFLAGS</span><span class="o">=</span><span class="s2">&quot;-Wl,-rpath /usr/local/lib&quot;</span> <span class="linenos" data-linenos="2 "></span>$ ./configure --enable-optimizations </code></pre></div> <h3 id="build-and-install">Build and install<a class="headerlink" href="#build-and-install" title="Permanent link">&para;</a></h3> <div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span>$ make <span class="linenos" data-linenos="2 "></span>$ sudo make altinstall </code></pre></div> <p>Now, Python 3.6.6 is ready to be used in your system; located in <code>/usr/local/bin/python3.6</code> <div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span>$ which python3.6 <span class="linenos" data-linenos="2 "></span>/usr/local/bin/python3.6 <span class="linenos" data-linenos="3 "></span> <span class="linenos" data-linenos="4 "></span>$ python3.6 <span class="linenos" data-linenos="5 "></span>Python <span class="m">3</span>.6.6 <span class="o">(</span>default, Jul <span class="m">10</span> <span class="m">2018</span>, <span class="m">14</span>:04:26<span class="o">)</span> <span class="linenos" data-linenos="6 "></span><span class="o">[</span>GCC <span class="m">4</span>.8.5 <span class="m">20150623</span> <span class="o">(</span>Red Hat <span class="m">4</span>.8.5-28<span class="o">)]</span> on linux <span class="linenos" data-linenos="7 "></span>Type <span class="s2">&quot;help&quot;</span>, <span class="s2">&quot;copyright&quot;</span>, <span class="s2">&quot;credits&quot;</span> or <span class="s2">&quot;license&quot;</span> <span class="k">for</span> more information. <span class="linenos" data-linenos="8 "></span>&gt;&gt;&gt; </code></pre></div></p> <p>For convenience, you can create a symbolic-link with a shorter name. If you had system-installed Python3 (unlikely), <strong>don&rsquo;t</strong> do this, as some system-components may depend on that specific older version of Python 3. <div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span>$ sudo ln -s /usr/local/bin/python3.6 /usr/local/bin/python3 <span class="linenos" data-linenos="2 "></span>$ python3 <span class="linenos" data-linenos="3 "></span>Python <span class="m">3</span>.6.6 <span class="o">(</span>default, Jul <span class="m">10</span> <span class="m">2018</span>, <span class="m">14</span>:04:26<span class="o">)</span> <span class="linenos" data-linenos="4 "></span><span class="o">[</span>GCC <span class="m">4</span>.8.5 <span class="m">20150623</span> <span class="o">(</span>Red Hat <span class="m">4</span>.8.5-28<span class="o">)]</span> on linux <span class="linenos" data-linenos="5 "></span>Type <span class="s2">&quot;help&quot;</span>, <span class="s2">&quot;copyright&quot;</span>, <span class="s2">&quot;credits&quot;</span> or <span class="s2">&quot;license&quot;</span> <span class="k">for</span> more information. <span class="linenos" data-linenos="6 "></span>&gt;&gt;&gt; </code></pre></div></p> <h2 id="install-wheel-and-pip"><del>Install wheel and pip</del><a class="headerlink" href="#install-wheel-and-pip" title="Permanent link">&para;</a></h2> <p>You don&rsquo;t need to, because <code>Python 3.6.6</code> includes these necessary tools included. <div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span>$ pip3.6 -V <span class="linenos" data-linenos="2 "></span>pip <span class="m">10</span>.0.1 from /usr/local/lib/python3.6/site-packages/pip <span class="o">(</span>python <span class="m">3</span>.6<span class="o">)</span> <span class="linenos" data-linenos="3 "></span>$ wheel version <span class="linenos" data-linenos="4 "></span>wheel <span class="m">0</span>.29.0 </code></pre></div></p>HA(High-Availability) Setup for InfluxDB2018-01-18T00:00:00+06:002018-01-18T00:00:00+06:00Khaled Monsoortag:blog.kmonsoor.com,2018-01-18:/ha-setup-for-influxdb/<p>Create a robust, highly-available, time-series InfluxDB cluster with the community(free) version of&nbsp;it</p><p><strong><span class="caps">NOTE</span></strong> <em>Since I have written this article, all the components used in this below architecture have gone through many updates and releases. While the general premise involving <code>influxdb-relay</code> and the multiplexing might still hold, please sync up with the latest release docs before jumping into some serious system&nbsp;design.</em></p> <hr> <p>Currently, from version 0.9, you cannot create an InfluxDB cluster from the open-sourced free edition. Only commercially available InfluxDB Enterprise can do that for now. That stirred up the early-adopter enthusiast users, especially for their usage in professional setups. They complained that InfluxData, the company behind InfluxDB, is trying to milk the <span class="caps">OSS</span> solution for&nbsp;profit.</p> <p><img alt="Archiving isn't easy ... tobias-fischer-PkbZahEG2Ng" src="https://i.imgur.com/0IdYOYnl.jpg"></p> <p>I can&rsquo;t blame the InfluxData guys much, as they got to pay their bills too. So far, we — the users of open-source systems — couldn&rsquo;t show much promise about the financial realities of the projects. Continuing development of <span class="caps">OSS</span> products, by only depending on donations, patrons, or enterprise sponsorship, is far too rare and unpredictable, even for the projects that many successful organizations heavily rely&nbsp;on.</p> <p>Anyways, InfluxDB then promised and later introduced <code>Influx Relay</code> as a complimentary consolation for missing <span class="caps">HA</span> parts of InfluxDB. You can get the details here and here about&nbsp;that. </p> <h2 id="premise">Premise<a class="headerlink" href="#premise" title="Permanent link">&para;</a></h2> <p>For my needs, I have to try to create a reliable <span class="caps">HA</span>(High-Availability) setup from available free options, hence InfluxDB and the relay. It&rsquo;s quite a bit far from an InfluxDB-cluster in terms of robustness or ease of setup, but it&rsquo;s got the job done, at least for&nbsp;me.</p> <p>I needed a setup to receive system-stats from at least 500+ instances and to store them for a while, but without breaking the bank in bills from <span class="caps">AWS</span>. Meaning, I could ask for and could use only couple of instances for my&nbsp;solution.</p> <p>Here were my&nbsp;trade-offs.</p> <ul> <li>Not too many instances for this purpose. Neither, any of the heavyweight lifters e.g. <span class="caps">AWS</span>&rsquo; m3-xlarge etc. To use only what&rsquo;s&nbsp;necessary. </li> <li>To satisfy the budget, hence avoiding pay-per-use solutions as far as it is&nbsp;possible.</li> <li>Solutions must not be crazy complex, so that handover to the DevOps team be&nbsp;smooth.</li> <li>Reading the data would be too rarely w.r.t. writing. The related Grafana dashboards will be only used to investigate issues by a handful of&nbsp;people.</li> </ul> <h2 id="overall-design">Overall Design<a class="headerlink" href="#overall-design" title="Permanent link">&para;</a></h2> <h3 id="write">Write<a class="headerlink" href="#write" title="Permanent link">&para;</a></h3> <p>From a birds&rsquo; eye view, I decided to use two server instances to run parallelly, hosting InfluxDB on them independently and then sending the same data over to them for storing. This scheme mostly looks like <a href="https://en.wikipedia.org/wiki/Standard_RAID_levels#RAID_1"><span class="caps">RAID</span>-1 systems</a>.</p> <p><img alt="Overall architecture" src="https://i.imgur.com/ZKYIyOd.png"></p> <p>That brings up a couple of&nbsp;challenges.</p> <ul> <li> <p>None of the agents I used on the sender side could multiplex output. That means, they were able to send data to a single destination, not multiple. On the Windows front, I&rsquo;ve used <code>Telegraf</code> which is able randomly to switch between pre-listed destinations, but <span class="caps">NOT</span> multiple at-once.<br> In the case of Linux hosts, I used <code>Netdata</code> which is excellent in its own right, but unable to send stats to multiple destinations.<br> Here comes <code>Influx-relay</code>. It can receive time-series data-stream from hosts on a <span class="caps">TCP</span> or <span class="caps">UDP</span> port, buffer for a while, and then re-send those received and buffered data to multiple receive ends which can either be an InfluxDB instance or another listening Influx-relay instances.<br> This chaining can broaden the relaying scheme even further. However, for my purpose, this relay-chaining was not necessary. Rather, from the relay, I am sending data to the separate InfluxDB instances, running on two separate&nbsp;instances. </p> </li> <li> <p>Now that I partially multiplexed the output, my hosts (senders) still are able to send to one destination. So, I need a proxy as well as a load-balancer. For a while, I was torn between <span class="caps">NGINX</span> and HAProxy. Both were new to&nbsp;me. </p> </li> </ul> <p>However, for a couple of reasons, I went for HAProxy. Firstly, I don&rsquo;t need <span class="caps">HTTP</span> session management. Secondly, as I wanted to keep my <span class="caps">UDP</span> for later, HAProxy was perfectly capable of that.<br> <span class="caps">NGINX</span> has the support recently, but the maturity was a concern. Also, configuring <span class="caps">NGINX</span> seems a little intimidating (which I know might not be so true). Last but not least, and for what it&rsquo;s worth, out-of-the-box, HAProxy&rsquo;s stat page carries much more in-depth information than that of free-version of <span class="caps">NGINX</span>.<br> Upon receiving the stats stream, HAProxy was supposed to send that to different Influx-relays in a load-balanced&nbsp;fashion.</p> <p>So, here&rsquo;s my rough&nbsp;plan. </p> <p>collector-agent &rarr; HAProxy &rarr; (50/50 load-balanced) &rarr; Influx-relay &rarr; (multiplexed) &rarr; 2 InfluxDB&nbsp;instances</p> <p>Now, each one of the received data is to go to both of the InfluxDB instances, or at least to one in case of failure (or, overload per se) of any the relays or Influx instances.   Also, I have chosen to keep Influx-relays deployed as Dockerized and kept HAProxy and InfluxDB instances running as native services. Of course, you can Dockerize HAProxy and InfluxDB,&nbsp;too. </p> <h3 id="read">Read<a class="headerlink" href="#read" title="Permanent link">&para;</a></h3> <p>As I&rsquo;ve already noted in the section that reading the data, meaning to fetch data to visualize on Grafana end, will happen rarely and sporadically; only to investigate alarms or any other client-side performance&nbsp;issues. </p> <p>So, the read requests, reaching the HAProxy end, needed not much routing, other than directly to InfluxDB itself. Still, to better distribute the load I decided to load-balance it 50/50&nbsp;basis.</p> <h3 id="ports">Ports<a class="headerlink" href="#ports" title="Permanent link">&para;</a></h3> <ul> <li>As all the <span class="caps">READ</span> requests are routed through <code>HAProxy</code> running on each of the instances, to the external world only HAProxy&rsquo;s port should be opened for this&nbsp;purpose. </li> <li>On the other hand, for <span class="caps">WRITE</span> requests, InfluxDBs are receiving data from relays, one of its own instance and another one on other instance, so InfluxDB should listen on its own port for <span class="caps">WRITE</span> requests only. But, this must be accessible only from own <span class="caps">VPS</span> zone, but not open to the outside&nbsp;world.</li> <li>In case of HAProxy as well as InfluxDB, you can use the default ports, obviously, which is 8086 <span class="amp">&amp;</span> 8088 respectively. Or, you can choose to go for other ports (security through obfuscation). Your call. In this writing, I&rsquo;ll go with the&nbsp;defaults.</li> </ul> <h3 id="authentication-ssl">Authentication, <span class="caps">SSL</span><a class="headerlink" href="#authentication-ssl" title="Permanent link">&para;</a></h3> <p>You can configure <span class="caps">SSL</span> with your own server certificates through the HAProxy configs. You can even go for <span class="caps">SSL</span> from the relays to InfluxDB writes. If your sender hosts are connecting to your HAProxy through public internet, you should at least go for password-based authentication, better to utilize <span class="caps">SSL</span>. However, for brevity&rsquo;s sake, I&rsquo;ll skip them in this&nbsp;post.</p> <p>**Note: * Please bear in mind, this is an &ldquo;in-progress&rdquo; post; prematurely published to force me to work on it. I have the plan to add all the necessary configurations <span class="amp">&amp;</span> commands, that I used,&nbsp;here.</p>Increase virtual-disk size in VirtualBox on Windows 72012-05-26T08:02:00+06:002012-05-26T08:02:00+06:00Khaled Monsoortag:blog.kmonsoor.com,2012-05-26:/increase-virtual-disk-size-in-virtualbox-windows/<p>Stuck with your small virtual disk partition for VirtualBox? I also stuck with same problem; researched many forums, and here is the gist. Find out&nbsp;how.</p><p>Are you stuck with your small virtual disk partition for VirtualBox? You created the partition for some testing <span class="amp">&amp;</span> practicing, now it needs more space. I was also stuck with the same problem; so I researched many forums, and here is the&nbsp;gist.</p> <p>[Note: This procedure won&rsquo;t work for <span class="caps">VM</span> with snapshots. So, please take note the fact about your system&nbsp;beforehand.]</p> <ul> <li>Download <a href="http://gparted.org/download.php">Gparted</a>, disk manager for Linux. It&rsquo;ll come as an <span class="caps">ISO</span>&nbsp;file.</li> <li>Boot into your guest <span class="caps">OS</span>, check, with df command, which partition you need to grow. Take note of that specific mounted <span class="caps">HD</span>, such as&nbsp;/dev/hdb/sda3</li> <li>Take backup of your existing data, as I <span class="caps">WILL</span> <span class="caps">NOT</span> <span class="caps">TAKE</span> <span class="caps">ANY</span> <span class="caps">RESPONSIBILITY</span> <span class="caps">IF</span> <span class="caps">YOU</span> <span class="caps">DAMAGE</span> <span class="caps">YOUR</span> <span class="caps">DATA</span>.</li> <li>In host <span class="caps">OS</span>, Goto the command prompt by running,&nbsp;cmd.exe</li> <li>Navigate to the Virtualbox installation&nbsp;folder</li> <li>Execute the&nbsp;command:</li> </ul> <div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span><span class="go">C:\ VBoxManage modifyhd X:\yourVM_DiskPath_InHost\yourVM_Disk.vdi --resize 40960</span> </code></pre></div> <p>you will see progress as&nbsp;below:</p> <p><img alt="10% ... 20% .. .. 100%" src="http://i.imgur.com/iYORelg.png"></p> <p>If you fail with a message like&nbsp;thid</p> <blockquote> <p><span class="dquo">&ldquo;</span>VBoxManage.exe: error: Resize hard disk operation for this format is not implemented&nbsp;yet!&rdquo;</p> </blockquote> <p>Now, you need this tool <a href="https://forums.virtualbox.org/download/file.php?id=7579">CloneVDI.exe</a> from this VirtualBox forum-post. If you&rsquo;re using this tool, remember to check &ldquo;Increase virtual drive size to &rdquo; with your desired&nbsp;size.</p> <p><img alt="VDI_tool" src="http://i.imgur.com/YB49ZVk.png"></p> <ul> <li>Now, Load the <span class="caps">ISO</span> file to the <span class="caps">CD</span>/<span class="caps">DVD</span> drive of your virtual&nbsp;Linux.</li> </ul> <p><img alt="GParted.iso loaded on IDE Primary Master" src="http://i.imgur.com/UKyPkl8.png"></p> <ul> <li>Boot the Guest <span class="caps">OS</span>; from the boot menu, select <span class="caps">CD</span>/<span class="caps">DVD</span> drive, then it will boot in GParted tiny <span class="caps">OS</span>. Now the PartitionManager tool will come up automatically, like&nbsp;below:</li> </ul> <p><img alt="Gparted partition-manager" src="http://i.imgur.com/aK9kAtK.jpg"></p> <ul> <li>Now &ldquo;shrink/Grow&rdquo; or &ldquo;Move&rdquo; your desired partition, but be careful. Don&rsquo;t rename any of them. Be careful about your&nbsp;data.</li> <li>Don&rsquo;t worry, unless you clicked Apply, nothing has actually took place. When you are done with moving and resizing, you have to click <strong><code>Apply</code></strong> to commit the&nbsp;change</li> </ul> <p><img alt="just before applying" src="http://i.imgur.com/wUMCHVQ.jpg"></p> <ul> <li>Once completed, close Gparted, and then shutdown the <span class="caps">OS</span></li> <li>Unload the <span class="caps">ISO</span> aka virtual <span class="caps">CD</span> from virtual <span class="caps">OS</span></li> <li>Boot into the virtual <span class="caps">OS</span>&nbsp;again</li> <li>Now, check that if the desired partition grew or not by using the <code>df</code> command</li> </ul> <p>Thanks for visiting my blog. If it just helped you, please feel free to &ldquo;Like&rdquo; or &ldquo;share&rdquo;. Also, your suggestion or comment would be great as&nbsp;well.</p> <hr> <p>If you find this post helpful, you can show your support <a href="https://www.patreon.com/kmonsoor">through Patreon</a> or <a href="https://paypal.me/KhaledMonsoor/">Paypal</a> or by <a href="https://ko-fi.com/kmonsoor">buying me a coffee</a>. <em>Thanks!</em></p>