环境
- 操作系统:Centos 6.5 X64
- IP地址:192.168.56.100
- JDK 环境:
# java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
新建立用户:
# useradd elastic
# su - elastic
# mkdir ~/opt
接下来的操作都是使用elastic用户的opt/目录来进行操作。
下载安装
下载
下载地址:https://www.elastic.co/downloads/past-releases/elasticsearch-5-2-1
下载后解压
$ ls -l elasticsearch-5.2.1.zip
-rw-r--r--. 1 elastic elastic 33533234 Feb 15 14:24 elasticsearch-5.2.1.zip
$ unzip elasticsearch-5.2.1.zip
主要的文件及目录:
elasticsearch-5.2.1
├── bin/ #命令
│ ├── elasticsearch #启动服务命令
│ ├── elasticsearch.in.sh
│ ├── elasticsearch-plugin
│ ├── elasticsearch-translog
├── config/ #配置目录
│ ├── elasticsearch.yml #主要配置文件
│ ├── jvm.options
│ └── log4j2.properties
├── lib/
├── modules/
├── NOTICE.txt
├── plugins/ #插件目录
└── README.textile
安装
elasticsearch是开箱即用软件,解压完后,可以先试运行一次
$ cd ~/opt/elasticsearch-5.2.1
$ bin/elasticsearch
......
启动完后,可以在另一个终端查看运行情况:
$ curl -XGET "http://localhost:9200?pretty"
{
"name" : "es-node-01",
"cluster_name" : "es-cluster",
"cluster_uuid" : "wDw2aF-1THGSCqvyq6KPNw",
"version" : {
"number" : "5.2.1",
"build_hash" : "db0d481",
"build_date" : "2017-02-09T22:05:32.386Z",
"build_snapshot" : false,
"lucene_version" : "6.4.1"
},
"tagline" : "You Know, for Search"
}
配置
elasticsearch 5.x版本后,需要配置才可以通过IP来进行访问,主要配置如下:
系统配置(root用户操作)
# cat >> /etc/security/limits.conf <EOF
* soft nofile 65536
* hard nofile 65536
EOF
# vim /etc/security/limits.d/90-nproc.conf
soft nproc 1024 =>修改为soft nproc 2048
# cat >> /etc/sysctl.conf <EOF
vm.max_map_count=655360
EOF
# sysctl -p
elasticsearch配置
修改配置文件~/opt/elasticsearch-5.2.1/config/elasticsearch.yml
cluster.name: "es-cluster"
node.name: "es-node-01"
node.master: true
node.data: true
http.enabled: true
network.host: 0.0.0.0
http.port: 9200
http.cors.enabled: true
http.cors.allow-origin: "*"
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
启动
elasticsearch可以直接启动,也可以加上-b参数在后台启动
$ bin/elasticsearch -b
......