文章目录
三个步骤(linux系统皆可)
1.安装JDK1.8+
2.安装并配置elasticsearch
下载压缩包(文章中用的是7.3.2版本)
使用或新建普通用户
配置
配置资源使用限制
3.启动elasticsearch
三个步骤(linux系统皆可)
- 安装Java环境
- 安装并配置elasticsearch
- 启动elasticsearch
1. 安装JDK1.8+
安装1.8版本或以上的jdk
2. 安装并配置elasticsearch
下载压缩包(文章中用的是7.3.2版本)
$ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.3.2-linux-x86_64.tar.gz
$ tar -zxvf elasticsearch-7.3.2-linux-x86_64.tar.gz
使用或新建普通用户
要以普通用户来运行才可以
useradd es
passwd es
chown -R es elasticsearch-7.3.2
配置
开启步骤 - 在配置文件elasticsearch.yml中配置好初始化参数
$ vim /config/elasticsearch.yml
在文件中添加以下配置
#配置节点名
node.name: node-1
#配置远程访问
network.host: 0.0.0.0
#配置端口
http.port: 9200
#配置跨域访问
http.cors.enabled: true
http.cors.allow-origin: "*"
#配置集群主节点
cluster.initial_master_nodes: ["node-1"]
#关闭机器学习
xpack.ml.enabled: false
配置资源使用限制
#提高可用资源限制(重新登录用户后才生效)
vim /etc/security/limits.conf
在文件最后的表格中添加以下配置
* soft nofile 65536
* hard nofile 65536
* soft nproc 4096
* hard nproc 4096
提高可用资源限制
$ vim /etc/sysctl.conf
在文件最后添加以下内容
vm.max_map_count=262144
查看配置
$ sysctl -p
3. 启动elasticsearch
启动elasticsearch(如果需要以后台守护进程模式运行,则添加参数 -d)
$ ./bin/elasticsearch
基于HTTP协议,以JSON为数据交互格式的RESTful API,通过9200端口的与Elasticsearch进行通信。
如访问http://ipaddress:9200/
得到以下返回
{
"name" : "master1",
"cluster_name" : "cluster1",
"cluster_uuid" : "Fo9Qwp_FS8i-8lbZu0A6tA",
"version" : {
"number" : "7.3.2",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "1c1faf1",
"build_date" : "2019-09-06T14:40:30.409026Z",
"build_snapshot" : false,
"lucene_version" : "8.1.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}