centos7使用docker安装es(elasticsearch)
1、安装docker依赖(已安装可以不用安装)
yum install -y docker
2、搜索镜像
docker search elasticsearch
如果出现以下报错
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
执行以下代码
systemctl daemon-reload sudo service docker restart
3、拉取镜像(我这里拉取的是6.6.0版本的)
docker pull elasticsearch:6.6.0
4、查看镜像
[root@host1 bin]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE docker.io/elasticsearch 6.6.0 752be83a5396 10 months ago
5、启动镜像
先执行
echo "http.host: 0.0.0.0" >>/data/elasticsearch/config/elasticsearch.yml
(我在这里使用了 -e 限制内存大小 )
docker run --name elasticsearch -p 9200:9200 -p 9300:9300 -e discovery.type="single-node" -e ES_JAVA_OPTS="-Xms128m -Xmx256m" -v /data/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /data/elasticsearch/data:/usr/share/elasticsearch/data -v /data/elasticsearch/plugins:/usr/share/elasticsearch/plugins -d elasticsearch:6.6.0
docker-compose方式
version: '3' services: elasticsearch: container_name: elas image: elasticsearch:6.6.0 ports: - 9200:9200 - 9300:9300 restart: always network_mode: "host" privileged: true environment: - discovery.type=single-node - ES_JAVA_OPTS=-Xms128m -Xmx256m volumes: - /data/elasticsearch/config:/usr/share/elasticsearch/config
- /data/elasticsearch/data:/usr/share/elasticsearch/data - /data/elasticsearch/plugins:/usr/share/elasticsearch/plugins
6、使用命令查看防火墙端口是否已经开放
firewall-cmd --list-port
如果结果中没有看到9200和9300端口,需要开放这两个端口,使用以下命令
7、开放相关端口
firewall-cmd --zone=public --add-port=9200/tcp --permanent firewall-cmd --zone=public --add-port=9300/tcp --permanent
重启防火墙
firewall-cmd --reload
打开谷歌浏览器访问
服务器IP:9200
出现以下内容
{ "name" : "MKKyl86", "cluster_name" : "elasticsearch", "cluster_uuid" : "ZsFLqfP9Tg6olrvJCuiqHw", "version" : { "number" : "6.6.0", "build_flavor" : "default", "build_type" : "tar", "build_hash" : "a9861f4", "build_date" : "2019-01-24T11:27:09.439740Z", "build_snapshot" : false, "lucene_version" : "7.6.0", "minimum_wire_compatibility_version" : "5.6.0", "minimum_index_compatibility_version" : "5.0.0" }, "tagline" : "You Know, for Search" }
说明安装成功
Linux(centos)安装es(elasticsearch)参考:https://www.cnblogs.com/pxblog/p/12632756.html
es(elasticsearch)安装IK中文分词器参考:https://www.cnblogs.com/pxblog/p/12633189.html
-----------------------有任何问题可以在评论区评论,也可以私信我,我看到的话会进行回复,欢迎大家指教------------------------
(蓝奏云官网有些地址失效了,需要把请求地址lanzous改成lanzoux才可以)