ElasticSearch:安装、head插件、集群、root启动

来自Wikioe
跳到导航 跳到搜索


关于

【转自:https://www.orchome.com/489

Linux下安装

  • 确保jdk为jdk1.8.0_73以上,并已确保安装ok。
  1. 下载 ElasticSearch:
    wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.1.1.tar.gz
    tar -zxvf elasticsearch-5.1.1.tar.gz
    
    cd elasticsearch-5.1.1
    
  2. 修改limit限制:(5.0以后都要修改)
    > vi /etc/security/limits.conf
    * soft nofile 65536
    * hard nofile 65536
    
    > echo 'vm.max_map_count=262144'>> /etc/sysctl.conf
    > sysctl -p
    
    > vi /etc/security/limits.d/90-nproc.conf
    *          soft    nproc     2048
    
  3. 设置配置文件:
    > vim config/elasticsearch.yml
    
    node.name: node-1
    path.data: /tmp/elasticsearch/data
    path.logs: /tmp/elasticsearch/logs
    network.host: 192.168.x.x
    http.port: 9200
    # 跨域
    http.cors.enabled: true
    http.cors.allow-origin: "*"
    
  4. 创建用户:
    # 创建elasticsearch用户
    groupadd elasticsearch
    useradd elasticsearch -g elasticsearch -p elasticsearch
    # 赋权限
    chown elasticsearch:elasticsearch -R /usr/local/elasticsearch-5.1.1
    
  5. 启动:
    su - elasticsearch -c "nohup /usr/local/elasticsearch-5.1.1/bin/elasticsearch >/dev/null 2>&1 &"
    

head插件的安装

  1. 下载:
    git clone git://github.com/mobz/elasticsearch-head.git
    cd elasticsearch-head
    
    • 在 elasticsearch-head 目录下 node_modules/grunt 下如果没有 grunt 二进制程序,需要执行:
      cd elasticsearch-head
      npm install grunt --save
      
  2. 修改服务器监听地址:
    修改 elasticsearch-head 下 Gruntfile.js 文件,默认监听在 127.0.0.1 下 9200 端口;
    Elasticsearch:安装head插件:修改Gruntfile.js文件.png
    修改head的连接地址:(目录:head/_site/app.js)(把 localhost 修改成 es 的服务器地址)
    this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "https://localhost:9200";
    
    在head目录中,执行npm install下载依赖的包:
    npm install
    
  3. 启动服务:
    /usr/local/elasticsearch-head/node_modules/grunt/bin/grunt server
    
    Elasticsearch:安装head插件:启动.png
  4. 访问:https://192.168.1.1:9100
    Elasticsearch:安装head插件:访问.png

如果没有npm,则需安装npm

如下:

curl https://npmjs.org/install.sh | sh
sh install.sh

如果出现:

npm cannot be installed without Node.js.
Install Node.js first, and then try again.

则需要 安装Node.js:

yum install -y nodejs


如果node.js版本过低,则需要升级:

# 第一步:首先安装 n 模块:
npm install -g n

# 第二步:升级node.js到最新稳定版
n stable

集群搭建