测试开发技术网站
博客
设计
设计
开发
Python
测试
unittest
运维
Linux基础应用
CI/CD
CI/CD
数据库
数据库
云计算
云计算
云原生
云原生
爬虫
爬虫
数据分析
数据分析
人工智能
人工智能
登录
注册
ElasticStack----使用Docker方式安装单节点的8.1.3版本的ElasticSearch
收藏本文
作者:redrose2100 类别: 日期:2022-05-19 16:02:06 阅读:927 次 消耗积分:0 分
### 1 下载镜像 ```bash docker pull docker.elastic.co/elasticsearch/elasticsearch:8.1.3 ``` ### 2 创建挂载目录,将数据盘挂载出来 ```bash mkdir -p /docker/elasticsearch/usr/share/elasticsearch/data chmod 777 -R /docker/elasticsearch ``` ### 3 创建docker启动Elasticsearch服务 ```bqwh docker run -d --name elasticsearch -p 10013:9200 -p 10014:9300 -e "discovery.type=single-node" -e ES_JAVA_OPTS="-Xms512m -Xmx1024m" -e "http.host=0.0.0.0" --privileged --restart=always -v /docker/elasticsearch/usr/share/elasticsearch/data:/usr/share/elasticsearch/data docker.elastic.co/elasticsearch/elasticsearch:8.1.3 ``` ### 4 Elasticsearch从8开始不再提供默认密码,这里需要重置密码 使用如下命令一次性将 elastic,apm_system,kibana,kibana_system,logstash_system,beats_system,remote_monitoring_user 等用户密码都重新设置 ```bash docker exec -it elasticsearch /usr/share/elasticsearch/bin/elasticsearch-setup-passwords interactive ``` 如下依次输入各个用户的密码,当然也可以设置为一个,自己需要记住: ```bash [root@redrose2100 ~]# docker exec -it elasticsearch /usr/share/elasticsearch/bin/elasticsearch-setup-passwords interactive ****************************************************************************** Note: The 'elasticsearch-setup-passwords' tool has been deprecated. This command will be removed in a future release. ****************************************************************************** Initiating the setup of passwords for reserved users elastic,apm_system,kibana,kibana_system,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_system]: Reenter password for [kibana_system]: Enter password for [logstash_system]: Reenter password for [logstash_system]: 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_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@redrose2100 ~]# ``` ### 5 由于Elasticsearch从8开始启用了安全证书机制,将证书拷贝到宿主机 ```bash mkdir -p /docker/elasticsearch/usr/share/elasticsearch/config/certs docker cp elasticsearch:/usr/share/elasticsearch/config/certs/http_ca.crt /docker/elasticsearch/usr/share/elasticsearch/config/certs/ ``` ### 6 在命令行使用如下命令验证Elasticsearch是否安装成功 使用如下命令,然后在交互环境根据提示输入上面重置后的密码 ```bash curl --cacert /docker/elasticsearch/usr/share/elasticsearch/config/certs/http_ca.crt -u elastic https://127.0.0.1:10013 ``` 过程如下: ```bash [root@redrose2100 ~]# curl --cacert /docker/elasticsearch/usr/share/elasticsearch/config/certs/http_ca.crt -u elastic https://127.0.0.1:10013 Enter host password for user 'elastic': { "name" : "994bcface178", "cluster_name" : "docker-cluster", "cluster_uuid" : "xOFaXy78QxWuJ8b-qcUF1g", "version" : { "number" : "8.1.3", "build_flavor" : "default", "build_type" : "docker", "build_hash" : "39afaa3c0fe7db4869a161985e240bd7182d7a07", "build_date" : "2022-04-19T08:13:25.444693396Z", "build_snapshot" : false, "lucene_version" : "9.0.0", "minimum_wire_compatibility_version" : "7.17.0", "minimum_index_compatibility_version" : "7.0.0" }, "tagline" : "You Know, for Search" } [root@redrose2100 ~]# ``` ### 7 至此,Elasticsearch 8.1.3版本的安装就已经成功完成了 ### 8 若后期想单独修改某个用户的密码时,使用如下命令即可 如下为修改用户elastic的密码 ```bash docker exec -it elasticsearch /usr/share/elasticsearch/bin/elasticsearch-reset-password -u elastic ``` ### 9 为了简单使用,也可以将使用认证的开关关掉,首先将ElasticSearch中的配置文件拷贝出来 ```bash docker cp elasticsearch:/usr/share/elasticsearch/config/elasticsearch.yml /docker/elasticsearch/usr/share/elasticsearch/config/ ``` ### 10 编辑配置文件, ```bash vi /docker/elasticsearch/usr/share/elasticsearch/config/elasticsearch.yml ``` 将如下两个位置的配置的true修改为false ![](/static/upload/20220523_013951.png) ### 11 然后使用如下命令将修改后的配置重新拷贝到docker容器中 ```bash docker cp /docker/elasticsearch/usr/share/elasticsearch/config/elasticsearch.yml elasticsearch:/usr/share/elasticsearch/config/elasticsearch.yml ``` ### 12 重启docker ```bash docker restart elasticsearch ``` ### 13 此时,直接使用如下命令再次请求Elasticsearch,即不适用证书直接请求 ```bash curl http://127.0.0.1:10013 -u elastic ``` 结果如下: ```bash Enter host password for user 'elastic': { "name" : "994bcface178", "cluster_name" : "docker-cluster", "cluster_uuid" : "xOFaXy78QxWuJ8b-qcUF1g", "version" : { "number" : "8.1.3", "build_flavor" : "default", "build_type" : "docker", "build_hash" : "39afaa3c0fe7db4869a161985e240bd7182d7a07", "build_date" : "2022-04-19T08:13:25.444693396Z", "build_snapshot" : false, "lucene_version" : "9.0.0", "minimum_wire_compatibility_version" : "7.17.0", "minimum_index_compatibility_version" : "7.0.0" }, "tagline" : "You Know, for Search" } [root@redrose2100 elasticsearch]# ``` ### 14 至此,可以在浏览器通过ip+端口访问了,如下: ![](/static/upload/20220522_054727.png)
始终坚持开源开放共享精神,同时感谢您的充电鼓励和支持!
版权所有,转载本站文章请注明出处:redrose2100, http://blog.redrose2100.com/article/238
上一篇:
禅道----禅道和Gitlab对接
下一篇:
ElasticStack----使用Docker方式安装8.1.3版本的Kibana
搜索
个人成就
出版书籍
《Pytest企业级应用实战》
测试开发技术全栈公众号
测试开发技术全栈公众号
DevOps技术交流微信群
加微信邀请进群
常用网站链接
开源软件洞察
云原生技术栈全景图
Python语言官方文档
Golang官方文档
Docker官方文档
Jenkins中文用户手册
Scrapy官方文档
VUE官方文档
Harbor官方文档
openQA官方文档
云原生开源社区
开源中国
Kubernetes中文文档
Markdown语法官方教程
Kubernetes中文社区
Kubersphere官方文档
BootStrap中文网站
JavaScript中文网
NumPy官方文档
Pandas官方文档
GitLink确实开源网站
数据库排名网站
编程语言排名网站
SEO综合查询网站
数学加减法练习自动生成网站
Kickstart Generator
文章分类
最新文章
最多阅读
特别推荐
×
Close
登录
注册
找回密码
登录邮箱:
登录密码:
图片验证码:
注册邮箱:
注册密码:
邮箱验证码:
发送邮件
注册邮箱:
新的密码:
邮箱验证码:
发送邮件