Apache Geode install - TuPengXiong/TuPengXiong.github.io GitHub Wiki

Apache Geode 特性和安装

特性

  1. High Read-and-Write Throughput //高读写吞吐量
  2. Low and Predictable Latency //低和可预测的延迟
  3. High Scalability //高扩展性
  4. Continuous Availability //连续可用性
  5. Reliable Event Notifications //可靠的事件通知
  6. Parallelized Application Behavior on Data Stores //并行应用程序的行为的数据存储
  7. Shared-Nothing Disk Persistence //无共享磁盘持久性
  8. Reduced Cost of Ownership //降低所有权成本
  9. Single-Hop Capability for Client/Server //客户/服务器的单跳能力
  10. Client/Server Security //客户/服务器安全
  11. Multisite Data Distribution //多点数据分布
  12. Continuous Querying //连续查询

环境要求

  1. jdk8 及以上
  2. 系统时间同步正确 比如使用 Network Time Protocol (NTP)
  3. 主机名和主机文件正确 影响 gfsh
  4. 取消 SYN cookies
编辑 /etc/sysctl.conf
net.ipv4.tcp_syncookies = 0
重启
sysctl -p

安装

  1. JDK 环境配置
export JAVA_HOME=/usr/local/jdk1.8.0_60/
export PATH=$JAVA_HOME/bin:$PATH
source /etc/profile
  1. 下载 apache-geode包 http://geode.incubator.apache.org/
apache-geode-1.0.0-incubating.tar.gz
  1. 解压 添加环境变量 检验
tar -zvxf apache-geode-1.0.0-incubating.tar.gz 

export APACHE_GEODE_HOME=/usr/local/apache-geode-1.0.0-incubating/
export PATH=$APACHE_GEODE_HOME/bin:$PATH 
source /etc/profile
  1. 检验
gfsh version
出现版本
1.0.0-incubating

使用 gfsh 启动服务

1.gfsh 进入管理命令行

gfsh
gfsh help 

2.开启一个 locator

start locator --name=locator1
出现:
Starting a Geode Locator in /home/tpx/locator1...
......
Locator in /home/tpx/locator1 on 172.16.109.1[10334] as locator1 is currently online.
Process ID: 20717
Uptime: 3 seconds
GemFire Version: 1.0.0-incubating
Java Version: 1.8.0_20
Log File: /home/tpx/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/tpx/apache-geode-1.0.0-incubating/lib/geode-core-1.0.0-incubating.jar:/home/tpx/apache-geode-1.0.0-incubating/lib/geode-dependencies.jar

Successfully connected to: JMX Manager [host=172.16.109.1, port=1099]

Cluster configuration service is up and running.

3.start pulse

start pulse
出现:
Launched Geode Pulse

并弹出一个管理界面 默认用户和密码是admin:admin

4.开启服务

start server --name=server1 --server-port=40411
  1. 创建一个复制区域
create region --name=regionA --type=REPLICATE_PERSISTENT
显示:
Member  | Status
------- | --------------------------------------
server1 | Region "/regionA" created on "server1"

列出集群区域
list regions

列出 locator and cache servers
list members

查看区域的信息
describe region --name=regionA

6.添加数据到区域中 put

put --region=regionA --key="1" --value="one"

7.查询区域数据 query

query --query="select * from /regionA"

8.关闭服务

stop server --name=server1

9.开启服务

start server --name=server1 --server-port=40411

10.检验集群影响

gfsh>start server --name=server2 --server-port=40412
Starting a Geode Server in /home/tpx/server2...
.......
Server in /home/tpx/server2 on 172.16.109.1[40412] as server2 is currently online.
Process ID: 24399
Uptime: 3 seconds
GemFire Version: 1.0.0-incubating
Java Version: 1.8.0_20
Log File: /home/tpx/server2/server2.log
JVM Arguments: -Dgemfire.default.locators=172.16.109.1[10334] -Dgemfire.use-cluster-configuration=true -Dgemfire.http-service-port=8080 -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: /home/tpx/apache-geode-1.0.0-incubating/lib/geode-core-1.0.0-incubating.jar:/home/tpx/apache-geode-1.0.0-incubating/lib/geode-dependencies.jar
           
gfsh>describe region --name=regionA
..........................................................
Name            : regionA
Data Policy     : persistent replicate
Hosting Members : server2
                  server1

Non-Default Attributes Shared By Hosting Members  

 Type  |    Name     | Value
------ | ----------- | --------------------
Region | data-policy | PERSISTENT_REPLICATE
       | size        | 2
       | scope       | distributed-ack
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/tpx/server1 on 172.16.109.1[40411] as server1...
Process ID: 24080
Log File: /home/tpx/server1/server1.log
....
gfsh>query --query="select * from /regionA"

Result     : true
startCount : 0
endCount   : 20
Rows       : 3

Result
------
two
one
three

NEXT_STEP_NAME : END
           
gfsh>list members
  Name   | Id
-------- | -------------------------------------------------
locator1 | 172.16.109.1(locator1:20717:locator)<ec><v0>:1024
server2  | 172.16.109.1(server2:24399)<v4>:1026

gfsh>put --region=regionA --key="4" --value="four"
Result      : true
Key Class   : java.lang.String
Key         : 4
Value Class : java.lang.String
Old Value   : <NULL>


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 | data-policy | PERSISTENT_REPLICATE
       | size        | 4
       | scope       | distributed-ack

gfsh>stop server --name=server2
Stopping Cache Server running in /home/tpx/server2 on 172.16.109.1[40412] as server2...
Process ID: 24399
Log File: /home/tpx/server2/server2.log
....

平行启动服务

start server --name=server1 --server-port=40411
显示:
Starting a Geode Server in /home/username/my_geode/server1...
............................................................................
............................................................................
日志:
[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.

重新开一个命令窗口:
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]
启动server2:
start server --name=server2 --server-port=40412
显示:
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.0.0
Java Version: 1.8.0_60
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/gemfire.jar:
/home/username/Apache_Geode_Linux/lib/server-dependencies.jar

gfsh>list members
  Name   | Id
-------- | -------------------------------------------------
locator1 | 172.16.109.1(locator1:20717:locator)<ec><v0>:1024
server1  | 172.16.109.1(server1:25751)<v7>:1025
server2  | 172.16.109.1(server2:27273)<v8>:1026

server1 也起来了

关闭

shutdown --include-locators=true

exit

###集群

start locator --name="locators13" --enable-cluster-configuration=true --bind-address=192.168.0.13 --mcast-port=0 --hostname-for-clients=192.168.0.13 --J="-Dgemfire.distributed-system-id=13" --J="-Dgemfire.remote-locators=192.168.0.64[10334]"

⚠️ **GitHub.com Fallback** ⚠️