1 安装
官网下载 https://www.elastic.co/cn/downloads/past-releases/elasticsearch-6-8-1
# 上传至服务器/data/script目录解压
tar -xf elasticsearch-6.8.1.tar.gz
cd elasticsearch-6.8.1/
# 修改配置文件
vim config/elasticsearch.yml
network.host: 127.0.0.1
http.port: 9200
修改内存
vim config/jvm.options
-Xms1g
-Xmx1g
创建用户
useradd elasticsearch
chown -R elasticsearch:elasticsearch /data/script/elasticsearch-6.8.1
su elasticsearch
cd /data/script/elasticsearch-6.8.1/bin
./elasticsearch -d
本机验证:
curl 127.0.0.1:9200
2 设置密码
2.1 6.3之前的版本
2.1.1 安装x-pack (elasticsearch用户下操作)
cd /data/elasticsearch-6.2.4 --进到elasticsearch的安装目录
./bin/elasticsearch-plugin install x-pack
能联网的情况,不能联网就只能下载离线包 上传到bin目录下
2.1.2 设置密码
cd /data/elasticsearch-6.2.4/bin/x-pack
./setup-passwords interactive
会对elasticsearch、logstash、kibana分别设置登录密码(默认es用户名为elastic,logstash用户名为logstash_system,kibana用户名为kibana)

2.1.3 设置配置文件
vim /data/elasticsearch-6.2.4/config/elasticsearch.yml --添加如下三行
http.cors.enabled: true
http.cors.allow-origin: '*'
http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type
重启
设置密码后的验证:
curl 127.0.0.1:9200 -u elastic:密码
2.1.4 修改密码
$curl -XPOST -H 'Content-type: application/json' -u elastic:elastic123 'http://10.163.19.231:9600/_xpack/security/user/martin/_password?pretty' -d '{"password": "dxm1234%"}'
curl参数含义如下:
-XPOST 使用post方法传递参数
-H 指定http协议的header信息
-u 指定用于认证的用户信息,用户名与密码使用冒号分隔
-d 指定具体要传递的参数信息
2.2 6.8.1 设置密码
步骤大致相同 就是不用再安装x-pack了
1、打开elasticsearch.yml文件。
2、启用基本认证,添加以下行:
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
3、重启
4、使用Elasticsearch的elasticsearch-setup-passwords工具设置内置用户密码:
bin/elasticsearch-setup-passwords interactive
然后验证即可
6298

被折叠的 条评论
为什么被折叠?



