{"id":5281,"date":"2020-02-10T19:00:53","date_gmt":"2020-02-10T18:00:53","guid":{"rendered":"https:\/\/nil.uniza.sk\/?p=5281"},"modified":"2020-06-23T16:43:48","modified_gmt":"2020-06-23T14:43:48","slug":"elasticsearch-cluster-upgrade","status":"publish","type":"post","link":"https:\/\/nil.uniza.sk\/en\/elasticsearch-cluster-upgrade\/","title":{"rendered":"Elasticsearch cluster upgrade"},"content":{"rendered":"<h1>Elasticsearch cluster upgrade from 5.5.1 to 6.8.1<\/h1>\n<ul>\n<li><strong>Author :<\/strong> Miroslav Koh\u00fatik<\/li>\n<li><strong>Operating System :<\/strong> Ubuntu 16.04<\/li>\n<\/ul>\n<p>In this guide we will show you how to upgrade an Elasticsearch cluster located on a single machine.<br \/>\nAs an example we will use our Elasticsearch cluster that consists of five ES nodes.<\/p>\n<p>All nodes need to be stopped before upgrading<\/p>\n<pre><code>sudo systemctl stop elasticsearch_data1\nsudo systemctl stop elasticsearch_data2\nsudo systemctl stop elasticsearch_data3\nsudo systemctl stop elasticsearch_ingest\nsudo systemctl stop elasticsearch_master<\/code><\/pre>\n<p>Download the installation package for Elasticsearch version 6.8.1<\/p>\n<pre><code>wget https:\/\/artifacts.elastic.co\/downloads\/elasticsearch\/elasticsearch-6.8.1.deb<\/code><\/pre>\n<p>Install the new version<\/p>\n<pre><code>sudo dpkg -i elasticsearch-6.8.1.deb<\/code><\/pre>\n<p>Elasticsearch should now be successfully updated to version 6.8.1. However, we cannot start up our cluster just yet. First, we need to update the Linux services for each node since service definition in 6.x is slightly different from version 5.x.<br \/>\nOur Cluster&#8217;s nodes&#8216; services are located in <em>\/usr\/lib\/systemd\/system\/<\/em><\/p>\n<p>Here is an excerpt from <em>\/usr\/lib\/systemd\/system\/elasticsearch_master.service<\/em>:<\/p>\n<pre><code>[Service]\nEnvironment=ES_HOME=\/usr\/share\/elasticsearch\nEnvironment=CONF_DIR=\/etc\/master\nEnvironment=DATA_DIR=\/var\/lib\/elasticsearch\/master\nEnvironment=LOG_DIR=\/var\/log\/elasticsearch\/master\nEnvironment=PID_DIR=\/var\/run\/elasticsearch\nEnvironmentFile=-\/etc\/default\/elasticsearch\n\nWorkingDirectory=\/usr\/share\/elasticsearch\n\nUser=elasticsearch\nGroup=elasticsearch\n\nExecStartPre=\/usr\/share\/elasticsearch\/bin\/elasticsearch-systemd-pre-exec\n\nExecStart=\/usr\/share\/elasticsearch\/bin\/elasticsearch \n                                                -p ${PID_DIR}\/elasticsearch.pid \n                                                -Edefault.path.logs=${LOG_DIR} \n                                                -Edefault.path.data=${DATA_DIR} \n                                                -Edefault.path.conf=${CONF_DIR}\n<\/code><\/pre>\n<p>Here is the same excerpt from the same service file updated for version 6.x:<\/p>\n<pre><code>[Service]\nEnvironment=ES_HOME=\/usr\/share\/elasticsearch\nEnvironment=PID_DIR=\/var\/run\/elasticsearch\nEnvironmentFile=-\/etc\/default\/elasticsearch\nLimitMEMLOCK=infinity\nRuntimeDirectory=elasticsearch\nPrivateTmp=true\nEnvironment=ES_PATH_CONF=\/etc\/master\n\nWorkingDirectory=\/usr\/share\/elasticsearch\n\nUser=elasticsearch\nGroup=elasticsearch\n\nExecStart=\/usr\/share\/elasticsearch\/bin\/elasticsearch -p ${PID_DIR}\/elasticsearch.pid --quiet<\/code><\/pre>\n<p><strong>Make sure that for every single variable you have set in your <em>elasticsearch_.service<\/em> files you have also commented out its equivalent in <em>\/etc\/default\/elasticsearch<\/em>. Otherwise, values in the latter file will override the changes you have made in the former.<\/strong><\/p>\n<p>Service files of the remaining nodes (in our case the following files: <em>elasticsearch_ingest.service<\/em>, <em>elasticsearch_data1.service<\/em>, <em>elasticsearch_data2.service<\/em> and <em>elasticsearch_data3.service<\/em>) need to be updated in a similar manner.<\/p>\n<p>Each node&#8217;s service also requires its own <em>elasticsearch.yaml<\/em> file. This file should be located on the path set in <strong>ES_PATH_CONF<\/strong> in the service file as seen above (in the case of master node it is <em>\/etc\/master\/<\/em>).<br \/>\nHere is an example of <em>elasticsearch.yaml<\/em> located in <em>\/etc\/master\/<\/em>. Note the attributes <em>node.master<\/em>, <em>node.data<\/em>, and <em>node.ingest<\/em>, these need to be set in respect to the role of the node in particular and are different for nodes of other types.<\/p>\n<pre><code># ---------------------------------- Cluster -----------------------------------\n# Use a descriptive name for your cluster:\ncluster.name: elastic\n# ------------------------------------ Node ------------------------------------\n# Use a descriptive name for the node:\nnode.name: master\n# Add custom attributes to the node:\nnode.master: true\nnode.data: false\nnode.ingest: false\nnode.max_local_storage_nodes: 5\n# ----------------------------------- Paths ------------------------------------\n# Path to directory where to store the data (separate multiple locations by comma):\npath.data: \/data\/elasticsearch\/data_master\n# Path to log files:\npath.logs: \/var\/log\/elasticsearch\/master\n# ----------------------------------- Memory -----------------------------------\n# Lock the memory on startup:\nbootstrap.memory_lock: true\n# Make sure that the heap size is set to about half the memory available\n# on the system and that the owner of the process is allowed to use this\n# limit.<\/code><\/pre>\n<p>Each node also uses a distinct pair of HTTP and TCP ports specified by attributes <em>http.port<\/em> and <em>transport.tcp.port<\/em>.<\/p>\n<pre><code># ---------------------------------- Network -----------------------------------\n# Set the bind address to a specific IP (IPv4 or IPv6):\nnetwork.host: 192.168.1.1\n# Set a custom port for HTTP:\nhttp.port: 9200\ntransport.tcp.port: 9300<\/code><\/pre>\n<p>Master node needs to bo able to discover other nodes in the cluster, therefore, attribute <em>discovery.zen.ping.unicast.hosts<\/em> contains a list of IPs and transport ports of all the other nodes. On nodes other than master it will contain only the master&#8217;s IP and transport port [&#8222;192.168.1.1:9300&#8220;]:<\/p>\n<pre><code># --------------------------------- Discovery ----------------------------------\n# Pass an initial list of hosts to perform discovery when new node is started:\n# The default list of hosts is [\"127.0.0.1\", \"[::1]\"]\ndiscovery.zen.ping.unicast.hosts: [\"192.168.1.1:9301\",\"192.168.1.1:9302\",\"192.168.1.1:9303\",\"192.168.1.1:9304\"]<\/code><\/pre>\n<p>You should now be able to get the Elasticsearch cluster up and running:<\/p>\n<pre><code>sudo systemctl stop elasticsearch_master\nsudo systemctl stop elasticsearch_ingest\nsudo systemctl stop elasticsearch_data1\nsudo systemctl stop elasticsearch_data2\nsudo systemctl stop elasticsearch_data3<\/code><\/pre>","protected":false},"excerpt":{"rendered":"<p>Elasticsearch cluster upgrade from 5.5.1 to 6.8.1 Author : Miroslav Koh\u00fatik Operating System : Ubuntu 16.04 In this guide we will show you how to upgrade an Elasticsearch cluster located on a single machine. As an example we will use our Elasticsearch cluster that consists of five ES nodes. All nodes need to be stopped&#8230;<\/p>","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_seopress_robots_primary_cat":"","_seopress_titles_title":"","_seopress_titles_desc":"","_seopress_robots_index":"","_kad_blocks_custom_css":"","_kad_blocks_head_custom_js":"","_kad_blocks_body_custom_js":"","_kad_blocks_footer_custom_js":"","_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"footnotes":""},"categories":[685],"tags":[],"class_list":["post-5281","post","type-post","status-publish","format-standard","hentry","category-linux_-_howto-en"],"taxonomy_info":{"category":[{"value":685,"label":"Linux - HOWTO"}]},"featured_image_src_large":false,"author_info":{"display_name":"Miroslav Koh\u00fatik","author_link":"https:\/\/nil.uniza.sk\/en\/author\/miroslav-kohutik\/"},"comment_info":5,"category_info":[{"term_id":685,"name":"Linux - HOWTO","slug":"linux_-_howto-en","term_group":0,"term_taxonomy_id":683,"taxonomy":"category","description":"","parent":0,"count":71,"filter":"raw","cat_ID":685,"category_count":71,"category_description":"","cat_name":"Linux - HOWTO","category_nicename":"linux_-_howto-en","category_parent":0}],"tag_info":false,"_links":{"self":[{"href":"https:\/\/nil.uniza.sk\/en\/wp-json\/wp\/v2\/posts\/5281","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nil.uniza.sk\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nil.uniza.sk\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nil.uniza.sk\/en\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/nil.uniza.sk\/en\/wp-json\/wp\/v2\/comments?post=5281"}],"version-history":[{"count":0,"href":"https:\/\/nil.uniza.sk\/en\/wp-json\/wp\/v2\/posts\/5281\/revisions"}],"wp:attachment":[{"href":"https:\/\/nil.uniza.sk\/en\/wp-json\/wp\/v2\/media?parent=5281"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nil.uniza.sk\/en\/wp-json\/wp\/v2\/categories?post=5281"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nil.uniza.sk\/en\/wp-json\/wp\/v2\/tags?post=5281"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}