elasticsearch - 如何使用 Elastic Search 修复集群健康黄色

标签 elasticsearch

我在服务器上安装了 MongoDb 和 ElasticSearch。使用 https://github.com/richardwilly98/elasticsearch-river-mongodb我已将 ElasticSearch 和 MongoDb 连接在一起。

我使用以下方法创建了一个新索引:

curl -XPUT 'http://127.0.0.1:9200/_river/mongodb/_meta' -d '{ 
        "type": "mongodb", 
        "mongodb": { 
        "db": "my_database", 
        "collection": "my_collection"
    }, 
        "index": {
        "name": "mainindex", 
        "type": "string",
        "bulk": {
            "concurrent_requests": 1
        }
    }
}'

命令执行后,我转到http://x.x.x.x:9200/_plugin/head/我看到消息:集群运行状况:黄色 (1, 6)。

cluster health: yellow (1, 6)

enter image description here

最佳答案

正在通过在 Elasticsearch 配置中使用相同的集群名称来配置集群

您可能使用的默认 elasticsearch.yml 在开始时具有如下设置:

################################### Cluster ###################################

# Cluster name identifies your cluster for auto-discovery. If you're running
# multiple clusters on the same network, make sure you're using unique names.
#
# cluster.name: elasticsearch


#################################### Node #####################################

# Node names are generated dynamically on startup, so you're relieved
# from configuring them manually. You can tie this node to a specific name:
#
# node.name: "Franz Kafka"

在这里你需要配置一个独特的

cluster.name: "MainCluster"

并且对于每台机器和/或实例一个不同的唯一

node.name: "LocalMachine1"

您现在需要将此 elasticsearch.yml 复制到另一台机器(在同一网络中),或复制到与例如 elasticsearch_2.yml 相同的位置编辑它:

node.name: "LocalMachine2"

您的集群已准备就绪

如果没有配置 elastiscsearch 将使用一个随机的 Marvel 角色(根据文档为 3000 个),所以不要更改 node.name 也应该没问题

为了让两个节点在同一台机器上运行, 您必须进行配置,例如elasticsearch_2.yml 复制,并进行上述更改。 您还必须拥有数据和日志路径的副本 例如(自制程序特定路径:)

cp -r /usr/local/var/elasticsearch /usr/local/var/elasticsearch_2
cp -r /usr/local/var/log/elasticsearch /usr/local/var/log/elasticsearch_2

可能看起来像

#################################### Paths ####################################

# Path to directory containing configuration (this file and logging.yml):
#
# path.conf: /path/to/conf

# Path to directory where to store index data allocated for this node.
#
path.data: /usr/local/var/elasticsearch_2/
#
# Can optionally include more than one location, causing data to be striped across
# the locations (a la RAID 0) on a file level, favouring locations with most free
# space on creation. For example:
#
# path.data: /path/to/data1,/path/to/data2

# Path to temporary files:
#
# path.work: /path/to/work

# Path to log files:
#
path.logs: /usr/local/var/log/elasticsearch_2/

确保您没有在本地主机环回设备上运行 elasicsearch

127.0.0.1

如果不是,就把它注释掉(自制软件就是这样打补丁的)

############################## Network And HTTP ###############################

# Elasticsearch, by default, binds itself to the 0.0.0.0 address, and listens
# on port [9200-9300] for HTTP traffic and on port [9300-9400] for node-to-node
# communication. (the range means that if the port is busy, it will automatically
# try the next port).

# Set the bind address specifically (IPv4 or IPv6):
#
# network.bind_host: 192.168.0.1

# Set the address other nodes will use to communicate with this node. If not
# set, it is automatically derived. It must point to an actual IP address.
#
# network.publish_host: 192.168.0.1

# Set both 'bind_host' and 'publish_host':
#
# network.host: 127.0.0.1

现在你可以像这样开始 Elasticsearch 了:

bin/elasticsearch -D es.config=/usr/local/Cellar/elasticsearch/1.0.0.RC1/config/elasticsearch.yml

对于第一个节点和master(因为先启动)

然后

bin/elasticsearch -D es.config=/usr/local/Cellar/elasticsearch/1.0.0.RC1/config/elasticsearch_2.yml

现在你应该有 2 个节点在运行

关于elasticsearch - 如何使用 Elastic Search 修复集群健康黄色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20730151/

相关文章:

php - Elasticsearch查找输入词和所有同义词

ruby-on-rails - Rails:Elasticsearch已索引已从数据库中删除的记录

python Elasticsearch : how do you enable curl logging?

caching - 字段作为 Doc_Values 以减少内存使用

mysql - 存储和索引 1M+ XML 文档的最佳实践?

elasticsearch - 在 Elasticsearch 上按多个值嵌套排序

regex - Logstash过滤器(如果字段匹配正则表达式不起作用)

elasticsearch - 如何增加数据节点进行 Elasticsearch

java - 使用 Java API 时如何在 ElasticSearch 中使用特定的分析器

elasticsearch - 尝试构建同义词过滤器时获取 “Failed to build synonyms”消息