Geode集群搭建
1.下载安装包
http://mirror.bit.edu.cn/apache/geode/1.2.0/
2.安装解压后即可直接使用
apache-geode-1.2.0
3.进入bin目录,执行$ ./gfsh进行命令行模式
3.1.启动locator(定位器),相当于集群中的master
gfsh>start locator --name=locator1
[trade@web01 bin]$ ./gfsh
_________________________ __
/ _____/ ______/ ______/ /____/ /
/ / __/ /___ /_____ / _____ /
/ /__/ / ____/ _____/ / / / /
/______/_/ /______/_/ /_/ 1.2.0
Monitor and Manage Apache Geode
gfsh>start locator --name=locator1
Starting a Geode Locator in /data/trade/apache-geode-1.2.0/bin/locator1...
.........
Locator in /data/trade/apache-geode-1.2.0/bin/locator1 on web01[10334] as locator1 is currently online.
Process ID: 23550
Uptime: 5 seconds
Geode Version: 1.2.0
Java Version: 1.8.0_131
Log File: /data/trade/apache-geode-1.2.0/bin/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: /data/trade/apache-geode-1.2.0/lib/geode-core-1.2.0.jar:/data/trade/apache-geode-1.2.0/lib/geode-dependencies.jar
Successfully connected to: JMX Manager [host=web01, port=1099]
Cluster configuration service is up and running.
3.2.启动server端
创建一个和master的连接
gfsh>connect --locator=192.168.30.2[10334]
启动server
gfsh>start server --name=server1
[trade@web02 bin]$ ./gfsh
_________________________ __
/ _____/ ______/ ______/ /____/ /
/ / __/ /___ /_____ / _____ /
/ /__/ / ____/ _____/ / / / /
/______/_/ /______/_/ /_/ 1.2.0
Monitor and Manage Apache Geode
gfsh>connect --locator=192.168.30.2[10334]
Connecting to Locator at [host=192.168.30.2, port=10334] ..
Connecting to Manager at [host=web01, port=1099] ..
Successfully connected to: [host=web01, port=1099]
gfsh>start server --name=server1
Starting a Geode Server in /data/trade/apache-geode-1.2.0/bin/server1...
..........
Server in /data/trade/apache-geode-1.2.0/bin/server1 on web02[40404] as server1 is currently online.
Process ID: 8273
Uptime: 5 seconds
Geode Version: 1.2.0
Java Version: 1.8.0_131
Log File: /data/trade/apache-geode-1.2.0/bin/server1/server1.log
JVM Arguments: -Dgemfire.default.locators=192.168.30.2[10334] -Dgemfire.use-cluster-configuration=true -Dgemfire.start-dev-rest-api=false -XX:OnOutOfMemoryError=kill -KILL %p -Dgemfire.launcher.registerSignalHandlers=true -Djava.awt.headless=true -Dsun.rmi.dgc.server.gcInterval=9223372036854775806
Class-Path: /data/trade/apache-geode-1.2.0/lib/geode-core-1.2.0.jar:/data/trade/apache-geode-1.2.0/lib/geode-dependencies.jar
3.3.创建区域数据块
创建数据区域块
gfsh>create region --name=userMap --type=REPLICATE
REPLICATE复制
REPLICATE_PERSISTENT复制并持久化
插入数据
gfsh>put --region=userMap --key="1" --value="one"
查询数据
gfsh>query --query="select * from /userMap"
gfsh>create region --name=userMap --type=REPLICATE
Member | Status
------- | --------------------------------------
server1 | Region "/userMap" created on "server1"
gfsh>put --region=userMap --key="1" --value="one"
Result : true
Key Class : java.lang.String
Key : 1
Value Class : java.lang.String
Old Value : <NULL>
gfsh>query --query="select * from /userMap"
以上命令的执行默认是以集群为范围的,如果要单机执行,需要修改apache-geode\config\gemfire.properties文件中的属性:enable-cluster-configuration=true,改为false。
3.4.常用命令
查看集群上的region列表
list regions
查看集群成员
list members
查看region详细信息
describe region --name=<region name>