elasticsearch

是一个分布式、高扩展、高实时的搜索与数据分析引擎
日志存储索引
https://blog.csdn.net/qq_40942490/article/details/111594267
https://blog.csdn.net/fangkang7/article/details/119942514
https://zhuanlan.zhihu.com/p/576557188



docker安装elasticsearch

#查看镜像最新版本
curl -XGET https://mirror.ccs.tencentyun.com/v2/library/elasticsearch/tags/list
curl -XGET  https://bhtknto5.mirror.aliyuncs.com/v2/library/elasticsearch/tags/list
#拉取镜像
docker pull elasticsearch:7.9.3 
docker pull elasticsearch:8.9.2
docker pull elasticsearch:8.13.4

配置elasticsearch.yml

vi elasticsearch.yml
关闭ssl
设置cors
注释掉以下2行
xpack.security.enabled: true
xpack.security.authc.api_key.enabled: true
#跨域
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: "*"
#快照存储库保存目录
path.repo: ["/usr/share/elasticsearch/backup"]

检测启动docker logs

deploy.yml

    volumes:
      - "$/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml"
      - "$/data:/usr/share/elasticsearch/data:rw"
      - "$/plugins:/usr/share/elasticsearch/plugins:rw"
      - "$/logs:/usr/share/elasticsearch/logs:rw"
      - "$/backup:/usr/share/elasticsearch/backup:rw"
    ports:
      - "$:$" 
      - "$:$"
    environment:
      - TZ=$
      - discovery.type=single-node

设置密码

https://blog.csdn.net/m0_60721514/article/details/124168827

docker exec -it elasticsearch bash
cd  /usr/share/elasticsearch/bin/
#自动初始化多个帐号的密码
./elasticsearch-setup-passwords auto
./elasticsearch-setup-passwords auto  -u 'http://localhost:9200'
#手工设置每一个帐号的密码
./elasticsearch-setup-passwords interactive 
   # 如果提示connect failed,可以尝试 
  ./elasticsearch-setup-passwords interactive -u 'http://[ip]:9200'
  ./elasticsearch-setup-passwords interactive -u 'http://localhost:9200'

设置完密码重新一下容器



#忘记密码
#创建一个临时的超级用户 RyanMiao
/elasticsearch-users useradd ryan -r superuser
#用这个用户去修改elastic用户的密码
curl -XPUT -u ryan:ryan123 http://localhost:9200/_xpack/security/user/elastic/_password -H "Content-Type: application/json" -d '{ "password": "q5f2qNfUJQyvZPIz57MZ"}'


#报错
Connection failure to: http://10.11.2.74:9200/_security/_authenticate?pretty failed: Connection timed out
将elasticsearch.yml配置文件中的xpack.security.enabled: true注释掉
重启es
再次执行

测试地址

http://121.43.147.xx:9200
#命令行测试地址
curl -u elastic:changeme http://172.16.122.xx:9200/