1. Docker-ce安装(Centos7环境)
①移除旧版本
yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine
②安装必要的系统工具
yum install -y yum-utils device-mapper-persistent-data lvm2
③添加软件源信息
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
④更新 yum 缓存
yum makecache fast
⑤安装 Docker-ce
yum -y install docker-ce
⑥启动 Docker 后台服务
systemctl start docker
⑦设置Docker开机自启动
systemctl enable docker
2. ElasticSearch安装
①拉取镜像
docker pull elasticsearch:7.9.3
②查看镜像
docker images
③创建所需文件夹和文件
mkdir -p /mydata/elasticsearch/config
mkdir -p /mydata/elasticsearch/data
echo "http.host: 0.0.0.0">>/mydata/elasticsearch/config/elasticsearch.yml
④文件夹赋权
chmod -R 777 /mydata/elasticsearch/
⑤创建并启动elasticsearch容器
docker run --name elasticsearch -p 9200:9200 \
-p 9300:9300 \
-e "discovery.type=single-node" \
-e ES_JAVA_OPTS="-Xms64m -Xmx128m" \
-v /mydata/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
-v /mydata/elasticsearch/data:/usr/share/elasticsearch/data \
-v /mydata/elasticsearch/plugins:/usr/share/elasticsearch/plugins \
-d elasticsearch:7.9.3
⑥设置elasticsearch容器自启动
docker update elasticsearch --restart=always
⑦安装IK中文分词器
cd /mydata/elasticsearch/plugins/
wget https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.9.3/elasticsearch-analysis-ik-7.9.3.zip
mkdir ik
unzip -d ik/ elasticsearch-analysis-ik-7.9.3.zip
docker restart elasticsearch
3.Kibana安装
①拉取镜像
docker pull kibana:7.9.3
②创建并启动kibana容器
docker run -tid \
--restart=always \
-p 15601:5601 \
-v /etc/localtime:/etc/localtime \
-e TZ='Asia/Shanghai' \
-e LANG="en_US.UTF-8" \
kibana:7.9.3
③Copy容器中的文件到宿主机上,并给文件夹授权
mkdir -p /mydata/kibana/
docker cp <容器ID>:/usr/share/kibana/config/ /mydata/kibana/
docker cp <容器ID>:/usr/share/kibana/data/ /mydata/kibana/
docker cp <容器ID>:/usr/share/kibana/plugins/ /mydata/kibana
chmod -R 777 /mydata/kibana
④删除容器
docker rm -f <容器ID>
⑤修改kibana.yml配置文件
#
# ** THIS IS AN AUTO-GENERATED FILE **
#
# Default Kibana configuration for docker target
server.name: kibana
server.host: "0.0.0.0"
elasticsearch.hosts: [ "http://192.168.0.105:9200" ]
monitoring.ui.container.elasticsearch.enabled: true
⑥重新创建并启动kibana容器
docker run -tid \
--restart=always \
-p 15601:5601 \
-v /mydata/kibana/config/:/usr/share/kibana/config/ \
-v /mydata/kibana/data/:/usr/share/kibana/data/ \
-v /mydata/kibana/plugins/:/usr/share/kibana/plugins/ \
-v /etc/localtime:/etc/localtime \
-e TZ='Asia/Shanghai' \
-e LANG="en_US.UTF-8" \
kibana:7.9.3
⑦查看kibana启动日志
docker logs <容器ID>
注意:kibana的启动时间较长,需要查看日志确保kibana启动成功后再访问,否则一开始访问失败并不能说明kibana的安装配置有问题。
4.放行端口号
firewall-cmd --zone=public --add-port=9200/tcp --permanent
firewall-cmd --zone=public --add-port=15601/tcp --permanent
systemctl restart firewalld.service
5.访问Kibana
http://ip:15601
6.创建索引
PUT /novel
{
"mappings" : {
"properties" : {
"id" : {
"type" : "long"
},
"authorId" : {
"type" : "long"
},
"authorName" : {
"type" : "text",
"analyzer": "ik_smart",
"boost": 1.5
},
"bookName" : {
"type" : "text",
"analyzer": "ik_smart",
"boost": 2
},
"bookDesc" : {
"type" : "text",
"analyzer": "ik_smart",
"boost": 0.1
},
"bookStatus" : {
"type" : "short"
},
"catId" : {
"type" : "integer"
},
"catName" : {
"type" : "text",
"analyzer": "ik_smart",
"boost": 1.0
},
"lastIndexId" : {
"type" : "long"
},
"lastIndexName" : {
"type" : "text",
"analyzer": "ik_smart",
"boost": 0.1
},
"lastIndexUpdateTime" : {
"type": "keyword"
},
"picUrl" : {
"type" : "keyword",
"index" : false,
"doc_values" : false
},
"score" : {
"type" : "float"
},
"wordCount" : {
"type" : "integer"
},
"workDirection" : {
"type" : "short"
},
"visitCount" : {
"type": "long"
}
}
}
}
7.开启搜索引擎功能
spring:
elasticsearch:
#是否开启搜索引擎,1:开启,0:不开启
enable: 0
jest:
#es的访问URI
uris: http://127.0.0.1:9200
来源:oschina
链接:https://my.oschina.net/java2nb/blog/4874387