一、安装elasticsearch
1.下载好相关版本ES
docker pull elasticsearch:7.4.2
2.创建映射文件夹
mkdir -p /mydata/elasticsearch/config
mkdir -p /mydata/elasticsearch/data
echo "http.host: 0.0.0.0" >/mydata/elasticsearch/config/elasticsearch.yml # 创建 elasticsearch.yml 并配置所有人都可以访问
chmod -R 777 /mydata/elasticsearch/ # elasticsearch 文件夹权限
3.执行
docker run --name elasticsearch -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e ES_JAVA_OPTS="-Xms64m -Xmx512m" -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.4.2
4.访问地址
image.png二、安装kibana
注意:kibana 版本要跟 elasticsearch 一样
直接一条docker 命令
docker run --name kibana -e ELASTICSEARCH_HOSTS=http://elasticsearch:9200 --link elasticsearch -p 5601:5601 -d kibana:7.4.2
--link elasticsearch 为关联到 elasticsearch (docker的name)
ELASTICSEARCH_HOSTS=http://elasticsearch:9200 # 连接你的elasticsearch
image.png
分词
注意:不能用默认的 elasticsearch-plugin.install xxx.zip 进行自动安装
下载地址:
https://github.com/medcl/elasticsearch-analysis-ik/releases
下载与 es对应的版本
image.png
上传服务器,解压后拷贝到 plugins 目录下
image.png image.png创建ik 文件夹复制到文件夹下并解压
image.png注意:记得删除掉复制进来的压缩文件不然重启不了,只保留ik即可
image.png
重启elasticsearch容器,并进行测试
image.png image.pngES设置密码
修改
/mydata/elasticsearch/config/elasticsearch.yml
开启x-pack插件
http.host: 0.0.0.0
# Uncomment the following lines for a production cluster deployment
#transport.host: 0.0.0.0
#discovery.zen.minimum_master_nodes: 1
#Password config
xpack.security.enabled: true #这一步是开启x-pack插件
进入容器,设定的密码很多基本上设定相同的就好了
[root@f18d8bc7b8f5 elasticsearch]# cd bin
[root@f18d8bc7b8f5 bin]# ls
elasticsearch elasticsearch-croneval elasticsearch-migrate elasticsearch-setup-passwords elasticsearch-syskeygen x-pack-watcher-env
elasticsearch-certgen elasticsearch-env elasticsearch-node elasticsearch-shard elasticsearch-users
elasticsearch-certutil elasticsearch-env-from-file elasticsearch-plugin elasticsearch-sql-cli x-pack-env
elasticsearch-cli elasticsearch-keystore elasticsearch-saml-metadata elasticsearch-sql-cli-7.6.2.jar x-pack-security-env
[root@f18d8bc7b8f5 bin]# elasticsearch-setup-passwords interactive #此步为手动设置密码
Initiating the setup of passwords for reserved users elastic,apm_system,kibana,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]:
Passwords do not match.
Try again.
Enter password for [elastic]:
Reenter password for [elastic]:
Enter password for [apm_system]:
Reenter password for [apm_system]:
Enter password for [kibana]:
Reenter password for [kibana]:
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]
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@f18d8bc7b8f5 bin]# exit #退出容器
默认 用户名是 elastic 密码:自己设定的
修改kinbana 配置
进入kibana容器
vi /opt/kibana/config/kibana.yml
#
# ** THIS IS AN AUTO-GENERATED FILE **
#
# Default Kibana configuration for docker target
server.name: kibana
server.host: "0"
elasticsearch.hosts: [ "http://elasticsearch:9200" ]
xpack.monitoring.ui.container.elasticsearch.enabled: true
elasticsearch.username: elastic #账号 elastic
elasticsearch.password: # 密码 自己设定的
重新访问kibana 就输入当前账号密码登录即可
网友评论