├── LICENSE ├── README.md ├── configuration ├── elastic-config.xml └── elastic-env.xml ├── metainfo.xml ├── package ├── scripts │ ├── elastic_common.py │ ├── master.py │ ├── params.py │ └── status_params.py └── templates │ └── elasticsearch.yml.j2 └── quicklinks └── quicklinks.json /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Ambari Elasticsearch Service 2 | 3 | The Ambari Elasticsearch Service is a custom service for Ambari that allows you to install and manage Elasticsearch via Ambari. This service is provided as a community project and is not supported by Hortonworks. Futhermore, this service is intended for testing and development and should not be used in a production environment. This service is for Ambari 2.4.x and Elasticsearch 5.x. 4 | 5 | ## System Requirements 6 | 7 | Prior to deploying the Ambari Elasticsearch Service, there are specific operating system configuration changes needed for Elasticsearch to run properly. 8 | 9 | When configuring Elasticsearch to bind to a non-loopback address, Elasticsearch will perform additional system checks called "bootstrap checks". If these bootstrap checks fail, Elasticsearch will shutdown. You can read more about those checks here: 10 | 11 | ### /etc/security/limits.conf 12 | 13 | Modify */etc/security/limits.conf* to include the following settings: 14 | 15 | ``` 16 | elasticsearch - nofile 65536 17 | elasticsearch - nproc 2048 18 | elasticsearch - memlock unlimited 19 | ``` 20 | 21 | NOTE: This assumes that elasticsearch is the user configured to run Elasticsearch via the Ambari configuration. 22 | 23 | ### /etc/sysctl.conf 24 | 25 | Modify */etc/sysctl.conf* to include the following settings: 26 | 27 | ``` 28 | # Controls mmap counts 29 | vm.max_map_count = 262144 30 | ``` 31 | 32 | You can read more about Elasticsearch configuration settings here: 33 | 34 | These changes should be made to any node on which you plan to deploy Elasticsearch. After the changes have been implemented, it is a good idea to reboot the servers to ensure the changes take affect. 35 | 36 | ## Installation 37 | 38 | To install this service, you need access to the Ambari Server with sudo permissions. 39 | 40 | ``` 41 | VERSION=`hdp-select status hadoop-client | sed 's/hadoop-client - \([0-9]\.[0-9]\).*/\1/'` 42 | sudo git clone https://github.com/Jaraxal/ambari-elasticsearch-service /var/lib/ambari-server/resources/stacks/HDP/$VERSION/services/ELASTICSEARCH 43 | ``` 44 | 45 | If you do not have the ability to use git, you can download the repo archive and extract it to directory shown above. 46 | 47 | After you have installed the service, you need to restart the Ambari Server. 48 | 49 | ``` 50 | sudo service ambari-server restart 51 | ``` 52 | 53 | Once the Ambari Server service has been restarted, you should see Elasticsearch as an available service to install from the Add Service screen. 54 | 55 | ## Compatibility 56 | 57 | This service has been tested with the following: 58 | 59 | - CentOS 6.x 60 | - Ambari 2.4.2.0 61 | - HDP 2.5.3.0 62 | - Elasticsearch 5.x 63 | 64 | ## Limitations 65 | 66 | The following limitations currently apply: 67 | 68 | - The service currently deploys all nodes as master=true, data=true, and ingest=true. 69 | - The service has only been tested with CentOS/RHEL 6.x. 70 | - The service exposes only the default configuration options present in the Elasticsearch configuration file. 71 | - Quick Links do not currently work. 72 | - The service does not currently support Kerberos. 73 | - The service does not currently have Ambari Service Advisor or Ambari Alert functionality. 74 | 75 | ## Contributors 76 | 77 | This project is a complete refactoring to enable support for Elasticsearch 5.x. However, the base started from a fork of 78 | 79 | ## License 80 | 81 | Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. 82 | 83 | You may obtain a copy of the License at 84 | 85 | 86 | 87 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 88 | -------------------------------------------------------------------------------- /configuration/elastic-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 17 | 18 | 19 | 20 | 21 | cluster_name 22 | my_es_cluster 23 | Use a descriptive name for your cluster 24 | 25 | 26 | 27 | 28 | node_attr_rack 29 | rack01 30 | Add custom attributes to the node 31 | 32 | 33 | 34 | 35 | path_data 36 | /opt/elasticsearch/data 37 | Path to directory where to store the data (separate multiple locations by comma) 38 | 39 | 40 | 41 | path_logs 42 | /opt/elasticsearch/logs 43 | Path to directory where to store the logs 44 | 45 | 46 | 47 | 48 | bootstrap_memory_lock 49 | true 50 | Lock the memory on startup 51 | 52 | 53 | 54 | 55 | network_host 56 | {{hostname}} 57 | Set the bind address to a specific IP (IPv4 or IPv6) 58 | 59 | 60 | 61 | http_port 62 | 9200 63 | Set a custom port for HTTP 64 | 65 | 66 | 67 | 68 | discovery_zen_ping_unicast_hosts 69 | 127.0.0.1 70 | Pass an initial list of hosts to perform discovery when new node is started 71 | 72 | 73 | 74 | discovery_zen_minimum_master_nodes 75 | 3 76 | Prevent the "split brain" by configuring the majority of nodes (total number of nodes / 2 + 1) 77 | 78 | 79 | 80 | 81 | gateway_recover_after_nodes 82 | 3 83 | Block initial recovery after a full cluster restart until N nodes are started 84 | 85 | 86 | 87 | 88 | node_max_local_storage_nodes 89 | 1 90 | Disable starting multiple nodes on a single system 91 | 92 | 93 | 94 | action_destructive_requires_name 95 | true 96 | Require explicit names when deleting indices 97 | 98 | 99 | 100 | xpack_security_enabled 101 | false 102 | Enable X-Pack security module 103 | 104 | 105 | -------------------------------------------------------------------------------- /configuration/elastic-env.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 17 | 18 | 19 | 20 | elastic_user 21 | elasticsearch 22 | USER 23 | Elasticsearch user 24 | 25 | 26 | 27 | elastic_group 28 | elasticsearch 29 | GROUP 30 | Elasticsearch group 31 | 32 | 33 | 34 | elastic_base_dir 35 | /opt/elasticsearch 36 | Elasticsearch base directory 37 | 38 | 39 | 40 | elastic_log_dir 41 | /opt/elasticsearch/logs 42 | Elasticsearch log directory 43 | 44 | 45 | 46 | elastic_conf_dir 47 | /opt/elasticsearch/config 48 | Elasticsearch configuration directory 49 | 50 | 51 | 52 | elastic_pid_dir 53 | /var/run/elasticsearch 54 | Elasticsearch PID directory 55 | 56 | 57 | -------------------------------------------------------------------------------- /metainfo.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 2.0 18 | 19 | 20 | ELASTICSEARCH 21 | Elasticsearch 22 | Elasticsearch is a distributed, RESTful search and analytics engine capable of solving a growing number of use cases. As the heart of the Elastic Stack, it centrally stores your data so you can discover the expected and uncover the unexpected. 23 | 5.2.0 24 | 25 | 26 | MASTER 27 | Elasticsearch Master 28 | MASTER 29 | 1+ 30 | 31 | 32 | PYTHON 33 | 600 34 | 35 | 36 | 37 | 38 | 39 | 40 | any 41 | 42 | 43 | 44 | 45 | elastic-env 46 | elastic-config 47 | 48 | 49 | false 50 | 51 | 52 | 53 | quicklinks.json 54 | true 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /package/scripts/elastic_common.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """ 4 | Licensed to the Apache Software Foundation (ASF) under one 5 | or more contributor license agreements. See the NOTICE file 6 | distributed with this work for additional information 7 | regarding copyright ownership. The ASF licenses this file 8 | to you under the Apache License, Version 2.0 (the 9 | "License"); you may not use this file except in compliance 10 | with the License. You may obtain a copy of the License at 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | """ 18 | 19 | from resource_management.core.resources.system import Execute, File 20 | from resource_management.libraries.functions.format import format 21 | from resource_management.libraries.functions.get_user_call_output import get_user_call_output 22 | from resource_management.libraries.functions.show_logs import show_logs 23 | 24 | def kill_process(pid_file, user, log_dir): 25 | import params 26 | """ 27 | Kill the process by pid file, then check the process is running or not. If the process is still running after the kill 28 | command, it will try to kill with -9 option (hard kill) 29 | """ 30 | pid = get_user_call_output(format("cat {pid_file}"), user=user, is_checked_call=False)[1] 31 | process_id_exists_command = format("ls {pid_file} >/dev/null 2>&1 && ps -p {pid} >/dev/null 2>&1") 32 | 33 | kill_cmd = format("kill {pid}") 34 | Execute(kill_cmd, 35 | not_if=format("! ({process_id_exists_command})")) 36 | wait_time = 5 37 | 38 | hard_kill_cmd = format("kill -9 {pid}") 39 | Execute(hard_kill_cmd, 40 | not_if=format("! ({process_id_exists_command}) || ( sleep {wait_time} && ! ({process_id_exists_command}) )"), 41 | ignore_failures=True) 42 | try: 43 | Execute(format("! ({process_id_exists_command})"), 44 | tries=20, 45 | try_sleep=3, 46 | ) 47 | except: 48 | show_logs(log_dir, user) 49 | raise 50 | 51 | File(pid_file, 52 | action="delete" 53 | ) 54 | 55 | 56 | -------------------------------------------------------------------------------- /package/scripts/master.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """ 4 | Licensed to the Apache Software Foundation (ASF) under one 5 | or more contributor license agreements. See the NOTICE file 6 | distributed with this work for additional information 7 | regarding copyright ownership. The ASF licenses this file 8 | to you under the Apache License, Version 2.0 (the 9 | "License"); you may not use this file except in compliance 10 | with the License. You may obtain a copy of the License at 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | """ 18 | 19 | import sys 20 | import os 21 | import glob 22 | import pwd 23 | import grp 24 | import signal 25 | import time 26 | from resource_management import * 27 | from elastic_common import kill_process 28 | 29 | class Master(Script): 30 | 31 | # Install Elasticsearch 32 | def install(self, env): 33 | # Import properties defined in -config.xml file from the params class 34 | import params 35 | 36 | # This allows us to access the params.elastic_pid_file property as 37 | # format('{elastic_pid_file}') 38 | env.set_params(params) 39 | 40 | # Install dependent packages 41 | self.install_packages(env) 42 | 43 | # Create user and group for Elasticsearch if they don't exist 44 | try: grp.getgrnam(params.elastic_group) 45 | except KeyError: Group(group_name=params.elastic_group) 46 | 47 | try: pwd.getpwnam(params.elastic_user) 48 | except KeyError: User(username=params.elastic_user, 49 | gid=params.elastic_group, 50 | groups=[params.elastic_group], 51 | ignore_failures=True 52 | ) 53 | 54 | # Create Elasticsearch directories 55 | Directory([params.elastic_base_dir, params.elastic_log_dir, params.elastic_pid_dir], 56 | mode=0755, 57 | cd_access='a', 58 | owner=params.elastic_user, 59 | group=params.elastic_group, 60 | create_parents=True 61 | ) 62 | 63 | # Create empty Elasticsearch install log 64 | File(params.elastic_install_log, 65 | mode=0644, 66 | owner=params.elastic_user, 67 | group=params.elastic_group, 68 | content='' 69 | ) 70 | 71 | # Download Elasticsearch 72 | cmd = format("cd {elastic_base_dir}; wget {elastic_download} -O elasticsearch.tar.gz -a {elastic_install_log}") 73 | Execute(cmd, user=params.elastic_user) 74 | 75 | # Install Elasticsearch 76 | cmd = format("cd {elastic_base_dir}; tar -xf elasticsearch.tar.gz --strip-components=1") 77 | Execute(cmd, user=params.elastic_user) 78 | 79 | # Ensure all files owned by elasticsearch user 80 | cmd = format("chown -R {elastic_user}:{elastic_group} {elastic_base_dir}") 81 | Execute(cmd) 82 | 83 | # Remove Elasticsearch installation file 84 | cmd = format("cd {elastic_base_dir}; rm elasticsearch.tar.gz") 85 | Execute(cmd, user=params.elastic_user) 86 | 87 | Execute('echo "Install complete"') 88 | 89 | 90 | def configure(self, env): 91 | # Import properties defined in -config.xml file from the params class 92 | import params 93 | 94 | # This allows us to access the params.elastic_pid_file property as 95 | # format('{elastic_pid_file}') 96 | env.set_params(params) 97 | 98 | configurations = params.config['configurations']['elastic-config'] 99 | 100 | File(format("{elastic_conf_dir}/elasticsearch.yml"), 101 | content=Template("elasticsearch.yml.j2", 102 | configurations=configurations), 103 | owner=params.elastic_user, 104 | group=params.elastic_group 105 | ) 106 | 107 | # Install HEAD and HQ puglins - these plugins are not currently supported by ES 5.x 108 | #cmd = format("{elastic_base_dir}/bin/elasticsearch-plugin install mobz/elasticserach-head") 109 | #Execute(cmd) 110 | 111 | # Attempt to remove X-Pack plugin 112 | cmd = format("{elastic_base_dir}/bin/elasticsearch-plugin remove x-pack") 113 | Execute(cmd) 114 | 115 | # Install X-Pack plugin 116 | cmd = format("{elastic_base_dir}/bin/elasticsearch-plugin install x-pack") 117 | Execute(cmd) 118 | 119 | # Ensure all files owned by elasticsearch user 120 | cmd = format("chown -R {elastic_user}:{elastic_group} {elastic_base_dir}") 121 | Execute(cmd) 122 | 123 | Execute('echo "Configuration complete"') 124 | 125 | def stop(self, env): 126 | # Import properties defined in -config.xml file from the params class 127 | import params 128 | 129 | # Import properties defined in -env.xml file from the status_params class 130 | import status_params 131 | 132 | # This allows us to access the params.elastic_pid_file property as 133 | # format('{elastic_pid_file}') 134 | env.set_params(params) 135 | 136 | # Stop Elasticsearch 137 | kill_process(params.elastic_pid_file, params.elastic_user, params.elastic_log_dir) 138 | #cmd = format("kill `cat {elastic_pid_file}`") 139 | #Execute(cmd, user=params.elastic_user, only_if=format("test -f {elastic_pid_file}")) 140 | 141 | 142 | def start(self, env): 143 | # Import properties defined in -config.xml file from the params class 144 | import params 145 | 146 | # This allows us to access the params.elastic_pid_file property as 147 | # format('{elastic_pid_file}') 148 | env.set_params(params) 149 | 150 | # Configure Elasticsearch 151 | self.configure(env) 152 | 153 | # Start Elasticsearch 154 | cmd = format("{elastic_base_dir}/bin/elasticsearch -d -p {elastic_pid_file}") 155 | Execute(cmd, user=params.elastic_user) 156 | 157 | 158 | def status(self, env): 159 | # Import properties defined in -env.xml file from the status_params class 160 | import status_params 161 | 162 | # This allows us to access the params.elastic_pid_file property as 163 | # format('{elastic_pid_file}') 164 | env.set_params(status_params) 165 | 166 | #try: 167 | # pid_file = glob.glob(status_params.elastic_pid_file)[0] 168 | #except IndexError: 169 | # pid_file = '' 170 | 171 | # Use built-in method to check status using pidfile 172 | check_process_status(status_params.elastic_pid_file) 173 | 174 | if __name__ == "__main__": 175 | Master().execute() 176 | -------------------------------------------------------------------------------- /package/scripts/params.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """ 4 | Licensed to the Apache Software Foundation (ASF) under one 5 | or more contributor license agreements. See the NOTICE file 6 | distributed with this work for additional information 7 | regarding copyright ownership. The ASF licenses this file 8 | to you under the Apache License, Version 2.0 (the 9 | "License"); you may not use this file except in compliance 10 | with the License. You may obtain a copy of the License at 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | """ 18 | 19 | from resource_management import * 20 | import os 21 | 22 | # config object that holds the configurations declared in the -config.xml file 23 | config = Script.get_config() 24 | 25 | java64_home = config['hostLevelParams']['java_home'] 26 | 27 | hostname = config['hostname'] 28 | 29 | elastic_user = config['configurations']['elastic-env']['elastic_user'] 30 | elastic_group = config['configurations']['elastic-env']['elastic_group'] 31 | 32 | elastic_base_dir = config['configurations']['elastic-env']['elastic_base_dir'] 33 | elastic_conf_dir = config['configurations']['elastic-env']['elastic_conf_dir'] 34 | elastic_log_dir = config['configurations']['elastic-env']['elastic_log_dir'] 35 | elastic_pid_dir = config['configurations']['elastic-env']['elastic_pid_dir'] 36 | elastic_pid_file = format("{elastic_pid_dir}/elasticsearch.pid") 37 | 38 | elastic_install_log = elastic_base_dir + '/elasticsearch-install.log' 39 | elastic_download = 'https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.2.0.tar.gz' 40 | 41 | cluster_name = config['configurations']['elastic-config']['cluster_name'] 42 | hostname = config['hostname'] 43 | node_attr_rack = config['configurations']['elastic-config']['node_attr_rack'] 44 | path_data = config['configurations']['elastic-config']['path_data'] 45 | path_logs = config['configurations']['elastic-config']['path_logs'] 46 | 47 | bootstrap_memory_lock = str(config['configurations']['elastic-config']['bootstrap_memory_lock']) 48 | 49 | # Elasticsearch expetcs that boolean values to be true or false and will generate an error if you use True or False. 50 | if bootstrap_memory_lock == 'True': 51 | bootstrap_memory_lock = 'true' 52 | else: 53 | bootstrap_memory_lock = 'false' 54 | 55 | network_host = config['configurations']['elastic-config']['{network_host'] 56 | http_port = config['configurations']['elastic-config']['http_port'] 57 | 58 | discovery_zen_ping_unicast_hosts = str(config['configurations']['elastic-config']['discovery_zen_ping_unicast_hosts']) 59 | 60 | # Need to parse the comma separated hostnames to create the proper string format within the configuration file 61 | # Elasticsearch expects the format ["host1","host2"] 62 | master_node_list = discovery_zen_ping_unicast_hosts.split(',') 63 | discovery_zen_ping_unicast_hosts = '[' + ','.join('"' + x + '"' for x in master_node_list) + ']' 64 | 65 | discovery_zen_minimum_master_nodes = config['configurations']['elastic-config']['discovery_zen_minimum_master_nodes'] 66 | 67 | 68 | gateway_recover_after_nodes = config['configurations']['elastic-config']['gateway_recover_after_nodes'] 69 | node_max_local_storage_nodes = config['configurations']['elastic-config']['node_max_local_storage_nodes'] 70 | 71 | action_destructive_requires_name = str(config['configurations']['elastic-config']['action_destructive_requires_name']) 72 | 73 | # Elasticsearch expecgts boolean values to be true or false and will generate an error if you use True or False. 74 | if action_destructive_requires_name == 'True': 75 | action_destructive_requires_name = 'true' 76 | else: 77 | action_destructive_requires_name = 'false' 78 | 79 | xpack_security_enabled = str(config['configurations']['elastic-config']['xpack_security_enabled']) 80 | 81 | # Elasticsearch expects boolean values to be true or false and will generate an error if you use True or False. 82 | if xpack_security_enabled == 'True': 83 | xpack_security_enabled = 'true' 84 | else: 85 | xpack_security_enabled = 'false' 86 | -------------------------------------------------------------------------------- /package/scripts/status_params.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """ 4 | Licensed to the Apache Software Foundation (ASF) under one 5 | or more contributor license agreements. See the NOTICE file 6 | distributed with this work for additional information 7 | regarding copyright ownership. The ASF licenses this file 8 | to you under the Apache License, Version 2.0 (the 9 | "License"); you may not use this file except in compliance 10 | with the License. You may obtain a copy of the License at 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | """ 18 | 19 | from resource_management import * 20 | 21 | config = Script.get_config() 22 | 23 | elastic_pid_dir = config['configurations']['elastic-env']['elastic_pid_dir'] 24 | elastic_pid_file = format("{elastic_pid_dir}/elasticsearch.pid") 25 | -------------------------------------------------------------------------------- /package/templates/elasticsearch.yml.j2: -------------------------------------------------------------------------------- 1 | # ======================== Elasticsearch Configuration ========================= 2 | # 3 | # NOTE: Elasticsearch comes with reasonable defaults for most settings. 4 | # Before you set out to tweak and tune the configuration, make sure you 5 | # understand what are you trying to accomplish and the consequences. 6 | # 7 | # The primary way of configuring a node is via this file. This template lists 8 | # the most important settings you may want to configure for a production cluster. 9 | # 10 | # Please see the documentation for further information on configuration options: 11 | # 12 | 13 | # ---------------------------------- Cluster ----------------------------------- 14 | # Use a descriptive name for your cluster: 15 | cluster.name: {{cluster_name}} 16 | 17 | # ------------------------------------ Node ------------------------------------ 18 | # Use a descriptive name for the node: 19 | node.name: {{hostname}} 20 | 21 | # Add custom attributes to the node: 22 | node.attr.rack: {{node_attr_rack}} 23 | 24 | node.master: true 25 | node.data: true 26 | node.ingest: true 27 | 28 | # ----------------------------------- Paths ------------------------------------ 29 | # Path to directory where to store the data (separate multiple locations by comma): 30 | path.data: {{path_data}} 31 | 32 | # Path to log files: 33 | path.logs: {{path_logs}} 34 | 35 | # ----------------------------------- Memory ----------------------------------- 36 | # Lock the memory on startup:# Elasticsearch expects that boolean values to be true or false and will generate an error if you use True or False. 37 | bootstrap.memory_lock: {{bootstrap_memory_lock}} 38 | 39 | # ---------------------------------- Network ----------------------------------- 40 | # Set the bind address to a specific IP (IPv4 or IPv6): 41 | network.host: {{hostname}} 42 | 43 | # Set a custom port for HTTP: 44 | http.port: {{http_port}} 45 | 46 | # --------------------------------- Discovery ---------------------------------- 47 | # Pass an initial list of hosts to perform discovery when new node is started: 48 | # The default list of hosts is ["127.0.0.1", "[::1]"] 49 | discovery.zen.ping.unicast.hosts: {{discovery_zen_ping_unicast_hosts}} 50 | 51 | # Prevent the "split brain" by configuring the majority of nodes (total number of nodes / 2 + 1): 52 | discovery.zen.minimum_master_nodes: {{discovery_zen_minimum_master_nodes}} 53 | 54 | # ---------------------------------- Gateway ----------------------------------- 55 | # Block initial recovery after a full cluster restart until N nodes are started: 56 | gateway.recover_after_nodes: {{gateway_recover_after_nodes}} 57 | 58 | # ---------------------------------- Various ----------------------------------- 59 | # Disable starting multiple nodes on a single system: 60 | node.max_local_storage_nodes: {{node_max_local_storage_nodes}} 61 | 62 | # Require explicit names when deleting indices: 63 | # Lock the memory on startup:# Elasticsearch expects that boolean values to be true or false and will generate an error if you use True or False. 64 | action.destructive_requires_name: {{action_destructive_requires_name}} 65 | 66 | # ---------------------------------- X-Pack ----------------------------------- 67 | # Disabling security 68 | xpack.security.enabled: {{xpack_security_enabled}} 69 | -------------------------------------------------------------------------------- /quicklinks/quicklinks.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "default", 3 | "description": "default quick links configuration", 4 | "configuration": { 5 | "protocol": { 6 | "type":"http", 7 | "checks":[ 8 | ] 9 | }, 10 | "links": [ 11 | { 12 | "name": "elasticsearch_ui", 13 | "label": "Elasticsearch UI", 14 | "requires_user_name": "false", 15 | "component_name": "ELASTICSEARCH", 16 | "url":"%@://%@:%@", 17 | "port":{ 18 | "http_property": "http_port", 19 | "http_default_port": "9200", 20 | "https_property": "http_port", 21 | "https_default_port": "9200", 22 | "regex": "\\w*:(\\d+)", 23 | "site": "elastic-config" 24 | } 25 | } 26 | ] 27 | } 28 | } 29 | --------------------------------------------------------------------------------