第一步要确保安装了java环境
输入java -version 查看是否安装
[root@localhost www]# java -version
openjdk version "1.8.0_222"
OpenJDK Runtime Environment (build 1.8.0_222-b10)
OpenJDK 64-Bit Server VM (build 25.222-b10, mixed mode)
[root@localhost www]#
若显示没有找到该命令 可使用yum进行安装
yum install java-1.8.0-openjdk* -y
第二步 开始下载elasticsearch 下载地址
https://www.elastic.co/cn/downloads/elasticsearch
自行选择需要下载的版本
第三步 下载后放到指定的目录 我放在了/www/es/ 目录下 这个可根据你的需求自行摆放 然后解压缩
[root@localhost elasticsearch-7.4.0]# pwd
/www/es/es_01/elasticsearch-7.4.0
[root@localhost elasticsearch-7.4.0]# ls
bin config data jdk lib LICENSE.txt logs modules NOTICE.txt plugins README.textile
[root@localhost elasticsearch-7.4.0]# cd config/
[root@localhost config]# ls
elasticsearch.keystore jvm.options role_mapping.yml users
elasticsearch.yml log4j2.properties roles.yml users_roles
[root@localhost config]#
然后进入到/www/es/es_01/elasticsearch-7.4.0/config 修改elasticsearch.yml里面的配置文件 增加如下内容
xpack.ml.enabled: false
# 配置内外网都可以访问
network.host: 0.0.0.0
# 配置端口号 默认9200
http.port: 9200
# 内存
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
# 开启跨域
http.cors.enabled: true
http.cors.allow-origin: "*"
discovery.zen.ping.unicast.hosts: ["127.0.0.1"]
# 集群的名字
cluster.name: test_cluster
node.name: test_01
# 设置为主服务 其他的机器需要设置为false
node.master: true
进入到文件夹elasticsearch-7.4.0 然后输入./bin/elasticsearch,会出现下面的错误 因为elasticsearch不允许使用root用户进行启动
所以需要新建一个用户 使用useradd root3 新增一个用户root3为用户名 可自行定义
[root@localhost elasticsearch-7.4.0]# useradd root3
需要修改一下配置文件
[root@localhost elasticsearch-7.4.0]# vim /etc/security/limits.conf
# root3为启动用户的名称
root3 soft nofile 65536
root3 hard nofile 65536
root3 soft nproc 4096
root3 hard nproc 4096
然后使用su root3切换用户
[root@localhost elasticsearch-7.4.0]# su root3
再次执行./bin/elasticsearch时会出现如下错误 没有执行权限 所以需要切换为root用户修改权限
然后再次执行./bin/elasticsearch 出现以下页面
接着在浏览器上输入ip:端口 如http://192.168.189.100:9200/ 显示如下内容 说明安装成功
{
"name" : "test_01",
"cluster_name" : "test_cluster",
"cluster_uuid" : "_na_",
"version" : {
"number" : "7.4.0",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "22e1767283e61a198cb4db791ea66e3f11ab9910",
"build_date" : "2019-09-27T08:36:48.569419Z",
"build_snapshot" : false,
"lucene_version" : "8.2.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
未完待续
参考链接:https://blog.csdn.net/zhanghe687/article/details/84979833