0. 首先需要安装jdk,因为elasticsearch是Java写的,默认需要Java环境,且安装elasticsearch 7.x需要使用jdk 1.8或更高版本

1. 执行以下命令,创建elasticsearch仓库(计划安装7.x版本的elasticsearch)

cat <<EOF | sudo tee /etc/yum.repos.d/elasticsearch.repo
[elasticsearch-.x]
name=Elasticsearch repository for .x packages
baseurl=https://artifacts.elastic.co/packages/oss-7.x/yum
gpgcheck=
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=
autorefresh=
type=rpm-md
EOF

2. 建立elasticsearch仓库之后,需要刷新yum索引

sudo yum clean all
sudo yum makecache

3. 安装elasticsearch

sudo yum -y install elasticsearch-oss

4. 编辑文件: /etc/elasticsearch/jvm.options, 设置内存大小:

默认是:-Xms1g -Xmx1g

可以设置为:-Xms256m -Xmx512m

5. 启动elasticsearch

sudo systemctl enable --now elasticsearch.service 

使用如下命令也可以启动

/etc/init.d/elasticsearch start

6. 检验一下是否启动起来了

[root@localhost ~]# curl http://localhost:9200
{
"name" : "localhost.localdomain",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "Ybtkma76SSKOmXw89fMnuQ",
"version" : {
"number" : "7.3.2",
"build_flavor" : "oss",
"build_type" : "rpm",
"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"
}
[root@localhost ~]# curl http://127.0.0.1:9200
{
"name" : "localhost.localdomain",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "Ybtkma76SSKOmXw89fMnuQ",
"version" : {
"number" : "7.3.2",
"build_flavor" : "oss",
"build_type" : "rpm",
"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"
}
[root@localhost ~]#

7. 目前只可以在服务器上使用127.0.0.1与localhost进行访问,如果需要对elasticsearch使用公网访问,还需要将elasticsearch.yum配置添加如下内容:

network.host: 0.0.0.0
http.port:
http.cors.enabled: true
http.cors.allow-origin: "*"
cluster.initial_master_nodes: ["node-1"]

8. 服务器上访问结果:

[root@localhost elasticsearch]# curl http://192.168.1.27:9200/
{
"name" : "localhost.localdomain",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "Ybtkma76SSKOmXw89fMnuQ",
"version" : {
"number" : "7.3.2",
"build_flavor" : "oss",
"build_type" : "rpm",
"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"
}

本地访问结果

C:\Users\YFZX-MY->curl http://192.168.1.27:9200
{
"name" : "localhost.localdomain",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "Ybtkma76SSKOmXw89fMnuQ",
"version" : {
"number" : "7.3.2",
"build_flavor" : "oss",
"build_type" : "rpm",
"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"
} C:\Users\YFZX-MY->

9. 配置过程中,启动elasticsearch怎么着都启动不起来,去看了启动日志(日志文件位置再elasticsearch.yum文件中有描述),报错如下:

[localhost.localdomain] no plugins loaded
[--19T02::,][INFO ][o.e.d.DiscoveryModule ] [localhost.localdomain] using discovery type [zen] and seed hosts providers [settings]
[--19T02::,][INFO ][o.e.n.Node ] [localhost.localdomain] initialized
[--19T02::,][INFO ][o.e.n.Node ] [localhost.localdomain] starting ...
[--19T02::,][INFO ][o.e.t.TransportService ] [localhost.localdomain] publish_address {192.168.1.27:}, bound_addresses {[::]:}
[--19T02::,][INFO ][o.e.b.BootstrapChecks ] [localhost.localdomain] bound or publishing to a non-loopback address, enforcing bootstrap checks
[--19T02::,][ERROR][o.e.b.Bootstrap ] [localhost.localdomain] node validation exception
[] bootstrap checks failed
[]: 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
[--19T02::,][INFO ][o.e.n.Node ] [localhost.localdomain] stopping ...
[--19T02::,][INFO ][o.e.n.Node ] [localhost.localdomain] stopped
[--19T02::,][INFO ][o.e.n.Node ] [localhost.localdomain] closing ...
[--19T02::,][INFO ][o.e.n.Node ] [localhost.localdomain] closed

去elasticsearch.yum文件里面添加:

#cluster.initial_master_nodes: ["node-1", "node-2"]
cluster.initial_master_nodes: ["node-1"] 这个的话,这里的node-1是上面一个默认的记得打开就可以了

RedHat linux服务器安装elasticsearch且设置公网访问的更多相关文章

  1. RedHat Linux下iptables防火墙设置

    一般情况下iptables已经包含在Linux发行版中.运行 # iptables --version 来查看系统是否安装iptables 启动iptables:# service iptables ...

  2. 实现Redhat Linux 6和Windows通过Windows Server AD统一认证并共享访问Oracle ZS存储系统

    Windows Server 2012 AD设置 1.  建立新的组织单位OU 为用户提前建立好OU,是为了AD用户管理简单清晰. 2.  建立新的用户和用户组 建立新的用户的时候,要同时将用户归属到 ...

  3. linux服务器安装mysql并配置外网访问

    linux服务器安装mysql并配置外网访问 更新系统,如果不运行该命令,直接安装mysql,会出现"有几个软件包无法下载 sudo apt-get update 安装mysql sudo ...

  4. 解决CentOS6.x或RedHat Linux 6.x版本不能通过System eth0以固定IP访问外网的问题

    当你在VMware Workstation Pro中,打开从别人那里克隆来的系统,或者是开启迁移后的虚拟机系统时,VMware将会提示你:此虚拟机可能已被移动或 复制.为了配置特定的管理和网络功能.V ...

  5. 在Linux系统中如何设置APACHE服务器里的后台页面只允许某个IP地址访问

    补充资料 本网络中使用LINUX服务器,web服务器是由APACHE搭建,IP地址为192.168.1.5,后台页面为/admin/login.jsp . 如何设置后台页面LOGIN.JSP只允许19 ...

  6. linux 搭建ftp服务并设置限制访问目录

    服务器有好几个项目,新项目前端外包,因为要微信授权登陆,所以前端没有办法本地调试,必须上次ftp在我们服务器上调试代码,当然要限制ftp访问的目录,否则整个服务器项目都能看到了. 安装vsftpd s ...

  7. 阿里云mysql数据库设置让公网访问客户端访问

    第一步 首先使用root登入你的mysql ./mysql -u root -p 你的密码 第二步 备注:也可以添加一个用户名为yuancheng,密码为123456,权限为%(表示任意ip都能连接) ...

  8. NO2:设置RedHat Linux下的samba开机启动

    安装的samba默认不是开机启动的,这样每次都要进入系统人为启动,很不方便,当然系统肯定可以设置开机启动的. 因为我的是RedHat Linux系统,支持chkconfig命令直接配置,会简单些,其它 ...

  9. Linux 安装MongoDB 并设置防火墙,使用远程客户端访问

    1. 下载 MongoDB 提供了 linux 各发行版本 64 位的安装包  下载地址:https://www.mongodb.com/download-center#community 2. 安装 ...

随机推荐

  1. https的原理入门

    现在基本上互联网上访问的地址都是使用HTTPS协议了,只有局域网才会使用HTTP协议,因此了解HTTPS十分重要. HTTP存在的问题 上过网的朋友都知道,网络是非常不安全的.尤其是公共场所有很多免费 ...

  2. 【linux】CentOS 6 使用cron定时任务,报错:Redirecting to /bin/systemctl restart crond.service

    在centos7上,执行cron定时任务的相关命令,反馈如下: 定时任务执行,反馈是: Redirecting to /bin/systemctl restart crond.service 原因: ...

  3. Java实习生入职测试

    网络上一度流行的Java实习生入职测试题,可以看看. 1.String类为什么是final的. 2.JDK8的HashMap的源码,实现原理,底层结构 3.反射中,Class.forName和clas ...

  4. python 练习题:使用迭代查找一个list中最小和最大值,并返回一个tuple

    # -*- coding: utf-8 -*- # 请使用迭代查找一个list中最小和最大值,并返回一个tuple from collections import Iterable def findM ...

  5. python 进程和线程-进程和线程的比较以及分布式进程

    进程和线程的比较 参考链接:https://www.liaoxuefeng.com/wiki/1016959663602400/1017631469467456 我们介绍了多进程和多线程,这是实现多任 ...

  6. rabbitmq 延迟队列

    1.rabbitmq 延时的原理,有2个队列,一个是发送消息,设置消息过期时间或者队列过期时间(死信队列),如果达到过期时间后 将改消息发送到指定的队列中进行处理. 链接:https://share. ...

  7. NLog日志

    配置nlog 1.从nuget中获取配置 安装前2个文件 然后会有一个NLog.config 更改内容 <?xml version="1.0" encoding=" ...

  8. Spark GraphX图计算核心算子实战【AggreagteMessage】

    一.简介 参考博客:https://www.cnblogs.com/yszd/p/10186556.html 二.代码实现 package graphx import org.apache.log4j ...

  9. Mysql-5.5版本搭建实例的部分库的从库

    由于业务需要在Mysql实例中创建部分库的从库,已有的Mysql实例的版本是mysql-5.5.49,是一个非常老的版本. 本文档涉及到服务器中运行多实例和构建实例中部分库的从库. 服务器 mysql ...

  10. sql server 如何在全库中查找数据在哪个表

    1.查找字段在库中哪个表 如果要查找FName select   a.name,b.name   from   syscolumns a   inner   join   sysobjects   b ...