A Geode server is a process that acts as a long-running, configurable member of a client/server system. The Geode server is primarily used as a server that holds long-lived data areas and runs standard Geode processes such as in a client/server configuration. You can stop the server with:
- The gfsh tool allows you to manage your Geode server processes from the command line.
- You can also
com.gemstone.gemfire.distributed.ServerLauncher
start, stop and manage Geode servers through the API.ServerLauncher
API can only be used forgfsh启动的服务器或是
ServerLauncher类自己启动的。查看《
JavaDocs》来获得额外的
ServerLauncher
API使用说明。
Default server configuration and log files
The gfsh utility uses a working directory to hold configuration files and log files. These are the default and configuration options:
- When you start a standalone server with gfsh, gfsh will automatically load the required jar files
$GEMFIRE/lib/server-dependencies.jar
and the$JAVA_HOME/lib/tools.jar到jvm进程的类路径。如果你是使用
ServerLauncher API to start a standalone server, you must specify in your run process command$GEMFIRE/lib/server-dependencies.jar。查看《Geode进程类路径设置》来获取更多的类路径设置信息。
- The server is configured like any other Geode process, with
gemfire.properties和共享的集群配置文件。它是不可编程的,除了通过应用程序插件。
normally, you providegemfire.properties
files andgfsecurity.properties
files (if you are using a separate, restricted access security settings file). You can also specify a working directory in the cache servercache.xml文件。
-
By default, a new server started using gfsh receives its initial cache configuration from the cluster config service, assuming the locator is running the cluster config service. If you specify a group when you start the server, the server also receives the configuration applied to the group. The shared configuration includes
cache.xml
files,gemfire.properties
files, and deployed jar files. You can specify to--use-cluster-configuration=false来
disable . View the Cluster Configuration Service Overview -
If you are using the spring framework, you can
--spring-xml-location
specify a Spring ApplicationContext XML file with command line options when starting the server with gfsh. This option allows you to restart your geode server process with your spring application configuration. See the Spring Documentation for more information on this document. -
For log output, log file output defaults to
server_name.log。如果你使用相同的服务器名重启一个服务器,已有的
server_name in the cache server working directory. The log file is automatically renamed for you (eg,server1-01-01.log
orserver1-02-01.log
).--log-level参数中
You can change the log level in this file by specifying a level when starting the server . -
By default, the server is started in a subdirectory (named after the server) under the gfsh execution directory. This subdirectory is considered the current working directory. You can also specify a different working directory when starting the server with gfsh.
-
By default, a server that is shut down and disconnected due to network disconnection or unresponsiveness of members will restart itself and automatically attempt to reconnect to the distributed system. See Handling Passive Cache Drops Using Auto-Reconnect for more details.
-
--J=-Dproperty.name=value将
You can use JVM arguments to pass to the server's JVM arguments when starting the server . These parameters can be used as java properties or Geode configuration properties such asgemfire.jmx-manager。例如:
gfsh>start server --name=server1 --J=-Dgemfire.jmx-manager=true \ --J=-Dgemfire.jmx-manager-start=true --J=-Dgemfire.http-port=8080
Pivotal recommends that you do not start the server with -XX:+UseCompressedStrings
and-XX:+UseStringCache JVM配置参数。 这些JVM选项可能会导致数据损坏和兼容性问题。
The gfsh syntax to start the Geode server is:
start server --name=value [--assign-buckets(=value)] [--bind-address=value] [--cache-xml-file=value] [--classpath=value] [--disable-default-server(=value)] [--disable-exit-when-out-of-memory(=value)] [--enable-time-statistics(=value)] [--force(=value)] [--include-system-classpath(=value)] [--properties-file=value] [--security-properties-file=value] [--group=value] [--locators=value] [--locator-wait-time=value] [--log-level=value] [--mcast-address=value] [--mcast-port=value] [--memcached-port=value] [--memcached-protocol=value] [--rebalance(=value)] [--server-bind-address=value] [--server-port=value] [--spring-xml-location=value] [--statistic-archive-file=value] [--dir=value] [--initial-heap=value] [--max-heap=value] [--use-cluster-configuration(=value)] [--J=value(,value)*] [--critical-heap-percentage=value] [--critical-off-heap-percentage=value] [--eviction-heap-percentage=value] [--eviction-off-heap-percentage=value] [--hostname-for-clients=value] [--max-connections=value] [--message-time-to-live=value] [--max-message-count=value] [--max-threads=value] [--socket-buffer-size=value] [--lock-memory=value] [--off-heap-memory-size=value]
Note:--max-heap
When the and --initial-heap,额外的GC参数由
Geode的资源管理器的内部指定。如果你不想要
资源管理器设置的
额外的默认GC属性,那就使用
e -Xms
& -Xmx
JVM options are specified during server startup . See Source Manager Heap Usage Control for more information.
as followsgfsh start server启动序列为每个缓存配置指定一个cache.xml文件,并且使用不同的传入的客户端连接端口:
gfsh>start server --name=server1 --mcast-port=10338 \ --cache-xml-file=../ServerConfigs/cache.xml --server-port=40404 gfsh>start server --name=server2 --mcast-port=10338 \ --cache-xml-file=../ServerConfigs/cache.xml --server-port=40405
This is gemfire.properties的一部份,它
setting one up cache.xml位置
and setting the multicast port:
mcast-port=10338 cache-xml-file=D:\gfeserver\cacheCS.xml
To start the server with the gemfire.properties
file, type:
gfsh>start server --name=server1 \ --properties-file=D:\gfeserver\gemfire.properties
To start a server with a JMX manager embedded, you can enter the following command:
gfsh>start server --name=server2 \ --J=-Dgemfire.jmx-manager=true --J=-Dgemfire.jmx-manager-start=true
To start a server and provide JVM configuration settings, you can issue a command like this:
gfsh>start server --name=server3 \ --J=-Xms80m,-Xmx80m --J=-XX:+UseConcMarkSweepGC,-XX:CMSInitiatingOccupancyFraction=65
Start the server programmatically
com.gemstone.gemfire.distributed.ServerLauncher
Use the API in your code to start the cache server process. Use ServerLauncher.Builder类来构建
ServerLauncher实例,然后用
start()
method to start the server service.ServerLauncher类中的其它方法提交了服务器状态信息并可以允许你停止服务器。
import com.gemstone.gemfire.distributed.ServerLauncher; public class MyEmbeddedServer { public static void main(String[] args){ ServerLauncher serverLauncher = new ServerLauncher.Builder() .setMemberName("server1") .setServerPort(40405) .set("jmx-manager", "true") .set("jmx-manager-start", "true") .build(); serverLauncher.start(); System.out.println("Cache server successfully started"); } }
Check server status
If you connect to a distributed system with gfsh, you can check the status of a running cache server by providing the server name. E.g:
gfsh>status server --name=server1
If you are not connected to a distributed system, you can check the status of the local cache by providing the process ID or the current working directory of the server. E.g:
gfsh>status server --pid=2484
or
% gfsh status server --dir=<server_working_directory>
< server_working_directory > corresponds to where, where is the working directory where the server runs. If successful, the command will return the following information (with the jvm parameters provided at startup):
% gfsh status server --dir=server4 Server in /home/stymon/server4 on ubuntu.local[40404] as server4 is currently online. Process ID: 3324 Uptime: 1 minute 5 seconds GemFire Version: 8.0.0 Java Version: 1.7.0_65 Log File: /home/stymon/server4/server4.log JVM Arguments: ...
stop the server
If you are connected to a distributed system with gfsh, you can stop a running server by providing the server name. E.g:
gfsh>stop server --name=server1
If you are not connected to a distributed system, you can stop a local server by its process ID or the server's current working directory. E.g:
gfsh>stop server --pid=2484
or
gfsh>stop server --dir=<server_working_directory>
< server_working_directory > corresponds to where, where is the working directory where the server runs.
You can also use the gfsh
shutdown
command to shut down all cache servers in an orderly fashion. This is useful if you are using persistent areas. See "Starting and Shutting Down Your System" for more details.