ElasticSearch安装及注意事项

基本要求

 JDK 1.8+

本机环境

Centos 7
JDK 1.8

下载与安装

  下载tar包
  curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.5.2.tar.gz
  解压tar包
  tar -xvf elasticsearch-5.5.2.tar.gz
  启动服务
  cd elasticsearch-5.5.2/bin
  ./elasticsearch

注意事项

1.最好`chomod -R 777 ./elasticsearch-5.5.2`,防止启动报错无权限
2.不能使用root用户

配置跨域访问

1.修改elasticsearch.yml network.host为ip
2.在elasticsearch.yml 添加
     http.cors.enabled: true
     http.cors.allow-origin: "*"

安装head

1.git clone https://github.com/mobz/elasticsearch-head
2.yum install -y nodejs nodejs-npm #head所需环境
  node -v  #检测是否正确安装
  npm -v  #检测是否正确安装
3.npm install -g grunt-cli
4.npm install -g grunt
5.cd head目录
  npm install -g cnpm --registry=https://registry.npm.taobao.org
6.修改Gruntfile.js 添加hostname:"*",
  connect: {
    server: {
      options: {
        port: 9100,
        hostname: '*',
        base: '.',
        keepalive: true
      }
    }
  }
7.修改head/_site/app.js
  修改head的连接地址:this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://localhost:9200";
  把localhost修改成你es的服务器地址:this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://ip:9200";
8.启动
  ./es/bin/elasticsearch
  ./es-head/grunt server

你可能感兴趣的:(ElasticSearch安装及注意事项)