ES 6.2.4安装及head插件安装 —— 来自QQ空间

#!/bin/bash

# 定义变量

declare -A map=(

["*"]="192.168.*" 

["*"]="192.168.*"

["*"]="192.168.*"

)

hosts="["

for key in ${!map[@]}

do

    if [ "$hosts" == '[' ]

    then

        hosts=['"'${map[$key]}'"'

    else

        hosts=$hosts,'"'${map[$key]}'"'

    fi

done

hosts="$hosts"]

echo $hosts

echo -e "\033[32m ==========修改limits参数========== \033[0m"

for key in ${!map[@]}

do

    echo -e "\033[34m ======NTP at $key====== \033[0m"

    ssh $key "echo '* soft nofile 65536

* soft nproc 2048

* hard nofile 131072

* hard nproc 4096

es soft memlock unlimited

es hard memlock unlimited

'>> /etc/security/limits.conf"

    ssh -t -p 22 root@$key "echo '* soft nproc unlimited' >> /limits.d/20-nproc.conf"

    ssh -t -p 22 root@$key "echo 'vm.max_map_count=655360' >> /etc/sysctl.conf" 

    ssh -t -p 22 root@$key "echo 'sysctl -p && useradd -d /home/es -m es" 

done

  

echo -e "\033[32m ==========解压配置elasticsearch========== \033[0m"

tar zxvf elasticsearch-6.2.4.tar.gz -C /opt

chown -R -c es:es /opt/elasticsearch-6.2.4

cp /opt/elasticsearch-6.2.4/config/elasticsearch.yml /opt/elasticsearch-6.2.4/config/elasticsearch.yml.bak

echo -e "\033[32m ==========替换配置文件========== \033[0m"

for key in ${!map[@]}

do

echo -e "\033[32m ==========$key========== \033[0m"

echo "cluster.name: pdmi

node.name: $key

#path.data: /var/lib/elasticsearch

#path.logs: /var/log/elasticsearch

bootstrap.memory_lock: true

bootstrap.system_call_filter: false

network.host: ${map[$key]}

discovery.zen.ping.unicast.hosts: $hosts

discovery.zen.minimum_master_nodes: 2

#head插件需要

http.cors.enabled: true

http.cors.allow-origin: "*"

" > elasticsearch.yml

    scp -r /opt/elasticsearch-6.2.4 root@$key:/opt/

    scp -r elasticsearch.yml root@$key:/opt/elasticsearch-6.2.4/config/

    ssh -t -p 22 root@$key "chown -R -c es:es /opt/elasticsearch-6.2.4"

    ssh -t -p 22 root@$key "su - es -c '/opt/elasticsearch-6.2.4/bin/elasticsearch -d'"

done

安装head
下载 好nodejs
 yum -y install xz
 tar xvf node-v8.12.0-linux-x64.tar.xz 
vi /etc/profile

export JAVA_HOME=/opt/jdk1.8.0_112

export NODE_HOME=/opt/node-v8.12.0-linux-x64

export PATH=$PATH:$JAVA_HOME/bin:$NODE_HOME/bin

export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
 source /etc/profile
 node -v
npm -v

 wget https://github.com/mobz/elasticsearch-head/archive/master.zip

unzip master.zip 
cd elasticsearch-head-master/
npm install --registry=https://registry.npm.taobao.org
vi Gruntfile.js

connect: {

                        server: {

                                options: {                     
                                       hostname:'192.168.x.xx',

                                        port: 9100,

                                        base: '.',

                                        keepalive: true

                                }

                        }

                }

nohup npm run start &

猜你喜欢

转载自blog.csdn.net/jzy3711/article/details/84143729