ES安装避坑-Windows成功安装ES实战

ES介绍:

Elasticsearch(ES)和传统数据库之间没有一一对应的关系,因为它们在数据存储和查询上有很大的区别。然而,在某些方面,它们具有一些相似之处。下面是一些它们之间可能存在的类比:

1. 索引(Index) - 数据库(Database)

Elasticsearch的索引类似于传统数据库中的数据库。在一个索引中,你可以存储多种类型的文档,并在每个文档中定义不同的字段。

2. 类型(Type) - 数据表(Table)

在Elasticsearch中,类型类似于传统数据库中的表格。在一个类型中,你可以定义不同的字段,并将其映射到每个文档中。

3. 文档(Document) - 行(Row)

在Elasticsearch中,文档类似于传统数据库中的行。每个文档都有一个唯一的ID,对应于关系数据库表中的主键。每个文档也包含一个或多个字段,对应于表格中的列。

4. 字段(Field) - 字段(Column)

在Elasticsearch中,每个文档包含多个字段。每个字段都有一个名称和一个值,对应于传统数据库表格的列。

5. 分片(Shard) - 分区(Partition)

在Elasticsearch中,索引被分成多个分片。每个分片存储了索引的一部分数据。这类似于传统数据库中的分区,其中表格的数据被分成多个区域以提高查询性能。

虽然Elasticsearch和传统数据库之间有一些类比,但它们在数据存储和查询方式上有很大的区别。Elasticsearch是一种分布式搜索引擎,可以快速处理大量数据。它不是传统数据库,不能完全替代它们。

一、下载地址

https://www.elastic.co/cn/elasticsearch

选择对应版本即可

二、配置操作

# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
#       Before you set out to tweak and tune the configuration, make sure you
#       understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
#cluster.name: my-application
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
#node.name: node-1
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
#path.data: /path/to/data
#
# Path to log files:
#
#path.logs: /path/to/logs
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# By default Elasticsearch is only accessible on localhost. Set a different
# address here to expose this node on the network:
#
#network.host: 192.168.0.1
#
# By default Elasticsearch listens for HTTP traffic on the first free port it
# finds starting at 9200. Set a specific HTTP port here:
#
http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.seed_hosts: ["host1", "host2"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
#cluster.initial_master_nodes: ["node-1", "node-2"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
# --------------------------------- Readiness ----------------------------------
#
# Enable an unauthenticated TCP readiness endpoint on localhost
#
#readiness.port: 9399
#
# ---------------------------------- Various -----------------------------------
#
# Allow wildcard deletion of indices:
#
#action.destructive_requires_name: false

#----------------------- BEGIN SECURITY AUTO CONFIGURATION -----------------------
#
# The following settings, TLS certificates, and keys have been automatically      
# generated to configure Elasticsearch security features on 21-03-2023 07:44:21
#
# --------------------------------------------------------------------------------

# Enable security features
xpack.security.enabled: false 

xpack.security.enrollment.enabled: true

# Enable encryption for HTTP API client connections, such as Kibana, Logstash, and Agents
xpack.security.http.ssl:
  enabled: false
  keystore.path: certs/http.p12

# Enable encryption and mutual authentication between cluster nodes
xpack.security.transport.ssl:
  enabled: true
  verification_mode: certificate
  keystore.path: certs/transport.p12
  truststore.path: certs/transport.p12
# Create a new cluster with the current node only
# Additional nodes can still join the cluster later
cluster.initial_master_nodes: ["ZB-PF2G5QX1"]

# Allow HTTP API connections from anywhere
# Connections are encrypted and require user authentication
http.host: 0.0.0.0

# Allow other nodes to join the cluster from anywhere
# Connections are encrypted and mutually authenticated
#transport.host: 0.0.0.0

#----------------------- END SECURITY AUTO CONFIGURATION -------------------------

其中注意点:

关闭密码验证:xpack.security.enabled: false

关闭SSL验证:

xpack.security.http.ssl:

enabled: false

keystore.path: certs/http.p12

三、验证

http://127.0.0.1:9200/

出现如下界面即可:

四、Python ES Demo示例

遍历Dataframe:

import pandas as pd

persons={'number':['小花','狗蛋','二狗','小草'],'crmFinalTag':[17,20,30,20],'crmFinalTagDesc':['女','男','男','女']}

df=pd.DataFrame(persons)

存入ES:

es.indices.create(index="tmp_crm_grade", ignore=400)

for index,row in df.iterrows():

data = {

"number": row['number'],

"crmFinalTag": row['crmFinalTag'],

"crmFinalTagDesc": row['crmFinalTagDesc']

} # 构建插入数据的结构

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

L先生AI课堂

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

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

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

打赏作者

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

抵扣说明:

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

余额充值