Elastic Certified Engineer复习记录-复习题详解篇-集群的安装和配置(2)

INSTALLATION AND CONFIGURATION

集群安装和配置

GOAL: Secure a cluster and an index using Elasticsearch Security

目标:用ES的安全模块保护集群和索引

REQUIRED SETUP

第0题,按要求创建集群

  1. a running Elasticsearch cluster with at least one node and a Kibana instance
    1. 创建一个最少拥有1个ES节点1个Kibana节点的集群
  2. no index with name hamlet is indexed on the cluster
    1. 在集群中没有叫hamlet的索引

第0题,题解

  1. 初始化集群
    1. rpm/命令 方式
      1. sh $ES_HOME/bin/elasticsearch -d
      2. sh $KIBANA_HOME/bin kibana
      3. systemctl start elasticsearch.server
      4. systemctl start kibana.server
    2. docker 方式
      1. docker run -p 9200:9200 -p 9300:9300 --name elasticsearch elasticsearch:7.2.1 -d
      2. docker-compose -f 1e1k_base_cluster.yml up -d --build
    3. 参考链接和页面路径不贴了,根据前人的经验,这题可能会出现某些节点没启动,配合elasticsearch.yml等配置文件的检查做就好。
  2. 清理索引
    1. 在kibana里运行DELETE hamlet
    2. 在命令行里运行curl -X DELETE http://localhost:9200/hamlet
    3. 参考链接
    4. 页面路径:Indices APIS =》 Delete index

第0题,题解说明

  • 这题没什么特别需要说明的,创建和启动集群前一章已经讲过了,这里主要需要注意的是kibana的配置和进程
    1. 配置:
      1. kibana的配置中需要添加elasticsearch.hosts: ["http://localhost:9200",]。由于kibana是一个前端项目,所以这里需要一个完整的可以被前端访问的url才行。
      2. 当ES开启了认证之后,kibana中需要添加针对kibana这个账户的账号密码(通过ES自带工具生成或指定),以保证kibana实体可以连接到ES节点,但是在登录kibana页面的时候需要填写的是elastic这个账户的账号密码。
    2. 进程:
      1. kibana是通过nodejs启动的,所以通过命令ps -ef | grep kibana是找不到他的进程的,正确的做法是通过lsof -i:5601找到监听5601(或者其他指定的kibana监听端口的进程),然后通过进程 pid 来找。
      2. 7.x 的kibana的进程多半会长得类似./../node/bin/node ./../src/cli

第1题,配置集群安全

  1. Enable xPack security on the cluster
    1. 开启x-pack保护集群
  2. Set the password of the elastic and kibana built-in users. Use the pattern “{ {username}}-password” (e.g., “elastic-password”)
    1. 以"{ {username}}-password"为模板,给elastickibana等内置账户设置密码
  3. Login to Kibana using the elastic user credentials
    1. elastic的认证信息登录 kibana

第1题,题解

  1. 修改配置文件$ES_HOME/config/elasticsearch.yml
    1. 添加xpack.security.enabled: true
    2. 有的时候可能启动报错,还需要添加配套的xpack.security.transport.ssl.enabled=true
  2. 在ES安装目录里(包含bin目录的那个)运行bin/elasticsearch-setup-passwords interactive给用户设置密码
    1. docker 运行的同学先要通过docker exec -it elasticsearch bash登录到docker实例里面,然后再执行
    2. 物理机部署的同学直接进入$ES_HOME就好

第1题,题解说明

  • 这题分两个部分,开启验证和设置密码
    1. 开启认证是需要修改ES的配置文件才能生效的,所以会涉及到$ES_HOME/config/elasticsearch.yml
      1. 参考链接
      2. 页面路径:Set up Elasticsearch =》 Configuring Elasticsearch =》Security settings
    2. 第一次设置密码得通过ES命令行工具进行设置,后面的创建用户、修改密码等可以通过kibana的[ Management > Users]页面来配置。
      1. 参考链接
      2. 页面路径:Command line tools =》 elasticsearch-setup-passwords

第2题,添加数据

We are now going to use the _bulk API to index some documents into the cluster. The documents are lines from Hamlet by William Shakespeare, and have the following structure:

  1. 来让我们通过bulk API把莎士比亚写的一些哈姆雷特第句子存到ES里,数据结构如下
{
   
  "line_number": "String",
  "speaker": "String",
  "text_entry": "String",
}
  1. Let’s continue with the exercise.
    1. Create the index hamlet and add some documents by running the following _bulk command:
    2. 通过下面一些bulk的命令把哈姆雷特的句子存进ES(这些命令基本上得在kibana里执行,因为他们不是正常的curl命令)
    PUT hamlet/_bulk
    {
         "index":{
         "_index":"hamlet","_id":0}}
    {
         "line_number":"1","speaker":"BERNARDO","text_entry":"Whos there?"}
    {
         "index":{
         "_index":"hamlet","_id":1}}
    {
         "line_number":"2","speaker":"FRANCISCO","text_entry":"Nay, answer me: stand, and unfold yourself."}
    {
         "index":{
         "_index"</
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值