安装elasticsearch官网安装,配置,后台启动

es 安装自己编写的脚本

#!/bin/bash
cd /letv
rsync -avzP 10.180.92.199::wVioz35SWO9zywesmagfOrP9XjigoF8j/james/elasticsearch-5.0.0.tar.gz .
tar -xzf elasticsearch-5.0.0.tar.gz
ln -s  /letv/elasticsearch-5.0.0 /usr/local/elasticsearch
export ES_HOME=/usr/local/elasticsearch
echo "export ES_HOME=/usr/local/elasticsearch 
export PATH=${ES_HOME}/bin:$PATH
" >> /root/.bashrc

官网 我没用

cd /letv
export http_proxy=http://10.182.63.40:3128/
export https_proxy=$http_proxy
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.0.2.tar.gz
sha1sum elasticsearch-5.0.2.tar.gz 
tar -xzf elasticsearch-5.0.2.tar.gz
cd elasticsearch-5.0.2/ 

es配置
vim es.config.sh

#!/bin/bash
cat >> /usr/local/elasticsearch/config/elasticsearch.yml << EOF
cluster.name: hadoop_log
path.data: /data/slot0
path.logs: /data/slot0
node.name:    ${HOSTNAME}
network.host: 0.0.0.0
discovery.zen.ping.unicast.hosts:
   - 10.183.93.129
   - 10.183.93.131
   - 10.183.93.132
discovery.zen.minimum_master_nodes: 2
#action.destructive_requires_name: true 
#node.max_local_storage_nodes: 1
EOF

单机启动

启动daemon
./bin/elasticsearch -d -p pid
elasticsearch -d -p 9988

创建个用户

sudo ansible -i ansible_hosts elk -m shell -a "useradd elk -g root -G root"

改一下系统环境

sudo ansible -i ansible_hosts elk -m shell -a "sysctl -w vm.max_map_count=262144"

改data目录权限

sudo ansible -i ansible_hosts elk -m shell -a "chown elk.root -R /data/slot0/"

改elasticsearch目录权限

sudo ansible -i ansible_hosts elk -m shell -a "chown elk.root -R /usr/local/elasticsearch/"

启动daemon

sudo ansible -i ansible_hosts elk -m shell -a "su - elk -c '/usr/local/elasticsearch/bin/elasticsearch -d -p 9988'"

检查一下进程

sudo ansible -i ansible_hosts elk -m shell -a "ps -ef | grep elasticsearch"

查一下端口

sudo ansible -i ansible_hosts elk -m shell -a "netstat -anlpt"

创建文件夹

sudo ansible -i ansible_hosts elk -m shell -a "mkdir /data/elasticsearch"

替换配置文件内容

sudo ansible -i ansible_hosts elk -m shell -a "sed -i  's/\/data\/slot0/\/data\/elasticsearch/g' /usr/local/elasticsearch/config/elasticsearch.yml"
sudo ansible -i ansible_hosts elk -m shell -a "sed -i  's/2g/64g/g' /usr/local/elasticsearch/config/jvm.options"

改个权限

sudo ansible -i ansible_hosts elk -m shell -a "chown elk.root -R /data"

你可能感兴趣的:(elk)