文章目录
1 系统初始化
系统版本 : CentOS 7.6
sed -i 's/enforcing/disabled/g' /etc/selinux/config
setenforce 0
sed -i 's/#UseDNS yes/UseDNS no/g' /etc/ssh/sshd_config
systemctl restart sshd
grep DNS /etc/ssh/sshd_config
grep SELINUX=disabled /etc/selinux/config
systemctl disable firewalld NetworkManager
systemctl stop firewalld NetworkManager
2 下载安装包
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.10.2-x86_64.rpm -P /opt/
3 安装es
yum -y install /opt/elasticsearch-7.10.0-x86_64.rpm
4 配置es
vim /etc/elasticsearch/elasticsearch.yml
cluster.name: my-application
node.name: node-1
network.host: 0.0.0.0
http.port: 9200
cluster.initial_master_nodes: ["node-1"]
5 启动es
systemctl start elasticsearch
6 curl es api
列出所有index
curl 192.168.3.13:9200/_cat/indices
查看 某个index 下的所有数据
curl 192.168.3.13:9200/logstash-2021.04.12-000001/_search? | jq .
7 安全
1 Set up minimal security
systemctl stop elasticsearch
echo 'xpack.security.enabled: true' >> /etc/elasticsearch/elasticsearch.yml
echo 'xpack.security.transport.ssl.enabled: true' >> /etc/elasticsearch/elasticsearch.yml
2 为内置用户创建密码
systemctl start elasticsearch
/usr/share/elasticsearch/bin/elasticsearch-setup-passwords auto
Initiating the setup of passwords for reserved users elastic,apm_system,kibana,kibana_system,logstash_system,beats_system,remote_monitoring_user.
The passwords will be randomly generated and printed to the console.
Please confirm that you would like to continue [y/N]y
Changed password for user apm_system
PASSWORD apm_system = w32LOEng7e52MONvrsyH
Changed password for user kibana_system
PASSWORD kibana_system = 5kxXG6a5HQE87bFzwUJZ
Changed password for user kibana
PASSWORD kibana = 5kxXG6a5HQE87bFzwUJZ
Changed password for user logstash_system
PASSWORD logstash_system = fBZT9qHTsPz9hZLIy9yD
Changed password for user beats_system
PASSWORD beats_system = zCzeFrpVdonwXaLqhAPB
Changed password for user remote_monitoring_user
PASSWORD remote_monitoring_user = 1XD7B0BSc3lvDhzacAiV
Changed password for user elastic
PASSWORD elastic = iv57ZpA2DvuDAqA6smJr
3 curl 测试 es 账号密码
curl --user elastic:iv57ZpA2DvuDAqA6smJr http://127.0.0.1:9200
{
"name" : "node-1",
"cluster_name" : "my-application",
"cluster_uuid" : "cvQs8Y78SM6BWOa1O98ygg",
"version" : {
"number" : "7.12.0",
"build_flavor" : "default",
"build_type" : "rpm",
"build_hash" : "78722783c38caa25a70982b5b042074cde5d3b3a",
"build_date" : "2021-03-18T06:17:15.410153305Z",
"build_snapshot" : false,
"lucene_version" : "8.8.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
4 logstash 测试对接
/usr/share/logstash/bin/logstash -e 'input{stdin{}}output{stdout{codec=>rubydebug}elasticsearch{hosts=>["192.168.3.13:9200"] user=>elastic password=>iv57ZpA2DvuDAqA6smJr}}'