【Elasticsearch】CentOS 64 Elasticsearch安装

笔者环境:虚拟机CentOS 64 位 jdk14

es安装

官方下载地址:官方下载地址
在这里插入图片描述
选择自己对应的系统进行下载,笔者当时的下载地址为下载地址
下载完成之后是如下,通过tar zxf 进行解压。

[root@localhost es]# ls
elasticsearch-7.8.0-linux-x86_64.tar.gz
[root@localhost es]# tar zxf elasticsearch-7.8.0-linux-x86_64.tar.gz 
[root@localhost es]# ls
elasticsearch-7.8.0  elasticsearch-7.8.0-linux-x86_64.tar.gz

es不允许root用户运行如果root启动会报错

java.lang.RuntimeException: can not run elasticsearch as root

创建使用用户 user1

adduser user1  # 创建用户
passwd user1  # 生成用户密码
chown -R user1 /es/  # 用户权限设置
su user1  # 切换用户

切换完成。
查看目录 直接进入./bin/elasticsearch 就可以启动es
启动日志有很多,可看到127.0.0.1:9200,默认端口为9200

head插件安装

head是es的一款可视化插件,类似连接mysql的Navicat,不同的是navicat是客户端,head是一个网页。
注意用户权限哦,如果刚刚切换到user1了, 记得切换到root,免得各种权限问题。
查看是否有nodejs

[root@localhost elasticsearch-head]# node -v
v10.21.0
[root@localhost elasticsearch-head]# npm -v
6.14.4

如果没有通过yum -y install nodejs进行安装。
如果找不到依赖包,
执行curl --silent --location https://rpm.nodesource.com/setup_10.x | sudo bash -

git clone git://github.com/mobz/elasticsearch-head.git
cd elasticsearch-head
npm install
npm run start

执行完成,按道理不会有什么错误,访问http://localhost:9100/
head 必须配置node环境
另外如果有此错误是fsevents的问题,不必理会

npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN elasticsearch-head@0.0.0 license should be a valid SPDX license expression

added 66 packages from 70 contributors and audited 518 packages in 67.652s

3 packages are looking for funding
  run `npm fund` for details

found 46 vulnerabilities (20 low, 2 moderate, 24 high)
  run `npm audit fix` to fix them, or `npm audit` for details

启动成功之后可以访问9100端口访问这个页面,可是发现集群一直连接不上,注意:
问题1:head无法连接es
es必须得需要配置之后才能在head中连接,在es的config/elasticsearch.yml下加入,进行跨域处理

http.cors.enabled: true

http.cors.allow-origin: "*"

一般情况下就可以访问了

问题2:只能通过127.0.0.1:9200访问es。
通过vim config/elasticsearch.yml中的network修改为本机地址。
network.host: 192.168.16.128
更多错误问题到https://blog.csdn.net/happyzxs/article/details/89156068

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

叁滴水

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

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

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

打赏作者

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

抵扣说明:

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

余额充值