- 首先安装Elasticsearch要把JDK1.8安装好 ,自己去百度查资料
- 把Elasticsearch 下载好安装包或者使用命令下载
1、 命令下载方式
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.2.0-linux-x86_64.tar.gz
2、官网地址下载
Elasticsearch下载地址
- 弄好然后随意放到那个目录进行解压,把名字改掉为了方便之后方便启动
[root@localhost es]# pwd
/usr/local/es
[root@localhost es]# ls
elasticsearch elasticsearch-7.2.1-linux-x86_64.tar.gz
[root@localhost es]#
- 进入 elasticsearch 中config 修改 elasticsearch.yml
vim elasticsearch/config/elasticsearch.yml
- 只贴需要修改得地方
#名称
cluster.name: es-all
#节点
node.name: node-1
#数据地址
path.data: /usr/local/to/data
#日志地址
path.logs: /usr/local/to/logs
#所有人可以连接
network.host: 0.0.0.0
#默认端口号
http.port: 9200
- 设置资源参数
vim /etc/security/limits.conf
- 添加以下数据内容
- soft nofile 65536
- hard nofile 65536
- soft nproc 4096
- hard nproc 4096
-
- 另外 elasticsearch 启动不能使用root账号 ,需要创建一个新的用户
useradd es
passwd 123456
#赋予目录权限
chown -R es /usr/local/es/
- 切换账号启动 加&让它在后台启动
/usr/local/es/elasticsearch/bin/elasticsearch &
- 启动报错信息
ERROR: [1] bootstrap checks failed
[1]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
- 解决方案
需要配置cluster.initial_master_nodes,修改 elasticsearch.yml,
由于暂时我们的es是单节点的,所以只要配置一个node节点就行了,
这里node-1必须和 node.name: 名称相同
cluster.initial_master_nodes: ["node-1"]
- 如果请求不到,看下是否需要开放端口 ,弄完请求地址看到这一串json就大功告成了。