<!DOCTYPE html>
<html lang="en-US" prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# article: http://ogp.me/ns/article#">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="profile" href="http://gmpg.org/xfn/11">
  <link rel="pingback" href="http://secaserver.com/xmlrpc.php">
  <title>SecaServer</title>
  <meta name="description" content="how-to | notes | tips &amp; tricks | knowledge base">
  <meta property="og:type" content="blog">
  <meta property="og:title" content="SecaServer">
  <meta property="og:description" content="how-to | notes | tips &amp; tricks | knowledge base">
  <meta property="og:url" content="http://secaserver.com/">
  <meta property="og:site_name" content="SecaServer">
  <meta name="twitter:card" content="summary">
  <link rel='dns-prefetch' href='//www.google.com'>
  <link rel='dns-prefetch' href='//s0.wp.com'>
  <link rel='dns-prefetch' href='//secure.gravatar.com'>
  <link rel='dns-prefetch' href='//ajax.googleapis.com'>
  <link rel='dns-prefetch' href='//fonts.googleapis.com'>
  <link rel='dns-prefetch' href='//s.w.org'>
  <link rel="alternate" type="application/rss+xml" title="SecaServer &raquo; Feed" href="http://secaserver.com/feed/">
  <link rel="alternate" type="application/rss+xml" title="SecaServer &raquo; Comments Feed" href="http://secaserver.com/comments/feed/">
  <script type='text/javascript' data-cfasync='false'>
  //<![CDATA[
    _SHR_SETTINGS = {"endpoints":{"local_recs_url":"http:\/\/blog.secaserver.com\/wp-admin\/admin-ajax.php?action=shareaholic_permalink_related"}};
  //]]>
  </script>
  <script type='text/javascript' data-cfasync='false' src='//apps.shareaholic.com/assets/pub/shareaholic.js' data-shr-siteid='59ea8ece087faa578e89af8b5033c235' async='async'></script>
  <meta name='shareaholic:site_name' content='SecaServer'>
  <meta name='shareaholic:language' content='en-US'>
  <meta name='shareaholic:article_visibility' content='private'>
  <meta name='shareaholic:site_id' content='59ea8ece087faa578e89af8b5033c235'>
  <meta name='shareaholic:wp_version' content='8.6.1'>
  <script type="text/javascript">
                        window._wpemojiSettings = {"baseUrl":"https:\/\/s.w.org\/images\/core\/emoji\/11\/72x72\/","ext":".png","svgUrl":"https:\/\/s.w.org\/images\/core\/emoji\/11\/svg\/","svgExt":".svg","source":{"concatemoji":"http:\/\/blog.secaserver.com\/wp-includes\/js\/wp-emoji-release.min.js?ver=4.9.9"}};
                        !function(a,b,c){function d(a,b){var c=String.fromCharCode;l.clearRect(0,0,k.width,k.height),l.fillText(c.apply(this,a),0,0);var d=k.toDataURL();l.clearRect(0,0,k.width,k.height),l.fillText(c.apply(this,b),0,0);var e=k.toDataURL();return d===e}function e(a){var b;if(!l||!l.fillText)return!1;switch(l.textBaseline="top",l.font="600 32px Arial",a){case"flag":return!(b=d([55356,56826,55356,56819],[55356,56826,8203,55356,56819]))&&(b=d([55356,57332,56128,56423,56128,56418,56128,56421,56128,56430,56128,56423,56128,56447],[55356,57332,8203,56128,56423,8203,56128,56418,8203,56128,56421,8203,56128,56430,8203,56128,56423,8203,56128,56447]),!b);case"emoji":return b=d([55358,56760,9792,65039],[55358,56760,8203,9792,65039]),!b}return!1}function f(a){var c=b.createElement("script");c.src=a,c.defer=c.type="text/javascript",b.getElementsByTagName("head")[0].appendChild(c)}var g,h,i,j,k=b.createElement("canvas"),l=k.getContext&&k.getContext("2d");for(j=Array("flag","emoji"),c.supports={everything:!0,everythingExceptFlag:!0},i=0;i<j.length;i++)c.supports[j[i]]=e(j[i]),c.supports.everything=c.supports.everything&&c.supports[j[i]],"flag"!==j[i]&&(c.supports.everythingExceptFlag=c.supports.everythingExceptFlag&&c.supports[j[i]]);c.supports.everythingExceptFlag=c.supports.everythingExceptFlag&&!c.supports.flag,c.DOMReady=!1,c.readyCallback=function(){c.DOMReady=!0},c.supports.everything||(h=function(){c.readyCallback()},b.addEventListener?(b.addEventListener("DOMContentLoaded",h,!1),a.addEventListener("load",h,!1)):(a.attachEvent("onload",h),b.attachEvent("onreadystatechange",function(){"complete"===b.readyState&&c.readyCallback()})),g=c.source||{},g.concatemoji?f(g.concatemoji):g.wpemoji&&g.twemoji&&(f(g.twemoji),f(g.wpemoji)))}(window,document,window._wpemojiSettings);
  </script>
  <style type="text/css">
  img.wp-smiley,
  img.emoji {
        display: inline !important;
        border: none !important;
        box-shadow: none !important;
        height: 1em !important;
        width: 1em !important;
        margin: 0 .07em !important;
        vertical-align: -0.1em !important;
        background: none !important;
        padding: 0 !important;
  }
  </style>
  <link rel='stylesheet' id='ccf-jquery-ui-css' href='//ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css?ver=4.9.9' type='text/css' media='all'>
  <link rel='stylesheet' id='ccf-form-css' href='http://secaserver.com/wp-content/plugins/custom-contact-forms/assets/build/css/form.min.css?ver=7.8.5' type='text/css' media='all'>
  <link rel='stylesheet' id='wp-syntax-css-css' href='http://secaserver.com/wp-content/plugins/wp-syntax/css/wp-syntax.css?ver=1.1' type='text/css' media='all'>
  <link rel='stylesheet' id='dashicons-css' href='http://secaserver.com/wp-includes/css/dashicons.min.css?ver=4.9.9' type='text/css' media='all'>
  <link rel='stylesheet' id='toivo-lite-fonts-css' href='https://fonts.googleapis.com/css?family=Lato%3A300%2C400%2C700%2C300italic%2C400italic%2C700italic%7CRaleway%3A400%2C600%2C500%2C700%2C800&#038;subset=latin%2Clatin-ext' type='text/css' media='all'>
  <link rel='stylesheet' id='genericons-css' href='http://secaserver.com/wp-content/plugins/jetpack/_inc/genericons/genericons/genericons.css?ver=3.1' type='text/css' media='all'>
  <link rel='stylesheet' id='toivo-lite-style-css' href='http://secaserver.com/wp-content/themes/toivo-lite/style.css?ver=4.9.9' type='text/css' media='all'>
  <style id='toivo-lite-style-inline-css' type='text/css'>

                        .site-header,
                        .custom-header-image .site-header > .wrap::before {
                                background-color: rgba( 59, 86, 103, 0.94);
                        }
  </style>
  <link rel='stylesheet' id='jetpack-widget-social-icons-styles-css' href='http://secaserver.com/wp-content/plugins/jetpack/modules/widgets/social-icons/social-icons.css?ver=20170506' type='text/css' media='all'>
  <link rel='stylesheet' id='jetpack_css-css' href='http://secaserver.com/wp-content/plugins/jetpack/css/jetpack.css?ver=6.3.2' type='text/css' media='all'>
  <link rel='stylesheet' id='thickbox-css' href='http://secaserver.com/wp-content/plugins/auto-thickbox-plus/thickbox.min.css?ver=1.9' type='text/css' media='all'>
  <script type='text/javascript' src='http://secaserver.com/wp-includes/js/jquery/jquery.js?ver=1.12.4'></script>
  <script type='text/javascript' src='http://secaserver.com/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.4.1'></script>
  <script type='text/javascript' src='http://secaserver.com/wp-content/plugins/plum-code-box/chili/jquery.chili-2.2.js?ver=2.2'></script>
  <script type='text/javascript' src='http://secaserver.com/wp-content/plugins/plum-code-box/chili/recipes.js?ver=2.2'></script>
  <script type='text/javascript' src='http://secaserver.com/wp-includes/js/jquery/ui/core.min.js?ver=1.11.4'></script>
  <script type='text/javascript' src='http://secaserver.com/wp-includes/js/jquery/ui/datepicker.min.js?ver=1.11.4'></script>
  <script type='text/javascript'>
  jQuery(document).ready(function(jQuery){jQuery.datepicker.setDefaults({"closeText":"Close","currentText":"Today","monthNames":["January","February","March","April","May","June","July","August","September","October","November","December"],"monthNamesShort":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"nextText":"Next","prevText":"Previous","dayNames":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],"dayNamesShort":["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],"dayNamesMin":["S","M","T","W","T","F","S"],"dateFormat":"d MM yy","firstDay":1,"isRTL":false});});
  </script>
  <script type='text/javascript' src='http://secaserver.com/wp-includes/js/underscore.min.js?ver=1.8.3'></script>
  <script type='text/javascript'>
  /* <![CDATA[ */
  var ccfSettings = {"ajaxurl":"http:\/\/blog.secaserver.com\/wp-admin\/admin-ajax.php","required":"This field is required.","date_required":"Date is required.","hour_required":"Hour is required.","minute_required":"Minute is required.","am-pm_required":"AM\/PM is required.","match":"Emails do not match.","email":"This is not a valid email address.","recaptcha":"Your reCAPTCHA response was incorrect.","recaptcha_theme":"light","phone":"This is not a valid phone number.","digits":"This phone number is not 10 digits","hour":"This is not a valid hour.","date":"This date is not valid.","minute":"This is not a valid minute.","fileExtension":"This is not an allowed file extension","fileSize":"This file is bigger than","unknown":"An unknown error occured.","website":"This is not a valid URL. URL's must start with http(s):\/\/"};
  /* ]]> */
  </script>
  <script type='text/javascript' src='http://secaserver.com/wp-content/plugins/custom-contact-forms/assets/build/js/form.min.js?ver=7.8.5'></script>
  <link rel='https://api.w.org/' href='http://secaserver.com/wp-json/'>
  <link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://secaserver.com/xmlrpc.php?rsd">
  <link rel="wlwmanifest" type="application/wlwmanifest+xml" href="http://secaserver.com/wp-includes/wlwmanifest.xml">
  <link rel='shortlink' href='https://wp.me/1FuWZ'>
  <script type='text/javascript' src='http://secaserver.com/wp-content/plugins/anti-captcha/anti-captcha-0.3.js.php?ver=16002f7a455a94aa4e91cc34ebdb9f2d'></script>
  <script type='text/javascript' src='http://secaserver.api.oneall.com/socialize/library.js'></script>
  <script type="text/javascript">
  (function(url){
        if(/(?:Chrome\/26\.0\.1410\.63 Safari\/537\.31|WordfenceTestMonBot)/.test(navigator.userAgent)){ return; }
        var addEvent = function(evt, handler) {
                if (window.addEventListener) {
                        document.addEventListener(evt, handler, false);
                } else if (window.attachEvent) {
                        document.attachEvent('on' + evt, handler);
                }
        };
        var removeEvent = function(evt, handler) {
                if (window.removeEventListener) {
                        document.removeEventListener(evt, handler, false);
                } else if (window.detachEvent) {
                        document.detachEvent('on' + evt, handler);
                }
        };
        var evts = 'contextmenu dblclick drag dragend dragenter dragleave dragover dragstart drop keydown keypress keyup mousedown mousemove mouseout mouseover mouseup mousewheel scroll'.split(' ');
        var logHuman = function() {
                if (window.wfLogHumanRan) { return; }
                window.wfLogHumanRan = true;
                var wfscr = document.createElement('script');
                wfscr.type = 'text/javascript';
                wfscr.async = true;
                wfscr.src = url + '&r=' + Math.random();
                (document.getElementsByTagName('head')[0]||document.getElementsByTagName('body')[0]).appendChild(wfscr);
                for (var i = 0; i < evts.length; i++) {
                        removeEvent(evts[i], logHuman);
                }
        };
        for (var i = 0; i < evts.length; i++) {
                addEvent(evts[i], logHuman);
        }
  })('//blog.secaserver.com/?wordfence_lh=1&hid=D953B86CC9AD7FB60F25F46FF76CE60D');
  </script>
  <style data-context="foundation-flickity-css">
  /*! Flickity v2.0.2
  http://flickity.metafizzy.co
  ---------------------------------------------- */.flickity-enabled{position:relative}.flickity-enabled:focus{outline:0}.flickity-viewport{overflow:hidden;position:relative;height:100%}.flickity-slider{position:absolute;width:100%;height:100%}.flickity-enabled.is-draggable{-webkit-tap-highlight-color:transparent;tap-highlight-color:transparent;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.flickity-enabled.is-draggable .flickity-viewport{cursor:move;cursor:-webkit-grab;cursor:grab}.flickity-enabled.is-draggable .flickity-viewport.is-pointer-down{cursor:-webkit-grabbing;cursor:grabbing}.flickity-prev-next-button{position:absolute;top:50%;width:44px;height:44px;border:none;border-radius:50%;background:#fff;background:hsla(0,0%,100%,.75);cursor:pointer;-webkit-transform:translateY(-50%);transform:translateY(-50%)}.flickity-prev-next-button:hover{background:#fff}.flickity-prev-next-button:focus{outline:0;box-shadow:0 0 0 5px #09F}.flickity-prev-next-button:active{opacity:.6}.flickity-prev-next-button.previous{left:10px}.flickity-prev-next-button.next{right:10px}.flickity-rtl .flickity-prev-next-button.previous{left:auto;right:10px}.flickity-rtl .flickity-prev-next-button.next{right:auto;left:10px}.flickity-prev-next-button:disabled{opacity:.3;cursor:auto}.flickity-prev-next-button svg{position:absolute;left:20%;top:20%;width:60%;height:60%}.flickity-prev-next-button .arrow{fill:#333}.flickity-page-dots{position:absolute;width:100%;bottom:-25px;padding:0;margin:0;list-style:none;text-align:center;line-height:1}.flickity-rtl .flickity-page-dots{direction:rtl}.flickity-page-dots .dot{display:inline-block;width:10px;height:10px;margin:0 8px;background:#333;border-radius:50%;opacity:.25;cursor:pointer}.flickity-page-dots .dot.is-selected{opacity:1}
  </style>
  <style data-context="foundation-slideout-css">
  .slideout-menu{position:fixed;left:0;top:0;bottom:0;right:auto;z-index:0;width:256px;overflow-y:auto;-webkit-overflow-scrolling:touch;display:none}.slideout-menu.pushit-right{left:auto;right:0}.slideout-panel{position:relative;z-index:1;will-change:transform}.slideout-open,.slideout-open .slideout-panel,.slideout-open body{overflow:hidden}.slideout-open .slideout-menu{display:block}.pushit{display:none}
  </style>
  <link rel='dns-prefetch' href='//v0.wordpress.com'>
  <style type="text/css" id="custom-header-css">
  @media screen and (min-width: 1px) { body.custom-header-image .site-header { background: url(http://secaserver.com/wp-content/themes/toivo-lite/images/header.jpg) no-repeat 50% 50%; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; } }.site-title, .site-title a, .site-description, .site-description a { color: #fff }.site-title a { border-color: #fff }
  </style>
  <style type="text/css" id="custom-background-css">
  body.custom-background { background: #fafafa; }
  </style>
  <style>
  .ios7.web-app-mode.has-fixed header{ background-color: rgba(3,122,221,.88);}
  </style>
</head>
<body class="home blog custom-header-image top-menus-disabled layout-2c-l custom-background" itemscope itemtype="http://schema.org/Blog">
  <div id="page" class="site">
    <a class="skip-link screen-reader-text" href="#content">Skip to content</a>
    <header id="masthead" class="site-header" role="banner" aria-labelledby="site-title" itemscope="itemscope" itemtype="http://schema.org/WPHeader">
      <div class="wrap">
        <div class="site-branding">
          <h1 id="site-title" class="site-title" itemprop="headline"><a href="http://secaserver.com/" rel="home">SecaServer</a></h1>
          <div id="site-description" class="site-description" itemprop="description">
            how-to | notes | tips &amp; tricks | knowledge base
          </div>
        </div>
      </div>
    </header><button id="nav-toggle">Menu</button>
    <nav id="menu-primary" class="menu main-navigation" role="navigation" aria-label="Primary Menu" itemscope="itemscope" itemtype="http://schema.org/SiteNavigationElement">
      <h2 class="screen-reader-text">Primary Menu</h2>
      <div class="wrap">
        <div id="menu-primary-items" class="menu-items">
          <ul>
            <li class="page_item page-item-109">
              <a href="http://secaserver.com/about/">About</a>
            </li>
            <li class="page_item page-item-877">
              <a href="http://secaserver.com/contact/">Contact</a>
            </li>
          </ul>
        </div>
      </div>
    </nav>
    <div id="content" class="site-content">
      <div class="wrap">
        <div class="wrap-inside">
          <div id="primary" class="content-area">
            <main id="main" class="site-main" role="main">
              <article id="post-2874" class="post-2874 post type-post status-publish format-standard category-database category-sql tag-how-to-install-mysql-5-7 tag-install-mysql-5-7 tag-install-mysql-5-7-apt tag-install-mysql-5-7-debian tag-install-mysql-5-7-ubuntu entry" itemscope="itemscope" itemtype="http://schema.org/BlogPosting" itemprop="blogPost">
                <div class="entry-inner">
                  <header class="entry-header">
                    <div class="entry-meta">
                      <span class="entry-date"><span class="screen-reader-text">Posted on</span> <a href="http://secaserver.com/2016/04/installing-mysql-5-7-oracle-apt-repository/" rel="bookmark"><time class="entry-date" datetime="2016-04-14T17:49:27+00:00" itemprop="datePublished">14 April 2016</time></a></span><span class="byline"><span class="entry-author" itemprop="author" itemscope="itemscope" itemtype="http://schema.org/Person"><span class="screen-reader-text">Author</span> <a class="entry-author-link" href="http://secaserver.com/author/admin/" rel="author" itemprop="url"><span itemprop="name">SecaGuy</span></a></span></span> <span class="comments-link"><a href="http://secaserver.com/2016/04/installing-mysql-5-7-oracle-apt-repository/#respond" class="comments-link" itemprop="discussionURL">No Comments <span class="screen-reader-text">on Installing MySQL 5.7 (Oracle) using APT repository</span></a></span>
                    </div>
                    <h2 class="entry-title" itemprop="headline"><a href="http://secaserver.com/2016/04/installing-mysql-5-7-oracle-apt-repository/" rel="bookmark">Installing MySQL 5.7 (Oracle) using APT repository</a></h2>
                  </header>
                  <div class="entry-content" itemprop="articleBody">
                    <div class='shareaholic-canvas' data-app-id='9753856' data-app-id-name='index_above_content' data-app='share_buttons' data-title='Installing MySQL 5.7 (Oracle) using APT repository' data-link='http://secaserver.com/2016/04/installing-mysql-5-7-oracle-apt-repository/' data-summary=''></div>
                    <p>I got a task to test and deploy the latest MySQL 5.7 from Oracle on Ubuntu and Debian servers. It turns out with MySQL&#8217;s APT repository, this is very trivial. Here is how to get MySQL 5.7 installed on Debian-based systems:</p>
                    <p>1) Download mysql-apt-config from MySQL download page. Just click on the &#8220;Download&#8221; button then &#8220;No thanks, just start my download&#8221;. Copy the link and use wget:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #666666;">$ </span><span style="color: #c20cb9; font-weight: bold;">wget</span> https:<span style="color: #000000; font-weight: bold;">//</span>dev.mysql.com<span style="color: #000000; font-weight: bold;">/</span>get<span style="color: #000000; font-weight: bold;">/</span>mysql-apt-config_0.7.2-<span style="color: #000000;">1</span>_all.deb</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ wget&nbsp;https://dev.mysql.com/get/mysql-apt-config_0.7.2-1_all.deb</p>
                    </div>
                    <p>2) Install the package:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #666666;">$ </span><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">dpkg</span> -i mysql-apt-config_0.7.2-<span style="color: #000000;">1</span>_all.deb</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ sudo dpkg -i&nbsp;mysql-apt-config_0.7.2-1_all.deb</p>
                    </div>
                    <p>* It will prompt out a wizard to configure APT repository. Choose the first option if you need a <a href="https://lei-registration.org/">LEI number</a> to have registered:</p>
                    <div style="text-align: center;margin: px;">
                    </div>
        
                    <p>Then, choose mysql-5.7</p>
                    <p>Then, choose OK on the menu</p>
                    <p>3) Update repository package list:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #666666;">$ </span><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get update</span></pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ sudo apt-get update</p>
                    </div>
                    <p>4) Install MySQL community server:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #666666;">$ </span><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get install</span> mysql-community-server</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ sudo apt-get install mysql-community-server</p>
                    </div>
                    <p>*This will install all required packages as well.</p>
                    <p>MySQL 5.7 is now installed! That&#8217;s it. Easy peasy.</p>
                  </div>
                  <footer class="entry-footer">
                    <span class="entry-terms category" itemprop="articleSection">Posted in <a href="http://secaserver.com/category/database/" rel="tag">Database</a>, <a href="http://secaserver.com/category/sql/" rel="tag">SQL</a></span><br>
                    <span class="entry-terms post_tag" itemprop="keywords">Tagged <a href="http://secaserver.com/tag/how-to-install-mysql-5-7/" rel="tag">how to install mysql 5.7</a>, <a href="http://secaserver.com/tag/install-mysql-5-7/" rel="tag">install mysql 5.7</a>, <a href="http://secaserver.com/tag/install-mysql-5-7-apt/" rel="tag">install mysql 5.7 apt</a>, <a href="http://secaserver.com/tag/install-mysql-5-7-debian/" rel="tag">install mysql 5.7 debian</a>, <a href="http://secaserver.com/tag/install-mysql-5-7-ubuntu/" rel="tag">install mysql 5.7 ubuntu</a></span>
                  </footer>
                </div>
              </article>
              <article id="post-2856" class="post-2856 post type-post status-publish format-standard category-applications category-database category-sql tag-easy-way-to-setup-haproxy tag-haproxy-galera-cluster tag-haproxy-mysql-load-balance tag-mysql-galera-haproxy tag-percona-xtradb-cluster-haproxy entry" itemscope="itemscope" itemtype="http://schema.org/BlogPosting" itemprop="blogPost">
                <div class="entry-inner">
                  <header class="entry-header">
                    <div class="entry-meta">
                      <span class="entry-date"><span class="screen-reader-text">Posted on</span> <a href="http://secaserver.com/2015/09/configure-haproxy-galera-cluster/" rel="bookmark"><time class="entry-date" datetime="2015-09-17T15:12:12+00:00" itemprop="datePublished">17 September 2015</time></a></span><span class="byline"><span class="entry-author" itemprop="author" itemscope="itemscope" itemtype="http://schema.org/Person"><span class="screen-reader-text">Author</span> <a class="entry-author-link" href="http://secaserver.com/author/admin/" rel="author" itemprop="url"><span itemprop="name">SecaGuy</span></a></span></span> <span class="comments-link"><a href="http://secaserver.com/2015/09/configure-haproxy-galera-cluster/#respond" class="comments-link" itemprop="discussionURL">No Comments <span class="screen-reader-text">on Install and Configure HAProxy for MySQL Galera Cluster</span></a></span>
                    </div>
                    <h2 class="entry-title" itemprop="headline"><a href="http://secaserver.com/2015/09/configure-haproxy-galera-cluster/" rel="bookmark">Install and Configure HAProxy for MySQL Galera Cluster</a></h2>
                  </header>
                  <div class="entry-content" itemprop="articleBody">
                    <div class='shareaholic-canvas' data-app-id='9753856' data-app-id-name='index_above_content' data-app='share_buttons' data-title='Install and Configure HAProxy for MySQL Galera Cluster' data-link='http://secaserver.com/2015/09/configure-haproxy-galera-cluster/' data-summary=''></div>
                    <p>In this post, I&#8217;m going to cover on how to add load balancer for the MariaDB Galera Cluster. The major steps are:</p>
                    <ol>
                      <li>Ensure&nbsp;all Galera nodes are running as a single cluster (all nodes are primary and synced).</li>
                      <li>Install HAproxy (you can install it on separate node or on the application server).</li>
                      <li>Configure clustercheck script. This script performs health check on each backend server.</li>
                      <li>Configure HAproxy statistic page.</li>
                      <li>Point the application to load balancer.</li>
                    </ol>
                    <p>Our architecture looks like below:</p>
                    <div style="text-align: center;margin: px;">
                      <script type="text/javascript">
                      <!--
                      google_ad_client = "pub-8702393221774508";
                      google_alternate_color = "FFFFFF";
                      google_ad_width = 468;
                      google_ad_height = 60;
                      google_ad_format = "468x60_as";
                      google_ad_type = "image";
                      google_ad_channel ="";
                      google_color_border = "FFFFFF";
                      google_color_link = "0000FF";
                      google_color_bg = "FFFFFF";
                      google_color_text = "000000";
                      google_color_url = "008000";
                      google_ui_features = "rc:6";
                      //-->
                      </script> 
                      <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
                    </div>
                    <p><a href="http://secaserver.com/wp-content/uploads/2015/09/galera_haproxy_secaserver.png" class="thickbox no_icon" title="galera_haproxy_secaserver"><img class="aligncenter size-full wp-image-2867" src="http://secaserver.com/wp-content/uploads/2015/09/galera_haproxy_secaserver.png" alt="galera_haproxy_secaserver" width="325" height="390" srcset="http://secaserver.com/wp-content/uploads/2015/09/galera_haproxy_secaserver.png 325w, http://secaserver.com/wp-content/uploads/2015/09/galera_haproxy_secaserver-250x300.png 250w, http://secaserver.com/wp-content/uploads/2015/09/galera_haproxy_secaserver-300x360.png 300w" sizes="(max-width: 325px) 100vw, 325px"></a></p>
                    <h3>Configure clustercheck script</h3>
                    <p>*&nbsp;Steps described in this section should be performed on all DB nodes unless specified otherwise.</p>
                    <p>1. Firstly, we need to configure the backend health check reporting. We will use Percona&#8217;s clustercheck script available here. Get the script and put it under <em>/usr/local/bin</em> by running following commands:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">git clone</span> https:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>olafz<span style="color: #000000; font-weight: bold;">/</span>percona-clustercheck
$ <span style="color: #c20cb9; font-weight: bold;">cp</span> percona-clustercheck<span style="color: #000000; font-weight: bold;">/</span>clustercheck <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ git clone&nbsp;https://github.com/olafz/percona-clustercheck $ cp percona-clustercheck/clustercheck /usr/local/bin</p>
                    </div>
                    <p>2.&nbsp;The clustercheck script performs regular check on the Galera node by monitoring several MySQL variables/status. It yields a simple HTML output with corresponding HTTP return code (either 503 &#8211; Service Unavailable or 200 &#8211; OK). To make things easier for HAproxy to trigger the script and get the latest status of the backend, we have to make it listens to a port. We can use xinetd to turn the script into a service daemon&nbsp;and make it listen to a custom port, in this case, I&#8217;m going to use 9200.</p>
                    <p>Create a new file called <em>/etc/xinet.d/mysqlchk</em>, and add following lines:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># default: on</span>
<span style="color: #666666; font-style: italic;"># description: mysqlchk</span>
service mysqlchk
<span style="color: #7a0874; font-weight: bold;">&#123;</span>
  disable = no
  flags = REUSE
  socket_type = stream
  port = <span style="color: #000000;">9200</span>
  <span style="color: #7a0874; font-weight: bold;">wait</span> = no
  user = nobody
  server = <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>clustercheck
  log_on_failure += USERID
  only_from = 0.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0</span>
  per_source = UNLIMITED
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;"># default: on # description: mysqlchk service mysqlchk { disable = no flags = REUSE socket_type = stream port = 9200 wait = no user = nobody server = /usr/local/bin/clustercheck log_on_failure += USERID only_from = 0.0.0.0/0 per_source = UNLIMITED }</p>
                    </div>
                    <p>3. Then, we need to add the mysqlchk service into xinetd:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #666666;">$ </span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'mysqlchk      9200/tcp    # MySQL check'</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>services</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ echo 'mysqlchk &nbsp; &nbsp; &nbsp;9200/tcp &nbsp; &nbsp;# MySQL check' &gt;&gt; /etc/services</p>
                    </div>
                    <p>4. By default, the script will use a MySQL user called &#8220;clustercheckuser&#8221; with password &#8220;clustercheckpassword!&#8221;. We need&nbsp;to ensure this MySQL user is exist with the corresponding password before the script would be able to perform health checks. Run following DDL statements on one of the DB node (Galera should replicate the statement to the other nodes):</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="mysql" style="font-family:monospace;">mysql<span style="color: #CC0099;">&gt;</span> <span style="color: #990099; font-weight: bold;">GRANT</span> PROCESS <span style="color: #990099; font-weight: bold;">ON</span> <span style="color: #CC0099;">*</span>.<span style="color: #CC0099;">*</span> <span style="color: #990099; font-weight: bold;">TO</span> <span style="color: #008000;">'clustercheckuser'</span>@<span style="color: #008000;">'localhost'</span> IDENTIFIED BY <span style="color: #008000;">'clustercheckpassword!'</span><span style="color: #000033;">;</span>
mysql<span style="color: #CC0099;">&gt;</span> FLUSH <span style="color: #990099; font-weight: bold;">PRIVILEGES</span><span style="color: #000033;">;</span></pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">mysql&gt; GRANT PROCESS ON *.* TO 'clustercheckuser'@'localhost' IDENTIFIED BY 'clustercheckpassword!'; mysql&gt; FLUSH PRIVILEGES;</p>
                    </div>
                    <p>You can change this value inside the clustercheck script in line 32,33. In this post, I&#8217;m going to use the default username and password.</p>
                    <p>5. Verify if the script returns a correct value:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;">$ <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>clustercheck <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
$ <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$?</span>
<span style="color: #000000;">0</span></pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ /usr/local/bin/clustercheck &gt; /dev/null $ echo $? 0</p>
                    </div>
                    <p>If the DB node is in synced, you should get 0. Otherwise 1 should be the output. The backend health check is configured.</p>
                    <h3>Install HAproxy</h3>
                    <p>* Steps described in this section should be performed on HAproxy or application server.</p>
                    <p>1. The easy way is using package manager (yum/apt). However, it&#8217;s highly recommended to use the latest version available on HAproxy site. Either way, I&#8217;ll show the the installation steps here.</p>
                    <p>a) If you choose to install HAproxy via package manager:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">yum install</span> haproxy <span style="color: #666666; font-style: italic;"># Redhat/CentOS</span>
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get install</span> haproxy <span style="color: #666666; font-style: italic;"># Debian/Ubuntu</span></pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ yum install haproxy # Redhat/CentOS $ sudo apt-get install haproxy # Debian/Ubuntu</p>
                    </div>
                    <p>b) Via source from HAproxy download site:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">yum install</span> php-curl <span style="color: #c20cb9; font-weight: bold;">gcc</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #666666; font-style: italic;"># Redhat/CentOS</span>
$ <span style="color: #c20cb9; font-weight: bold;">apt-get install</span> php5-curl <span style="color: #c20cb9; font-weight: bold;">gcc</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #666666; font-style: italic;"># Debian/Ubuntu</span>
$ <span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>www.haproxy.org<span style="color: #000000; font-weight: bold;">/</span>download<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.5</span><span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>
$ <span style="color: #c20cb9; font-weight: bold;">tar</span> xvzfz
$ <span style="color: #7a0874; font-weight: bold;">cd</span>
$ <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #007800;">TARGET</span>=linux26
$ <span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #660033;">-f</span> haproxy <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>haproxy</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ yum install php-curl gcc make # Redhat/CentOS $ apt-get install php5-curl gcc make # Debian/Ubuntu $ wget http://www.haproxy.org/download/1.5/src/ $ tar xvzfz $ cd $ make TARGET=linux26 $ cp -f haproxy /usr/sbin/haproxy</p>
                    </div>
                    <p>Installing from source (option b) comes with no init script. So you have to create it manually or simply provision the process via command line (which is non-standard way). I&#8217;m not going to cover this unconventional way in this post.</p>
                    <p>&nbsp;</p>
                    <h3>Configure HAproxy</h3>
                    <p>Now we have HAproxy installed. We need to configure it to listen on port 3307 for MySQL service and perform back-end health checks. On /etc/haproxy/haproxy.cfg, ensure following lines exist:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;">global
        pidfile <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>haproxy.pid
        daemon
        user haproxy
        group haproxy
        stats socket <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>haproxy.socket user haproxy group haproxy mode <span style="color: #000000;">600</span> level admin
&nbsp;
        maxconn <span style="color: #000000;">8192</span>
        spread-checks <span style="color: #000000;">3</span>
        quiet
defaults
        mode    tcp
        option  dontlognull
        option tcp-smart-accept
        option tcp-smart-connect
        retries <span style="color: #000000;">3</span>
        option redispatch
        maxconn <span style="color: #000000;">8192</span>
        timeout check   3500ms
        timeout queue   3500ms
        timeout connect 3500ms
        timeout client  10800s
        timeout server  10800s
&nbsp;
userlist STATSUSERS
        group admin <span style="color: #c20cb9; font-weight: bold;">users</span> admin
        user admin insecure-password admin
        user stats insecure-password yourpassword
&nbsp;
listen admin_page 0.0.0.0:<span style="color: #000000;">9600</span>
        mode http
        stats <span style="color: #7a0874; font-weight: bold;">enable</span>
        stats refresh 60s
        stats uri <span style="color: #000000; font-weight: bold;">/</span>
        acl AuthOkay_ReadOnly http_auth<span style="color: #7a0874; font-weight: bold;">&#40;</span>STATSUSERS<span style="color: #7a0874; font-weight: bold;">&#41;</span>
        acl AuthOkay_Admin http_auth_group<span style="color: #7a0874; font-weight: bold;">&#40;</span>STATSUSERS<span style="color: #7a0874; font-weight: bold;">&#41;</span> admin
        stats http-request auth realm admin_page unless AuthOkay_ReadOnly
&nbsp;
listen  mysql_3307
        <span style="color: #7a0874; font-weight: bold;">bind</span> <span style="color: #000000; font-weight: bold;">*</span>:<span style="color: #000000;">3307</span>
        mode tcp
        timeout client  10800s
        timeout server  10800s
        balance leastconn
        option httpchk
        option allbackups
        default-server port <span style="color: #000000;">9200</span> inter 2s downinter 5s rise <span style="color: #000000;">3</span> fall <span style="color: #000000;">2</span> slowstart 60s maxconn <span style="color: #000000;">64</span> maxqueue <span style="color: #000000;">128</span> weight <span style="color: #000000;">100</span>
        server db1 10.0.0.187:<span style="color: #000000;">3306</span> check
        server db2 10.0.0.188:<span style="color: #000000;">3306</span> check
        server db3 10.0.0.189:<span style="color: #000000;">3306</span> check</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">global pidfile /var/run/haproxy.pid daemon user haproxy group haproxy stats socket /var/run/haproxy.socket user haproxy group haproxy mode 600 level admin maxconn 8192 spread-checks 3 quiet defaults mode tcp option dontlognull option tcp-smart-accept option tcp-smart-connect retries 3 option redispatch maxconn 8192 timeout check 3500ms timeout queue 3500ms timeout connect 3500ms timeout client 10800s timeout server 10800s userlist STATSUSERS group admin users admin user admin insecure-password admin user stats insecure-password yourpassword listen admin_page 0.0.0.0:9600 mode http stats enable stats refresh 60s stats uri / acl AuthOkay_ReadOnly http_auth(STATSUSERS) acl AuthOkay_Admin http_auth_group(STATSUSERS) admin stats http-request auth realm admin_page unless AuthOkay_ReadOnly listen mysql_3307 bind *:3307 mode tcp timeout client 10800s timeout server 10800s balance leastconn option httpchk option allbackups default-server port 9200 inter 2s downinter 5s rise 3 fall 2 slowstart 60s maxconn 64 maxqueue 128 weight 100 server db1 10.0.0.187:3306 check server db2 10.0.0.188:3306 check server db3 10.0.0.189:3306 check</p>
                    </div>
                    <p>Now enable the service on boot and fire it up:</p>
                    <p><em>RHEL/CentOS 6:</em></p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;">$ chkconfig haproxy on <span style="color: #666666; font-style: italic;"># RHEL6</span>
$ service haproxy start <span style="color: #666666; font-style: italic;"># RHEL6</span></pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ chkconfig haproxy on # RHEL6 $ service haproxy start # RHEL6</p>
                    </div>
                    <p><em>Ubuntu 14.04 and lower, Debian 7 and lower:</em></p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;">$ update-rc.d haproxy defaults
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> service haproxy start</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ update-rc.d haproxy defaults $ sudo service haproxy start</p>
                    </div>
                    <p><em>RHEL/CentOS 7, Debian 8, Ubuntu 15.04:</em></p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;">$ systemctl <span style="color: #7a0874; font-weight: bold;">enable</span> haproxy
$ systemctl start haproxy</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ systemctl enable haproxy $ systemctl start haproxy</p>
                    </div>
                    <p>Verify if HAproxy is listening to the correct ports:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">netstat</span> <span style="color: #660033;">-tulpn</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> haproxy
tcp        <span style="color: #000000;">0</span>      <span style="color: #000000;">0</span> 0.0.0.0:<span style="color: #000000;">9600</span>            0.0.0.0:<span style="color: #000000; font-weight: bold;">*</span>               LISTEN      <span style="color: #000000;">370</span><span style="color: #000000; font-weight: bold;">/</span>haproxy
tcp        <span style="color: #000000;">0</span>      <span style="color: #000000;">0</span> 0.0.0.0:<span style="color: #000000;">3307</span>            0.0.0.0:<span style="color: #000000; font-weight: bold;">*</span>               LISTEN      <span style="color: #000000;">370</span><span style="color: #000000; font-weight: bold;">/</span>haproxy</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ sudo netstat -tulpn | grep haproxy tcp 0 0 0.0.0.0:9600 0.0.0.0:* LISTEN 370/haproxy tcp 0 0 0.0.0.0:3307 0.0.0.0:* LISTEN 370/haproxy</p>
                    </div>
                    <p>3307 is the MySQL load-balanced port, while 9600 is the HAproxy statistic page. You can login to check the status by going to http://haproxy_ip_address:9600/ and login with username &#8216;admin&#8217; and password &#8216;yourpassword&#8217; as configured inside haproxy.cfg. You should see something like below:</p>
                    <p><a href="http://secaserver.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-17-at-3.00.03-PM.png" class="thickbox no_icon" title="Screen Shot 2015-09-17 at 3.00.03 PM"><img class="aligncenter size-full wp-image-2866" src="http://secaserver.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-17-at-3.00.03-PM.png" alt="Screen Shot 2015-09-17 at 3.00.03 PM" width="1136" height="437" srcset="http://secaserver.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-17-at-3.00.03-PM.png 1136w, http://secaserver.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-17-at-3.00.03-PM-300x115.png 300w, http://secaserver.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-17-at-3.00.03-PM-644x248.png 644w, http://secaserver.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-17-at-3.00.03-PM-900x346.png 900w" sizes="(max-width: 1136px) 100vw, 1136px"></a></p>
                    <p>Now, you can redirect the application or MySQL client to HAproxy host on port 3307, for a load balanaced&nbsp; MySQL connections with auto failover.</p>
                  </div>
                  <footer class="entry-footer">
                    <span class="entry-terms category" itemprop="articleSection">Posted in <a href="http://secaserver.com/category/applications/" rel="tag">Applications</a>, <a href="http://secaserver.com/category/database/" rel="tag">Database</a>, <a href="http://secaserver.com/category/sql/" rel="tag">SQL</a></span><br>
                    <span class="entry-terms post_tag" itemprop="keywords">Tagged <a href="http://secaserver.com/tag/easy-way-to-setup-haproxy/" rel="tag">easy way to setup haproxy</a>, <a href="http://secaserver.com/tag/haproxy-galera-cluster/" rel="tag">haproxy galera cluster</a>, <a href="http://secaserver.com/tag/haproxy-mysql-load-balance/" rel="tag">haproxy mysql load balance</a>, <a href="http://secaserver.com/tag/mysql-galera-haproxy/" rel="tag">mysql galera haproxy</a>, <a href="http://secaserver.com/tag/percona-xtradb-cluster-haproxy/" rel="tag">percona xtradb cluster haproxy</a></span>
                  </footer>
                </div>
              </article>
              <article id="post-2838" class="post-2838 post type-post status-publish format-standard category-linux category-networking tag-curl-ip-address tag-get-public-ip-linux tag-linux-get-ip tag-linux-public-ip tag-show-ip-address entry" itemscope="itemscope" itemtype="http://schema.org/BlogPosting" itemprop="blogPost">
                <div class="entry-inner">
                  <header class="entry-header">
                    <div class="entry-meta">
                      <span class="entry-date"><span class="screen-reader-text">Posted on</span> <a href="http://secaserver.com/2015/05/various-ways-determine-public-ip-linux-cli/" rel="bookmark"><time class="entry-date" datetime="2015-05-21T21:49:20+00:00" itemprop="datePublished">21 May 2015</time></a></span><span class="byline"><span class="entry-author" itemprop="author" itemscope="itemscope" itemtype="http://schema.org/Person"><span class="screen-reader-text">Author</span> <a class="entry-author-link" href="http://secaserver.com/author/admin/" rel="author" itemprop="url"><span itemprop="name">SecaGuy</span></a></span></span> <span class="comments-link"><a href="http://secaserver.com/2015/05/various-ways-determine-public-ip-linux-cli/#respond" class="comments-link" itemprop="discussionURL">No Comments <span class="screen-reader-text">on Various Ways to Determine Public IP on Linux CLI</span></a></span>
                    </div>
                    <h2 class="entry-title" itemprop="headline"><a href="http://secaserver.com/2015/05/various-ways-determine-public-ip-linux-cli/" rel="bookmark">Various Ways to Determine Public IP on Linux CLI</a></h2>
                  </header>
                  <div class="entry-content" itemprop="articleBody">
                    <div class='shareaholic-canvas' data-app-id='9753856' data-app-id-name='index_above_content' data-app='share_buttons' data-title='Various Ways to Determine Public IP on Linux CLI' data-link='http://secaserver.com/2015/05/various-ways-determine-public-ip-linux-cli/' data-summary=''></div>
                    <p>Always when you are working a lot with CLI environment, Linux particularly, you would like to know the public IP address especially when you were running on NAT environment. Here is a list of command that you can use to determine the public IP of your host via command line.</p>
                    <h2>Using curl</h2>
                    <p>cURL is mostly available on all Linux distributions, and is the most popular way to determine public IP address of the host. You just need to know the URL or host that will&nbsp;response with the correct public IP as per below:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;">$ curl ifconfig.me
52.74.127.152
&nbsp;
$ curl ipecho.net<span style="color: #000000; font-weight: bold;">/</span>plain
52.74.127.152
&nbsp;
$ curl ident.me
52.74.127.152
&nbsp;
$ curl icanhazip.com
52.74.127.152
&nbsp;
$ curl bot.whatismyipaddress.com
52.74.127.152</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ curl ifconfig.me 52.74.127.152 $ curl ipecho.net/plain 52.74.127.152 $ curl ident.me 52.74.127.152 $ curl icanhazip.com 52.74.127.152 $ curl bot.whatismyipaddress.com 52.74.127.152</p>
                    </div>
                    <h2>Using wget</h2>
                    <p>Basically, command executed on curl can be replace with wget -qO- option, as per below:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #660033;">-qO-</span> http:<span style="color: #000000; font-weight: bold;">//</span>ipecho.net<span style="color: #000000; font-weight: bold;">/</span>plain
52.74.127.152</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ wget -qO- http://ipecho.net/plain 52.74.127.152</p>
                    </div>
                    <h2>Using Lynx</h2>
                    <p>Lynx is a text-based browser which runs like a browser for your CLI</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #666666;">$ </span><span style="color: #c20cb9; font-weight: bold;">lynx</span> checkip.dyndns.org <span style="color: #666666; font-style: italic;"># you will be redirected to a text-based browser</span></pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ lynx checkip.dyndns.org # you will be redirected to a text-based browser</p>
                    </div>
                    <p>If you have the simplest method apart from what being mentioned here, please share it. I can&#8217;t imagine how simple it would be!</p>
                    <p>&nbsp;</p>
                  </div>
                  <footer class="entry-footer">
                    <span class="entry-terms category" itemprop="articleSection">Posted in <a href="http://secaserver.com/category/linux/" rel="tag">Linux</a>, <a href="http://secaserver.com/category/networking/" rel="tag">Networking</a></span><br>
                    <span class="entry-terms post_tag" itemprop="keywords">Tagged <a href="http://secaserver.com/tag/curl-ip-address/" rel="tag">curl ip address</a>, <a href="http://secaserver.com/tag/get-public-ip-linux/" rel="tag">get public ip linux</a>, <a href="http://secaserver.com/tag/linux-get-ip/" rel="tag">linux get ip</a>, <a href="http://secaserver.com/tag/linux-public-ip/" rel="tag">linux public ip</a>, <a href="http://secaserver.com/tag/show-ip-address/" rel="tag">show ip address</a></span>
                  </footer>
                </div>
              </article>
              <article id="post-2843" class="post-2843 post type-post status-publish format-standard category-security-2 category-sql tag-mysql-encryption tag-mysql-secure tag-mysql-ssh-encryption-mysql-encrypt tag-secure-ssh-mysql entry" itemscope="itemscope" itemtype="http://schema.org/BlogPosting" itemprop="blogPost">
                <div class="entry-inner">
                  <header class="entry-header">
                    <div class="entry-meta">
                      <span class="entry-date"><span class="screen-reader-text">Posted on</span> <a href="http://secaserver.com/2015/05/mysql-encryption-ssh-supervisor/" rel="bookmark"><time class="entry-date" datetime="2015-05-19T20:53:21+00:00" itemprop="datePublished">19 May 2015</time></a></span><span class="byline"><span class="entry-author" itemprop="author" itemscope="itemscope" itemtype="http://schema.org/Person"><span class="screen-reader-text">Author</span> <a class="entry-author-link" href="http://secaserver.com/author/admin/" rel="author" itemprop="url"><span itemprop="name">SecaGuy</span></a></span></span> <span class="comments-link"><a href="http://secaserver.com/2015/05/mysql-encryption-ssh-supervisor/#respond" class="comments-link" itemprop="discussionURL">No Comments <span class="screen-reader-text">on MySQL Encryption using SSH and Supervisor</span></a></span>
                    </div>
                    <h2 class="entry-title" itemprop="headline"><a href="http://secaserver.com/2015/05/mysql-encryption-ssh-supervisor/" rel="bookmark">MySQL Encryption using SSH and Supervisor</a></h2>
                  </header>
                  <div class="entry-content" itemprop="articleBody">
                    <div class='shareaholic-canvas' data-app-id='9753856' data-app-id-name='index_above_content' data-app='share_buttons' data-title='MySQL Encryption using SSH and Supervisor' data-link='http://secaserver.com/2015/05/mysql-encryption-ssh-supervisor/' data-summary=''></div>
                    <p>If MySQL security is one of your concerns, you should use encryption when connecting to the server. Setting up SSL in MySQL is not really straightforward as you have to generate key, certificate and GRANT for specific user with REQUIRE SSL statement. This&nbsp;would bring additional maintenance task for DBA.</p>
                    <p>The easiest way to achieve this is by using SSH encryption. Instead directing the application to connect to standard port 3306 with plain connection, why don&#8217;t you connect it to a &#8216;forwarding&#8217; port which map to the MySQL port via SSH? SSH is secure and almost everyone with Linux basic knowledge knows how to manage it.</p>
                    <h2>Setting up SSH access and port forwarding</h2>
                    <p>Let&#8217;s say we have a application/web server and a MySQL server listening on standard port 3306:</p>
                    <ul>
                      <li>10.0.0.20 &#8211; web server</li>
                      <li>10.0.0.21 &#8211;&nbsp;mysql server</li>
                    </ul>
                    <p>Following steps should be performed on the application/web server.</p>
                    <p>1. As root user, generate a SSH key:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">whoami</span> 
root
$ <span style="color: #c20cb9; font-weight: bold;">ssh-keygen</span> <span style="color: #660033;">-t</span> rsa <span style="color: #666666; font-style: italic;"># press enter on all prompts</span></pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ whoami root $ ssh-keygen -t rsa # press enter on all prompts</p>
                    </div>
                    <p>2. Copy the SSH key on web server to MySQL node:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #666666;">$ </span>ssh-copy-id 10.0.0.21 <span style="color: #666666; font-style: italic;"># enter the root password for 10.0.0.21 if prompted</span></pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ ssh-copy-id 10.0.0.21 # enter the root password for 10.0.0.21 if prompted</p>
                    </div>
                    <p>3. Verify that you can run following command without the MySQL node prompting a password:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #666666;">$ </span><span style="color: #c20cb9; font-weight: bold;">ssh</span> 10.0.0.21 <span style="color: #ff0000;">&quot;ls /usr&quot;</span></pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ ssh 10.0.0.21 &quot;ls /usr&quot;</p>
                    </div>
                    <p>4. Run SSH command to listen to port 10001 on localhost IP and forward it to port 3306 on 10.0.0.21 as root user:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #666666;">$ </span><span style="color: #c20cb9; font-weight: bold;">ssh</span> <span style="color: #660033;">-fNg</span> <span style="color: #660033;">-L</span> <span style="color: #000000;">10001</span>:127.0.0.1:<span style="color: #000000;">3306</span> 10.0.0.21</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ ssh -fNg -L 10001:127.0.0.1:3306 10.0.0.21</p>
                    </div>
                    <p>5. Verify that you got following port listed:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">netstat</span> <span style="color: #660033;">-tulpn</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #000000;">10001</span>
$ <span style="color: #c20cb9; font-weight: bold;">ps</span> aux <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #c20cb9; font-weight: bold;">ssh</span></pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ netstat -tulpn | grep 10001 $ ps aux | grep ssh</p>
                    </div>
                    <p>6. Finally, connect to MySQL server using MySQL client securely:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #666666;">$ </span>mysql <span style="color: #660033;">-uroot</span> <span style="color: #660033;">-p</span> -h127.0.0.1 <span style="color: #660033;">-P10001</span></pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ mysql -uroot -p -h127.0.0.1 -P10001</p>
                    </div>
                    <p>At this point, you can redirect your application to communicate through 127.0.0.1 port 10001 as a secured MySQL connection via SSH.</p>
                    <h2>Dedicated SSH user</h2>
                    <p>Above method works fine if you are running as user root, but this is not the safest method. Since running the SSH command does not require super user privilege, we should create a specific user other than root specifically for this process. In this example, I created a user called &#8216;myuser&#8217;.</p>
                    <p>1. On both servers, create the user and assign a password.:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;">$ useradd myuser
$ <span style="color: #c20cb9; font-weight: bold;">passwd</span> myuser</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ useradd myuser $ passwd myuser</p>
                    </div>
                    <p>2. On application/web server, generate a SSH key for myuser:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">su</span> - myuser
$ <span style="color: #c20cb9; font-weight: bold;">whoami</span> 
myuser
$ <span style="color: #c20cb9; font-weight: bold;">ssh-keygen</span> <span style="color: #660033;">-t</span> rsa <span style="color: #666666; font-style: italic;"># press enter on all prompts</span></pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ su - myuser $ whoami myuser $ ssh-keygen -t rsa # press enter on all prompts</p>
                    </div>
                    <p>3. Then, copy the SSH key to MySQL server, 10.0.0.21:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #666666;">$ </span>ssh-copy-id 10.0.0.21 <span style="color: #666666; font-style: italic;"># enter the myuser password for 10.0.0.21 if prompted</span></pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ ssh-copy-id 10.0.0.21 # enter the myuser password for 10.0.0.21 if prompted</p>
                    </div>
                    <p>4. Start the SSH port forwarding using following command:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #666666;">$ </span><span style="color: #c20cb9; font-weight: bold;">ssh</span> <span style="color: #660033;">-fNg</span> <span style="color: #660033;">-L</span> <span style="color: #000000;">10001</span>:127.0.0.1:<span style="color: #000000;">3306</span> 10.0.0.21</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ ssh -fNg -L 10001:127.0.0.1:3306 10.0.0.21</p>
                    </div>
                    <p>5. To auto execute the command after a reboot, just add following line under /etc/rc.local:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;">runuser <span style="color: #660033;">-l</span> myuser <span style="color: #660033;">-c</span> <span style="color: #ff0000;">'ssh -fNg -L 10001:127.0.0.1:3306 10.0.0.21'</span></pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">runuser -l myuser -c 'ssh -fNg -L 10001:127.0.0.1:3306 10.0.0.21'</p>
                    </div>
                    <p>Now, it&#8217;s safer to have a dedicated user to perform the port forwarding process.</p>
                    <h2>Setting up Supervisor</h2>
                    <p>Now we have secured our MySQL connection. We need to ensure the SSH process is monitored so when it fails (or if the server rebooted) it will be automatically restarted. You can basically put the command directly inside /etc/rc.local (as shown above), which will be executed automatically upon startup, but this does not cover the worst-case scenario where the process crashes, stops or being killed. This is where Supervisor comes in handy.</p>
                    <p>Supervisor is a client/server system that allows its users to monitor and control a number of processes on UNIX-like operating systems.</p>
                    <p>1. Install Supervisor via python easy_install:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">yum install</span> <span style="color: #660033;">-y</span> python-setuptools
$ easy_install supervisor</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ yum install -y python-setuptools $ easy_install supervisor</p>
                    </div>
                    <p>2. Create a configuration file, /etc/supervisord.conf:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #666666;">$ </span><span style="color: #c20cb9; font-weight: bold;">vim</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>supervisord.conf</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ vim /etc/supervisord.conf</p>
                    </div>
                    <p>And add following lines:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>supervisord<span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #007800;">nodaemon</span>=<span style="color: #c20cb9; font-weight: bold;">false</span>
<span style="color: #007800;">logfile</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>supervisord.log
<span style="color: #007800;">pidfile</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>supervisord.pid
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#91;</span>program:mysql_secure<span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #007800;">command</span>=<span style="color: #c20cb9; font-weight: bold;">ssh</span> <span style="color: #660033;">-Ng</span> <span style="color: #660033;">-L</span> <span style="color: #000000;">10001</span>:127.0.0.1:<span style="color: #000000;">3306</span> 10.0.0.21
<span style="color: #007800;">user</span>=myuser</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">[supervisord] nodaemon=false logfile=/var/log/supervisord.log pidfile=/var/run/supervisord.pid [program:mysql_secure] command=ssh -Ng -L 10001:127.0.0.1:3306 10.0.0.21 user=myuser</p>
                    </div>
                    <p>3. To start Supervisor, just run following command:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #666666;">$ </span>supervisord <span style="color: #660033;">-c</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>supervisord.conf</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ supervisord -c /etc/supervisord.conf</p>
                    </div>
                    <p>4. To ensure it starts on boot, we add following line into /etc/rc.local:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>supervisord -c <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>supervisord.conf</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">/usr/bin/supervisord -c&nbsp;/etc/supervisord.conf</p>
                    </div>
                    <p>Here is some excerpt from /var/log/supervisord.log indicating it monitors the process correctly:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="text" style="font-family:monospace;">$ less /var/log/supervisord.log
2015-05-19 20:22:14,093 CRIT Supervisor running as root (no user in config file)
2015-05-19 20:22:14,100 INFO daemonizing the supervisord process
2015-05-19 20:22:14,101 INFO supervisord started with pid 1944
2015-05-19 20:22:15,105 INFO spawned: 'mysql_secure' with pid 1945
2015-05-19 20:22:16,108 INFO success: mysql_secure entered RUNNING state, process has stayed up for &gt; than 1 seconds (startsecs)
2015-05-19 20:22:24,581 CRIT Supervisor running as root (no user in config file)
2015-05-19 20:22:24,585 INFO daemonizing the supervisord process
2015-05-19 20:22:24,585 INFO supervisord started with pid 1952
2015-05-19 20:22:25,591 INFO spawned: 'mysql_secure' with pid 1953
2015-05-19 20:22:26,801 INFO success: mysql_secure entered RUNNING state, process has stayed up for &gt; than 1 seconds (startsecs)</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ less /var/log/supervisord.log 2015-05-19 20:22:14,093 CRIT Supervisor running as root (no user in config file) 2015-05-19 20:22:14,100 INFO daemonizing the supervisord process 2015-05-19 20:22:14,101 INFO supervisord started with pid 1944 2015-05-19 20:22:15,105 INFO spawned: 'mysql_secure' with pid 1945 2015-05-19 20:22:16,108 INFO success: mysql_secure entered RUNNING state, process has stayed up for &gt; than 1 seconds (startsecs) 2015-05-19 20:22:24,581 CRIT Supervisor running as root (no user in config file) 2015-05-19 20:22:24,585 INFO daemonizing the supervisord process 2015-05-19 20:22:24,585 INFO supervisord started with pid 1952 2015-05-19 20:22:25,591 INFO spawned: 'mysql_secure' with pid 1953 2015-05-19 20:22:26,801 INFO success: mysql_secure entered RUNNING state, process has stayed up for &gt; than 1 seconds (startsecs)</p>
                    </div>
                    <p>That&#8217;s all folks!</p>
                    <p>&nbsp;</p>
                  </div>
                  <footer class="entry-footer">
                    <span class="entry-terms category" itemprop="articleSection">Posted in <a href="http://secaserver.com/category/security-2/" rel="tag">Security</a>, <a href="http://secaserver.com/category/sql/" rel="tag">SQL</a></span><br>
                    <span class="entry-terms post_tag" itemprop="keywords">Tagged <a href="http://secaserver.com/tag/mysql-encryption/" rel="tag">mysql encryption</a>, <a href="http://secaserver.com/tag/mysql-secure/" rel="tag">mysql secure</a>, <a href="http://secaserver.com/tag/mysql-ssh-encryption-mysql-encrypt/" rel="tag">mysql ssh encryption mysql encrypt</a>, <a href="http://secaserver.com/tag/secure-ssh-mysql/" rel="tag">secure ssh mysql</a></span>
                  </footer>
                </div>
              </article>
              <article id="post-2833" class="post-2833 post type-post status-publish format-standard category-installation category-linux category-sql tag-install-mysql-centos-7 tag-install-mysql-redhat-7 tag-install-mysql-rhel-7 tag-mariadb-centos-7 tag-mysql-centos-7 tag-mysql-rhel-7 entry" itemscope="itemscope" itemtype="http://schema.org/BlogPosting" itemprop="blogPost">
                <div class="entry-inner">
                  <header class="entry-header">
                    <div class="entry-meta">
                      <span class="entry-date"><span class="screen-reader-text">Posted on</span> <a href="http://secaserver.com/2015/03/centos-7-installing-managing-mysql/" rel="bookmark"><time class="entry-date" datetime="2015-03-30T16:49:05+00:00" itemprop="datePublished">30 March 2015</time></a></span><span class="byline"><span class="entry-author" itemprop="author" itemscope="itemscope" itemtype="http://schema.org/Person"><span class="screen-reader-text">Author</span> <a class="entry-author-link" href="http://secaserver.com/author/admin/" rel="author" itemprop="url"><span itemprop="name">SecaGuy</span></a></span></span> <span class="comments-link"><a href="http://secaserver.com/2015/03/centos-7-installing-managing-mysql/#respond" class="comments-link" itemprop="discussionURL">No Comments <span class="screen-reader-text">on CentOS 7: Installing and Managing MySQL</span></a></span>
                    </div>
                    <h2 class="entry-title" itemprop="headline"><a href="http://secaserver.com/2015/03/centos-7-installing-managing-mysql/" rel="bookmark">CentOS 7: Installing and Managing MySQL</a></h2>
                  </header>
                  <div class="entry-content" itemprop="articleBody">
                    <div class='shareaholic-canvas' data-app-id='9753856' data-app-id-name='index_above_content' data-app='share_buttons' data-title='CentOS 7: Installing and Managing MySQL' data-link='http://secaserver.com/2015/03/centos-7-installing-managing-mysql/' data-summary=''></div>
                    <p>Starting from CentOS/RHEL 7, standard MySQL (Oracle) package is no longer available and has been replaced by MariaDB. There will be almost no difference when managing MariaDB since it is basically a drop-in replacement for MySQL. Certainly, MariaDB has attracted huge attention and many of existing MySQL users have been switching to MariaDB, this includes Google and Tumblr.</p>
                    <p>To install MySQL/MariaDB on CentOS 7 box, just use following command:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #666666;">$ </span><span style="color: #c20cb9; font-weight: bold;">yum install</span> mariadb mariadb-server</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ yum install mariadb mariadb-server</p>
                    </div>
                    <p>In RHEL, when you run yum install mysql, it will automatically install mariadb 5.5. The MySQL configuration still located in the familiar location: <em>/etc/my.cnf</em>, the MySQL error log is located at <em>/var/log/mariadb/mariadb.log</em> while the data directory is still located at <em>/var/lib/mysql</em>.</p>
                    <p>CentOS 7 runs on systemd, thus to start the service (similar to service mysqld start):</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #666666;">$ </span>systemctl start mariadb.service</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ systemctl start mariadb.service</p>
                    </div>
                    <p>** Other options are: restart, stop, status</p>
                    <p>To enable the service to start on boot (similar to chkconfig mysqld on):</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #666666;">$ </span>systemctl <span style="color: #7a0874; font-weight: bold;">enable</span> mariadb.service</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ systemctl enable mariadb.service</p>
                    </div>
                    <p>Above are the only differences when managing MySQL running on CentOS/RHEL 7. To retrieve the list of services with the status, use following command:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #666666;">$ </span>systemctl list-units</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ systemctl list-units</p>
                    </div>
                    <p>Or:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #666666;">$ </span>systemctl list-unit-files</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ systemctl list-unit-files</p>
                    </div>
                    <p>That&#8217;s it. Having MariaDB as replacement for MySQL is definitely a great choice. You would have no regret using it!</p>
                  </div>
                  <footer class="entry-footer">
                    <span class="entry-terms category" itemprop="articleSection">Posted in <a href="http://secaserver.com/category/installation/" rel="tag">Installation</a>, <a href="http://secaserver.com/category/linux/" rel="tag">Linux</a>, <a href="http://secaserver.com/category/sql/" rel="tag">SQL</a></span><br>
                    <span class="entry-terms post_tag" itemprop="keywords">Tagged <a href="http://secaserver.com/tag/install-mysql-centos-7/" rel="tag">install mysql centos 7</a>, <a href="http://secaserver.com/tag/install-mysql-redhat-7/" rel="tag">install mysql redhat 7</a>, <a href="http://secaserver.com/tag/install-mysql-rhel-7/" rel="tag">install mysql rhel 7</a>, <a href="http://secaserver.com/tag/mariadb-centos-7/" rel="tag">mariadb centos 7</a>, <a href="http://secaserver.com/tag/mysql-centos-7/" rel="tag">mysql centos 7</a>, <a href="http://secaserver.com/tag/mysql-rhel-7/" rel="tag">mysql rhel 7</a></span>
                  </footer>
                </div>
              </article>
              <article id="post-2763" class="post-2763 post type-post status-publish format-standard category-database category-linux category-sql tag-multiple-mysql-servers tag-mysql-sandbox tag-mysql-sandbox-installation tag-running-multiple-mysql tag-running-multiple-mysql-servers entry" itemscope="itemscope" itemtype="http://schema.org/BlogPosting" itemprop="blogPost">
                <div class="entry-inner">
                  <header class="entry-header">
                    <div class="entry-meta">
                      <span class="entry-date"><span class="screen-reader-text">Posted on</span> <a href="http://secaserver.com/2014/11/centosredhat-install-mysql-sandbox/" rel="bookmark"><time class="entry-date" datetime="2014-11-20T17:23:44+00:00" itemprop="datePublished">20 November 2014</time></a></span><span class="byline"><span class="entry-author" itemprop="author" itemscope="itemscope" itemtype="http://schema.org/Person"><span class="screen-reader-text">Author</span> <a class="entry-author-link" href="http://secaserver.com/author/admin/" rel="author" itemprop="url"><span itemprop="name">SecaGuy</span></a></span></span> <span class="comments-link"><a href="http://secaserver.com/2014/11/centosredhat-install-mysql-sandbox/#respond" class="comments-link" itemprop="discussionURL">No Comments <span class="screen-reader-text">on CentOS/Redhat: How to Install MySQL Sandbox</span></a></span>
                    </div>
                    <h2 class="entry-title" itemprop="headline"><a href="http://secaserver.com/2014/11/centosredhat-install-mysql-sandbox/" rel="bookmark">CentOS/Redhat: How to Install MySQL Sandbox</a></h2>
                  </header>
                  <div class="entry-content" itemprop="articleBody">
                    <div class='shareaholic-canvas' data-app-id='9753856' data-app-id-name='index_above_content' data-app='share_buttons' data-title='CentOS/Redhat: How to Install MySQL Sandbox' data-link='http://secaserver.com/2014/11/centosredhat-install-mysql-sandbox/' data-summary=''></div>
                    <p>When you have started to work heavily with MySQL servers, and you need to create, install, configure and destroy MySQL instances, MySQL Sandbox is a great tool to automate those tasks. MySQL Sandbox allows us to deploy a MySQL test environment within seconds with simple commands.</p>
                    <p>So following is what I would do to install MySQL Sandbox on my CentOS box and create 3 mysql instances for my test environment:</p>
                    <p>1. Install Perl CPAN package:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #666666;">$ </span><span style="color: #c20cb9; font-weight: bold;">yum install</span> perl-CPAN</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ yum install perl-CPAN</p>
                    </div>
                    <p>2. Connect to Perl MCPAN shell :</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #666666;">$ </span><span style="color: #c20cb9; font-weight: bold;">perl</span> <span style="color: #660033;">-MCPAN</span> <span style="color: #660033;">-e</span> shell</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ perl -MCPAN -e shell</p>
                    </div>
                    <p>**Answer &#8216;yes&#8217; for the prompt. Perl will auto-configure most of the stuff for you</p>
                    <p>3. Install required Perl modules:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="perl" style="font-family:monospace;">install Test<span style="color: #339933;">::</span><span style="color: #006600;">More</span>
install MySQL<span style="color: #339933;">::</span><span style="color: #006600;">Sandbox</span></pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">install Test::More install MySQL::Sandbox</p>
                    </div>
                    <p>4. MySQL Sandbox is recommended to run as a non-root user. Create a user called sandbox and switch to the user&#8217;s environment:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;">$ useradd sandbox
$ <span style="color: #c20cb9; font-weight: bold;">su</span> - sandbox</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ useradd sandbox $ su - sandbox</p>
                    </div>
                    <p>5. Download the MySQL Sandox package from Launchpad:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #666666;">$ </span><span style="color: #c20cb9; font-weight: bold;">wget</span> https:<span style="color: #000000; font-weight: bold;">//</span>launchpadlibrarian.net<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">187745286</span><span style="color: #000000; font-weight: bold;">/</span>MySQL-Sandbox-3.0.47.tar.gz</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ wget https://launchpadlibrarian.net/187745286/MySQL-Sandbox-3.0.47.tar.gz</p>
                    </div>
                    <p>6. Add MySQL sandbox into environment path of user sandbox&#8217;s bashrc:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #666666;">$ </span><span style="color: #c20cb9; font-weight: bold;">vim</span> ~<span style="color: #000000; font-weight: bold;">/</span>.bashrc</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ vim ~/.bashrc</p>
                    </div>
                    <p>And append following line:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PATH</span>=<span style="color: #007800;">$PATH</span>:<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>sandbox<span style="color: #000000; font-weight: bold;">/</span>MySQL-Sandbox-3.0.47<span style="color: #000000; font-weight: bold;">/</span>bin</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">export PATH=$PATH:/home/sandbox/MySQL-Sandbox-3.0.47/bin</p>
                    </div>
                    <p>7. Re-login as the sandbox user to activate environment:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">exit</span>
$ <span style="color: #c20cb9; font-weight: bold;">su</span> - sandbox</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ exit $ su - sandbox</p>
                    </div>
                    <p>8. Download MySQL generic TAR file from MySQL Server archive page:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #666666;">$ </span><span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>downloads.mysql.com<span style="color: #000000; font-weight: bold;">/</span>archives<span style="color: #000000; font-weight: bold;">/</span>get<span style="color: #000000; font-weight: bold;">/</span>file<span style="color: #000000; font-weight: bold;">/</span>mysql-5.6.20-linux-glibc2.5-x86_64.tar.gz</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ wget http://downloads.mysql.com/archives/get/file/mysql-5.6.20-linux-glibc2.5-x86_64.tar.gz</p>
                    </div>
                    <p>** I used MySQL 5.6.20 for this installation</p>
                    <p>Installation completed. To create a single MySQL instances, use following command:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #666666;">$ </span>make_sandbox mysql-5.6.20-linux-glibc2.5-x86_64.tar.gz</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ make_sandbox mysql-5.6.20-linux-glibc2.5-x86_64.tar.gz</p>
                    </div>
                    <p>I use following command to create 3 MySQL instances for my test environment:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #666666;">$ </span>make_multiple_sandbox mysql-5.6.20-linux-glibc2.5-x86_64.tar.gz</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ make_multiple_sandbox mysql-5.6.20-linux-glibc2.5-x86_64.tar.gz</p>
                    </div>
                    <p>Your instances should be ready and running within minutes. They will be created under <em>/home/sandbox/sandboxes</em>.</p>
                  </div>
                  <footer class="entry-footer">
                    <span class="entry-terms category" itemprop="articleSection">Posted in <a href="http://secaserver.com/category/database/" rel="tag">Database</a>, <a href="http://secaserver.com/category/linux/" rel="tag">Linux</a>, <a href="http://secaserver.com/category/sql/" rel="tag">SQL</a></span><br>
                    <span class="entry-terms post_tag" itemprop="keywords">Tagged <a href="http://secaserver.com/tag/multiple-mysql-servers/" rel="tag">multiple mysql servers</a>, <a href="http://secaserver.com/tag/mysql-sandbox/" rel="tag">mysql sandbox</a>, <a href="http://secaserver.com/tag/mysql-sandbox-installation/" rel="tag">mysql sandbox installation</a>, <a href="http://secaserver.com/tag/running-multiple-mysql/" rel="tag">running multiple mysql</a>, <a href="http://secaserver.com/tag/running-multiple-mysql-servers/" rel="tag">running multiple mysql servers</a></span>
                  </footer>
                </div>
              </article>
              <article id="post-2758" class="post-2758 post type-post status-publish format-standard category-backup-2 category-database category-sql tag-percona-restore-xbstream tag-restore-backup-qpress tag-restore-backup-xbstream tag-restore-xbstream-percona tag-xbstrea-qpress-backup entry" itemscope="itemscope" itemtype="http://schema.org/BlogPosting" itemprop="blogPost">
                <div class="entry-inner">
                  <header class="entry-header">
                    <div class="entry-meta">
                      <span class="entry-date"><span class="screen-reader-text">Posted on</span> <a href="http://secaserver.com/2014/11/restoring-xbstream-backup-created-percona-xtrabackup/" rel="bookmark"><time class="entry-date" datetime="2014-11-13T23:20:28+00:00" itemprop="datePublished">13 November 2014</time></a></span><span class="byline"><span class="entry-author" itemprop="author" itemscope="itemscope" itemtype="http://schema.org/Person"><span class="screen-reader-text">Author</span> <a class="entry-author-link" href="http://secaserver.com/author/admin/" rel="author" itemprop="url"><span itemprop="name">SecaGuy</span></a></span></span> <span class="comments-link"><a href="http://secaserver.com/2014/11/restoring-xbstream-backup-created-percona-xtrabackup/#respond" class="comments-link" itemprop="discussionURL">No Comments <span class="screen-reader-text">on Restoring xbstream Backup Created by Percona Xtrabackup</span></a></span>
                    </div>
                    <h2 class="entry-title" itemprop="headline"><a href="http://secaserver.com/2014/11/restoring-xbstream-backup-created-percona-xtrabackup/" rel="bookmark">Restoring xbstream Backup Created by Percona Xtrabackup</a></h2>
                  </header>
                  <div class="entry-content" itemprop="articleBody">
                    <div class='shareaholic-canvas' data-app-id='9753856' data-app-id-name='index_above_content' data-app='share_buttons' data-title='Restoring xbstream Backup Created by Percona Xtrabackup' data-link='http://secaserver.com/2014/11/restoring-xbstream-backup-created-percona-xtrabackup/' data-summary=''></div>
                    <p>&nbsp;</p>
                    <h2>Backing up</h2>
                    <p>Once Percona Xtrabackup is installed, you can create a full backup with parallel compression as below:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #666666;">$ </span>innobackupex <span style="color: #660033;">--stream</span>=xbstream <span style="color: #660033;">--parallel</span>=<span style="color: #000000;">4</span> <span style="color: #660033;">--compress</span> <span style="color: #660033;">--compress-threads</span>=<span style="color: #000000;">2</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>mysql <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>root<span style="color: #000000; font-weight: bold;">/</span>backup<span style="color: #000000; font-weight: bold;">/</span>backup.xbstream</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ innobackupex --stream=xbstream --parallel=4 --compress --compress-threads=2 /var/lib/mysql &gt; /root/backup/backup.xbstream</p>
                    </div>
                    <p>Once completed, you should see a backup file has been created with .xbstream extension:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">du</span> -sh <span style="color: #000000; font-weight: bold;">/</span>root<span style="color: #000000; font-weight: bold;">/</span>backup<span style="color: #000000; font-weight: bold;">/</span>backup.xbstream
106M backup.xbstream</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$&nbsp;du -sh&nbsp;/root/backup/backup.xbstream 106M backup.xbstream</p>
                    </div>
                    <p>&nbsp;</p>
                    <h2>Restoration</h2>
                    <p>1. Extract the file using&nbsp;xbstream -x command as below:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #666666;">$ </span>xbstream <span style="color: #660033;">-x</span> <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight: bold;">/</span>root<span style="color: #000000; font-weight: bold;">/</span>backup<span style="color: #000000; font-weight: bold;">/</span>backup.xbstream</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ xbstream -x &lt; /root/backup/backup.xbstream</p>
                    </div>
                    <p>2. If you look into the current folder recursively, you should see there are a lot&nbsp;of&nbsp;files ended with .qp extension. We need to extract these files using qpress which is available in Percona repository. Install qpress as below:</p>
                    <p><strong>CentOS/Redhat:</strong></p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">yum install</span> http:<span style="color: #000000; font-weight: bold;">//</span>www.percona.com<span style="color: #000000; font-weight: bold;">/</span>downloads<span style="color: #000000; font-weight: bold;">/</span>percona-release<span style="color: #000000; font-weight: bold;">/</span>redhat<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0.1</span>-<span style="color: #000000;">3</span><span style="color: #000000; font-weight: bold;">/</span>percona-release-<span style="color: #000000;">0.1</span>-<span style="color: #000000;">3</span>.noarch.rpm
$ <span style="color: #c20cb9; font-weight: bold;">yum install</span> qpress</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ yum install http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm $ yum install qpress</p>
                    </div>
                    <p><strong>Debian/Ubuntu:</strong></p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">apt-key adv</span> <span style="color: #660033;">--keyserver</span> keys.gnupg.net <span style="color: #660033;">--recv-keys</span> 1C4CBDCDCD2EFD2A
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'deb http://repo.percona.com/apt VERSION main'</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apt<span style="color: #000000; font-weight: bold;">/</span>sources.list
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'deb-src http://repo.percona.com/apt VERSION main'</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apt<span style="color: #000000; font-weight: bold;">/</span>sources.list
$ <span style="color: #c20cb9; font-weight: bold;">apt-get update</span>
$ <span style="color: #c20cb9; font-weight: bold;">apt-get install</span> qpress</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$&nbsp;apt-key adv --keyserver keys.gnupg.net --recv-keys 1C4CBDCDCD2EFD2A echo 'deb http://repo.percona.com/apt VERSION main' &gt;&gt; /etc/apt/sources.list echo 'deb-src http://repo.percona.com/apt VERSION main'&nbsp;&gt;&gt; /etc/apt/sources.list $ apt-get update $ apt-get install qpress</p>
                    </div>
                    <p>* Replace VERSION with your Debian/Ubuntu release name</p>
                    <p>3. Extract each file ended with .qp and in their respective directory, then remove .qp file once its extracted:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #666666;">$ </span><span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">find</span> <span style="color: #660033;">-name</span> <span style="color: #ff0000;">&quot;*.qp&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>; <span style="color: #000000; font-weight: bold;">do</span> qpress <span style="color: #660033;">-vd</span> <span style="color: #007800;">$i</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">dirname</span> <span style="color: #800000;">${i}</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$i</span>; <span style="color: #000000; font-weight: bold;">done</span></pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ for i in $(find -name &quot;*.qp&quot;); do qpress -vd $i $(dirname ${i}) &amp;&amp; rm -f $i; done</p>
                    </div>
                    <p>4. You can now use the <em>&#8211;apply-log</em> command to prepare the MySQL data:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #666666;">$ </span>innobackupex <span style="color: #660033;">--apply-log</span> .<span style="color: #000000; font-weight: bold;">/</span></pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ innobackupex --apply-log ./</p>
                    </div>
                    <p>5. Stop MySQL server:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #666666;">$ </span>service mysql stop</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ service mysql stop</p>
                    </div>
                    <p>5. Move or remove the current data directory and use <em>&#8211;copy-back</em> command to let xtrabackup copy the prepared data to MySQL data directory:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-Rf</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/*</span>
$ innobackupex <span style="color: #660033;">--copy-back</span> .<span style="color: #000000; font-weight: bold;">/</span></pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ rm -Rf /var/lib/mysql/* $ innobackupex --copy-back ./</p>
                    </div>
                    <p>6. Assign correct ownership to MySQL data directory:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #666666;">$ </span><span style="color: #c20cb9; font-weight: bold;">chown</span> <span style="color: #660033;">-Rf</span> mysql.mysql <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>mysql</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ chown -Rf mysql.mysql /var/lib/mysql</p>
                    </div>
                    <p>7. Start the MySQL server:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #666666;">$ </span>service mysql start</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ service mysql start</p>
                    </div>
                    <p>&nbsp;</p>
                    <p>Restoration completed!</p>
                  </div>
                  <footer class="entry-footer">
                    <span class="entry-terms category" itemprop="articleSection">Posted in <a href="http://secaserver.com/category/backup-2/" rel="tag">Backup</a>, <a href="http://secaserver.com/category/database/" rel="tag">Database</a>, <a href="http://secaserver.com/category/sql/" rel="tag">SQL</a></span><br>
                    <span class="entry-terms post_tag" itemprop="keywords">Tagged <a href="http://secaserver.com/tag/percona-restore-xbstream/" rel="tag">percona restore xbstream</a>, <a href="http://secaserver.com/tag/restore-backup-qpress/" rel="tag">restore backup qpress</a>, <a href="http://secaserver.com/tag/restore-backup-xbstream/" rel="tag">restore backup xbstream</a>, <a href="http://secaserver.com/tag/restore-xbstream-percona/" rel="tag">restore xbstream percona</a>, <a href="http://secaserver.com/tag/xbstrea-qpress-backup/" rel="tag">xbstrea qpress backup</a></span>
                  </footer>
                </div>
              </article>
              <article id="post-2750" class="post-2750 post type-post status-publish format-standard category-cluster-2 category-sql tag-mysql-calculate-ratio tag-mysql-calculate-read-write tag-mysql-read-write-ratio tag-mysql-show-read-write entry" itemscope="itemscope" itemtype="http://schema.org/BlogPosting" itemprop="blogPost">
                <div class="entry-inner">
                  <header class="entry-header">
                    <div class="entry-meta">
                      <span class="entry-date"><span class="screen-reader-text">Posted on</span> <a href="http://secaserver.com/2014/11/mysql-calculate-read-write-ratios-percentage/" rel="bookmark"><time class="entry-date" datetime="2014-11-10T23:51:57+00:00" itemprop="datePublished">10 November 2014</time></a></span><span class="byline"><span class="entry-author" itemprop="author" itemscope="itemscope" itemtype="http://schema.org/Person"><span class="screen-reader-text">Author</span> <a class="entry-author-link" href="http://secaserver.com/author/admin/" rel="author" itemprop="url"><span itemprop="name">SecaGuy</span></a></span></span> <span class="comments-link"><a href="http://secaserver.com/2014/11/mysql-calculate-read-write-ratios-percentage/#respond" class="comments-link" itemprop="discussionURL">No Comments <span class="screen-reader-text">on MySQL: Calculate Read and Write Ratios in Percentage</span></a></span>
                    </div>
                    <h2 class="entry-title" itemprop="headline"><a href="http://secaserver.com/2014/11/mysql-calculate-read-write-ratios-percentage/" rel="bookmark">MySQL: Calculate Read and Write Ratios in Percentage</a></h2>
                  </header>
                  <div class="entry-content" itemprop="articleBody">
                    <div class='shareaholic-canvas' data-app-id='9753856' data-app-id-name='index_above_content' data-app='share_buttons' data-title='MySQL: Calculate Read and Write Ratios in Percentage' data-link='http://secaserver.com/2014/11/mysql-calculate-read-write-ratios-percentage/' data-summary=''></div>
                    <p>I have been assigned a task to assist a client to get some idea on his database usage in MySQL Cluster before migrating them to Galera cluster. Galera scales well for reads but not for writes. So the first thing you need to do is to calculate the reads/writes ratio:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">SELECT</span> @total_com <span style="color: #CC0099;">:=</span> <span style="color: #000099;">SUM</span><span style="color: #FF00FF;">&#40;</span><span style="color: #009900;">IF</span><span style="color: #FF00FF;">&#40;</span>variable_name <span style="color: #990099; font-weight: bold;">IN</span> <span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'Com<span style="color: #008080; font-weight: bold;">_</span>select'</span><span style="color: #000033;">,</span> <span style="color: #008000;">'Com<span style="color: #008080; font-weight: bold;">_</span>delete'</span><span style="color: #000033;">,</span> <span style="color: #008000;">'Com<span style="color: #008080; font-weight: bold;">_</span>insert'</span><span style="color: #000033;">,</span> <span style="color: #008000;">'Com<span style="color: #008080; font-weight: bold;">_</span>update'</span><span style="color: #000033;">,</span> <span style="color: #008000;">'Com<span style="color: #008080; font-weight: bold;">_</span>replace'</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">,</span> variable_value<span style="color: #000033;">,</span> <span style="color: #008080;">0</span><span style="color: #FF00FF;">&#41;</span><span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">AS</span> <span style="color: #008000;">`Total`</span><span style="color: #000033;">,</span>
 @total_reads <span style="color: #CC0099;">:=</span> <span style="color: #000099;">SUM</span><span style="color: #FF00FF;">&#40;</span><span style="color: #009900;">IF</span><span style="color: #FF00FF;">&#40;</span>variable_name <span style="color: #CC0099;">=</span> <span style="color: #008000;">'Com<span style="color: #008080; font-weight: bold;">_</span>select'</span><span style="color: #000033;">,</span> variable_value<span style="color: #000033;">,</span> <span style="color: #008080;">0</span><span style="color: #FF00FF;">&#41;</span><span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">AS</span> <span style="color: #008000;">`Total reads`</span><span style="color: #000033;">,</span>
 @total_writes <span style="color: #CC0099;">:=</span> <span style="color: #000099;">SUM</span><span style="color: #FF00FF;">&#40;</span><span style="color: #009900;">IF</span><span style="color: #FF00FF;">&#40;</span>variable_name <span style="color: #990099; font-weight: bold;">IN</span> <span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'Com<span style="color: #008080; font-weight: bold;">_</span>delete'</span><span style="color: #000033;">,</span> <span style="color: #008000;">'Com<span style="color: #008080; font-weight: bold;">_</span>insert'</span><span style="color: #000033;">,</span> <span style="color: #008000;">'Com<span style="color: #008080; font-weight: bold;">_</span>update'</span><span style="color: #000033;">,</span> <span style="color: #008000;">'Com<span style="color: #008080; font-weight: bold;">_</span>replace'</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">,</span> variable_value<span style="color: #000033;">,</span> <span style="color: #008080;">0</span><span style="color: #FF00FF;">&#41;</span><span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">as</span> <span style="color: #008000;">`Total writes`</span><span style="color: #000033;">,</span>
 <span style="color: #000099;">ROUND</span><span style="color: #FF00FF;">&#40;</span><span style="color: #FF00FF;">&#40;</span>@total_reads <span style="color: #CC0099;">/</span> @total_com <span style="color: #CC0099;">*</span> <span style="color: #008080;">100</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">,</span><span style="color: #008080;">2</span><span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">as</span> <span style="color: #008000;">`Reads <span style="color: #008080; font-weight: bold;">%</span>`</span><span style="color: #000033;">,</span>
 <span style="color: #000099;">ROUND</span><span style="color: #FF00FF;">&#40;</span><span style="color: #FF00FF;">&#40;</span>@total_writes <span style="color: #CC0099;">/</span> @total_com <span style="color: #CC0099;">*</span> <span style="color: #008080;">100</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">,</span><span style="color: #008080;">2</span><span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">as</span> <span style="color: #008000;">`Writes <span style="color: #008080; font-weight: bold;">%</span>`</span>
<span style="color: #990099; font-weight: bold;">FROM</span> information_schema.GLOBAL_STATUS<span style="color: #000033;">;</span></pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">SELECT @total_com := SUM(IF(variable_name IN ('Com_select', 'Com_delete', 'Com_insert', 'Com_update', 'Com_replace'), variable_value, 0)) AS `Total`, @total_reads := SUM(IF(variable_name = 'Com_select', variable_value, 0)) AS `Total reads`, @total_writes := SUM(IF(variable_name IN ('Com_delete', 'Com_insert', 'Com_update', 'Com_replace'), variable_value, 0)) as `Total writes`, ROUND((@total_reads / @total_com * 100),2) as `Reads %`, ROUND((@total_writes / @total_com * 100),2) as `Writes %` FROM information_schema.GLOBAL_STATUS;</p>
                    </div>
                    <p>The output would be as below:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="mysql" style="font-family:monospace;"><span style="color: #CC0099;">+------------+-------------+--------------+--------+----------+</span>
<span style="color: #CC0099;">|</span> Total      <span style="color: #CC0099;">|</span> Total reads <span style="color: #CC0099;">|</span> Total writes <span style="color: #CC0099;">|</span> Reads <span style="color: #CC0099;">%</span> <span style="color: #CC0099;">|</span> Writes <span style="color: #CC0099;">%</span> <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">+------------+-------------+--------------+--------+----------+</span>
<span style="color: #CC0099;">|</span> <span style="color: #008080;">1932344732</span> <span style="color: #CC0099;">|</span>  <span style="color: #008080;">1899878513</span> <span style="color: #CC0099;">|</span>     <span style="color: #008080;">32466219</span> <span style="color: #CC0099;">|</span>  <span style="color: #008080;">98.32</span> <span style="color: #CC0099;">|</span>     <span style="color: #008080;">1.68</span> <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">+------------+-------------+--------------+--------+----------+</span>
<span style="color: #008080;">1</span> row <span style="color: #990099; font-weight: bold;">in</span> <span style="color: #990099; font-weight: bold;">set</span> <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">0.00</span> sec<span style="color: #FF00FF;">&#41;</span></pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">+------------+-------------+--------------+--------+----------+ | Total | Total reads | Total writes | Reads % | Writes % | +------------+-------------+--------------+--------+----------+ | 1932344732 | 1899878513 | 32466219 | 98.32 | 1.68 | +------------+-------------+--------------+--------+----------+ 1 row in set (0.00 sec)</p>
                    </div>
                    <p>The output calculated&nbsp;above is relative since the last restart. So if you just restarted your MySQL server, you may need to wait several hours at least to get a more accurate result.</p>
                    <p>Simple initial estimation; if writes percentage is less than 50%, then the schema should be running fine in Galera cluster. However, you need to totally understand the application side as well. Hope this helps people out there!</p>
                  </div>
                  <footer class="entry-footer">
                    <span class="entry-terms category" itemprop="articleSection">Posted in <a href="http://secaserver.com/category/cluster-2/" rel="tag">Cluster</a>, <a href="http://secaserver.com/category/sql/" rel="tag">SQL</a></span><br>
                    <span class="entry-terms post_tag" itemprop="keywords">Tagged <a href="http://secaserver.com/tag/mysql-calculate-ratio/" rel="tag">mysql calculate ratio</a>, <a href="http://secaserver.com/tag/mysql-calculate-read-write/" rel="tag">mysql calculate read write</a>, <a href="http://secaserver.com/tag/mysql-read-write-ratio/" rel="tag">mysql read write ratio</a>, <a href="http://secaserver.com/tag/mysql-show-read-write/" rel="tag">mysql show read write</a></span>
                  </footer>
                </div>
              </article>
              <article id="post-2739" class="post-2739 post type-post status-publish format-standard category-sql tag-export-table-and-split-using-mysql tag-mysql-export-and-split tag-mysql-split-export-files tag-mysql-stored-procedure-export-table entry" itemscope="itemscope" itemtype="http://schema.org/BlogPosting" itemprop="blogPost">
                <div class="entry-inner">
                  <header class="entry-header">
                    <div class="entry-meta">
                      <span class="entry-date"><span class="screen-reader-text">Posted on</span> <a href="http://secaserver.com/2014/10/mysql-export-table-split-csv-stored-procedure/" rel="bookmark"><time class="entry-date" datetime="2014-10-24T00:57:29+00:00" itemprop="datePublished">24 October 2014</time></a></span><span class="byline"><span class="entry-author" itemprop="author" itemscope="itemscope" itemtype="http://schema.org/Person"><span class="screen-reader-text">Author</span> <a class="entry-author-link" href="http://secaserver.com/author/admin/" rel="author" itemprop="url"><span itemprop="name">SecaGuy</span></a></span></span> <span class="comments-link"><a href="http://secaserver.com/2014/10/mysql-export-table-split-csv-stored-procedure/#respond" class="comments-link" itemprop="discussionURL">No Comments <span class="screen-reader-text">on MySQL: Export Table to Splitted CSV using Stored Procedure</span></a></span>
                    </div>
                    <h2 class="entry-title" itemprop="headline"><a href="http://secaserver.com/2014/10/mysql-export-table-split-csv-stored-procedure/" rel="bookmark">MySQL: Export Table to Splitted CSV using Stored Procedure</a></h2>
                  </header>
                  <div class="entry-content" itemprop="articleBody">
                    <div class='shareaholic-canvas' data-app-id='9753856' data-app-id-name='index_above_content' data-app='share_buttons' data-title='MySQL: Export Table to Splitted CSV using Stored Procedure' data-link='http://secaserver.com/2014/10/mysql-export-table-split-csv-stored-procedure/' data-summary=''></div>
                    <p>I have been working with Amazon Redshift lately and I need to export some huge tables (hundred millions of rows) to load them into Redshift cluster. Since Redshift supports parallel bulk loading of data files (CSV, TSV, Json), I took advantage of this feature by splitting the MySQL CSV data files before upload them to S3 for data loading. The only problem was I need to split the records evenly for the selected tables.</p>
                    <p>So, I have came out with following stored procedure. Let&#8217;s say we have two tables in MySQL that we want to export;&nbsp;<em>activity_log</em> and <em>messaging_log</em>.</p>
                    <p>To export and split, copy following stored procedure lines into MySQL:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="mysql" style="font-family:monospace;">DELIMITER <span style="color: #CC0099;">//</span>
<span style="color: #990099; font-weight: bold;">DROP</span> <span style="color: #990099; font-weight: bold;">PROCEDURE</span> <span style="color: #009900;">IF</span> <span style="color: #990099; font-weight: bold;">EXISTS</span> export_csv_split <span style="color: #CC0099;">//</span>
&nbsp;
<span style="color: #990099; font-weight: bold;">CREATE</span> <span style="color: #990099; font-weight: bold;">PROCEDURE</span> export_csv_split <span style="color: #FF00FF;">&#40;</span><span style="color: #990099; font-weight: bold;">IN</span> table_name <span style="color: #999900; font-weight: bold;">VARCHAR</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">50</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">,</span> <span style="color: #990099; font-weight: bold;">IN</span> rows <span style="color: #999900; font-weight: bold;">INT</span><span style="color: #FF00FF;">&#41;</span>
<span style="color: #990099; font-weight: bold;">BEGIN</span>
<span style="color: #990099; font-weight: bold;">DECLARE</span> <span style="color: #00CC00;">x</span> <span style="color: #999900; font-weight: bold;">INT</span><span style="color: #000033;">;</span>
<span style="color: #990099; font-weight: bold;">DECLARE</span> <span style="color: #00CC00;">y</span> <span style="color: #999900; font-weight: bold;">INT</span><span style="color: #000033;">;</span>
<span style="color: #990099; font-weight: bold;">DECLARE</span> total_row <span style="color: #999900; font-weight: bold;">INT</span><span style="color: #000033;">;</span>
&nbsp;
<span style="color: #990099; font-weight: bold;">SET</span> <span style="color: #00CC00;">x</span><span style="color: #CC0099;">=</span><span style="color: #008080;">0</span><span style="color: #000033;">;</span>
<span style="color: #990099; font-weight: bold;">SET</span> <span style="color: #00CC00;">y</span><span style="color: #CC0099;">=</span><span style="color: #008080;">1</span><span style="color: #000033;">;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">-- count the total rows of the select statement as @total_row</span>
<span style="color: #990099; font-weight: bold;">SET</span> @SQLString1 <span style="color: #CC0099;">=</span> <span style="color: #000099;">CONCAT</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'SELECT COUNT(*) INTO @total<span style="color: #008080; font-weight: bold;">_</span>row FROM '</span><span style="color: #000033;">,</span>table_name<span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span>
PREPARE test1 <span style="color: #990099; font-weight: bold;">FROM</span> @SQLString1<span style="color: #000033;">;</span>
EXECUTE test1<span style="color: #000033;">;</span>
&nbsp;
WHILE <span style="color: #00CC00;">x</span> <span style="color: #CC0099;">&lt;=</span> @total_row <span style="color: #990099; font-weight: bold;">DO</span>
&nbsp;
<span style="color: #808080; font-style: italic;">-- export the rows from select statement with limit</span>
<span style="color: #990099; font-weight: bold;">SET</span> @SQLString <span style="color: #CC0099;">=</span> <span style="color: #000099;">CONCAT</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'SELECT * FROM '</span><span style="color: #000033;">,</span>table_name<span style="color: #000033;">,</span><span style="color: #008000;">' LIMIT '</span><span style="color: #000033;">,</span><span style="color: #00CC00;">x</span><span style="color: #000033;">,</span><span style="color: #008000;">','</span><span style="color: #000033;">,</span>rows<span style="color: #000033;">,</span><span style="color: #008000;">' INTO OUTFILE &quot;/tmp/'</span><span style="color: #000033;">,</span>table_name<span style="color: #000033;">,</span><span style="color: #008000;">'-'</span><span style="color: #000033;">,</span><span style="color: #00CC00;">y</span><span style="color: #000033;">,</span><span style="color: #008000;">'.csv&quot; FIELDS TERMINATED BY '</span><span style="color: #008000;">','</span><span style="color: #008000;">' OPTIONALLY ENCLOSED BY '</span><span style="color: #008000;">'&quot;'</span><span style="color: #008000;">' LINES TERMINATED BY '</span><span style="color: #008000;">'<span style="color: #004000; font-weight: bold;">\n</span>'</span><span style="color: #008000;">''</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span>
PREPARE test2 <span style="color: #990099; font-weight: bold;">FROM</span> @SQLString<span style="color: #000033;">;</span>
EXECUTE test2<span style="color: #000033;">;</span>
&nbsp;
<span style="color: #990099; font-weight: bold;">SET</span> <span style="color: #00CC00;">x</span><span style="color: #CC0099;">=</span><span style="color: #00CC00;">x</span><span style="color: #CC0099;">+</span>rows<span style="color: #000033;">;</span>
<span style="color: #990099; font-weight: bold;">SET</span> <span style="color: #00CC00;">y</span><span style="color: #CC0099;">=</span><span style="color: #00CC00;">y</span><span style="color: #CC0099;">+</span><span style="color: #008080;">1</span><span style="color: #000033;">;</span>
&nbsp;
<span style="color: #009900;">END</span> WHILE<span style="color: #000033;">;</span>
&nbsp;
<span style="color: #009900;">END</span> <span style="color: #CC0099;">//</span>
DELIMITER <span style="color: #000033;">;</span></pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">DELIMITER // DROP PROCEDURE IF EXISTS export_csv_split // CREATE PROCEDURE export_csv_split (IN table_name VARCHAR(50), IN rows INT) BEGIN DECLARE x INT; DECLARE y INT; DECLARE total_row INT; SET x=0; SET y=1; -- count the total rows of the select statement as @total_row SET @SQLString1 = CONCAT('SELECT COUNT(*) INTO @total_row FROM ',table_name); PREPARE test1 FROM @SQLString1; EXECUTE test1; WHILE x &lt;= @total_row DO -- export the rows from select statement with limit SET @SQLString = CONCAT('SELECT * FROM ',table_name,' LIMIT ',x,',',rows,' INTO OUTFILE &quot;/tmp/',table_name,'-',y,'.csv&quot; FIELDS TERMINATED BY '','' OPTIONALLY ENCLOSED BY ''&quot;'' LINES TERMINATED BY ''\n'''); PREPARE test2 FROM @SQLString; EXECUTE test2; SET x=x+rows; SET y=y+1; END WHILE; END // DELIMITER ;</p>
                    </div>
                    <p>Then, call the stored procedure and pass the table name and the number of rows per file, 10M rows per file for table activity log and 5M rows per file for table messaging_log:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="mysql" style="font-family:monospace;">mysql<span style="color: #CC0099;">&gt;</span> <span style="color: #990099; font-weight: bold;">call</span> export_csv_split<span style="color: #FF00FF;">&#40;</span>activity_log<span style="color: #000033;">,</span><span style="color: #008080;">10000000</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span>
mysql<span style="color: #CC0099;">&gt;</span> <span style="color: #990099; font-weight: bold;">call</span> export_csv_split<span style="color: #FF00FF;">&#40;</span>messaging_log<span style="color: #000033;">,</span><span style="color: #008080;">5000000</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span></pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">mysql&gt; call export_csv_split(activity_log,10000000); mysql&gt; call export_csv_split(messaging_log,5000000);</p>
                    </div>
                    <p>The data files will be generated under /tmp directory:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-1</span> <span style="color: #000000; font-weight: bold;">/</span>tmp
activity_log-<span style="color: #000000;">1</span>.csv
activity_log-<span style="color: #000000;">2</span>.csv
activity_log-<span style="color: #000000;">3</span>.csv
activity_log-<span style="color: #000000;">4</span>.csv
activity_log-<span style="color: #000000;">5</span>.csv
activity_log-<span style="color: #000000;">6</span>.csv
...</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$&nbsp;ls -1 /tmp activity_log-1.csv activity_log-2.csv activity_log-3.csv activity_log-4.csv activity_log-5.csv activity_log-6.csv ...</p>
                    </div>
                    <p>&nbsp;</p>
                    <p>For another case, some huge tables need to be exported with conditions; export all records which have been&nbsp;created for the last 10 years:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="mysql" style="font-family:monospace;">DELIMITER <span style="color: #CC0099;">//</span>
<span style="color: #990099; font-weight: bold;">DROP</span> <span style="color: #990099; font-weight: bold;">PROCEDURE</span> <span style="color: #009900;">IF</span> <span style="color: #990099; font-weight: bold;">EXISTS</span> export_csv_split_condition <span style="color: #CC0099;">//</span>
&nbsp;
<span style="color: #990099; font-weight: bold;">CREATE</span> <span style="color: #990099; font-weight: bold;">PROCEDURE</span> export_csv_split_condition <span style="color: #FF00FF;">&#40;</span><span style="color: #990099; font-weight: bold;">IN</span> table_name <span style="color: #999900; font-weight: bold;">VARCHAR</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">50</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">,</span> <span style="color: #990099; font-weight: bold;">IN</span> rows <span style="color: #999900; font-weight: bold;">INT</span><span style="color: #FF00FF;">&#41;</span>
<span style="color: #990099; font-weight: bold;">BEGIN</span>
<span style="color: #990099; font-weight: bold;">DECLARE</span> <span style="color: #00CC00;">x</span> <span style="color: #999900; font-weight: bold;">INT</span><span style="color: #000033;">;</span>
<span style="color: #990099; font-weight: bold;">DECLARE</span> <span style="color: #00CC00;">y</span> <span style="color: #999900; font-weight: bold;">INT</span><span style="color: #000033;">;</span>
<span style="color: #990099; font-weight: bold;">DECLARE</span> total_row <span style="color: #999900; font-weight: bold;">INT</span><span style="color: #000033;">;</span>
&nbsp;
<span style="color: #990099; font-weight: bold;">SET</span> <span style="color: #00CC00;">x</span><span style="color: #CC0099;">=</span><span style="color: #008080;">0</span><span style="color: #000033;">;</span>
<span style="color: #990099; font-weight: bold;">SET</span> <span style="color: #00CC00;">y</span><span style="color: #CC0099;">=</span><span style="color: #008080;">1</span><span style="color: #000033;">;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">-- condition of the select statement</span>
<span style="color: #990099; font-weight: bold;">SET</span> @condition <span style="color: #CC0099;">=</span> <span style="color: #000099;">CONCAT</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'WHERE DATE(created) &lt; '</span><span style="color: #008000;">'2014-01-01'</span><span style="color: #008000;">' AND DATE(created) &gt;= '</span><span style="color: #008000;">'2004-01-01'</span><span style="color: #008000;">''</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">-- count the total rows of the select statement + condition as @total_row</span>
<span style="color: #990099; font-weight: bold;">SET</span> @SQLString1 <span style="color: #CC0099;">=</span> <span style="color: #000099;">CONCAT</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'SELECT COUNT(*) INTO @total<span style="color: #008080; font-weight: bold;">_</span>row FROM '</span><span style="color: #000033;">,</span>table_name<span style="color: #000033;">,</span><span style="color: #008000;">' '</span><span style="color: #000033;">,</span>@condition<span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span>
PREPARE test1 <span style="color: #990099; font-weight: bold;">FROM</span> @SQLString1<span style="color: #000033;">;</span>
EXECUTE test1<span style="color: #000033;">;</span>
&nbsp;
WHILE <span style="color: #00CC00;">x</span> <span style="color: #CC0099;">&lt;=</span> @total_row <span style="color: #990099; font-weight: bold;">DO</span>
&nbsp;
<span style="color: #808080; font-style: italic;">-- export the rows from select statement + condition with limit</span>
<span style="color: #990099; font-weight: bold;">SET</span> @SQLString <span style="color: #CC0099;">=</span> <span style="color: #000099;">CONCAT</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'SELECT * FROM '</span><span style="color: #000033;">,</span>table_name<span style="color: #000033;">,</span><span style="color: #008000;">' '</span><span style="color: #000033;">,</span>@condition<span style="color: #000033;">,</span><span style="color: #008000;">' LIMIT '</span><span style="color: #000033;">,</span><span style="color: #00CC00;">x</span><span style="color: #000033;">,</span><span style="color: #008000;">','</span><span style="color: #000033;">,</span>rows<span style="color: #000033;">,</span><span style="color: #008000;">' INTO OUTFILE &quot;/tmp/'</span><span style="color: #000033;">,</span>table_name<span style="color: #000033;">,</span><span style="color: #008000;">'-'</span><span style="color: #000033;">,</span><span style="color: #00CC00;">y</span><span style="color: #000033;">,</span><span style="color: #008000;">'.csv&quot; FIELDS TERMINATED BY '</span><span style="color: #008000;">','</span><span style="color: #008000;">' OPTIONALLY ENCLOSED BY '</span><span style="color: #008000;">'&quot;'</span><span style="color: #008000;">' LINES TERMINATED BY '</span><span style="color: #008000;">'<span style="color: #004000; font-weight: bold;">\n</span>'</span><span style="color: #008000;">''</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span>
PREPARE test2 <span style="color: #990099; font-weight: bold;">FROM</span> @SQLString<span style="color: #000033;">;</span>
EXECUTE test2<span style="color: #000033;">;</span>
&nbsp;
<span style="color: #990099; font-weight: bold;">SET</span> <span style="color: #00CC00;">x</span><span style="color: #CC0099;">=</span><span style="color: #00CC00;">x</span><span style="color: #CC0099;">+</span>rows<span style="color: #000033;">;</span>
<span style="color: #990099; font-weight: bold;">SET</span> <span style="color: #00CC00;">y</span><span style="color: #CC0099;">=</span><span style="color: #00CC00;">y</span><span style="color: #CC0099;">+</span><span style="color: #008080;">1</span><span style="color: #000033;">;</span>
&nbsp;
<span style="color: #009900;">END</span> WHILE<span style="color: #000033;">;</span>
&nbsp;
<span style="color: #009900;">END</span> <span style="color: #CC0099;">//</span>
DELIMITER <span style="color: #000033;">;</span></pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">DELIMITER // DROP PROCEDURE IF EXISTS export_csv_split_condition // CREATE PROCEDURE export_csv_split_condition (IN table_name VARCHAR(50), IN rows INT) BEGIN DECLARE x INT; DECLARE y INT; DECLARE total_row INT; SET x=0; SET y=1; -- condition of the select statement SET @condition = CONCAT('WHERE DATE(created) &lt; ''2014-01-01'' AND DATE(created) &gt;= ''2004-01-01'''); -- count the total rows of the select statement + condition as @total_row SET @SQLString1 = CONCAT('SELECT COUNT(*) INTO @total_row FROM ',table_name,' ',@condition); PREPARE test1 FROM @SQLString1; EXECUTE test1; WHILE x &lt;= @total_row DO -- export the rows from select statement + condition with limit SET @SQLString = CONCAT('SELECT * FROM ',table_name,' ',@condition,' LIMIT ',x,',',rows,' INTO OUTFILE &quot;/tmp/',table_name,'-',y,'.csv&quot; FIELDS TERMINATED BY '','' OPTIONALLY ENCLOSED BY ''&quot;'' LINES TERMINATED BY ''\n'''); PREPARE test2 FROM @SQLString; EXECUTE test2; SET x=x+rows; SET y=y+1; END WHILE; END // DELIMITER ;</p>
                    </div>
                    <p>Similar to the first case, just call the stored procedure as below:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="mysql" style="font-family:monospace;">mysql<span style="color: #CC0099;">&gt;</span> <span style="color: #990099; font-weight: bold;">call</span> export_csv_split_condition<span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'tbl<span style="color: #008080; font-weight: bold;">_</span>user<span style="color: #008080; font-weight: bold;">_</span>activities'</span><span style="color: #000033;">,</span><span style="color: #008080;">1000000</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span></pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">mysql&gt; call&nbsp;export_csv_split_condition('tbl_user_activities',1000000);</p>
                    </div>
                    <p>You may need to change the COUNT(*) to single column lookup instead, e.g: COUNT(id) to speed up the rows counting process in InnoDB/XtraDB storage engine. Hope this simple sharing can help you a lot on exporting huge tables to CSV.</p>
                  </div>
                  <footer class="entry-footer">
                    <span class="entry-terms category" itemprop="articleSection">Posted in <a href="http://secaserver.com/category/sql/" rel="tag">SQL</a></span><br>
                    <span class="entry-terms post_tag" itemprop="keywords">Tagged <a href="http://secaserver.com/tag/export-table-and-split-using-mysql/" rel="tag">export table and split using mysql</a>, <a href="http://secaserver.com/tag/mysql-export-and-split/" rel="tag">mysql export and split</a>, <a href="http://secaserver.com/tag/mysql-split-export-files/" rel="tag">mysql split export files</a>, <a href="http://secaserver.com/tag/mysql-stored-procedure-export-table/" rel="tag">mysql stored procedure export table</a></span>
                  </footer>
                </div>
              </article>
              <article id="post-2699" class="post-2699 post type-post status-publish format-standard category-installation category-linux tag-install-puppet-centos tag-install-puppet-debian tag-install-puppet-redhat tag-install-puppet-the-simplest-way tag-install-puppet-ubuntu tag-simple-puppet-tutorial entry" itemscope="itemscope" itemtype="http://schema.org/BlogPosting" itemprop="blogPost">
                <div class="entry-inner">
                  <header class="entry-header">
                    <div class="entry-meta">
                      <span class="entry-date"><span class="screen-reader-text">Posted on</span> <a href="http://secaserver.com/2014/10/install-puppet-os-distributions/" rel="bookmark"><time class="entry-date" datetime="2014-10-13T08:25:04+00:00" itemprop="datePublished">13 October 2014</time></a></span><span class="byline"><span class="entry-author" itemprop="author" itemscope="itemscope" itemtype="http://schema.org/Person"><span class="screen-reader-text">Author</span> <a class="entry-author-link" href="http://secaserver.com/author/admin/" rel="author" itemprop="url"><span itemprop="name">SecaGuy</span></a></span></span> <span class="comments-link"><a href="http://secaserver.com/2014/10/install-puppet-os-distributions/#respond" class="comments-link" itemprop="discussionURL">No Comments <span class="screen-reader-text">on Install Puppet on CentOS, Redhat, Ubuntu, Debian</span></a></span>
                    </div>
                    <h2 class="entry-title" itemprop="headline"><a href="http://secaserver.com/2014/10/install-puppet-os-distributions/" rel="bookmark">Install Puppet on CentOS, Redhat, Ubuntu, Debian</a></h2>
                  </header>
                  <div class="entry-content" itemprop="articleBody">
                    <div class='shareaholic-canvas' data-app-id='9753856' data-app-id-name='index_above_content' data-app='share_buttons' data-title='Install Puppet on CentOS, Redhat, Ubuntu, Debian' data-link='http://secaserver.com/2014/10/install-puppet-os-distributions/' data-summary=''></div>
                    <p>Lately, I have been spending my time doing research on developing a Puppet module. As you might know, Puppet is an orchestration tool used by many sysadmins to deploy and configure servers without hassle on repeating the same installation commands over and over again.</p>
                    <p>With Puppet you just simply:</p>
                    <ol>
                      <li>Install Puppet master</li>
                      <li>Define node configuration in Puppet master</li>
                      <li>Install Puppet agent</li>
                      <li>Let the Puppet agent deploy what you have defined</li>
                    </ol>
                    <p>Developing Puppet module requires me to test the module&#8217;s manifest on many popular OS distributions out there. I am going to stick with the subject of this post on installing Puppet on following OS distributions:</p>
                    <ul>
                      <li>RHEL 6/CentOS 6</li>
                      <li>RHEL 5/CentOS 5</li>
                      <li>Ubuntu 12.04</li>
                      <li>Ubuntu 14.04</li>
                      <li>Debian 6</li>
                      <li>Debian 7</li>
                    </ul>
                    <p>&nbsp;</p>
                    <h2>Requirement</h2>
                    <p>Ensure the host&#8217;s date and time is synced through ntp and <em>/etc/hosts</em> is configured correctly. Following is the example of <em>/etc/hosts</em> definition that I used:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;">192.168.10.100    puppetmaster.local
192.168.10.101    mysql1.local   <span style="color: #666666; font-style: italic;"># puppet-agent</span>
192.168.10.102    mysql2.local   <span style="color: #666666; font-style: italic;"># puppet-agent</span>
192.168.10.103    mysql3.local   <span style="color: #666666; font-style: italic;"># puppet-agent</span></pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">192.168.10.100 &nbsp; &nbsp;puppetmaster.local 192.168.10.101 &nbsp; &nbsp;mysql1.local &nbsp; # puppet-agent 192.168.10.102 &nbsp; &nbsp;mysql2.local # puppet-agent 192.168.10.103 &nbsp; &nbsp;mysql3.local &nbsp; # puppet-agent</p>
                    </div>
                    <p>** The <em>/etc/hosts</em>&nbsp;must be same on all nodes so hostname can be resolved to an IP. This is required later during the certificate signing stage by puppet master.</p>
                    <p>RHEL-based:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">yum install</span> <span style="color: #660033;">-y</span> ntpdate
ntpdate <span style="color: #660033;">-u</span> my.pool.ntp.org</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">yum install -y ntpdate ntpdate -u my.pool.ntp.org</p>
                    </div>
                    <p>Debian-based:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get install</span> <span style="color: #660033;">-y</span> ntpdate
ntpdate <span style="color: #660033;">-u</span> my.pool.ntp.org</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">sudo apt-get install -y ntpdate ntpdate -u my.pool.ntp.org</p>
                    </div>
                    <h2></h2>
                    <h2>Installing Puppetlabs Repository</h2>
                    <p>We&#8217;ll need to install official Puppetlabs repository on all nodes regardless of their role in puppet for the installation purposes. Install the repository definition on respective OS distribution:</p>
                    <p>RHEL 6/CentOS 6:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;">rpm <span style="color: #660033;">-ivh</span> http:<span style="color: #000000; font-weight: bold;">//</span>yum.puppetlabs.com<span style="color: #000000; font-weight: bold;">/</span>puppetlabs-release-el-<span style="color: #000000;">6</span>.noarch.rpm</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">rpm -ivh http://yum.puppetlabs.com/puppetlabs-release-el-6.noarch.rpm</p>
                    </div>
                    <p>RHEL 5/CentOS 5:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;">rpm <span style="color: #660033;">-ivh</span> http:<span style="color: #000000; font-weight: bold;">//</span>yum.puppetlabs.com<span style="color: #000000; font-weight: bold;">/</span>puppetlabs-release-el-<span style="color: #000000;">5</span>.noarch.rpm</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">rpm -ivh http://yum.puppetlabs.com/puppetlabs-release-el-5.noarch.rpm</p>
                    </div>
                    <p>Ubuntu 12.04 (Precise):</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">wget</span> https:<span style="color: #000000; font-weight: bold;">//</span>apt.puppetlabs.com<span style="color: #000000; font-weight: bold;">/</span>puppetlabs-release-precise.deb
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">dpkg</span> -i puppetlabs-release-precise.deb</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">wget https://apt.puppetlabs.com/puppetlabs-release-precise.deb sudo dpkg -i&nbsp;puppetlabs-release-precise.deb</p>
                    </div>
                    <p>Ubuntu 14.04 (Trusty):</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">wget</span> https:<span style="color: #000000; font-weight: bold;">//</span>apt.puppetlabs.com<span style="color: #000000; font-weight: bold;">/</span>puppetlabs-release-trusty.deb
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">dpkg</span> -i puppetlabs-release-trusty.deb</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">wget https://apt.puppetlabs.com/puppetlabs-release-trusty.deb sudo dpkg -i&nbsp;puppetlabs-release-trusty.deb</p>
                    </div>
                    <p>Debian 6 (Squeeze):</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">wget</span> https:<span style="color: #000000; font-weight: bold;">//</span>apt.puppetlabs.com<span style="color: #000000; font-weight: bold;">/</span>puppetlabs-release-squeeze.deb
<span style="color: #c20cb9; font-weight: bold;">dpkg</span> <span style="color: #660033;">-i</span> puppetlabs-release-squeeze.deb</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">wget https://apt.puppetlabs.com/puppetlabs-release-squeeze.deb dpkg -i puppetlabs-release-squeeze.deb</p>
                    </div>
                    <p>Debian 7 (Wheezy):</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">wget</span> https:<span style="color: #000000; font-weight: bold;">//</span>apt.puppetlabs.com<span style="color: #000000; font-weight: bold;">/</span>puppetlabs-release-wheezy.deb
<span style="color: #c20cb9; font-weight: bold;">dpkg</span> <span style="color: #660033;">-i</span> puppetlabs-release-wheezy.deb</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">wget https://apt.puppetlabs.com/puppetlabs-release-wheezy.deb dpkg -i puppetlabs-release-wheezy.deb</p>
                    </div>
                    <p>&nbsp;</p>
                    <h2>Installing Puppet Master</h2>
                    <p>On puppetmaster.local node, run following command to install Puppet master:</p>
                    <p>Redhat-based:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">yum install</span> <span style="color: #660033;">-y</span> puppet-server openssl</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">yum install -y puppet-server openssl</p>
                    </div>
                    <p>Debian-based:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get update</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get install</span> <span style="color: #660033;">-y</span> puppetmaster openssl</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">sudo apt-get update sudo apt-get install -y puppetmaster openssl</p>
                    </div>
                    <p>&nbsp;</p>
                    <h2>Installing Puppet Agent</h2>
                    <p>On all puppet agent nodes (mysql1.local, mysql2.local, mysql3.local), install puppet agent and its dependencies:</p>
                    <p>Redhat-based:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">yum install</span> <span style="color: #660033;">-y</span> puppet facter openssl</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">yum install -y puppet facter openssl</p>
                    </div>
                    <p>Debian-based:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get update</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get install</span> <span style="color: #660033;">-y</span> puppet facter openssl</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">sudo apt-get update sudo apt-get install -y puppet facter openssl</p>
                    </div>
                    <p>&nbsp;</p>
                    <h3>Signing the Certificate Authority</h3>
                    <p>Puppet communicates through a secured channel&nbsp;with SSL. When puppet agent runs for the first time, it&nbsp;will auto-generate a new SSL and puppet master must sign it before all the communications begin. Run following command on each agent node:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;">$ puppet agent <span style="color: #660033;">--server</span>=puppetmaser.local <span style="color: #660033;">--no-daemonize</span> <span style="color: #660033;">--verbose</span>
Info: Creating a new SSL key <span style="color: #000000; font-weight: bold;">for</span> mysql1.local
Info: Caching certificate <span style="color: #000000; font-weight: bold;">for</span> ca
Info: csr_attributes <span style="color: #c20cb9; font-weight: bold;">file</span> loading from <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>puppet<span style="color: #000000; font-weight: bold;">/</span>csr_attributes.yaml
Info: Creating a new SSL certificate request <span style="color: #000000; font-weight: bold;">for</span> ccpuppet.local
Info: Certificate Request fingerprint <span style="color: #7a0874; font-weight: bold;">&#40;</span>SHA256<span style="color: #7a0874; font-weight: bold;">&#41;</span>: 6F:8B:<span style="color: #000000;">92</span>:<span style="color: #000000;">46</span>:B0:3F:04:0A:4F:8D:BD:<span style="color: #000000;">56</span>:<span style="color: #000000;">77</span>:<span style="color: #000000;">24</span>:<span style="color: #000000;">77</span>:<span style="color: #000000;">50</span>:1C:E9:F4:EE:C6:00:5E:<span style="color: #000000;">82</span>:4F:B0:<span style="color: #000000;">85</span>:B5:<span style="color: #000000;">26</span>:<span style="color: #000000;">72</span>:<span style="color: #000000;">43</span>:E0
Info: Caching certificate <span style="color: #000000; font-weight: bold;">for</span> ca</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ puppet agent --server=puppetmaser.local --no-daemonize --verbose Info: Creating a new SSL key for mysql1.local Info: Caching certificate for ca Info: csr_attributes file loading from /etc/puppet/csr_attributes.yaml Info: Creating a new SSL certificate request for ccpuppet.local Info: Certificate Request fingerprint (SHA256): 6F:8B:92:46:B0:3F:04:0A:4F:8D:BD:56:77:24:77:50:1C:E9:F4:EE:C6:00:5E:82:4F:B0:85:B5:26:72:43:E0 Info: Caching certificate for ca</p>
                    </div>
                    <p>This will generate a certificate to be signed by the puppet master. Now in the puppet master, list the certificate authority (CA):</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;">$ puppet ca list
mysql1.local  <span style="color: #7a0874; font-weight: bold;">&#40;</span>SHA256<span style="color: #7a0874; font-weight: bold;">&#41;</span> 6F:8B:<span style="color: #000000;">92</span>:<span style="color: #000000;">46</span>:B0:3F:04:0A:4F:8D:BD:<span style="color: #000000;">56</span>:<span style="color: #000000;">77</span>:<span style="color: #000000;">24</span>:<span style="color: #000000;">77</span>:<span style="color: #000000;">50</span>:1C:E9:F4:EE:C6:00:5E:<span style="color: #000000;">82</span>:4F:B0:<span style="color: #000000;">85</span>:B5:<span style="color: #000000;">26</span>:<span style="color: #000000;">72</span>:<span style="color: #000000;">43</span>:E0</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ puppet ca list mysql1.local (SHA256) 6F:8B:92:46:B0:3F:04:0A:4F:8D:BD:56:77:24:77:50:1C:E9:F4:EE:C6:00:5E:82:4F:B0:85:B5:26:72:43:E0</p>
                    </div>
                    <p>Sign the CA for this agent:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;">$ puppet ca sign mysql1.local
Notice: Signed certificate request <span style="color: #000000; font-weight: bold;">for</span> mysql1.local
Notice: Removing <span style="color: #c20cb9; font-weight: bold;">file</span> Puppet::SSL::CertificateRequest ccpuppet.local at <span style="color: #ff0000;">'/var/lib/puppet/ssl/ca/requests/mysql1.local.pem'</span>
<span style="color: #ff0000;">&quot;-----BEGIN CERTIFICATE-----<span style="color: #000099; font-weight: bold;">\n</span>
...the key...&quot;</span></pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ puppet ca sign mysql1.local Notice: Signed certificate request for mysql1.local Notice: Removing file Puppet::SSL::CertificateRequest ccpuppet.local at '/var/lib/puppet/ssl/ca/requests/mysql1.local.pem' &quot;-----BEGIN CERTIFICATE-----\n ...the key...&quot;</p>
                    </div>
                    <p>Repeat the above steps on the other nodes, mysql2.local and mysql3.local. Now the puppet master should able to communicate with its agents securely.</p>
                    <p>&nbsp;</p>
                    <h3>Configure Puppet Agent</h3>
                    <p>The last step is to update&nbsp;<em>/etc/puppet/puppet.conf</em> and add following line under [main] directive:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #007800;">server</span>=puppetmaster.local</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">server=puppetmaster.local</p>
                    </div>
                    <p>** If you do not configure as above, you will need to add &#8211;server=puppetmaster.local on each of the puppet agent command below.</p>
                    <p>Now you can test from the agent node:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;">puppet agent <span style="color: #660033;">--test</span></pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">puppet agent --test</p>
                    </div>
                    <p>&nbsp;</p>
                    <h2>Deploy MySQL through Puppet</h2>
                    <p>Puppet is now ready. Let&#8217;s deploy a mysql server with the simplest way. Go to Puppet Forge and look for a puppet&nbsp;module called puppetlabs-mysql. To install this module, run following command on to the puppet master node:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;">puppet module <span style="color: #c20cb9; font-weight: bold;">install</span> puppetlabs-mysql</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">puppet module install puppetlabs-mysql</p>
                    </div>
                    <p>On the puppetmaster.local, create a puppet manifest to define how the agent should deploy at <em>/etc/puppet/manifests/site.pp</em>:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># /etc/puppet/manifests/site.pp</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Default node - this is compulsory</span>
node <span style="color: #ff0000;">&quot;default&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Define the agent nodes</span>
node <span style="color: #ff0000;">&quot;mysql1.local&quot;</span>, <span style="color: #ff0000;">&quot;mysql2.local&quot;</span>, <span style="color: #ff0000;">&quot;mysql3.local&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
 class <span style="color: #7a0874; font-weight: bold;">&#123;</span> <span style="color: #ff0000;">'::mysql::server'</span>:
 root_password =<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #ff0000;">'strongpassword'</span>
 <span style="color: #7a0874; font-weight: bold;">&#125;</span>
 class <span style="color: #7a0874; font-weight: bold;">&#123;</span> <span style="color: #ff0000;">'::mysql::client'</span>:
 package_ensure =<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #ff0000;">'present'</span>
 <span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;"># /etc/puppet/manifests/site.pp # Default node - this is compulsory node &quot;default&quot; { } # Define the agent nodes node &quot;mysql1.local&quot;, &quot;mysql2.local&quot;, &quot;mysql3.local&quot; { class { '::mysql::server': root_password =&gt; 'strongpassword' } class { '::mysql::client': package_ensure =&gt; 'present' } }</p>
                    </div>
                    <p>Above definition will tell Puppet to install a MySQL server and client package on mysql1.local, mysql2.local and mysql3.local. To immediately start the deployment, go to the agent node and run:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;">puppet agent <span style="color: #660033;">--test</span></pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">puppet agent --test</p>
                    </div>
                    <p>Or, wait for the Puppet agent service to apply the catalog automatically (depending on the <em>runinterval</em> value, default is 30 minutes).</p>
                    <p>Once done, you will have three MySQL servers ready to serve! Imagine how much time you would save if you have many servers, applications, softwares and configurations to maintain.</p>
                  </div>
                  <footer class="entry-footer">
                    <span class="entry-terms category" itemprop="articleSection">Posted in <a href="http://secaserver.com/category/installation/" rel="tag">Installation</a>, <a href="http://secaserver.com/category/linux/" rel="tag">Linux</a></span><br>
                    <span class="entry-terms post_tag" itemprop="keywords">Tagged <a href="http://secaserver.com/tag/install-puppet-centos/" rel="tag">install puppet centos</a>, <a href="http://secaserver.com/tag/install-puppet-debian/" rel="tag">install puppet debian</a>, <a href="http://secaserver.com/tag/install-puppet-redhat/" rel="tag">install puppet redhat</a>, <a href="http://secaserver.com/tag/install-puppet-the-simplest-way/" rel="tag">install puppet the simplest way</a>, <a href="http://secaserver.com/tag/install-puppet-ubuntu/" rel="tag">install puppet ubuntu</a>, <a href="http://secaserver.com/tag/simple-puppet-tutorial/" rel="tag">simple puppet tutorial</a></span>
                  </footer>
                </div>
              </article>
              <article id="post-2690" class="post-2690 post type-post status-publish format-standard category-scripts category-sql category-troubleshooting tag-galera-gra-reader tag-gra-file-content tag-how-to-read-gra-file tag-view-gra-file entry" itemscope="itemscope" itemtype="http://schema.org/BlogPosting" itemprop="blogPost">
                <div class="entry-inner">
                  <header class="entry-header">
                    <div class="entry-meta">
                      <span class="entry-date"><span class="screen-reader-text">Posted on</span> <a href="http://secaserver.com/2014/10/galera-read-gra-log-files/" rel="bookmark"><time class="entry-date" datetime="2014-10-09T02:03:47+00:00" itemprop="datePublished">9 October 2014</time></a></span><span class="byline"><span class="entry-author" itemprop="author" itemscope="itemscope" itemtype="http://schema.org/Person"><span class="screen-reader-text">Author</span> <a class="entry-author-link" href="http://secaserver.com/author/admin/" rel="author" itemprop="url"><span itemprop="name">SecaGuy</span></a></span></span> <span class="comments-link"><a href="http://secaserver.com/2014/10/galera-read-gra-log-files/#respond" class="comments-link" itemprop="discussionURL">No Comments <span class="screen-reader-text">on Galera Cluster &#8211; Simpler way to view GRA file content</span></a></span>
                    </div>
                    <h2 class="entry-title" itemprop="headline"><a href="http://secaserver.com/2014/10/galera-read-gra-log-files/" rel="bookmark">Galera Cluster &#8211; Simpler way to view GRA file content</a></h2>
                  </header>
                  <div class="entry-content" itemprop="articleBody">
                    <div class='shareaholic-canvas' data-app-id='9753856' data-app-id-name='index_above_content' data-app='share_buttons' data-title='Galera Cluster - Simpler way to view GRA file content' data-link='http://secaserver.com/2014/10/galera-read-gra-log-files/' data-summary=''></div>
                    <p>Galera Cluster (MySQL from Codership, Percona XtraDB Cluster, MariaDB Galera Cluster) generates a GRA log files if it fails to&nbsp;apply the writeset on the target node. This files exists in the MySQL data directory. You can get an overview of the file (if exist) by listing your MySQL data directory (in my case, the data directory is at <em>/var/lib/mysql</em>):</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-1</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>mysql <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> GRA
GRA_10_104865779.log
GRA_13_104865781.log
GRA_5_104865780.log</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$ ls -1 /var/lib/mysql | grep GRA GRA_10_104865779.log GRA_13_104865781.log GRA_5_104865780.log</p>
                    </div>
                    <p>MySQL Performance Blog&nbsp;has covered this topic in well-explained. I&#8217;m going to make this simple. Download <a href="http://secaserver.com/files/grareader">the script here</a> and copy it&nbsp;to your <em>/usr/bin</em> directory:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>blog.secaserver.com<span style="color: #000000; font-weight: bold;">/</span>files<span style="color: #000000; font-weight: bold;">/</span>grareader <span style="color: #660033;">-P</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">755</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>grareader</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">wget&nbsp;http://secaserver.com/files/grareader -P /usr/bin/ chmod 755 /usr/bin/grareader</p>
                    </div>
                    <p>Just run following command to simply convert the GRA log file to a human-readable output:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;">grareader <span style="color: #7a0874; font-weight: bold;">&#91;</span>gra_log_file<span style="color: #7a0874; font-weight: bold;">&#93;</span></pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">grareader [gra_log_file]</p>
                    </div>
                    <p>Here is the example output:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="mysql" style="font-family:monospace;"><span style="color: #808000; font-style: italic;">/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/</span><span style="color: #000033;">;</span>
<span style="color: #808000; font-style: italic;">/*!40019 SET @@session.max_insert_delayed_threads=0*/</span><span style="color: #000033;">;</span>
<span style="color: #808000; font-style: italic;">/*!50003 SET @<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="317e7d756e727e7c617d7465787e7f6e656861740c71">[email&#160;protected]</a>@COMPLETION_TYPE,COMPLETION_TYPE=0*/</span><span style="color: #000033;">;</span>
DELIMITER <span style="color: #808000; font-style: italic;">/*!*/</span><span style="color: #000033;">;</span>
<span style="color: #808080; font-style: italic;"># at 4</span>
<span style="color: #808080; font-style: italic;">#140114 3:12:42 server id 3 end_log_pos 120 Start: binlog v 4, server v 5.6.15-log created 140114 3:12:42 at startup</span>
<span style="color: #990099; font-weight: bold;">ROLLBACK</span><span style="color: #808000; font-style: italic;">/*!*/</span><span style="color: #000033;">;</span>
BINLOG <span style="color: #008000;">'
qjrUUg8DAAAAdAAAAHgAAAAAAAQANS42LjE1LWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAACqOtRSEzgNAAgAEgAEBAQEEgAAXAAEGggAAAAICAgCAAAACgoKGRkAAf73
8eY=
'</span><span style="color: #808000; font-style: italic;">/*!*/</span><span style="color: #000033;">;</span>
<span style="color: #808080; font-style: italic;"># at 120</span>
<span style="color: #808080; font-style: italic;">#140114 3:12:43 server id 3 end_log_pos 143 Stop</span>
<span style="color: #808080; font-style: italic;"># at 143</span>
<span style="color: #808080; font-style: italic;">#140507 14:55:42 server id 4 end_log_pos 126 Query thread_id=3173489 exec_time=0 error_code=0</span>
<span style="color: #990099; font-weight: bold;">use</span> <span style="color: #008000;">`test<span style="color: #008080; font-weight: bold;">_</span>shop`</span><span style="color: #808000; font-style: italic;">/*!*/</span><span style="color: #000033;">;</span>
<span style="color: #990099; font-weight: bold;">SET</span> <span style="color: #999900; font-weight: bold;">TIMESTAMP</span><span style="color: #CC0099;">=</span><span style="color: #008080;">1399445742</span><span style="color: #808000; font-style: italic;">/*!*/</span><span style="color: #000033;">;</span>
<span style="color: #990099; font-weight: bold;">SET</span> @@<span style="color: #990099; font-weight: bold;">session</span>.pseudo_thread_id<span style="color: #CC0099;">=</span><span style="color: #008080;">3173489</span><span style="color: #808000; font-style: italic;">/*!*/</span><span style="color: #000033;">;</span>
<span style="color: #990099; font-weight: bold;">SET</span> @@<span style="color: #990099; font-weight: bold;">session</span>.foreign_key_checks<span style="color: #CC0099;">=</span><span style="color: #008080;">1</span><span style="color: #000033;">,</span> @@<span style="color: #990099; font-weight: bold;">session</span>.sql_auto_is_null<span style="color: #CC0099;">=</span><span style="color: #008080;">0</span><span style="color: #000033;">,</span> @@<span style="color: #990099; font-weight: bold;">session</span>.unique_checks<span style="color: #CC0099;">=</span><span style="color: #008080;">1</span><span style="color: #000033;">,</span> @@<span style="color: #990099; font-weight: bold;">session</span>.autocommit<span style="color: #CC0099;">=</span><span style="color: #008080;">1</span><span style="color: #808000; font-style: italic;">/*!*/</span><span style="color: #000033;">;</span>
<span style="color: #990099; font-weight: bold;">SET</span> @@<span style="color: #990099; font-weight: bold;">session</span>.sql_mode<span style="color: #CC0099;">=</span><span style="color: #008080;">0</span><span style="color: #808000; font-style: italic;">/*!*/</span><span style="color: #000033;">;</span>
<span style="color: #990099; font-weight: bold;">SET</span> @@<span style="color: #990099; font-weight: bold;">session</span>.auto_increment_increment<span style="color: #CC0099;">=</span><span style="color: #008080;">1</span><span style="color: #000033;">,</span> @@<span style="color: #990099; font-weight: bold;">session</span>.auto_increment_offset<span style="color: #CC0099;">=</span><span style="color: #008080;">1</span><span style="color: #808000; font-style: italic;">/*!*/</span><span style="color: #000033;">;</span>
<span style="color: #808000; font-style: italic;">/*!\C utf8 */</span><span style="color: #808000; font-style: italic;">/*!*/</span><span style="color: #000033;">;</span>
<span style="color: #990099; font-weight: bold;">SET</span> @@<span style="color: #990099; font-weight: bold;">session</span>.character_set_client<span style="color: #CC0099;">=</span><span style="color: #008080;">33</span><span style="color: #000033;">,</span>@@<span style="color: #990099; font-weight: bold;">session</span>.collation_connection<span style="color: #CC0099;">=</span><span style="color: #008080;">33</span><span style="color: #000033;">,</span>@@<span style="color: #990099; font-weight: bold;">session</span>.collation_server<span style="color: #CC0099;">=</span><span style="color: #008080;">8</span><span style="color: #808000; font-style: italic;">/*!*/</span><span style="color: #000033;">;</span>
<span style="color: #990099; font-weight: bold;">SET</span> @@<span style="color: #990099; font-weight: bold;">session</span>.lc_time_names<span style="color: #CC0099;">=</span><span style="color: #008080;">0</span><span style="color: #808000; font-style: italic;">/*!*/</span><span style="color: #000033;">;</span>
<span style="color: #990099; font-weight: bold;">SET</span> @@<span style="color: #990099; font-weight: bold;">session</span>.collation_database<span style="color: #CC0099;">=</span><span style="color: #990099; font-weight: bold;">DEFAULT</span><span style="color: #808000; font-style: italic;">/*!*/</span><span style="color: #000033;">;</span>
<span style="color: #990099; font-weight: bold;">ALTER</span> <span style="color: #990099; font-weight: bold;">TABLE</span> <span style="color: #008000;">`tblreshipment<span style="color: #008080; font-weight: bold;">_</span>header`</span> <span style="color: #990099; font-weight: bold;">DROP</span> <span style="color: #008000;">`ShipmentStatus`</span>
<span style="color: #808000; font-style: italic;">/*!*/</span><span style="color: #000033;">;</span>
DELIMITER <span style="color: #000033;">;</span>
<span style="color: #808080; font-style: italic;"># End of log file</span>
<span style="color: #990099; font-weight: bold;">ROLLBACK</span> <span style="color: #808000; font-style: italic;">/* added by mysqlbinlog */</span><span style="color: #000033;">;</span>
<span style="color: #808000; font-style: italic;">/*!50003 SET <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4e0d01031e020b1a070100111a171e0b730e01020a">[email&#160;protected]</a>_COMPLETION_TYPE*/</span><span style="color: #000033;">;</span>
<span style="color: #808000; font-style: italic;">/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/</span><span style="color: #000033;">;</span></pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; /*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!50003 SET @<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="06494a425945494b564a43524f494859525f56433b46">[email&#160;protected]</a>@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; # at 4 #140114 3:12:42 server id 3 end_log_pos 120 Start: binlog v 4, server v 5.6.15-log created 140114 3:12:42 at startup ROLLBACK/*!*/; BINLOG ' qjrUUg8DAAAAdAAAAHgAAAAAAAQANS42LjE1LWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAACqOtRSEzgNAAgAEgAEBAQEEgAAXAAEGggAAAAICAgCAAAACgoKGRkAAf73 8eY= '/*!*/; # at 120 #140114 3:12:43 server id 3 end_log_pos 143 Stop # at 143 #140507 14:55:42 server id 4 end_log_pos 126 Query thread_id=3173489 exec_time=0 error_code=0 use `test_shop`/*!*/; SET TIMESTAMP=1399445742/*!*/; SET @@session.pseudo_thread_id=3173489/*!*/; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C utf8 *//*!*/; SET @@session.character_set_client=33,@@session.collation_connection=33,@@session.collation_server=8/*!*/; SET @@session.lc_time_names=0/*!*/; SET @@session.collation_database=DEFAULT/*!*/; ALTER TABLE `tblreshipment_header` DROP `ShipmentStatus` /*!*/; DELIMITER ; # End of log file ROLLBACK /* added by mysqlbinlog */; /*!50003 SET <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="dc9f93918c9099889593928388858c99e19c939098">[email&#160;protected]</a>_COMPLETION_TYPE*/; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;</p>
                    </div>
                    <p>You can download the script <a href="http://secaserver.com/files/grareader">here</a>&nbsp;or copy and paste the code:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #666666; font-style: italic;"># Convert Galera GRA_* files to human readable output</span>
<span style="color: #666666; font-style: italic;"># Usage: grareader </span>
<span style="color: #666666; font-style: italic;"># Example: grareader /var/lib/mysql/GRA_1_1.log</span>
&nbsp;
<span style="color: #666666; font-style: italic;">##</span>
<span style="color: #666666; font-style: italic;">## GRA header file path</span>
<span style="color: #666666; font-style: italic;">##</span>
<span style="color: #007800;">path</span>=<span style="color: #000000; font-weight: bold;">/</span>tmp
<span style="color: #007800;">gra_header_path</span>=<span style="color: #007800;">$path</span><span style="color: #000000; font-weight: bold;">/</span>GRA-Header
<span style="color: #007800;">tmp_path</span>=<span style="color: #007800;">$path</span><span style="color: #000000; font-weight: bold;">/</span>grareader.tmp
&nbsp;
<span style="color: #007800;">input</span>=<span style="color: #007800;">$1</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-e</span> <span style="color: #007800;">$input</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'Error: File does not exist'</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
&nbsp;
get_gra_header<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #7a0874; font-weight: bold;">&#123;</span>
        <span style="color: #007800;">download_url</span>=<span style="color: #ff0000;">'http://secaserver.com/files/GRA-Header'</span>
        <span style="color: #007800;">wget_bin</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">command</span> <span style="color: #660033;">-v</span> <span style="color: #c20cb9; font-weight: bold;">wget</span><span style="color: #000000; font-weight: bold;">`</span>
        <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$wget_bin</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'Error: Unable to locate wget. Please install it first'</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Downloadling GRA-Header file into <span style="color: #007800;">$path</span>&quot;</span>
        <span style="color: #007800;">$wget_bin</span> <span style="color: #660033;">--quiet</span> <span style="color: #007800;">$download_url</span> <span style="color: #660033;">-P</span> <span style="color: #007800;">$path</span>
        <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$?</span> <span style="color: #660033;">-ne</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'Error: Download failed'</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
locate_files<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #7a0874; font-weight: bold;">&#123;</span>
        <span style="color: #007800;">mysqlbinlog_bin</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">command</span> <span style="color: #660033;">-v</span> mysqlbinlog<span style="color: #000000; font-weight: bold;">`</span>
        <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$mysqlbinlog_bin</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'Error: Unable to locate mysqlbinlog binary. Please install it first'</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
        <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-e</span> <span style="color: #007800;">$gra_header_path</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'Error: Unable to locate GRA header file'</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> get_gra_header
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
locate_files
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #007800;">$gra_header_path</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$tmp_path</span>
<span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #007800;">$input</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$tmp_path</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">''</span>
<span style="color: #c20cb9; font-weight: bold;">clear</span>
<span style="color: #007800;">$mysqlbinlog_bin</span> <span style="color: #660033;">-v</span> <span style="color: #660033;">-v</span> <span style="color: #660033;">-v</span> <span style="color: #007800;">$tmp_path</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">''</span>
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> <span style="color: #007800;">$tmp_path</span></pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">#!/bin/bash # Convert Galera GRA_* files to human readable output # Usage: grareader # Example: grareader /var/lib/mysql/GRA_1_1.log ## ## GRA header file path ## path=/tmp gra_header_path=$path/GRA-Header tmp_path=$path/grareader.tmp input=$1 [ ! -e $input ] &amp;&amp; echo 'Error: File does not exist' &amp;&amp; exit 1 get_gra_header() { download_url='http://secaserver.com/files/GRA-Header' wget_bin=`command -v wget` [ -z &quot;$wget_bin&quot; ] &amp;&amp; echo 'Error: Unable to locate wget. Please install it first' &amp;&amp; exit 1 echo &quot;Downloadling GRA-Header file into $path&quot; $wget_bin --quiet $download_url -P $path [ $? -ne 0 ] &amp;&amp; echo 'Error: Download failed' &amp;&amp; exit 1 } locate_files() { mysqlbinlog_bin=`command -v mysqlbinlog` [ -z &quot;$mysqlbinlog_bin&quot; ] &amp;&amp; echo 'Error: Unable to locate mysqlbinlog binary. Please install it first' &amp;&amp; exit 1 [ ! -e $gra_header_path ] &amp;&amp; echo 'Error: Unable to locate GRA header file' &amp;&amp; get_gra_header } locate_files cat $gra_header_path &gt;&gt; $tmp_path cat $input &gt;&gt; $tmp_path echo '' clear $mysqlbinlog_bin -v -v -v $tmp_path echo '' rm -rf $tmp_path</p>
                    </div>
                    <p>&nbsp;</p>
                    <p>Hope this could help make your Galera administrative task simpler!</p>
                  </div>
                  <footer class="entry-footer">
                    <span class="entry-terms category" itemprop="articleSection">Posted in <a href="http://secaserver.com/category/scripts/" rel="tag">Scripts</a>, <a href="http://secaserver.com/category/sql/" rel="tag">SQL</a>, <a href="http://secaserver.com/category/troubleshooting/" rel="tag">Troubleshooting</a></span><br>
                    <span class="entry-terms post_tag" itemprop="keywords">Tagged <a href="http://secaserver.com/tag/galera-gra-reader/" rel="tag">galera gra reader</a>, <a href="http://secaserver.com/tag/gra-file-content/" rel="tag">gra file content</a>, <a href="http://secaserver.com/tag/how-to-read-gra-file/" rel="tag">how to read gra file</a>, <a href="http://secaserver.com/tag/view-gra-file/" rel="tag">view gra file</a></span>
                  </footer>
                </div>
              </article>
              <article id="post-2711" class="post-2711 post type-post status-publish format-standard category-linux category-sql category-troubleshooting tag-libssl-libcrypto-error tag-pecona-installation-error tag-socat-dependencies-failed tag-socat-error tag-socat-yum-error entry" itemscope="itemscope" itemtype="http://schema.org/BlogPosting" itemprop="blogPost">
                <div class="entry-inner">
                  <header class="entry-header">
                    <div class="entry-meta">
                      <span class="entry-date"><span class="screen-reader-text">Posted on</span> <a href="http://secaserver.com/2014/10/percona-server-error-libssl-libcrypto/" rel="bookmark"><time class="entry-date" datetime="2014-10-08T01:37:58+00:00" itemprop="datePublished">8 October 2014</time></a></span><span class="byline"><span class="entry-author" itemprop="author" itemscope="itemscope" itemtype="http://schema.org/Person"><span class="screen-reader-text">Author</span> <a class="entry-author-link" href="http://secaserver.com/author/admin/" rel="author" itemprop="url"><span itemprop="name">SecaGuy</span></a></span></span> <span class="comments-link"><a href="http://secaserver.com/2014/10/percona-server-error-libssl-libcrypto/#comments" class="comments-link" itemprop="discussionURL">1 Comment <span class="screen-reader-text">on Percona Server Installation Error &#8211; libssl.so.10 and libcrypto.so.10</span></a></span>
                    </div>
                    <h2 class="entry-title" itemprop="headline"><a href="http://secaserver.com/2014/10/percona-server-error-libssl-libcrypto/" rel="bookmark">Percona Server Installation Error &#8211; libssl.so.10 and libcrypto.so.10</a></h2>
                  </header>
                  <div class="entry-content" itemprop="articleBody">
                    <div class='shareaholic-canvas' data-app-id='9753856' data-app-id-name='index_above_content' data-app='share_buttons' data-title='Percona Server Installation Error - libssl.so.10 and libcrypto.so.10' data-link='http://secaserver.com/2014/10/percona-server-error-libssl-libcrypto/' data-summary=''></div>
                    <p>I stumbled upon one error when installing Percona Server and socat via yum repository with following error:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="text" style="font-family:monospace;">--&gt; Processing Dependency: libssl.so.10(libssl.so.10)(64bit) for package: socat-1.7.2.3-1.el6.x86_64
--&gt; Processing Dependency: libcrypto.so.10(libcrypto.so.10)(64bit) for package: socat-1.7.2.3-1.el6.x86_64</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">--&gt; Processing Dependency: libssl.so.10(libssl.so.10)(64bit) for package: socat-1.7.2.3-1.el6.x86_64 --&gt; Processing Dependency: libcrypto.so.10(libcrypto.so.10)(64bit) for package: socat-1.7.2.3-1.el6.x86_64</p>
                    </div>
                    <p>It turns out that:</p>
                    <blockquote>
                      <p>&#8220;Red Hat upgraded the version of OpenSSL in EL6 from 1.0.0 to 1.0.1 during the 6.4-6.5 cycle, in order to resolve a years-old feature request. This package is no longer binary compatible, and programs that were built against OpenSSL 1.0.0 must be rebuilt from source against 1.0.1.&#8221;</p>
                    </blockquote>
                    <h2></h2>
                    <h2>What do we need to do then?</h2>
                    <p>Luckily the package is available at IUS repository:</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;">rpm -Uhv http:<span style="color: #000000; font-weight: bold;">//</span>dl.iuscommunity.org<span style="color: #000000; font-weight: bold;">/</span>pub<span style="color: #000000; font-weight: bold;">/</span>ius<span style="color: #000000; font-weight: bold;">/</span>stable<span style="color: #000000; font-weight: bold;">/</span>Redhat<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">6</span><span style="color: #000000; font-weight: bold;">/</span>x86_64<span style="color: #000000; font-weight: bold;">/</span>epel-release-<span style="color: #000000;">6</span>-<span style="color: #000000;">5</span>.noarch.rpm
rpm -Uhv http:<span style="color: #000000; font-weight: bold;">//</span>dl.iuscommunity.org<span style="color: #000000; font-weight: bold;">/</span>pub<span style="color: #000000; font-weight: bold;">/</span>ius<span style="color: #000000; font-weight: bold;">/</span>stable<span style="color: #000000; font-weight: bold;">/</span>Redhat<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">6</span><span style="color: #000000; font-weight: bold;">/</span>x86_64<span style="color: #000000; font-weight: bold;">/</span>ius-release-<span style="color: #000000;">1.0</span>-<span style="color: #000000;">13</span>.ius.el6.noarch.rpm
<span style="color: #c20cb9; font-weight: bold;">yum install</span> yum-plugin-replace
<span style="color: #c20cb9; font-weight: bold;">yum</span> replace <span style="color: #660033;">--enablerepo</span>=ius-archive openssl <span style="color: #660033;">--replace-with</span> openssl10</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">rpm -Uhv&nbsp;http://dl.iuscommunity.org/pub/ius/stable/Redhat/6/x86_64/epel-release-6-5.noarch.rpm rpm -Uhv&nbsp;http://dl.iuscommunity.org/pub/ius/stable/Redhat/6/x86_64/ius-release-1.0-13.ius.el6.noarch.rpm yum install yum-plugin-replace yum replace --enablerepo=ius-archive openssl --replace-with openssl10</p>
                    </div>
                    <p>(Press y for any question)</p>
                    <p>Verify the dependent libraries are exist (libcrypto.so.10 and libssl.so.10) :</p>
                    <div class="wp_syntax" style="position:relative;">
                      <table>
                        <tr>
                          <td class="code">
                            <pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib64<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-e</span> ssl.so <span style="color: #660033;">-e</span> crypto.so
libcrypto.so.10
libcrypto.so.1.0.1e
libssl3.so
libssl.so.10
libssl.so.1.0.1e</pre>
                          </td>
                        </tr>
                      </table>
                      <p class="theCode" style="display:none;">$&nbsp;ls /usr/lib64/ | grep -e ssl.so -e crypto.so libcrypto.so.10 libcrypto.so.1.0.1e libssl3.so libssl.so.10 libssl.so.1.0.1e</p>
                    </div>
                    <p>Then, try again with the Percona Server installation command. In some cases, you might need to remove the installed epel-release package since it&#8217;s a little bit outdated with the current release 6.8.</p>
                    <p>Hope the solution will help&nbsp;you guys out there!</p>
                    <p>&nbsp;</p>
                    <p>&nbsp;</p>
                  </div>
                  <footer class="entry-footer">
                    <span class="entry-terms category" itemprop="articleSection">Posted in <a href="http://secaserver.com/category/linux/" rel="tag">Linux</a>, <a href="http://secaserver.com/category/sql/" rel="tag">SQL</a>, <a href="http://secaserver.com/category/troubleshooting/" rel="tag">Troubleshooting</a></span><br>
                    <span class="entry-terms post_tag" itemprop="keywords">Tagged <a href="http://secaserver.com/tag/libssl-libcrypto-error/" rel="tag">libssl libcrypto error</a>, <a href="http://secaserver.com/tag/pecona-installation-error/" rel="tag">pecona installation error</a>, <a href="http://secaserver.com/tag/socat-dependencies-failed/" rel="tag">socat dependencies failed</a>, <a href="http://secaserver.com/tag/socat-error/" rel="tag">socat error</a>, <a href="http://secaserver.com/tag/socat-yum-error/" rel="tag">socat yum error</a></span>
                  </footer>
                </div>
              </article>
              <nav class="navigation pagination" role="navigation">
                <h2 class="screen-reader-text">Posts navigation</h2>
                <div class="nav-links">
                  <span aria-current='page' class='page-numbers current'><span class="meta-nav screen-reader-text">Page</span> 1</span> <a class='page-numbers' href='http://secaserver.com/page/2/'><span class="meta-nav screen-reader-text">Page</span> 2</a> <span class="page-numbers dots">&hellip;</span> <a class='page-numbers' href='http://secaserver.com/page/16/'><span class="meta-nav screen-reader-text">Page</span> 16</a> <a class="next page-numbers" href="http://secaserver.com/page/2/">Next page</a>
                </div>
              </nav>
            </main>
          </div>
          <aside id="sidebar-primary" class="sidebar-primary sidebar" role="complementary" aria-labelledby="sidebar-primary-header" itemscope="itemscope" itemtype="http://schema.org/WPSideBar">
            <h2 class="screen-reader-text" id="sidebar-primary-header">Primary Sidebar</h2>
            <div class="wrap">
              <section id="search-7" class="widget widget_search">
                <form role="search" method="get" class="search-form" action="http://secaserver.com/">
                  <label><span class="screen-reader-text">Search for:</span> <input type="search" class="search-field" placeholder="Search &hellip;" value="" name="s"></label> <input type="submit" class="search-submit" value="Search">
                </form>
              </section>
              <section id="awesomegoogleadsense-9" class="widget widget_awesomegoogleadsense">
                <h3 class="widget-title">Inventory Management:</h3>
                <p><a href="https://www.mrpeasy.com/inventory-management/"><img src="/images/MRPeasy.png" style="width:250px;" alt="Inventory management software MRPeasy"></a></p>
              </section>
              <section id="text-2" class="widget widget_text">
                <h3 class="widget-title">Subscribe via Email</h3>
                <div class="textwidget">
                  <form style="border:1px solid #ccc;padding:3px;text-align:center;" action="http://feedburner.google.com/fb/a/mailverify" method="post" target="popupwindow" onsubmit="window.open('http://feedburner.google.com/fb/a/mailverify?uri=SecaserverBlog', 'popupwindow', 'scrollbars=yes,width=550,height=520');return true">
                    <p>Enter your email address:</p>
                    <p><input type="text" name="email"></p><input type="hidden" value="SecaserverBlog" name="uri"><input type="hidden" name="loc" value="en_US"><input type="submit" value="Subscribe" style="width:100%">
                    <p>Delivered by FeedBurner</p>
                  </form>
                  <p></p>
                  <center>
                    <img src="http://feeds.feedburner.com/~fc/SecaserverBlog?bg=99CCFF&amp;fg=444444&amp;anim=0" height="26" width="88" style="border:0" alt="">
                  </center>
                  <p></p>
                </div>
              </section>
              <section id="recent-posts-9" class="widget widget_recent_entries">
                <h3 class="widget-title">Recent Posts</h3>
                <ul>
                  <li>
                    <a href="http://secaserver.com/2016/04/installing-mysql-5-7-oracle-apt-repository/">Installing MySQL 5.7 (Oracle) using APT repository</a>
                  </li>
                  <li>
                    <a href="http://secaserver.com/2015/09/configure-haproxy-galera-cluster/">Install and Configure HAProxy for MySQL Galera Cluster</a>
                  </li>
                  <li>
                    <a href="http://secaserver.com/2015/05/various-ways-determine-public-ip-linux-cli/">Various Ways to Determine Public IP on Linux CLI</a>
                  </li>
                  <li>
                    <a href="http://secaserver.com/2015/05/mysql-encryption-ssh-supervisor/">MySQL Encryption using SSH and Supervisor</a>
                  </li>
                  <li>
                    <a href="http://secaserver.com/2015/03/centos-7-installing-managing-mysql/">CentOS 7: Installing and Managing MySQL</a>
                  </li>
                </ul>
              </section>
              <section id="categories-3" class="widget widget_categories">
                <h3 class="widget-title">Categories</h3>
                <ul>
                  <li class="cat-item cat-item-96">
                    <a href="http://secaserver.com/category/applications/">Applications</a>
                  </li>
                  <li class="cat-item cat-item-191">
                    <a href="http://secaserver.com/category/articles/">Articles</a>
                  </li>
                  <li class="cat-item cat-item-893">
                    <a href="http://secaserver.com/category/backup-2/">Backup</a>
                  </li>
                  <li class="cat-item cat-item-3">
                    <a href="http://secaserver.com/category/bsd/">BSD</a>
                  </li>
                  <li class="cat-item cat-item-481">
                    <a href="http://secaserver.com/category/cluster-2/">Cluster</a>
                  </li>
                  <li class="cat-item cat-item-4">
                    <a href="http://secaserver.com/category/cpanel/">cPanel</a>
                  </li>
                  <li class="cat-item cat-item-894">
                    <a href="http://secaserver.com/category/database/">Database</a>
                  </li>
                  <li class="cat-item cat-item-5">
                    <a href="http://secaserver.com/category/debian/">Debian</a>
                  </li>
                  <li class="cat-item cat-item-59">
                    <a href="http://secaserver.com/category/disk-management/">Disk Management</a>
                  </li>
                  <li class="cat-item cat-item-6">
                    <a href="http://secaserver.com/category/filesystem/">Filesystem</a>
                  </li>
                  <li class="cat-item cat-item-7">
                    <a href="http://secaserver.com/category/installation/">Installation</a>
                  </li>
                  <li class="cat-item cat-item-8">
                    <a href="http://secaserver.com/category/linux/">Linux</a>
                  </li>
                  <li class="cat-item cat-item-100">
                    <a href="http://secaserver.com/category/mail-server/">Mail Server</a>
                  </li>
                  <li class="cat-item cat-item-556">
                    <a href="http://secaserver.com/category/monitoring/">Monitoring</a>
                  </li>
                  <li class="cat-item cat-item-357">
                    <a href="http://secaserver.com/category/networking/">Networking</a>
                  </li>
                  <li class="cat-item cat-item-789">
                    <a href="http://secaserver.com/category/nosql/">NoSQL</a>
                  </li>
                  <li class="cat-item cat-item-710">
                    <a href="http://secaserver.com/category/pbx/">PBX</a>
                  </li>
                  <li class="cat-item cat-item-9">
                    <a href="http://secaserver.com/category/plesk/">Plesk</a>
                  </li>
                  <li class="cat-item cat-item-55">
                    <a href="http://secaserver.com/category/scripts/">Scripts</a>
                  </li>
                  <li class="cat-item cat-item-226">
                    <a href="http://secaserver.com/category/security-2/">Security</a>
                  </li>
                  <li class="cat-item cat-item-10">
                    <a href="http://secaserver.com/category/spamassassin/">SpamAssassin</a>
                  </li>
                  <li class="cat-item cat-item-11">
                    <a href="http://secaserver.com/category/sql/">SQL</a>
                  </li>
                  <li class="cat-item cat-item-12">
                    <a href="http://secaserver.com/category/troubleshooting/">Troubleshooting</a>
                  </li>
                  <li class="cat-item cat-item-414">
                    <a href="http://secaserver.com/category/unix/">UNIX</a>
                  </li>
                  <li class="cat-item cat-item-704">
                    <a href="http://secaserver.com/category/virtualization/">Virtualization</a>
                  </li>
                  <li class="cat-item cat-item-113">
                    <a href="http://secaserver.com/category/web-server/">Web Server</a>
                  </li>
                  <li class="cat-item cat-item-13">
                    <a href="http://secaserver.com/category/windows/">Windows</a>
                  </li>
                </ul>
              </section>
              <section id="rss-2" class="widget widget_rss">
                <h3 class="widget-title"><img class="rss-widget-icon" style="border:0" width="14" height="14" src="http://secaserver.com/wp-includes/images/rss.png" alt="RSS"> Top stories &#8211; Google News</h3>
                <ul>
                  <li>Sarawak Muslim leaders slam Maszlee over &#039;dakwah&#039; remark - Free Malaysia Today <span class="rss-date">20 December 2018</span></li>
                  <li>Samsung Galaxy S10 rumors: Everything we know about a Feb. 20 launch, March 8 release, specs, features and price - CNET <span class="rss-date">20 December 2018</span></li>
                  <li>Mars InSight deploys French-made quake sensor on Red Planet - New Straits Times <span class="rss-date">20 December 2018</span></li>
                  <li>Turn around: Najib offers Pakatan ministers video to help explain flip-flops - Nation - The Star Online <span class="rss-date">20 December 2018</span></li>
                  <li>Great Pacific garbage patch $20m cleanup fails to collect plastic - The Guardian <span class="rss-date">20 December 2018</span></li>
                </ul>
              </section>
              <section id="text-4" class="widget widget_text">
                <h3 class="widget-title">Bitcoin Price</h3>
                <div class="textwidget">
                  <div id="btc-quote"></div>
                  <script type="text/javascript" src="https://www.weusecoins.com/embed.js"></script>
                </div>
              </section>
            </div>
          </aside>
        </div>
      </div>
    </div>
    <aside id="sidebar-subsidiary" class="sidebar-subsidiary sidebar" role="complementary" aria-labelledby="sidebar-subsidiary-header" itemscope="itemscope" itemtype="http://schema.org/WPSideBar">
      <h2 class="screen-reader-text" id="sidebar-subsidiary-header">Subsidiary Sidebar</h2>
      <div class="wrap">
        <div class="wrap-inside">
          <section id="meta-9" class="widget widget_meta">
            <h3 class="widget-title">Meta</h3>
            <ul>
              <li>
                <a href="http://secaserver.com/wp-login.php?action=register">Register</a>
              </li>
              <li>
                <a href="http://secaserver.com/wp-login.php">Log in</a>
              </li>
              <li>
                <a href="http://secaserver.com/feed/">Entries <abbr title="Really Simple Syndication">RSS</abbr></a>
              </li>
              <li>
                <a href="http://secaserver.com/comments/feed/">Comments <abbr title="Really Simple Syndication">RSS</abbr></a>
              </li>
              <li>WordPress.org</li>
            </ul>
          </section>
          <section id="calendar-5" class="widget widget_calendar">
            <h3 class="widget-title">Calendar</h3>
            <div id="calendar_wrap" class="calendar_wrap">
              <table id="wp-calendar">
                <caption>
                  December 2018
                </caption>
                <thead>
                  <tr>
                    <th scope="col" title="Monday">M</th>
                    <th scope="col" title="Tuesday">T</th>
                    <th scope="col" title="Wednesday">W</th>
                    <th scope="col" title="Thursday">T</th>
                    <th scope="col" title="Friday">F</th>
                    <th scope="col" title="Saturday">S</th>
                    <th scope="col" title="Sunday">S</th>
                  </tr>
                </thead>
                <tfoot>
                  <tr>
                    <td colspan="3" id="prev">
                      <a href="http://secaserver.com/2016/04/">&laquo; Apr</a>
                    </td>
                    <td class="pad">&nbsp;</td>
                    <td colspan="3" id="next" class="pad">&nbsp;</td>
                  </tr>
                </tfoot>
                <tbody>
                  <tr>
                    <td colspan="5" class="pad">&nbsp;</td>
                    <td>1</td>
                    <td>2</td>
                  </tr>
                  <tr>
                    <td>3</td>
                    <td>4</td>
                    <td>5</td>
                    <td>6</td>
                    <td>7</td>
                    <td>8</td>
                    <td>9</td>
                  </tr>
                  <tr>
                    <td>10</td>
                    <td>11</td>
                    <td>12</td>
                    <td>13</td>
                    <td>14</td>
                    <td>15</td>
                    <td>16</td>
                  </tr>
                  <tr>
                    <td>17</td>
                    <td>18</td>
                    <td>19</td>
                    <td>20</td>
                    <td id="today">21</td>
                    <td>22</td>
                    <td>23</td>
                  </tr>
                  <tr>
                    <td>24</td>
                    <td>25</td>
                    <td>26</td>
                    <td>27</td>
                    <td>28</td>
                    <td>29</td>
                    <td>30</td>
                  </tr>
                  <tr>
                    <td>31</td>
                    <td class="pad" colspan="6">&nbsp;</td>
                  </tr>
                </tbody>
              </table>
            </div>
          </section>
        </div>
      </div>
    </aside>
    <footer id="colophon" class="site-footer" role="contentinfo" itemscope="itemscope" itemtype="http://schema.org/WPFooter">
      <div class="site-info">
        Proudly powered by WordPress <span class="sep">&middot;</span> Theme Toivo Lite by Foxland
      </div>
    </footer>
  </div>
  <div style="display:none"></div>
  <div id="su-footer-links" style="text-align: center;"></div>
  <script type='text/javascript' src='//www.google.com/recaptcha/api.js?ver=7.8.5&#038;onload=ccfRecaptchaOnload&#038;render=explicit'></script> 
  <script type='text/javascript' src='https://s0.wp.com/wp-content/js/devicepx-jetpack.js?ver=201851'></script> 
  <script type='text/javascript' src='http://secaserver.com/wp-content/plugins/wp-syntax/js/wp-syntax.js?ver=1.1'></script> 
  <script type='text/javascript' src='https://secure.gravatar.com/js/gprofiles.js?ver=2018Decaa'></script> 
  <script type='text/javascript'>


  /* <![CDATA[ */
  var WPGroHo = {"my_hash":""};
  /* ]]> */
  </script> 
  <script type='text/javascript' src='http://secaserver.com/wp-content/plugins/jetpack/modules/wpgroho.js?ver=4.9.9'></script> 
  <script type='text/javascript' src='http://secaserver.com/wp-includes/js/backbone.min.js?ver=1.2.3'></script> 
  <script type='text/javascript'>


  /* <![CDATA[ */
  var WP_API_Settings = {"root":"http:\/\/blog.secaserver.com\/wp-json\/","nonce":"8aac889cc2"};
  /* ]]> */
  </script> 
  <script type='text/javascript' src='http://secaserver.com/wp-content/plugins/custom-contact-forms/wp-api/wp-api.js?ver=1.2'></script> 
  <script type='text/javascript' src='http://secaserver.com/wp-content/themes/toivo-lite/js/responsive-nav.min.js?ver=1.1.1'></script> 
  <script type='text/javascript' src='http://secaserver.com/wp-content/themes/toivo-lite/js/settings.min.js?ver=1.1.1'></script> 
  <script type='text/javascript' src='http://secaserver.com/wp-content/themes/toivo-lite/js/functions.min.js?ver=1.1.1'></script> 
  <script type='text/javascript'>


  /* <![CDATA[ */
  var thickboxL10n = {"next":"Next >","prev":"< Prev","image":"Image","of":"of","close":"Close","noiframes":"This feature requires inline frames. You have iframes disabled or your browser does not support them.","loadingAnimation":"http:\/\/blog.secaserver.com\/wp-content\/plugins\/auto-thickbox-plus\/images\/loadingAnimation.gif","closeImage":"http:\/\/blog.secaserver.com\/wp-content\/plugins\/auto-thickbox-plus\/images\/tb-close.png"};
  /* ]]> */
  </script> 
  <script type='text/javascript' src='http://secaserver.com/wp-content/plugins/auto-thickbox-plus/thickbox.min.js?ver=1.9'></script> 
  <script type='text/javascript' src='http://secaserver.com/wp-includes/js/wp-embed.min.js?ver=4.9.9'></script> 
  <script type="text/javascript">


  /* <![CDATA[ */
  jQuery(function($) {

        // Set a different gallery-id for each WordPress Gallery
        $('div.gallery').each(function() {
                if (this.id)
                        $(this).find('a.thickbox').attr('rel', this.id);
        });
  });

  /* ]]> */
  </script> 
  <script type='text/javascript'>


        _stq = window._stq || [];
        _stq.push([ 'view', {v:'ext',j:'1:6.3.2',blog:'24666761',post:'0',tz:'8',srv:'blog.secaserver.com'} ]);
        _stq.push([ 'clickTrackerInit', '24666761', '0' ]);
  </script>
</body>
</html>
