Centos7.5安装ElasticSearch7.17

// 查看各版本支持的JDK

支持矩阵 | Elastic

//官方参考安装文档

Installing Elasticsearch | Elasticsearch Guide [8.0] | Elastic

//安装包下载

Past Releases of Elastic Stack Software | Elastic

这里我的是CentOS7.5,可以用命令查看系统版本

cat /etc/redhat-release 

我下载的不是最新的elasticsearch-7.17.1-linux-x86_64.tar.gz。

上传到Centos指定目录,比如/home/software/

解压

 tar -zxvf elasticsearch-7.17.tar.gz

cd到 bin目录下执行

 ./elasticsearch
[root@VM_0_2_centos bin]# ./elasticsearch
warning: usage of JAVA_HOME is deprecated, use ES_JAVA_HOME
Future versions of Elasticsearch will require Java 11; your Java version from [/usr/local/jdk/jdk1.8/jre] does not meet this requirement. Consider switching to a distribution of Elasticsearch with a bundled JDK. If you are already using a distribution with a bundled JDK, ensure the JAVA_HOME environment variable is not set.
warning: usage of JAVA_HOME is deprecated, use ES_JAVA_HOME
Future versions of Elasticsearch will require Java 11; your Java version from [/usr/local/jdk/jdk1.8/jre] does not meet this requirement. Consider switching to a distribution of Elasticsearch with a bundled JDK. If you are already using a distribution with a bundled JDK, ensure the JAVA_HOME environment variable is not set.
[2022-03-04T16:56:30,513][ERROR][o.e.b.ElasticsearchUncaughtExceptionHandler] [VM_0_2_centos] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:170) ~[elasticsearch-7.17.1.jar:7.17.1]
        at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:157) ~[elasticsearch-7.17.1.jar:7.17.1]
        at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:77) ~[elasticsearch-7.17.1.jar:7.17.1]
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:112) ~[elasticsearch-cli-7.17.1.jar:7.17.1]
        at org.elasticsearch.cli.Command.main(Command.java:77) ~[elasticsearch-cli-7.17.1.jar:7.17.1]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:122) ~[elasticsearch-7.17.1.jar:7.17.1]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:80) ~[elasticsearch-7.17.1.jar:7.17.1]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
        at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:107) ~[elasticsearch-7.17.1.jar:7.17.1]
        at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:183) ~[elasticsearch-7.17.1.jar:7.17.1]
        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:434) ~[elasticsearch-7.17.1.jar:7.17.1]
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:166) ~[elasticsearch-7.17.1.jar:7.17.1]
        ... 6 more
uncaught exception in thread [main]
java.lang.RuntimeException: can not run elasticsearch as root
        at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:107)
        at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:183)
        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:434)
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:166)
        at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:157)
        at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:77)
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:112)
        at org.elasticsearch.cli.Command.main(Command.java:77)
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:122)
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:80)
For complete error details, refer to the log at /home/software/elasticsearch-7.17.1/logs/elasticsearch.log
2022-03-04 08:56:30,849356 UTC [30437] INFO  Main.cc@111 Parent process died - ML controller exiting

 结果是报错can not run elasticsearch as root。

然后是一套创建,参考:

//新建用户组,组名叫elastic
1、 groupadd -g 700 elastic
//新建用户,用户名叫elastic
2、useradd -u 701 -g 700 elastic
//设置用户密码
3、passwd elastic
//将用户添加到用户组里面,第一个elastic表示用户名,第二个elastic表示组名。
4、gpasswd -a elastic elastic
//赋予权限
5.  chown -R elastic:elastic /home/software/elasticsearch-7.17.1/
// 切换用户
6、su elastic 

再次执行./elasticsearch,启动成功。


然而外部访问9200端口还是失败

 需要改参数

1./home/software/elasticsearch-7.17.1/config/elasticsearch.yml

cluster.initial_master_nodes: ["node-1"]
http.port: 9200
network.host: 0.0.0.0

2.在/etc/sysctl.conf 添加:

vm.max_map_count=262144

重启,外部访问9200端口就可以返回如下JSON数据

{
  "name": "VM_0_2_centos",
  "cluster_name": "elasticsearch",
  "cluster_uuid": "tOJOc_tVQJapivGA1HU17g",
  "version": {
    "number": "7.17.1",
    "build_flavor": "default",
    "build_type": "tar",
    "build_hash": "e5acb99f822233d62d6444ce45a4543dc1c8059a",
    "build_date": "2022-02-23T22:20:54.153567231Z",
    "build_snapshot": false,
    "lucene_version": "8.11.1",
    "minimum_wire_compatibility_version": "6.8.0",
    "minimum_index_compatibility_version": "6.0.0-beta1"
  },
  "tagline": "You Know, for Search"
}

 这里还有个ElasticSearch的web管理工具Cerebro可以试试。

Elasticsearch Web管理工具 - 废物大师兄 - 博客园

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

飞翔的咩咩

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值