Linux系统下安装ElasticSearch

一、228环境ES使用安装

1、检验ES服务是否安装成功的方法

(1)查看Elasticsearch进程是否成功

ps -ef|grep elasticsearch

(2)linux elasticsearch下访问(curl带认证访问)

curl --user elastic:Zhes.13DSWJWE3dfdd9098 -XGET 'localhost:9200'

2、elasticsearch-7.8 跟查询elasticsearch-head插件版本的对应的关系

3、elasticsearch-head插件中访问:http://192.168.2.228:9200/

关闭elasticsearch.yml 配置文件中 设置为false: xpack.security.enabled: false

wget https://nodejs.org/dist/v10.16.3/node-v10.16.3-linux-x64.tar.xz

4、elasticsearch-head插件后台运行:nohup npm run start &

5、elasticsearch-head 工具的使用

(1)elasticsearch-head添加mapping (这个里面的结构是对查询条件类型的设置),需要熟悉es的相关语法,才可以写出

(2)给索引添加mapping

{"settings":{"index":{"index.number_of_shards":3,"number_of_replicas":0}},"mappings":{"properties":{"baseId":{"type":"keyword"},"title":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256},"suggest":{"type":"completion","analyzer":"standard","preserve_separators":true,"preserve_position_increments":true,"max_input_length":50}},"analyzer":"standard"},"type":{"type":"keyword"},"newType":{"type":"keyword"},"creator":{"type":"keyword"},"creatorName":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}},"analyzer":"standard"},"place":{"type":"keyword"},"province":{"type":"keyword"},"city":{"type":"keyword"},"district":{"type":"keyword"},"dept":{"type":"nested","properties":{"baseId":{"type":"keyword"}}},"policyType":{"type":"nested","properties":{"baseId":{"type":"keyword"}}},"supportmode":{"type":"nested","properties":{"baseId":{"type":"keyword"}}},"tag":{"type":"nested","properties":{"baseId":{"type":"keyword"}}},"viewCount":{"type":"integer"},"auditState":{"type":"integer"},"longAuditTime":{"type":"long"},"longBaseCreateTime":{"type":"long"},"baseCreateTime":{"type":"date"},"isTop":{"type":"boolean"},"topSort":{"type":"long"},"content":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}},"analyzer":"standard"}}}}

(3)elasticsearch-head工具创建带有mapping结构的索引

{"mappings":{"properties":{"baseId":{"type":"keyword"},"title":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256},"suggest":{"type":"completion","analyzer":"standard","preserve_separators":true,"preserve_position_increments":true,"max_input_length":50}},"analyzer":"standard"},"type":{"type":"keyword"},"newType":{"type":"keyword"},"creator":{"type":"keyword"},"creatorName":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}},"analyzer":"standard"},"place":{"type":"keyword"},"province":{"type":"keyword"},"city":{"type":"keyword"},"district":{"type":"keyword"},"dept":{"type":"nested","properties":{"baseId":{"type":"keyword"}}},"policyType":{"type":"nested","properties":{"baseId":{"type":"keyword"}}},"supportmode":{"type":"nested","properties":{"baseId":{"type":"keyword"}}},"tag":{"type":"nested","properties":{"baseId":{"type":"keyword"}}},"viewCount":{"type":"integer"},"auditState":{"type":"integer"},"longAuditTime":{"type":"long"},"longBaseCreateTime":{"type":"long"},"baseCreateTime":{"type":"date"},"isTop":{"type":"boolean"},"topSort":{"type":"long"},"content":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}},"analyzer":"standard"}}}}

二 192.168.2.53 演示环境ES使用安装

1、Linux系统下ES账户操作和访问

(1) linux系统下的 es账户操作

root@localhost elastic\]# groupadd eszhgroup2 \[root@localhost elastic\]# useradd -g eszhgroup2 eszh \[root@localhost \~\]# passwd eszh Changing password for user eszh. New password: BAD PASSWORD: it is too short BAD PASSWORD: is too simple Retype new password: passwd: all authentication tokens updated successfully. (2) [http://192.168.2.53:9100/?auth_user=elastic\&auth_password=abc123](http://192.168.2.53:9100/?auth_user=elastic&auth_password=abc123 "http://192.168.2.53:9100/?auth_user=elastic&auth_password=abc123") 用户密码认证后的信息:用户名elastic 密码abc123 #### 2、相关命令 (1)解压zip的命令:unzip + 某某.zip (2)解压tar包的命令:tar -zvxf +tar包 (3)tar -xJf node-v10.16.3-linux-x64.tar.xz #### 3、elasticsearch-head插件的安装 服务器Elasticsearch-head插件的安装与配置 ##### 1.安装node.js 1.1、通过官网下载二进制安装包 [Node.js --- Download Node.js®](https://nodejs.org/en/download/ "Node.js — Download Node.js®") ![](https://file.jishuzhan.net/article/1775933446036656130/aac06dda13976f5532ce42fb20cd0602.webp) 选择对应的版本,右键复制下载链接,进入linux目录,切换到要安装目录的磁盘。这里我们软件安装在/usr/local目录下,执行如下命令下载安装包 cd /usr/local/ wget https://nodejs.org/dist/v10.16.3/node-v10.16.3-linux-x64.tar.xz 下载完之后可以在磁盘目录看到已经下载完成的压缩包 ![](https://file.jishuzhan.net/article/1775933446036656130/83da38f447f5fb97c97cb329756fc983.webp) 1.2、解压安装包 tar -xJf node-v10.16.3-linux-x64.tar.xz 1.3、配置环境变量 vi /etc/profile 在文件最后面追加node.js环境变量 export NODE_HOME=/usr/local/node-v10.16.3-linux-x64 export PATH=$NODE_HOME/bin:$PATH ![](https://file.jishuzhan.net/article/1775933446036656130/1b66a9dba36bf0dcb3c09edf7063369b.webp) 1.4、重新加载配置文件并验证是否安装成功 source /etc/profile node -v npm -v ![](https://file.jishuzhan.net/article/1775933446036656130/942180f2ede4fb038040b07600d77dc9.webp) 看到上图所示说明node.js配置安装成功! ##### 2.head插件的安装与配置 安装head插件需要下载安装包,但是通过git下载,所以我们首先需要在系统安装git插件,然后才能进行下载安装 2.1、安装git插件 yum install -y git 2.2、验证git插件是否安装成功 git --version 看到如下图所述说明git插件安装成功 ![](https://file.jishuzhan.net/article/1775933446036656130/e2df742993dc0ebc1b11fd80919a249a.webp) 2.3、下载并安装head插件 git clone git://github.com/mobz/elasticsearch-head.git cd elasticsearch-head/ npm install 2.4、配置elasticsearch,允许head插件远程访问 cd elasticsearch-6.5.1/config/ vi elasticsearch.yml 在配置文件末尾添加如下内容,重新启动elasticsearch服务 http.cors.enabled: true http.cors.allow-origin: "\*" 2.5、启动elasticsearch-head服务 cd elasticsearch-head/ npm run start ![](https://file.jishuzhan.net/article/1775933446036656130/6a6594b094b8bed0692a474081e5439e.webp) 可以看到head插件默认占用9100端口,浏览器输入:[http://192.168.31.170:9100/](http://192.168.31.170:9100/ "http://192.168.31.170:9100/")即可显示head插件界面 ![](https://file.jishuzhan.net/article/1775933446036656130/6d83b6885964cd4d7b529997673e8da8.webp) 2.6、通过head插件连接elasticsearch服务 输入elasticsearch服务地址,点击连接右边显示黄色信息说明连接成功,至此elasticsearch-head插件安装成功

相关推荐
小小鸭程序员6 分钟前
零基础教程:Windows电脑安装Linux系统(双系统/虚拟机)全攻略
linux·运维·服务器·mysql·spring
会飞的土拨鼠呀10 分钟前
开源酷炫的Linux监控工具:sampler
linux·运维·开源
_midnight1 小时前
Python 并发编程指南:协程 vs 多线程及其他模型比较
linux·python
CYRUS_STUDIO1 小时前
Frida 调用 kill 命令挂起&恢复 Android 线程
android·linux·逆向
GalaxyPokemon1 小时前
MySQL基础 [六] - 内置函数+复合查询+表的内连和外连
linux·运维·数据库·mysql·ubuntu
Linux运维老纪2 小时前
Linux 命令清单(Linux Command List)
linux·运维·服务器·数据库·mysql·云计算·运维开发
艾醒(AiXing-w)2 小时前
Linux系统管理(十九)——欧拉系统硬盘挂载、网络配置以及Docker环境安装
linux·网络·docker
参.商.2 小时前
【RH124】第六章 管理本地用户和组
linux·运维
Yharim2 小时前
中间件 - ElasticSearch
elasticsearch·面试
钡铼技术物联网关3 小时前
ARM分拣机vs传统PLC:实测数据揭示的4倍效率差
大数据·linux·arm开发·人工智能·边缘计算