- Lab
-
Libraries: If you want this lab, consider one of these libraries.
- Cloud
ECE Practice Exam — Part 1
In Part 1 of the Elastic Certified Engineer practice exam, you will be tested on the following objectives: * Deploy and start an Elasticsearch cluster that satisfies a given set of requirements * Configure the nodes of a cluster to satisfy a given set of requirements * Secure a cluster using Elasticsearch Security * Define role-based access control using Elasticsearch Security * Define an index that satisfies a given set of requirements * Define and use index aliases * Define and use an index template for a given pattern that satisfies a given set of requirements * Define and use a dynamic template that satisfies a given set of requirements * Define a mapping that satisfies a given set of requirements * Define and use a custom analyzer that satisfies a given set of requirements * Define and use multi-fields with different data types and/or analyzers * Configure an index so that it properly maintains the relationships of nested arrays of objects * Configure an index that implements a parent/child relationship * Allocate the shards of an index to specific nodes based on a given set of requirements * Configure Shard Allocation Awareness and Forced Awareness for an Index * Configure a cluster for use with a hot/warm architecture
Lab Info
Table of Contents
-
Challenge
Deploy and Start the 6-Node Cluster.
Deploy Elasticsearch
Using the Secure Shell (SSH), log in to each node as
cloud_uservia the public IP address.Open the
limits.conffile as root:sudo vim /etc/security/limits.confAdd the following line near the bottom:
elastic - nofile 65536Open the
sysctl.conffile asroot:sudo vim /etc/sysctl.confAdd the following line at the bottom:
vm.max_map_count=262144Load the new sysctl values:
sudo sysctl -pBecome the
elasticuser:sudo su - elasticDownload the binaries for Elasticsearch 7.2.1 in the
elasticuser's home directory:curl -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.2.1-linux-x86_64.tar.gzUnpack the archive:
tar -xzvf elasticsearch-7.2.1-linux-x86_64.tar.gzRemove the archive:
rm elasticsearch-7.2.1-linux-x86_64.tar.gzRename the unpacked directory:
mv elasticsearch-7.2.1 elasticsearchConfigure each node's elasticsearch.yml
Open the
elasticsearch.ymlfile:vim /home/elastic/elasticsearch/config/elasticsearch.ymlChange the following line:
#cluster.name: my-applicationto
cluster.name: linux_academyChange the following line on master-1:
#node.name: node-1to
node.name: master-1Change the following line on data-1:
#node.name: node-1to
node.name: data-1Change the following line on data-2:
#node.name: node-1to
node.name: data-2Change the following line on data-3:
#node.name: node-1to
node.name: data-3Change the following line on data-4:
#node.name: node-1to
node.name: data-4Change the following line on coordinator-1:
#node.name: node-1to
node.name: coordinator-1Change the following line on data-1:
#node.attr.rack: r1to
node.attr.zone: 1Add the following line on data-1:
node.attr.temp: hotChange the following line on data-2:
#node.attr.rack: r1to
node.attr.zone: 2Add the following line on data-2:
node.attr.temp: hotChange the following line on data-3:
#node.attr.rack: r1to
node.attr.zone: 1Add the following line on data-3:
node.attr.temp: warmChange the following line on data-4:
#node.attr.rack: r1to
node.attr.zone: 2Add the following line on data-4:
node.attr.temp: warmAdd the following lines on master-1:
node.master: true node.data: false node.ingest: falseAdd the following lines on data-1:
node.master: false node.data: true node.ingest: trueAdd the following lines on data-2:
node.master: false node.data: true node.ingest: trueAdd the following lines on data-3:
node.master: false node.data: true node.ingest: falseAdd the following lines on data-4:
node.master: false node.data: true node.ingest: falseAdd the following lines on coordinator-1:
node.master: false node.data: false node.ingest: falseChange the following on each node:
#network.host: 192.168.0.1to
network.host: [_local_, _site_]Change the following on each node:
#discovery.seed_hosts: ["host1", "host2"]to
discovery.seed_hosts: ["10.0.1.101"]Change the following on each node:
#cluster.initial_master_nodes: ["node-1", "node-2"]to
cluster.initial_master_nodes: ["master-1"]Configure the heap
Open the
jvm.optionsfile:vim /home/elastic/elasticsearch/config/jvm.optionsChange the following lines:
-Xms1g -Xmx1gto
-Xms2g -Xmx2gStart Elasticsearch as a daemon on each node
Switch to the
elasticsearchdirectory:cd /home/elastic/elasticsearchStart Elasticsearch as a daemon:
./bin/elasticsearch -d -p pidDeploy Kibana
On the
coordinator-1node, download the binaries for Kibana 7.2.1 in theelasticuser's home directory:cd /home/elastic curl -O https://artifacts.elastic.co/downloads/kibana/kibana-7.2.1-linux-x86_64.tar.gzUnpack the archive:
tar -xzvf kibana-7.2.1-linux-x86_64.tar.gzRemove the archive:
rm kibana-7.2.1-linux-x86_64.tar.gzRename the unpacked directory:
mv kibana-7.2.1-linux-x86_64 kibanaConfigure the kibana.yml file
Open the
kibana.ymlfile:vim /home/elastic/kibana/config/kibana.ymlChange the following line:
#server.port: 5601to
server.port: 80Change the following line:
#server.host: "localhost"to
server.host: "10.0.1.106"Start Kibana
Exit as the
elasticuser:exitBecome the
rootuser:sudo su -Start the Kibana server as
rootwith:/home/elastic/kibana/bin/kibana --allow-root -
Challenge
Secure the Cluster with X-Pack Security.
Generate a Certificate Authority (CA)
Using the Secure Shell (SSH), log in to each node as
cloud_uservia the public IP address.Become the
elasticuser with:sudo su - elasticCreate a
certsdirectory on each node:mkdir /home/elastic/elasticsearch/config/certsOn the master-1 node, create a CA certificate with password
elastic_cain the newcertsdirectory:/home/elastic/elasticsearch/bin/elasticsearch-certutil ca --out config/certs/ca --pass elastic_caGenerate and deploy a certificate for each node
On the master-1 node, generate each node's certificate with the CA:
/home/elastic/elasticsearch/bin/elasticsearch-certutil cert --ca config/certs/ca --ca-pass elastic_ca --name master-1 --dns ip-10-1-101.ec2.internal --ip 10.0.1.101 --out config/certs/master-1 --pass elastic_master_1 /home/elastic/elasticsearch/bin/elasticsearch-certutil cert --ca config/certs/ca --ca-pass elastic_ca --name data-1 --dns ip-10-1-102.ec2.internal --ip 10.0.1.102 --out config/certs/data-1 --pass elastic_data_1 /home/elastic/elasticsearch/bin/elasticsearch-certutil cert --ca config/certs/ca --ca-pass elastic_ca --name data-2 --dns ip-10-1-103.ec2.internal --ip 10.0.1.103 --out config/certs/data-2 --pass elastic_data_2 /home/elastic/elasticsearch/bin/elasticsearch-certutil cert --ca config/certs/ca --ca-pass elastic_ca --name data-3 --dns ip-10-1-104.ec2.internal --ip 10.0.1.104 --out config/certs/data-3 --pass elastic_data_3 /home/elastic/elasticsearch/bin/elasticsearch-certutil cert --ca config/certs/ca --ca-pass elastic_ca --name data-4 --dns ip-10-1-105.ec2.internal --ip 10.0.1.105 --out config/certs/data-4 --pass elastic_data_4 /home/elastic/elasticsearch/bin/elasticsearch-certutil cert --ca config/certs/ca --ca-pass elastic_ca --name coordinator-1 --dns ip-10-1-106.ec2.internal --ip 10.0.1.106 --out config/certs/coordinator-1 --pass elastic_coordinator_1On the master-1 node, remote copy each certificate to the
certsdirectory created on each node:scp /home/elastic/elasticsearch/config/certs/data-1 10.0.1.102:/home/elastic/elasticsearch/config/certs scp /home/elastic/elasticsearch/config/certs/data-2 10.0.1.103:/home/elastic/elasticsearch/config/certs scp /home/elastic/elasticsearch/config/certs/data-3 10.0.1.104:/home/elastic/elasticsearch/config/certs scp /home/elastic/elasticsearch/config/certs/data-4 10.0.1.105:/home/elastic/elasticsearch/config/certs scp /home/elastic/elasticsearch/config/certs/coordinator-1 10.0.1.106:/home/elastic/elasticsearch/config/certsAdd the transport keystore password on each node:
echo "CERTIFICATE_PASSWORD_HERE" | /home/elastic/elasticsearch/bin/elasticsearch-keystore add --stdin xpack.security.transport.ssl.keystore.secure_passwordAdd the transport truststore password on each node:
echo "CERTIFICATE_PASSWORD_HERE" | /home/elastic/elasticsearch/bin/elasticsearch-keystore add --stdin xpack.security.transport.ssl.truststore.secure_passwordAdd the HTTP keystore password on each node:
echo "CERTIFICATE_PASSWORD_HERE" | /home/elastic/elasticsearch/bin/elasticsearch-keystore add --stdin xpack.security.http.ssl.keystore.secure_passwordAdd the HTTP truststore password on each node:
echo "CERTIFICATE_PASSWORD_HERE" | /home/elastic/elasticsearch/bin/elasticsearch-keystore add --stdin xpack.security.http.ssl.truststore.secure_passwordConfigure transport network encryption and restart Elasticsearch
Add the following to
/home/elastic/elasticsearch/config/elasticsearch.ymlon each node:# # ---------------------------------- X-Pack ------------------------------------ # xpack.security.enabled: true xpack.security.transport.ssl.enabled: true xpack.security.transport.ssl.verification_mode: full xpack.security.transport.ssl.keystore.path: certs/CERTIFICATE_FILE_NAME_HERE xpack.security.transport.ssl.truststore.path: certs/CERTIFICATE_FILE_NAME_HEREStop Elasticsearch:
pkill -F /home/elastic/elasticsearch/pidStart Elasticsearch as a background daemon and record the PID to a file:
/home/elastic/elasticsearch/bin/elasticsearch -d -p pidUse the elasticsearch-setup-passwords tool to set the password for each built-in user
Set the built-in user passwords using the
elasticsearch-setup-passwordsutility on the master-1 node:/home/elastic/elasticsearch/bin/elasticsearch-setup-passwords interactiveUse the following passwords:
User: elastic Password: la_elastic_409 User: apm_system Password: la_apm_system_409 User: kibana Password: la_kibana_409 User: logstash_system Password: la_logstash_system_409 User: beats_system Password: la_beats_system_409 User: remote_monitoring_user Password: la_remote_monitoring_user_409Configure HTTP network encryption and restart Elasticsearch
Add the following to
/home/elastic/elasticsearch/config/elasticsearch.yml:xpack.security.http.ssl.enabled: true xpack.security.http.ssl.keystore.path: certs/CERTIFICATE_FILE_NAME_HERE xpack.security.http.ssl.truststore.path: certs/CERTIFICATE_FILE_NAME_HEREStop Elasticsearch:
pkill -F /home/elastic/elasticsearch/pidStart Elasticsearch as a background daemon and record the PID to a file:
/home/elastic/elasticsearch/bin/elasticsearch -d -p pidConfigure Kibana
Open the
kibana.ymlfile:vim /home/elastic/kibana/config/kibana.ymlChange the following lines:
elasticsearch.username: "elastic" elasticsearch.password: "yDaYCXL6KYgNligMpSwd"to
elasticsearch.username: "kibana" elasticsearch.password: "la_kibana_409"Change the following line:
#elasticsearch.hosts: ["http://localhost:9200"]to
elasticsearch.hosts: ["https://localhost:9200"]Change the following line:
#elasticsearch.ssl.verificationMode: fullto
elasticsearch.ssl.verificationMode: noneRestart Kibana
In the console with your Kibana instance running in the foreground, stop your Kibana instance with
ctrl+cStart the Kibana server as
rootwith:/home/elastic/kibana/bin/kibana --allow-root -
Challenge
Create the Custom Role and User.
Create the
cluster_readroleUse the Kibana console tool to execute the following:
POST /_security/role/cluster_read { "cluster": ["monitor"], "indices": [ { "names": ["logs-*"], "privileges": ["read", "monitor"] } ] }Create the
terryuserUse the Kibana console tool to execute the following:
POST /_security/user/terry { "roles": ["kibana_user", "monitoring_user", "cluster_read"], "full_name": "Terry Cox", "email": "[email protected]", "password": "scaryterry123" } -
Challenge
Create the "logs" Index Template.
Use the Kibana console tool to execute the following:
PUT _template/logs { "index_patterns": ["logs-*"], "aliases": { "logs": {} }, "mappings": { "dynamic_templates": [ { "strings_as_keywords": { "match_mapping_type": "string", "mapping": { "type": "keyword" } } } ], "properties": { "referrer": { "type": "join", "relations": { "referred_to": "referred_by" } }, "body": { "type": "text", "fields": { "html": { "type": "text", "analyzer": "html" } } }, "url": { "type": "text", "analyzer": "simple", "fields": { "keyword": { "type": "keyword", "ignore_above": 256 } } }, "geoip": { "properties": { "coordinates": { "type": "geo_point" } } }, "client_ip": { "type": "ip" }, "related_content": { "type": "nested" }, "useragent": { "type": "text", "fields": { "keyword": { "type": "keyword", "ignore_above": 256 } } } } }, "settings": { "number_of_shards": 2, "number_of_replicas": 1, "index.routing.allocation.require.temp": "hot", "analysis": { "analyzer": { "html": { "type": "custom", "tokenizer": "standard", "char_filter": "html_strip", "filter": "lowercase" } } } } } -
Challenge
Create the "logs" Indexes.
Create the
logs-2018-10-01IndexUse the Kibana console tool to execute the following:
PUT logs-2018-10-01 PUT logs-2018-10-01/_settings { "index.routing.allocation.require.temp": "warm" }Create the
logs-2018-10-02IndexPUT logs-2018-10-02/_doc/0 { "url": "https://linuxacademy.com/courses/elastic-certified-engineer", "response_code": "200", "bytes": 16384, "client_ip": "10.0.1.100", "geoip.coordinates": "32.9259,97.2531", "useragent": "Mozilla/5.0 (Macintosh; Intel Mac OS X x.y; rv:42.0) Gecko/20100101 Firefox/42.0", "method": "GET", "request_time": 84, "body": "<body><h1>Elastic Certified Engineer</h1></body>", "referrer": { "name": "referred_to" } } -
Challenge
Configure Shard Allocation Awareness.
Use the Kibana console tool to execute the following:
PUT _cluster/settings { "persistent": { "cluster.routing.allocation.awareness.attributes": "zone", "cluster.routing.allocation.awareness.force.zone.values": "1,2" } }
About the author
Real skill practice before real-world application
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Learn by doing
Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.
Follow your guide
All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.
Turn time into mastery
On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.