centos7 基于docker下的elasticsearch快速部署

shw3588 2019-09-16 AM 93℃ 0条
yum install -y wget vim
#查看当前的源网址
cat /etc/yum.repos.d/CentOS-Base.repo
#换成阿里的
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

#清除缓存
yum clean all  
#生成缓存
yum makecache

yum install docker
service docker start
chkconfig docker on

chkconfig docker on


[root@localhost ~]# docker pull docker.elastic.co/elasticsearch/elasticsearch:6.3.2
Trying to pull repository docker.elastic.co/elasticsearch/elasticsearch ... 
6.3.2: Pulling from docker.elastic.co/elasticsearch/elasticsearch
7dc0dca2b151: Pull complete 
72d60ff53590: Pull complete 
ca55c9f7cc1f: Pull complete 
822d6592a660: Pull complete 
22eceb1ece84: Pull complete 
30e73cf19e42: Pull complete 
f05e800ca884: Pull complete 
3e6ee2f75301: Pull complete 
Digest: sha256:8f06aecf7227dbc67ee62d8d05db680f8a29d0296ecd74c60d21f1fe665e04b0
Status: Downloaded newer image for docker.elastic.co/elasticsearch/elasticsearch:6.3.2


[root@localhost ~]# docker images
REPOSITORY                                      TAG                 IMAGE ID            CREATED             SIZE
docker.elastic.co/elasticsearch/elasticsearch   6.3.2               96dd1575de0f        14 months ago       826 MB

vim /etc/sysctl.conf

docker run -d --name es -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:6.3.2

docker exec -it es /bin/bash
cd config/
vi elasticsearch.yml
加入配置
http.cors.enabled: true
http.cors.allow-origin: "*"

exit
重启docker es
docker restart es

firewall-cmd --zone=public --permanent --add-port=9200/tcp

看效果

http://192.168.137.4:9200/

estest.png

迁移es

把本地的es 迁移过去

#
docker export 1ea3d267f873 > elasticsearch_guitar.tar
#
docker import - es < elasticsearch_guitar.tar
docker images
docker run -d --name es -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" 9c3858684801 /usr/local/bin/docker-entrypoint.sh
其中命令 /usr/local/bin/docker-entrypoint.sh 要事前确认原容器的运行参数是什么复制过来,不然会报 /usr/bin/docker-current: Error response from daemon: No command specified.
#还报了
 Error response from daemon: driver failed programming external connectivity on endpoint ......docker0: iptables: No chain/target/match by that name.
#处理为
systemctl restart docker
再启动容器即可 

#######
查看所有容器ip
 docker inspect -f='{{.Name}} {{.NetworkSettings.IPAddress}} {{.HostConfig.PortBindings}}' $(docker ps -aq)
 /mysql57 172.17.0.4 map[3306/tcp:[{ 3306}]]
/es 172.17.0.2 map[9300/tcp:[{ 9300}] 9200/tcp:[{ 9200}]]
/nginx 172.17.0.3 map[80/tcp:[{ 80}]]
标签: elasticsearch

评论啦~


    captcha
*为减少垃圾评论,评论提交后会审核,审核后才显示