【环境搭建】远程服务器搭建ElasticSearch

参考:

非常详细的阿里云服务器安装ElasticSearch过程..._阿里云服务器使用elasticsearch-CSDN博客

服务器平台:AutoDL

注意:

1、切换为非root用户,su 新用户名,否则ES无法启动

2、安装过程中没有出现设置账号密码,但请求时需要鉴权,可以关闭鉴权配置。

config-> elasticsearch.yml-> xpack.security.enabled false

创建索引:

复制代码
curl -X PUT "http://localhost:9200/docs" -H "Content-Type: application/json" -d '
{
  "mappings": {
    "properties": {
      "content": {
        "type": "text"
      }
    }
  }
}'

插入数据:

复制代码
curl -X POST "http://localhost:9200/docs/_doc" -H "Content-Type: application/json" -d '
{
  "content": "干完这个活就出门遛弯"
}'

通过python创建es对象,并且进行bm25检索

python 复制代码
from elasticsearch import Elasticsearch

self.es_client = Elasticsearch("http://127.0.0.1:9200")

dsl = {
            'query': {
                'match': {
                    'content': "想出门遛弯"
                }
            },
            "size": 3
        }

search_result = self.es_client.search(index='docs', body=dsl)

本地kibana怎么连接远程ES

以AutoDL为例

注意:本地kibana和远程服务器上的ES版本号要一致

AutoDL提供的SS H通道。host:127.0.0.1,port: 6006

STEP 1 修改ES的config->elasticresearch.yml, host和port配置

STEP2 修改kibama的config->kibana.yml, 修改对应的es host信息

STEP 3 服务器启动ES,./bin/elasticsearch, 本地启动kibana ./bin/kibana

注意kibana config中server port , 浏览器打开http:localhost:5602

相关推荐
砖厂小工18 小时前
用 GLM + OpenClaw 打造你的 AI PR Review Agent — 让龙虾帮你审代码
android·github
程序员鱼皮18 小时前
又一个新项目完结,我要出海了!
ai·github·开源项目
徐小夕19 小时前
pxcharts-vue:一款专为 Vue3 打造的开源多维表格解决方案
前端·vue.js·github
Moment19 小时前
想要长期陪伴你的助理?先从部署一个 OpenClaw 开始 😍😍😍
前端·后端·github
我叫黑大帅20 小时前
前端如何利用 GitHub Actions 自动构建并发布到 GitHub Pages?
前端·面试·github
YuMiao20 小时前
gstatic连接问题导致Google Gemini / Studio页面乱码或图标缺失问题
服务器·网络协议
HelloGitHub21 小时前
这个年轻的开源项目,想让每个人都能拥有自己的专业级 AI 智能体
开源·github·agent
刘发财1 天前
弃用html2pdf.js,这个html转pdf方案能力是它的几十倍
前端·javascript·github
sunny8651 天前
Claude Code 跨会话上下文恢复:从 8 次纠正到 0 次的工程实践
人工智能·开源·github