此内容没有您所选择的语言版本。
Chapter 2. Getting Started with Data Grid Server
Quickly set up Data Grid server and learn the basics.
2.1. Data Grid Server Requirements
Check host system requirements for the Data Grid server.
2.2. Downloading Server Distributions
The Data Grid server distribution is an archive of Java libraries (JAR
files), configuration files, and a data
directory.
Procedure
- Access the Red Hat customer portal.
- Download the Red Hat Data Grid 8.0 server from the software downloads section.
Verification
Use the checksum to verify the integrity of your download.
Run the
md5sum
orsha256sum
command with the server download archive as the argument, for example:$ sha256sum jboss-datagrid-${version}-server.zip
-
Compare with the
MD5
orSHA-256
checksum value on the Data Grid Software Details page.
Reference
Data Grid Server README describes the contents of the server distribution.
2.3. Installing Data Grid Server
Extract the Data Grid server archive to any directory on your host.
Procedure
Use any extraction tool with the server archive, for example:
$ unzip infinispan-server-${version}.zip
The resulting directory is your $RHDG_HOME
.
2.4. Running Data Grid Servers
Spin up Data Grid server instances that automatically form clusters. Learn how to create cache definitions to store your data.
2.4.1. Starting Data Grid Servers
Launch Data Grid server with the startup script.
Procedure
-
Open a terminal in
$RHDG_HOME
. Run the
server
script.- Linux
$ bin/server.sh
- Microsoft Windows
bin\server.bat
Server logs display the following messages:
ISPN080004: Protocol SINGLE_PORT listening on 127.0.0.1:11222 ISPN080001: Data Grid Server <$version> started in <mm>ms
Hello Data Grid!
-
Open
127.0.0.1:11222
in any browser to access the Data Grid console.
Reference
Data Grid Server README describes command line arguments for the server
script.
2.4.2. Verifying Data Grid Cluster Discovery
By default Data Grid servers running on the same network discover each other with the MPING
protocol.
This procedure shows you how to start two Data Grid servers on the same host and verify that the cluster view.
Prerequisites
Start a Data Grid server instance on your host.
Procedure
Install and run a new Data Grid server instance.
-
Open a terminal in
$RHDG_HOME
. Copy the root directory to
server2
.$ cp -r server server2
-
Open a terminal in
Specify a port offset and the location of the
server2
root directory.$ bin/server.sh -o 100 -s server2
Verification
Check the server logs for the following messages:
INFO [org.infinispan.CLUSTER] (jgroups-11,<server_hostname>) ISPN000094: Received new cluster view for channel cluster: [<server_hostname>|3] (2) [<server_hostname>, <server2_hostname>] INFO [org.infinispan.CLUSTER] (jgroups-11,<server_hostname>) ISPN100000: Node <server2_hostname> joined the cluster
2.5. Performing Operations with the Data Grid CLI
Connect to servers with the Data Grid command line interface (CLI) to access data and perform administrative functions.
2.5.1. Starting the Data Grid CLI
Start the Data Grid CLI as follows:
-
Open a terminal in
$ISPN_HOME
. Run the CLI.
$ bin/cli.sh [disconnected]>
2.5.2. Connecting to Data Grid Servers
Do one of the following:
Run the
connect
command to connect to a Data Grid server on the default port of11222
:[disconnected]> connect [hostname1@cluster//containers/default]>
Specify the location of a Data Grid server. For example, connect to a local server that has a port offset of 100:
[disconnected]> connect 127.0.0.1:11322 [hostname2@cluster//containers/default]>
Press the tab key to display available commands and options. Use the -h
option to display help text.
2.5.3. Creating Caches from Templates
Use Data Grid cache templates to add caches with recommended default settings.
Procedure
Create a distributed, synchronous cache from a template and name it "mycache".
[//containers/default]> create cache --template=org.infinispan.DIST_SYNC mycache
TipPress the tab key after the
--template=
argument to list available cache templates.Retrieve the cache configuration.
[//containers/default]> describe caches/mycache { "distributed-cache" : { "mode" : "SYNC", "remote-timeout" : 17500, "state-transfer" : { "timeout" : 60000 }, "transaction" : { "mode" : "NONE" }, "locking" : { "concurrency-level" : 1000, "acquire-timeout" : 15000, "striping" : false }, "statistics" : true } }
2.5.4. Adding Cache Entries
Add data to caches with the Data Grid CLI.
Prerequisites
Create a cache named "mycache" and
cd
into it.[//containers/default]> cd caches/mycache
Procedure
Put an entry into "mycache".
[//containers/default/caches/mycache]> put hello world
TipIf not in the context of a cache, use the
--cache=
parameter. For example:[//containers/default]> put --cache=mycache hello world
Get the entry to verify it.
[//containers/default/caches/mycache]> get hello world
2.5.5. Shutting Down Data Grid Servers
Use the CLI to gracefully shutdown running servers. This ensures that Data Grid passivates all entries to disk and persists state.
Use the
shutdown server
command to stop individual servers.[//containers/default]> shutdown server $hostname
Use the
shutdown cluster
command to stop all servers joined to the cluster.[//containers/default]> shutdown cluster
Verification
Check the server logs for the following messages:
ISPN080002: Data Grid Server stopping ISPN000080: Disconnecting JGroups channel cluster ISPN000390: Persisted state, version=<$version> timestamp=YYYY-MM-DDTHH:MM:SS ISPN080003: Data Grid Server stopped