我有installed Elastic with Docker:
int val = (token.value[1]-ASCII);// ASCII is 48
但docker run -p 9200:9200 \
-p 9300:9300 \
-e "discovery.type=single-node" \
docker.elastic.co/elasticsearch/elasticsearch:5.6.2
因身份验证错误而失败:
curl localhost:9200
Elasticsearch的默认用户名/密码组合是什么?
答案 0 :(得分:30)
{
"error": {
"root_cause": [
{
"type": "security_exception",
"reason": "missing authentication token for REST request [/]",
"header": {
"WWW-Authenticate": "Basic realm=\"security\" charset=\"UTF-8\""
}
}
],
"type": "security_exception",
"reason": "missing authentication token for REST request [/]",
"header": {
"WWW-Authenticate": "Basic realm=\"security\" charset=\"UTF-8\""
}
},
"status": 401
}
所以:
user: elastic
password: changeme
详细了解如何更改默认设置here。
答案 1 :(得分:6)
步骤1:首先在elasticsearch.yml文件中启用xpackmonitoring
root@flax:/etc/elasticsearch# vim elasticsearch.yml
Add the following line to the end of file:
xpack.security.enabled: true
File Contents:
# ======================== 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: /var/lib/elasticsearch
#
# Path to log files:
#
path.logs: /var/log/elasticsearch
#
# ----------------------------------- 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 -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
#network.host: 192.168.0.1
network.host: 127.0.0.1
http.host: 0.0.0.0
#
# Set a custom port for HTTP:
#
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.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true
xpack.security.enabled: true
步骤2: 转到/ usr / share / elasticsearch文件夹:
root@flax:/usr/share/elasticsearch# systemctl start elasticsearch
root@flax:/usr/share/elasticsearch# ./bin/elasticsearch-setup-passwords interactive
Initiating the setup of passwords for reserved users elastic,apm_system,kibana,logstash_system,beats_system,remote_monitoring_user.
You will be prompted to enter passwords as the process progresses.
Please confirm that you would like to continue [y/N]y
Enter password for [elastic]:
Reenter password for [elastic]:
Enter password for [apm_system]:
Reenter password for [apm_system]:
Enter password for [kibana]:
Reenter password for [kibana]:
Enter password for [logstash_system]:
Reenter password for [logstash_system]:
Enter password for [beats_system]:
Reenter password for [beats_system]:
Passwords do not match.
Try again.
Enter password for [beats_system]:
Reenter password for [beats_system]:
Enter password for [remote_monitoring_user]:
Reenter password for [remote_monitoring_user]:
Changed password for user [apm_system]
Changed password for user [kibana]
Changed password for user [logstash_system]
Changed password for user [beats_system]
Changed password for user [remote_monitoring_user]
Changed password for user [elastic]
root@flax:/usr/share/elasticsearch# systemctl restart elasticsearch
root@flax:/usr/share/elasticsearch# systemctl restart elasticsearch.service
答案 2 :(得分:4)
如果您在Elasticsearch 7.7版中使用df$Estrellas = web %>%
html_nodes("#ABOUT_TAB .uq1qMUbD") %>%
html_attr("alt") %>%
gsub(" of 5 stars", "", .) %>%
as.integer()
启用了基本的x-pack安全性(在撰写此答案时),它将没有默认密码(xpack.security.enabled: true
),就像以前那样在旧版本的x-pack中。
如getting started with security official doc
中所述X-Pack安全性提供了一个内置的弹性超级用户,可用于 开始进行设置。该弹性用户可以完全访问 集群,包括所有索引和数据, 默认情况下未设置密码。
因此,您需要更改changeme
的密码,如果要在安装后执行此操作,请遵循setting password for built-in users in interactive mode guide
这需要您从elasticsearch bin文件夹中运行以下命令。
elastic
答案 3 :(得分:1)
请注意ElasticSearch的版本。 在 7.2 中,参数ELASTIC_PASSWORD有效。
docker run -p 9200:9200 \
-p 9300:9300 \
-e "discovery.type=single-node" \
-e "ELASTIC_PASSWORD=my_own_password" \
但这行也应该添加到elasticsearch.yml中:
xpack.security.enabled: true
默认情况下,它不存在。
答案 4 :(得分:0)
在Elasticsearch版本6.x中-您可以使用 ELASTIC_PASSWORD env变量为 elastic 用户指定初始密码。
docker run -p 9200:9200 \
-p 9300:9300 \
-e "discovery.type=single-node" \
-e "ELASTIC_PASSWORD=my_own_password" \
docker.elastic.co/elasticsearch/elasticsearch:6.5.4
来源:https://www.elastic.co/guide/en/elasticsearch/reference/6.x/configuring-tls-docker.html