安装环境
[root@localhost ~]# cat /etc/redhat-release CentOS Linux release 7.8.2003 (Core)
检查 Java 版本
Elasticsearch 要求 Java 8 或以上版本。
[root@localhost ~]# java -version java version "1.8.0_202" Java(TM) SE Runtime Environment (build 1.8.0_202-b08) Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode) [root@localhost ~]#
新建用户
默认情况下,Elasticsearch 不允许使用 root 用户启动。
groupadd esgroup useradd esapp -g esgroup
修改资源配置
vi /etc/security/limits.conf # 在文件中添加下面内容 esapp soft nofile 65535 esapp hard nofile 65535
修改后,需要打开新的终端使之生效。
下载压缩包
cd /opt wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.8.17.tar.gz wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.8.17.tar.gz.sha512 shasum -a 512 -c elasticsearch-6.8.17.tar.gz.sha512
解压并修改属主
tar -xzf elasticsearch-6.8.17.tar.gz chown -R esapp: elasticsearch-6.8.17
修改配置文件
# 切换到之前创建的普通用户 su - esapp cd /opt/elasticsearch-6.8.17/config cp elasticsearch.yml elasticsearch.yml.bak vi elasticsearch.yml
将 network.host: 192.168.0.1
改为 network.host: 0.0.0.0
并取消注释。以便外部浏览器可以访问。
启动
# 依然使用普通用户 cd /opt/elasticsearch-6.8.17/bin # 启动 ./elasticsearch
检查是否启动成功
打开新的终端,输入下面的命令。
[root@localhost ~]# curl -X GET "localhost:9200/?pretty" { "name" : "h1TMR1i", "cluster_name" : "elasticsearch", "cluster_uuid" : "bFtHxxq0RzuWVx0xkW_Z0g", "version" : { "number" : "6.8.17", "build_flavor" : "default", "build_type" : "tar", "build_hash" : "206f6a2", "build_date" : "2021-07-01T18:51:20.391869Z", "build_snapshot" : false, "lucene_version" : "7.7.3", "minimum_wire_compatibility_version" : "5.6.0", "minimum_index_compatibility_version" : "5.0.0" }, "tagline" : "You Know, for Search" } [root@localhost ~]#
在非本地浏览器中访问 http://ES所在机器的IP:9200/
,正常的话同样也可以得到上面的信息。
相关资料
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于