1. 修改elasticsearch-6.8.0/config/elasticsearch.ymlpython
最後添加一行:xpack.security.enabled: trueelasticsearch
2. 初始化用戶和密碼ide
./bin/elasticsearch-setup-passwords interactive
我這裏初始化爲123456code
3. 修改kibana-6.8.0/config/kibana.ymlorm
# If your Elasticsearch is protected with basic authentication, these settings provide
# the username and password that the Kibana server uses to perform maintenance on the Kibana
# index at startup. Your Kibana users still need to authenticate with Elasticsearch, which
# is proxied through the Kibana server.
elasticsearch.username: "kibana"
elasticsearch.password: "123456"server
4. python示例ip
首先安裝pip install elasticsearchit
from elasticsearch import Elasticsearch def main(): es = Elasticsearch(hosts='http://elastic:123456@localhost:9200/') es.index('test1', doc_type='task', id=None, body={'doc': {"user": "777777"}}) if __name__ == '__main__': main()