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. 记录一次排查使用HttpWebRequest发送请求的发生“基础连接已关闭:接收时发生错误”异常问题的过程

    描述:某次更新程序,需要给测试员MM测试,之前都是正常的,更新后给MM测试就报异常System.Net.WebException 基础连接已经关闭:接收时发生错误 -------> System ...

  2. 使用linq对ado.net查询出来dataset集合转换成对象(查询出来的数据结构为一对多)

    public async Task<IEnumerable<QuestionAllInfo>> GetAllQuestionByTypeIdAsync(int id) { st ...

  3. 我是如何一步步编码完成万仓网ERP系统的(十四)库存 3.库存日志

    https://www.cnblogs.com/smh188/p/11533668.html(我是如何一步步编码完成万仓网ERP系统的(一)系统架构) https://www.cnblogs.com/ ...

  4. 使用xdebug对php做性能分析调优

    作为PHP程序员我们或多或少都了解或使用过xdebug.此文章记录安装和配置xdebug,以及如何使用它来分析php程序. 我的机器环境: mac, php 安装 xdebug 推荐使用 pecl 安 ...

  5. 25个特殊操作符(special operator)

    1. CLHS (Common-Lisp-Hyper-Spec) http://www.lispworks.com/documentation/HyperSpec/Body/03_ababa.htm ...

  6. sedlauncher.exe 磁盘爆满

    打开应用和功能,搜KB4023057,然后卸载. 快捷键WIN+R打开运行,输入services.msc回车打开系统服务,找到Windows Remediation Service (sedsvc)和 ...

  7. 2-kong的preserve_host和strip_uri解析

    原文参考:https://www.cnblogs.com/mentalidade/p/6847004.html preserve_host:当代理的时候,k代理时,Kong的默认行为是将上游请求的Ho ...

  8. 线程安全---Day23

    最近忙着备考大学四年最后的两科,昨天刚考完大学所有的考试,但是大学专业是机械,但是自己热衷于IT行业,想往IT行业走,希望毕业后能成功进入到IT行业,只希望毕业能找到一份Java开发工程师的工作,这样 ...

  9. vue中通过WeixinJSBridge关闭微信公众号当前页面,返回微信公众号首页

    之前有个需求,点击菜单进入到微信公众号模块,然后点击返回的时候不知道到哪里去,后来觉得点返回的时候直接关闭页面,但是window.close()并不能关闭页面,然后经过查找资料,发现通过以下方法可以 ...

  10. 2019-09-16 curl简单操作

    1.get请求 (使用file_get_contents()函数也可以实现get请求) //http_build_query() 构造一个url字符串 function http_get($url) ...