Create your first store
This article creates and starts a Clustron Zaris store from the command line, then connects a client and stores a value. By the end you have a running distributed store you can read from and write to.
This article assumes Zaris is already installed. If it isn't, follow Installation first.
The steps use two sets of PowerShell cmdlets. The admin cmdlets (New-ZrWorkspace, New-ZrStore, Start-ZrStore) manage the store through the manager. The client cmdlets (Connect-ZrStore, Set-ZrItem, Get-ZrItem) read and write data.
1. Create a workspace and connect to the manager
The manager coordinates the cluster. A workspace is a named connection to one or more managers that the admin cmdlets target. Create one that points at the local manager on its default port, 7801, and activate it with -Activate, before you create a store.
New-ZrWorkspace local -Managers localhost:7801 -Activate
If a workspace with that name already exists, or the manager is already part of another workspace, activate or join it instead:
Use-ZrWorkspace local -Managers localhost:7801
2. Create a store
Define a store named TestStore that runs two nodes on this machine. PartitionsPerNode sets how many partition processes run per machine, and ReplicationFactor sets how many copies of each partition to keep (1 means no replicas). BaseClusterPort is the starting port nodes use to talk to each other, and BaseClientPort is the starting port clients connect to; ports are assigned by incrementing these base values, one per process.
New-ZrStore `
-Name TestStore `
-PartitionsPerNode 2 `
-ReplicationFactor 1 `
-BaseClusterPort 7811 `
-BaseClientPort 7861
This defines the store but does not start it yet.
3. Start the store
Start the store to bring its nodes online and form the cluster.
Start-ZrStore TestStore
4. Connect a client
Connect a client to the store through one of its client endpoints. The endpoint is the host and the client port you set in step 2.
Connect-ZrStore -ConnectionString "zaris://localhost:7861/TestStore"
The connection string carries everything the client needs: zaris:// selects a plaintext connection, localhost:7861 is the client endpoint to seed from, and the path /TestStore is the store name.
5. Store and read a value
Store a value with Set-ZrItem, then read it back with Get-ZrItem.
Set-ZrItem -Key "order:1001" -Value "confirmed"
Get-ZrItem -Key "order:1001"
What you just did
You have a running distributed Zaris store and a connected client, created entirely from the command line. From here you can configure the store for production, connect to it from your .NET applications, or start using coordination primitives such as locks, leases, and counters.