在docker中安装Elasticsearch

1.安装docker

sudo apt install apt-transport-https ca-certificates software-properties-common curl

2.添加 GPG 密钥,并添加 Docker-ce 软件源,这里还是以中国科技大学的 Docker-ce 源为例

curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -

sudo add-apt-repository "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu $(lsb_release -cs) stable"

3.添加成功后更新软件包缓存

sudo apt update

4.安装 Docker-ce

sudo apt install docker-ce

5.设置开机自启动并启动 Docker-ce(安装成功后默认已设置并启动,可忽略)

sudo systemctl enable docker

sudo systemctl start docker

6.测试运行

sudo docker run hello-world

7.添加当前用户到 docker 用户组,可以不用 sudo 运行 docker(自定义)

sudo groupadd docker

sudo usermod -aG docker $USER

8.获取Elasticsearch镜像,可以通过网络pull

sudo docker image pull delron/elasticsearch-ik:2.4.6-1.0

9.修改elasticsearch的配置文件 elasticsearc-2.4.6/config/elasticsearch.yml第54行,更改ip地址为本机ip地址

network.host: ip地址

10.创建docker容器运行

sudo docker run -dti --network=host --name=elasticsearch -v /home/python/elasticsearch-2.4.6/config:/usr/share/elasticsearch/config delron/elasticsearch-ik:2.4.6-1.0

然后在网页中输入ip地址加默认端口9200,如果有如下响应,则成功,开始接入Elasticsearch吧

猜你喜欢

转载自blog.csdn.net/weixin_43795201/article/details/84985929