【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 [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN [email protected] 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

扫描二维码关注公众号,回复: 11452752 查看本文章

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

猜你喜欢

转载自blog.csdn.net/qq_30285985/article/details/107037430