Courseiva

CCNA Key Value Store Questions

38 questions · Key Value Store topic · All types, answers revealed

1
MCQeasy

What is the default value for the Consul KV flags field if not provided during a write?

A.1
B.null
C.0
D.-1
AnswerC

Flags defaults to 0.

Why this answer

The default value for flags is 0.

2
MCQeasy

Which Consul agent configuration parameter defines the KV store file location when running locally?

A.server_dir
B.kv_dir
C.state_dir
D.data_dir
AnswerD

Consul stores all state data in the directory specified by data_dir.

Why this answer

While the KV store is in-memory, its persistence (if snapshots are used) is managed by the data_dir.

3
MCQmedium

You need to perform a write operation to the Consul KV store that only succeeds if the current ModifyIndex of the key is zero. Which parameter should you include in your API call?

A.acquire=0
B.cas=0
C.flags=0
D.index=0
AnswerB

The cas parameter with a value of 0 is the standard way to perform a create-if-not-exists operation.

Why this answer

The cas (Check-And-Set) parameter allows for atomic operations. Setting cas to 0 ensures the write only occurs if the key does not already exist.

4
Multi-Selecthard

Which THREE of the following represent potential bottlenecks for Consul KV performance?

Select 3 answers
A.Very large number of keys
B.Very high write throughput
C.High read frequency
D.Very large value sizes
E.Using HTTP instead of RPC
AnswersA, B, D

Massive key counts increase memory usage.

Why this answer

High update frequency, massive key counts, and large value sizes all impact KV performance.

5
MCQhard

You observe that a session lock is being released unexpectedly. What is the most likely cause?

A.The Consul agent is in leader mode.
B.The index was not incremented.
C.The session TTL is too low, causing premature expiration.
D.The KV key was deleted.
AnswerC

If network latency prevents the renewal, the session expires.

Why this answer

If the session TTL is too short, the agent might fail to renew the session in time, causing it to expire.

6
MCQmedium

What is the purpose of the 'Behavior' field when creating a Consul session?

A.To specify what happens to locks on session invalidation.
B.To define the node affinity.
C.To determine if the session can be renewed.
D.To set the session priority.
AnswerA

The behavior field defines if locks are released or the key is deleted.

Why this answer

The behavior field determines what happens to locks when a session is invalidated; 'release' is the default, while 'delete' removes the key.

7
MCQeasy

Which HTTP method is used to create or update a key in the Consul KV store?

A.GET
B.PUT
C.DELETE
D.POST
AnswerB

PUT is used to write/update KV data.

Why this answer

The PUT method is the standard HTTP verb used for key creation and updates in the Consul API.

8
Multi-Selectmedium

Which THREE of the following fields are returned in a typical Consul KV API GET response?

Select 3 answers
A.ModifyIndex
B.Key
C.Value
D.SessionTTL
E.CreateTime
AnswersA, B, C

The index of the last modification is returned.

Why this answer

The Key, Value, and ModifyIndex are standard fields in the KV API response.

9
MCQmedium

You are configuring a Consul Watch to trigger a script whenever a specific KV key changes. Which type of watch should you define in your configuration file?

A.event
B.service
C.key
D.nodes
AnswerC

Key watches track updates to a specific KV path.

Why this answer

The 'key' watch type is specifically designed to monitor changes to a single KV entry.

10
MCQeasy

Which command-line interface command is used to set a value in the Consul KV store?

A.consul kv write
B.consul kv set
C.consul kv update
D.consul kv put
AnswerD

Put is the correct verb for setting values.

Why this answer

The 'consul kv put' command is the standard CLI utility for setting key values.

11
Multi-Selecteasy

Which THREE of the following are true about Consul KV keys?

Select 3 answers
A.Keys must start with a slash
B.Keys support storing binary data
C.Keys are case-sensitive
D.Keys cannot contain spaces
E.Keys can be organized in a folder-like hierarchy
AnswersB, C, E

Values are base64 encoded, allowing binary.

Why this answer

Keys are organized in a hierarchy, they are case-sensitive, and they can store arbitrary data.

12
MCQmedium

You want to delete a key and all its children in the KV store using the CLI. Which flag should you use?

A.-force
B.-recurse
C.--all
D.--cascade
AnswerB

-recurse allows recursive operations in the CLI.

Why this answer

The -recurse flag in the CLI allows the delete operation to act on the key and all nested keys.

13
MCQmedium

Which Consul API endpoint is used to create a new session that can be used for locking KV keys?

A./v1/kv/acquire
B./v1/session/create
C./v1/lock/init
D./v1/session/renew
AnswerB

This endpoint creates the session required for session-based locking.

Why this answer

The /v1/session/create endpoint is the standard way to initialize a session object in Consul.

14
MCQeasy

When using the Consul KV store, what is the maximum size allowed for a single value in a key?

A.There is no limit.
B.128 KB
C.1 MB
D.512 KB
AnswerD

Consul limits the value size to 512 KB.

Why this answer

Consul enforces a hard limit of 512 KB per KV entry value.

15
MCQmedium

When providing a session TTL, what is the minimum duration allowed?

A.10 seconds
B.30 seconds
C.5 seconds
D.1 second
AnswerA

The minimum is 10s.

Why this answer

The minimum session TTL allowed is 10 seconds.

16
MCQeasy

What happens if you try to write to a key that is currently locked by a session you do not own?

A.The write is rejected.
B.The write overwrites the lock.
C.The lock is transferred.
D.The write is queued.
AnswerA

Writes to locked keys require the matching session ID.

Why this answer

The write will be rejected if the session ID is not provided or if the session does not match the lock holder.

17
MCQhard

You need to ensure that a read operation from the KV store is strongly consistent. Which consistency mode should you specify?

A.default
B.consistent
C.quorum
D.stale
AnswerB

Consistent forces a leader check for strong consistency.

Why this answer

The 'consistent' consistency mode forces the leader to verify its leadership with a quorum of peers, ensuring strong consistency.

18
MCQeasy

Which flag can be used to pass arbitrary metadata to a KV entry?

A.labels
B.metadata
C.flags
D.tags
AnswerC

Flags is the defined field for metadata.

Why this answer

The 'flags' field in the KV API allows users to store an unsigned integer for application-specific metadata.

19
Multi-Selecteasy

Which THREE of the following are standard Consul KV CLI subcommands?

Select 3 answers
A.describe
B.list
C.put
D.delete
E.get
AnswersC, D, E

Used to create/update keys.

Why this answer

'put', 'get', and 'delete' are the standard CLI subcommands for KV.

20
Multi-Selectmedium

Which TWO of the following are valid ways to trigger a KV watch?

Select 2 answers
A.Reading the key
B.Updating the key's value
C.Creating a new session
D.Updating the key's flags
E.Changing the key's TTL
AnswersB, D

Value updates trigger watches.

Why this answer

Watches can be triggered by a change in the KV value or a change in the ModifyIndex (which occurs on any write).

21
Multi-Selecthard

Which TWO of the following are true regarding Consul KV watches?

Select 2 answers
A.Watches can only monitor keys that exist
B.Watches use blocking queries internally
C.Watches automatically restart after a script failure
D.Watches can be defined in agent configuration files
E.Watches are only available in the Enterprise edition
AnswersB, D

Watches are implemented using long polling.

Why this answer

Watches can be configured via agent configuration or the API, and they use blocking queries internally.

22
MCQmedium

You are using a Consul Watch to monitor KV changes. What does the 'handler' field specify?

A.The path to the executable to trigger.
B.The address of the Consul server.
C.The filter criteria for the watch.
D.The KV key to watch.
AnswerA

The handler is the command or script to run.

Why this answer

The handler field specifies the path to an executable that should be triggered when a change is detected.

23
MCQmedium

When a session is associated with a lock, what happens to the lock if the session is deleted?

A.The lock remains held by the server.
B.The lock is held until the key is deleted.
C.The lock is released.
D.The lock transfers to a new session.
AnswerC

Session deletion triggers the release of associated locks.

Why this answer

Deleting a session immediately releases any locks associated with that session.

24
Multi-Selectmedium

Which TWO of the following are true about the 'cas' parameter in KV writes?

Select 2 answers
A.It is only available in the CLI
B.It only works for new keys
C.It stands for Check-And-Set
D.It is mandatory for all writes
E.It requires a valid ModifyIndex
AnswersC, E

Correct definition.

Why this answer

The 'cas' parameter stands for Check-And-Set and requires the index to be provided to ensure atomicity.

25
MCQhard

What happens to a session if the associated node is marked as 'failed' by the Consul health check?

A.The session stays active.
B.The session is immediately deleted.
C.The session is invalidated when the TTL expires.
D.The session is transferred to another node.
AnswerC

Health check failure triggers the countdown for session invalidation.

Why this answer

When a node fails, the sessions associated with that node are invalidated after the session TTL expires.

26
MCQmedium

You want to perform a blocking query on a KV key to watch for updates. Which parameter must you provide in your request based on the last observed index?

A.consistency
B.wait
C.index
D.timeout
AnswerC

The index parameter specifies the last known index to block on.

Why this answer

The index parameter is used in the query string to inform Consul that you want to wait until the current state index is greater than the provided value.

27
MCQhard

When using Consul KV for distributed locking, why is it recommended to use a session?

A.It allows for TTL-based automatic lock release.
B.It encrypts the lock data.
C.It allows for multiple lock holders.
D.It speeds up read operations.
AnswerA

This prevents orphaned locks.

Why this answer

Sessions provide a mechanism for TTL-based auto-release, which prevents deadlocks if an application crashes while holding a lock.

28
MCQeasy

An application is using Consul KV to store configuration. You notice that the KV store is becoming large. What is the most efficient way to retrieve only the keys under the prefix "service/web/"?

A.Set the depth parameter to 1.
B.Use the index parameter with value 0.
C.Use the keys parameter with the prefix.
D.Use the recurse=true parameter in the query string.
AnswerD

Recurse=true returns all keys sharing the specified prefix.

Why this answer

The recurse parameter allows the KV API to return all keys with a matching prefix, rather than just the single key specified.

29
MCQhard

If a KV operation returns a 403 Forbidden status, what is the most common cause?

A.The ACL token lacks sufficient permissions.
B.The server is down.
C.The data is too large.
D.The key does not exist.
AnswerA

A 403 indicates a policy violation.

Why this answer

ACLs (Access Control Lists) are enabled, and the client token lacks the 'write' permission for that specific prefix.

30
MCQhard

You have implemented a leader election mechanism using Consul KV sessions. The session has a TTL of 15 seconds. If the application crashes, how long will it take for the lock to be automatically released?

A.Immediately.
B.60 seconds.
C.The lock is never released until manually deleted.
D.15 seconds.
AnswerD

The session TTL defines the duration after which an un-renewed session is invalidated, releasing associated locks.

Why this answer

When a session has a TTL, the lock is released when the session is invalidated by the health check failure. The default session invalidation is tied to the TTL.

31
MCQhard

If a Consul agent is configured with 'disable_remote_exec = true', how does this affect the KV store?

A.It forces all KV reads to be consistent.
B.It prevents all KV writes.
C.It disables KV watches.
D.It has no effect on the KV store.
AnswerD

Remote exec and KV store are distinct features.

Why this answer

This setting does not impact the KV store; it only restricts the execution of remote commands via the Consul event system.

32
Multi-Selecthard

Which THREE of the following are valid session behaviors when a session is invalidated?

Select 3 answers
A.transfer
B.keep
C.delete
D.terminate
E.release
AnswersB, C, E

The lock remains held (if supported by specific implementation logic).

Why this answer

Consul sessions support 'release' (default), 'delete' (deletes the key), and no other behaviors. 'Release' is the standard behavior.

33
Multi-Selecthard

Which TWO of the following are true regarding the behavior of the Consul KV store?

Select 2 answers
A.Keys can only contain alphanumeric characters
B.All KV writes are synchronous across all nodes
C.The KV store is limited to 1GB of data
D.Stale reads allow for reading from non-leader nodes
E.Values are stored as base64-encoded strings in the API response
AnswersD, E

Stale consistency mode permits non-leader reads.

Why this answer

KV values are stored as base64 encoded strings in the API, and they are eventually consistent for stale reads.

34
MCQmedium

You need to retrieve the session information for a specific session ID. Which endpoint should you query?

A./v1/session/read/:id
B./v1/session/info/:id
C./v1/kv/session/:id
D./v1/session/get/:id
AnswerB

This endpoint retrieves session metadata.

Why this answer

The /v1/session/info/:id endpoint returns the details of a specific session.

35
MCQmedium

You want to perform a list operation on a KV prefix to see all keys, but you don't want the values returned. Which API parameter helps reduce payload size?

A.raw=true
B.list=true
C.summarize=true
D.keys=true
AnswerD

The keys parameter returns only the list of keys.

Why this answer

The 'keys' parameter can be used with a prefix to return only the list of key names, not their contents.

36
MCQeasy

Which Consul feature allows you to observe the KV store for changes and run a command in response?

A.KV Hooks
B.Consul Watches
C.Consul Events
D.Consul Connect
AnswerB

Watches trigger actions upon data changes.

Why this answer

Consul Watches are the built-in mechanism for reacting to changes in the KV store.

37
Multi-Selectmedium

Which THREE of the following are required to successfully acquire a lock on a KV key?

Select 3 answers
A.A valid session ID
B.A 'write' ACL policy
C.The 'acquire' parameter in the API request
D.A 'wait' parameter
E.The key name to lock
AnswersA, C, E

The session ID is required to identify the locker.

Why this answer

To acquire a lock, you need a session, the key itself, and the acquire parameter in the API call.

38
Multi-Selecteasy

Which TWO of the following are common use cases for the Consul KV store?

Select 2 answers
A.Traffic routing
B.Distributed locking
C.Service discovery
D.Running custom scripts
E.Distributed configuration management
AnswersB, E

This is a core use case.

Why this answer

KV is primarily used for configuration management and distributed locking.

Ready to test yourself?

Try a timed practice session using only Key Value Store questions.