Elasticsearch 单节点测试环境

基础环境

mkdir -p -m 775 /elasticsearch_data/config
mkdir -p -m 775 /elasticsearch_data/data
mkdir -p -m 775 /elasticsearch_data/logs
mkdir -p -m 775 /elasticsearch_data/plugins

docker run -it --rm --group-add 0 -v /elasticsearch_data:/data elasticsearch:8.2.3 cp -r /usr/share/elasticsearch/config /data/

运行容器

docker network create elastic

docker run -d --name elasticsearch --group-add 0 --net elastic -p 9200:9200 -p 9300:9300 --group-add 0 -it -v /elasticsearch_data/data:/usr/share/elasticsearch/data -v /elasticsearch_data/config:/usr/share/elasticsearch/config -v /elasticsearch_data/logs:/usr/share/elasticsearch/logs -v /elasticsearch_data/plugins:/usr/share/elasticsearch/plugins  -e "discovery.type=single-node" elasticsearch:8.2.3

docker run -d --name kibana --group-add 0 --net elastic -p 5601:5601 kibana:8.2.3

密码

elasticsearch.yml 中设置 免密登录

xpack.security.enabled: false

如果Elasticsearch没有受到基本身份验证的保护,即elasticsearch.yml配置xpack.security.enabled: false,则不需要输入密码验证;否则需要在kibana.yml配置文件中配置登录elasticsearch的账号密码,且账号不能为elastic,因为kibana不允许配置超级用户帐户。

elasticsearch.username: zhangsan
elasticsearch.password: 1YKEUXktQTEbiC6ApGHX

如果出现以下错误,则需要在kibana.yml配置登录elasticsearch的账号密码,或者去elasticsearch.yml设置xpack.security.enabled: false关闭身份验证。

Unable to retrieve version information from Elasticsearch nodes. security_exception: [security_exception] Reason: missing authentication credentials for REST request [/_nodes?filter_path=nodes.*.version%2Cnodes.*.http.publish_address%2Cnodes.*.ip]

登录

访问http://{IP}:5601,根据提示即可登录。

Leave a Comment

Back to Top