{"id":563,"date":"2017-04-21T14:34:26","date_gmt":"2017-04-21T14:34:26","guid":{"rendered":"http:\/\/nicholshayes.co.uk\/blog\/?p=563"},"modified":"2017-04-25T08:27:38","modified_gmt":"2017-04-25T08:27:38","slug":"downgrading-the-elasticsearch-version-in-semaphoreci","status":"publish","type":"post","link":"http:\/\/nicholshayes.co.uk\/blog\/?p=563","title":{"rendered":"Downgrading the ElasticSearch version in SemaphoreCI"},"content":{"rendered":"<p>In our current project, we are using <a href=\"https:\/\/www.elastic.co\/\">Elasticsearch<\/a> for rapid search (it is the best search engine I&#8217;ve used to date), and are using <a href=\"https:\/\/semaphoreci.com\">Semaphore CI<\/a>\u00a0for continuous integration (Semaphore is new to me, but so far it looks very good). However, since the start of the project and now, the current Elasticsearch version has changed, and our code doesn&#8217;t match the latest\u00a0version. Semaphore has Elasticsearch available, but in a new (and for us incompatible) version to the one used in our project.<\/p>\n<p>Medium term, we need to update the version of Elasticsearch we are using on our project, but for now we need Semaphore to work with our code. To achieve that we need to install an older version of Elasticsearch in our Semaphore environment.<\/p>\n<p>So my first step was a google, but that didn&#8217;t give me an obvious answer (there were a couple of scripts, but I wasn&#8217;t sure where to put them or how to use them).<\/p>\n<p>I found the solution by using <a href=\"https:\/\/renderedtext.campfirenow.com\/6c9d5\">Semaphore support live chat<\/a>. The response was very quick and I had a work solution within minutes. Another plus point for Semaphore.<\/p>\n<p>The solution was to use the following commands:<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">wget https:\/\/gist.github.com\/rexich\/3de0be8b1fc0804a6ff81758192d6ed6\/raw\/elasticsearch-downgrade-semaphore.sh<br \/>\nsudo bash elasticsearch-downgrade-semaphore.sh 2.4.1<\/div><\/div>\n<p>These needed to be added to our Semaphore Project&#8217;s Build Settings, in the Setup section:<\/p>\n<p><a href=\"http:\/\/nicholshayes.co.uk\/blog\/wp-content\/uploads\/2017\/04\/semaphore_elasticsearch_setup.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-564\" src=\"http:\/\/nicholshayes.co.uk\/blog\/wp-content\/uploads\/2017\/04\/semaphore_elasticsearch_setup.png\" alt=\"\" width=\"678\" height=\"374\" srcset=\"http:\/\/nicholshayes.co.uk\/blog\/wp-content\/uploads\/2017\/04\/semaphore_elasticsearch_setup.png 678w, http:\/\/nicholshayes.co.uk\/blog\/wp-content\/uploads\/2017\/04\/semaphore_elasticsearch_setup-300x165.png 300w\" sizes=\"(max-width: 678px) 100vw, 678px\" \/><\/a><\/p>\n<p>With that code in place we were able to set the Elasticsearch version to 2.4.1 in our Semaphore project and the problem was solved.<\/p>\n<p><strong>An update<\/strong><br \/>\nOn using the script in anger for a few days we found we were sometimes getting build failures.<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">Purging configuration files for elasticsearch (5.2.2) ...<br \/>\nuserdel: user elasticsearch is currently used by process 2662<br \/>\ndpkg: error processing package elasticsearch (--purge):<br \/>\nsubprocess installed post-removal script returned error exit status 8<br \/>\nErrors were encountered while processing:<br \/>\nelasticsearch<\/div><\/div>\n<p>The process to purge the existing Elasticsearch files was occurring before the process had stopped. To fix this we created <a href=\"http:\/\/Purging configuration files for elasticsearch (5.2.2) ... userdel: user elasticsearch is currently used by process 2662 dpkg: error processing package elasticsearch (--purge):  subprocess installed post-removal script returned error exit status 8 Errors were encountered while processing:  elasticsearch\">a modified version of the script<\/a> with a 1 second pause prior to the file purge.<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">&nbsp; service elasticsearch stop<br \/>\n&nbsp; sleep 1<br \/>\n&nbsp; apt-get purge -y elasticsearch<\/div><\/div>\n<p>This seems to have fixed the problem.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In our current project, we are using Elasticsearch for rapid search (it is the best search engine I&#8217;ve used to date), and are using Semaphore CI\u00a0for continuous integration (Semaphore is new to me, but so far it looks very good). &hellip; <a href=\"http:\/\/nicholshayes.co.uk\/blog\/?p=563\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[17,18],"_links":{"self":[{"href":"http:\/\/nicholshayes.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/563"}],"collection":[{"href":"http:\/\/nicholshayes.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/nicholshayes.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/nicholshayes.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/nicholshayes.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=563"}],"version-history":[{"count":4,"href":"http:\/\/nicholshayes.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/563\/revisions"}],"predecessor-version":[{"id":568,"href":"http:\/\/nicholshayes.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/563\/revisions\/568"}],"wp:attachment":[{"href":"http:\/\/nicholshayes.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=563"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/nicholshayes.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=563"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/nicholshayes.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=563"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}