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. Oppo Reno2 不允许安装非正式签名应用

    一.背景 为了安全起见,开发者本地开发和Jenkins上正式构建时,App采取的签名文件是不一样的.本地开发采取通用的如debug.keystore,正式签名文件部署在服务端.现在不少机型,如Oppo ...

  2. String 和List 的互相转换

    List<String > 转换成 String : 首先String类没有提供直接转换出List的功能: String提供了一个根据字符来分割字符串的功能,但是分割的结果是String[ ...

  3. SSM基本配置详解

    需要查看SSM基本依赖和完整配置文件的到:SSM基本配置及依赖 示例项目:SSMDemo 1 Spring IOC容器配置 1.1 applicationContext.xml 1.1.1 配置数据源 ...

  4. 分享windows 10 下部署 elasticsearch 和 logstash

    最近和es杠上了.以前只听说过es一直没有机会体验一下. 最近有点时间,就着手体验一把.因为是第一次接触es,没有任何基础.入门的第一件是就是用 百度了, [不过建议改名为白度,基本上查不到想要的,一 ...

  5. Vert.x(vertx) 认证和授权

    每个线上系统几乎都是离不开认证和授权的,Vert.x提供了灵活.简单.便捷的认证和授权的支持.Vert.x抽象出了两个核心的认证和授权的接口,一个是 AuthProvider,另一个是User.通过这 ...

  6. Common Lisp中的读取宏 ' #' `( , ,@) #( ) #na( ) #<OBJECT> :Keyword

    当你把  xx 当做符号使用时   'xx  ,  这个符号是没有任何函数/变量语义的, 仅仅是一个 符号而已(就像一个string一样) 但你可以对这个string有其他的用法,比如使用它所bind ...

  7. Winform中实现跨窗体获取ZedGraph的ZedGraphControl控件对象

    场景 Winforn中设置ZedGraph曲线图的属性.坐标轴属性.刻度属性: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/10 ...

  8. 剑指:最小的k个数

    题目描述 输入 n 个整数,找出其中最小的 K 个数.例如输入 4,5,1,6,2,7,3,8 这 8 个数字,则最小的 4 个数字是 1,2,3,4. 解法 解法一 利用快排中的 partition ...

  9. Maven项目配置Logback输出JSON格式日志

    最近,项目提出需求,日志需要固定输出为JSON格式,以便后端Flink程序解析. 项目背景 项目为简单的Maven项目,日志由Filebeat采集,因此不需要配置输出至Logstash. 下面为pom ...

  10. elasticsearch查询所有数据restful api以及java代码实现

    原文:http://blog.java1234.com/blog/articles/366.html restful api实现如下: get http://192.168.1.111:9200/fi ...