Forked from ruanbekker/elasticsearch-bootstrap-data-node.sh
Created
January 17, 2018 21:49
-
-
Save asakasinsky/7b80af4513b39cb4c48f6f1357bbc6af to your computer and use it in GitHub Desktop.
Bootstrap Elasticsearch Data Node on Ubuntu 16.04
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
apt update && apt upgrade -y | |
apt install software-properties-common python-software-properties apt-transport-https -y | |
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - | |
echo "deb https://artifacts.elastic.co/packages/5.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list | |
add-apt-repository ppa:webupd8team/java -y | |
apt update | |
echo "oracle-java8-installer shared/accepted-oracle-license-v1-1 select true" | sudo debconf-set-selections | |
apt install oracle-java8-installer -y | |
apt install elasticsearch -y | |
mkfs.xfs /dev/xvdb | |
mkdir /data | |
echo '/dev/xvdb /data xfs defaults 0 0' >> /etc/fstab | |
mount -a | |
chown -R elasticsearch:elasticsearch /data | |
cat > /etc/elasticsearch/elasticsearch.yml << EOF | |
cluster.name: ruan-es-cluster | |
node.name: \${HOSTNAME} | |
node.master: false | |
node.data: true | |
path.data: /data | |
path.logs: /var/log/elasticsearch | |
bootstrap.memory_lock: true | |
network.host: 127.0.0.1 | |
transport.host: 0.0.0.0 | |
http.port: 9201 | |
transport.tcp.port: 9300 | |
discovery.zen.minimum_master_nodes: 2 | |
discovery.zen.ping_timeout: 10s | |
discovery.zen.fd.ping_retries: 3 | |
discovery.zen.fd.ping_interval: 3s | |
discovery.zen.fd.ping_timeout: 30s | |
discovery.zen.ping.unicast.hosts: ["es-master-1", "es-master-2", "es-master-3"] | |
EOF | |
cat > /etc/default/elasticsearch << EOF | |
ES_STARTUP_SLEEP_TIME=5 | |
MAX_OPEN_FILES=65536 | |
MAX_LOCKED_MEMORY=unlimited | |
EOF | |
sed -i 's/#LimitMEMLOCK=infinity/LimitMEMLOCK=infinity/'g /usr/lib/systemd/system/elasticsearch.service | |
cat > /etc/security/limits.conf << EOF | |
elasticsearch soft nofile 65536 | |
elasticsearch hard nofile 65536 | |
elasticsearch soft memlock unlimited | |
elasticsearch hard memlock unlimited | |
EOF | |
systemctl daemon-reload | |
systemctl enable elasticsearch | |
systemctl enable nginx | |
chown -R elasticsearch:elasticsearch /data | |
reboot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment