.zip
或者 .tar
文件从 http://geode.apache.org.
.zip
或者 .tar
文件, 这个 path_to_product
是绝对路径.
例如 .zip
格式:
$ unzip apache-geode-1.1.0.zip -d path_to_product
例如 .tar
格式:
$ tar -xvf apache-geode-1.1.0.tar -C path_to_product
JAVA_HOME
环境变量. 在 Linux/Unix 下:
JAVA_HOME=/usr/java/jdk1.8.0_60 export JAVA_HOME
在 Windows 平台:
set JAVA_HOME=c:\Program Files\Java\jdk1.8.0_60
Geode
脚本 到你的 PATH
环境变量里. 在 Linux/Unix 下:
PATH=$PATH:$JAVA_HOME/bin:path_to_product/bin export PATH
在 Windows
下:
set PATH=%PATH%;%JAVA_HOME%\bin;path_to_product\bin
gfsh version
命令, 查看输出. 例如:
$ gfsh version v1.1.0
想查看更详细的信息, 比如 构建日期和版本号, JDK 版本等等, 键入:
$ gfsh version --full
my_geode
) 然后进入它. gfsh
在此目录下保存locator 和 server 的工作目录和日志文件.
gfsh
命令启动它(或者 gfsh.bat
在Windows操作操作系统下).
_________________________ __ / _____/ ______/ ______/ /____/ / / / __/ /___ /_____ / _____ / / /__/ / ____/ _____/ / / / / /______/_/ /______/_/ /_/ 1.5 Monitor and Manage Geode gfsh>
gfsh
后, 键入 start locator
命令指定 locator 的名字:
gfsh>start locator --name=locator1 Starting a Geode Locator in /home/username/my_geode/locator1... ................................. Locator in /home/username/my_geode/locator1 on ubuntu.local[10334] as locator1 is currently online. Process ID: 3529 Uptime: 18 seconds Geode Version: 1.5 Java Version: 1.8.0_121 Log File: /home/username/my_geode/locator1/locator1.log JVM Arguments: -Dgemfire.enable-cluster-configuration=true -Dgemfire.load-cluster-configuration-from-dir=false -Dgemfire.launcher.registerSignalHandlers=true -Djava.awt.headless=true -Dsun.rmi.dgc.server.gcInterval=9223372036854775806 Class-Path: /home/username/Apache_Geode_Linux/lib/geode-core-1.0.0.jar: /home/username/Apache_Geode_Linux/lib/geode-dependencies.jar Successfully connected to: JMX Manager [host=10.118.33.169, port=1099] Cluster configuration service is up and running.
如果你运行 start locator
从 gfsh
没有指定 member 名字, gfsh 会自动生成一个随机的 member 名字. 这对自动化操作非常有用.
启动基于浏览器的脉冲监测工具. Pulse是一个Web应用程序,它提供了一个图形仪表板,用于监控Geode集群,成员和regions的重要的实时健康和性能.参考Geode Pulse
gfsh>start pulse
此命令启动Pulse并自动连接到在Locator
中运行的JMX Manager.在Pulse登录页面上,输入默认用户名admin
和密码admin
.
Pulse应用程序显示刚刚启动的定位器(locator1):
Geode服务器是作为一个长期运行的,可配置成员的集群(也称为分布式系统). Geode服务器主要用于托管长期数据区域(data regions)和运行标准Geode进程,例如客户端/服务器配置中的服务器.参考Running Geode Server Processes.
启动一个缓存服务器:
gfsh>start server -name=server1 -server-port=40411
此命令在 40411
的指定端口上启动名为"server1"的缓存服务器.
如果你运行 start server
命令从 gfsh
没有指定 member 名字, gfsh
会自动随机生成一个随机的 member 名字. 这对自动化操作非常有用.
在Pulse中观察变化(新成员[member]和服务器[server]).尝试扩展分布式系统图标,以图形方式查看定位器和缓存服务器.
在此步骤中,使用gfsh
命令创建一个region.region是Geode集群的核心构建块,并提供了组织数据的方法.在此次练习中创建的region在集群成员之间复制数据(replicated),并利用持久性将数据保存到磁盘(persistent).参考Data Regions
gfsh>create region --name=regionA --type=REPLICATE_PERSISTENT
Member | Status
------- | --------------------------------------
server1 | Region "/regionA" created on "server1"
注意该region被server1托管.
gfsh
命令查看集群上的region列表gfsh>list regions
List of regions
---------------
regionA
gfsh>list members
Name | Id
------------ | ---------------------------------------
Coordinator: | 192.0.2.0(locator1:3529:locator)<ec><v0>:59926
locator1 | 192.0.2.0(locator1:3529:locator)<ec><v0>:59926
server1 | 192.0.2.0(server1:3883)<v1>:65390
gfsh>describe region --name=regionA
..........................................................
Name : regionA
Data Policy : persistent replicate
Hosting Members : server1
Non-Default Attributes Shared By Hosting Members
Type | Name | Value
------ | ---- | -----
Region | size | 0
Note: 保持此
gfsh
提示打开以供后续步骤使用.
Apache Geode以键/值对形式对数据进行管理.在大多数应用程序中,Java程序添加,删除和修改存储的数据.同时也可以使用gfsh命令添加和检索数据.参考Data Commands.
put
命令向region中添加数据.gfsh>put --region=regionA --key="1" --value="one"
Result : true
Key Class : java.lang.String
Key : 1
Value Class : java.lang.String
Old Value : <NULL>
gfsh>put --region=regionA --key="2" --value="two"
Result : true
Key Class : java.lang.String
Key : 2
Value Class : java.lang.String
Old Value : <NULL>
gfsh>query --query="select * from /regionA"
Result : true
startCount : 0
endCount : 20
Rows : 2
Result
------
two
one
注意到结果是刚刚使用put
命令添加的两条数据条目(entries). 参考Data Entries.
gfsh>stop server --name=server1
Stopping Cache Server running in /home/username/my_geode/server1 on ubuntu.local[40411] as server1...
Process ID: 3883
Log File: /home/username/my_geode/server1/server1.log
....
gfsh>start server --name=server1 --server-port=40411
gfsh>query --query="select * from /regionA"
Result : true
startCount : 0
endCount : 20
Rows : 2
Result
------
two
one
因为regionA有持久性,它将数据的副本写入磁盘.当托管regionA的服务器启动时,数据将被填充到高速缓存中.请注意,结果显示停止服务器之前使用put
命令添加的两个数据条目的值. 参考Data Entries 参考Data Regions
在此步骤中,启动第二个缓存服务器.因为regionA是可复制的,所以该数据将在托管该区域的任何服务器上可用.
gfsh>start server --name=server2 --server-port=40412
describe region
命令,查看regionA的详细信息:gfsh>describe region --name=regionA
..........................................................
Name : regionA
Data Policy : persistent replicate
Hosting Members : server1
server2
Non-Default Attributes Shared By Hosting Members
Type | Name | Value
------ | ---- | -----
Region | size | 2
请注意,不需要再为server2创建regionA.命令的输出显示regionA托管在server1和server2上.当gfsh启动服务器时,它会从群集配置服务请求配置,集群配置服务会将共享配置分发到加入群集的任何新服务器.
gfsh>put --region=regionA --key="3" --value="three"
Result : true
Key Class : java.lang.String
Key : 3
Value Class : java.lang.String
Old Value : <NULL>
gfsh>stop server --name=server1
Stopping Cache Server running in /home/username/my_geode/server1 on ubuntu.local[40411] as server1...
Process ID: 4064
Log File: /home/username/my_geode/server1/server1.log
....
gfsh>query --query="select * from /regionA"
Result : true
startCount : 0
endCount : 20
Rows : 3
Result
------
two
one
three
注意数据包含3个条目, 包括你刚刚添加的那个.
gfsh>put --region=regionA --key="4" --value="four"
Result : true
Key Class : java.lang.String
Key : 3
Value Class : java.lang.String
Old Value : <NULL>
只有server2正在运行.因为数据被复制和持久化,所有数据仍然可用.但是新的数据条目当前仅在server2 上可用.
gfsh>describe region --name=regionA
..........................................................
Name : regionA
Data Policy : persistent replicate
Hosting Members : server2
Non-Default Attributes Shared By Hosting Members
Type | Name | Value
------ | ---- | -----
Region | size | 4
gfsh>stop server --name=server2
Stopping Cache Server running in /home/username/my_geode/server2 on ubuntu.local[40412] as server2...
Process ID: 4185
Log File: /home/username/my_geode/server2/server2.log
.....
在此步骤中,并行重新启动缓存服务器.由于数据是持久的,因此在服务器重新启动时数据可用.由于数据在多个服务器上存在副本,因此必须并行启动服务器,以便可以在启动之前同步其数据.
gfsh>start server --name=server1 --server-port=40411
Starting a Geode Server in /home/username/my_geode/server1...
............................................................................
............................................................................
此时如果在server1.log日志文件中查找重新启动服务器的相关信息,将看到类似于以下内容的日志消息:
[info 2015/01/14 09:08:13.610 PST server1 <main> tid=0x1] Region /regionA has pot
entially stale data. It is waiting for another member to recover the latest data.
My persistent id:
DiskStore ID: 8e2d99a9-4725-47e6-800d-28a26e1d59b1
Name: server1
Location: /192.0.2.0:/home/username/my_geode/server1/.
Members with potentially new data:
[
DiskStore ID: 2e91b003-8954-43f9-8ba9-3c5b0cdd4dfa
Name: server2
Location: /192.0.2.0:/home/username/my_geode/server2/.
]
Use the "gfsh show missing-disk-stores" command to see all disk stores that
are being waited on by other members.
my_geode
),启动gfsh:[username@localhost ~/my_geode]$ gfsh
_________________________ __
/ _____/ ______/ ______/ /____/ /
/ / __/ /___ /_____ / _____ /
/ /__/ / ____/ _____/ / / / /
/______/_/ /______/_/ /_/ 1.5
Monitor and Manage Geode
gfsh>connect --locator=localhost[10334]
Connecting to Locator at [host=localhost, port=10334] ..
Connecting to Manager at [host=ubuntu.local, port=1099] ..
Successfully connected to: [host=ubuntu.local, port=1099]
gfsh>start server --name=server2 --server-port=40412
当server2启动时,注意server1在第一个gfsh窗口中完成启动:
Server in /home/username/my_geode/server1 on ubuntu.local[40411] as server1 is currently online.
Process ID: 3402
Uptime: 1 minute 46 seconds
Geode Version: 1.5
Java Version: 1.8.0_121
Log File: /home/username/my_geode/server1/server1.log
JVM Arguments: -Dgemfire.default.locators=192.0.2.0[10334] -Dgemfire.use-cluster-configuration=true
-XX:OnOutOfMemoryError=kill -KILL %p -Dgemfire.launcher.registerSignalHandlers=true
-Djava.awt.headless=true -Dsun.rmi.dgc.server.gcInterval=9223372036854775806
Class-Path: /home/username/Apache_Geode_Linux/lib/geode-core-1.0.0.jar:
/home/username/Apache_Geode_Linux/lib/geode-dependencies.jar
gfsh>list members
Name | Id
------------ | ---------------------------------------
Coordinator: | ubuntu(locator1:2813:locator)<ec><v0>:46644
locator1 | ubuntu(locator1:2813:locator)<ec><v0>:46644
server2 | ubuntu(server2:3992)<v8>:21507
server1 | ubuntu(server1:3402)<v7>:36532
put
命令添加的所有数据是否可用:gfsh>query --query="select * from /regionA"
Result : true
startCount : 0
endCount : 20
Rows : 5
Result
------
one
two
four
Three
NEXT_STEP_NAME : END
gfsh>stop server --dir=server2
Stopping Cache Server running in /home/username/my_geode/server2 on 192.0.2.0[40412] as server2...
Process ID: 3992
Log File: /home/username/my_geode/server2/server2.log
....
gfsh>query --query="select * from /regionA"
Result : true
startCount : 0
endCount : 20
Rows : 5
Result
------
one
two
four
Three
NEXT_STEP_NAME : END
关闭集群有以下步骤:
gfsh>shutdown --include-locators=true
参见 shutdown.
As a lot of data in memory will be lost, including possibly events in queues,
do you really want to shutdown the entire distributed system? (Y/n): Y
Shutdown is triggered
gfsh>
No longer connected to ubuntu.local[1099].
gfsh>
exit
推出gfsh shell.Using gfsh
, the show missing-disk-stores
command lists all disk stores with most recent data that are being waited on by other members.
Example:
Missing Disk Stores
Disk Store ID | Host | Directory
------------------------------------ | -------------- | -------------------------
9eb7bf36-330b-4c08-995d-a66f745f0fd6 | /192.168.68.21 | /opt/geode_work/server4/.
4a83ec7f-d80c-460e-a315-01948bd4e396 | /192.168.68.20 | /opt/geode_work/server3/.
9eb7bf36-330b-4c08-995d-a66f745f0fd6 | /192.168.68.21 | /opt/geode_work/server4/.
9eb7bf36-330b-4c08-995d-a66f745f0fd6 | /192.168.68.21 | /opt/geode_work/server4/.
No missing colocated region found
Note: You need to be connected to
Locator
in gfsh to run this command.
This section applies to disk stores for which both of the following are true:
When you cannot bring the latest persisted copy online, use the revoke command to tell the other members to stop waiting for it. Once the store is revoked, the system finds the remaining most recent copy of data and uses that.
Note: Once revoked, a disk store cannot be reintroduced into the system.
Use gfsh show missing-disk-stores to properly identify the disk store you need to revoke. The revoke command takes the disk store ID as input, as listed by that command.
Example:
gfsh>revoke missing-disk-store --id=60399215-532b-406f-b81f-9b5bd8d1b55a
Missing disk store successfully revoked