Network-Attached Memory(HAM)terracotta笔记(一)

Network-Attached Memory(HAM)terracotta笔记(一)
首页
http://www.terracotta.org/web/display/orgsite/What+Is+Terracotta
Terracotta is Network-Attached Memory(HAM)

1、eclipse环境设置
eclipse plugin
terracotta
Final       http://download.terracotta.org/eclipse/update
Nightly   http://download.terracotta.org/nightly/eclipse/update

2、集成lucene的例子
integrations - Lucene
demo SVN url:
http://svn.terracotta.org/svn/forge/projects/labs/terracotta-lucene-examples/trunk/terracotta-lucene-examples

3、在WINDOWS上安装服务端和客户端
下载得到该文件,安装
terracotta-windows-2.6.4.exe

4、在UBUNTU上部署服务端
下载得到文件
terracotta-generic-2.6.4.tar.gz
解开压缩包拷贝到工作目录
tar zxvf terracotta-generic-2.6.4.tar.gz
mv terracotta-2.6.4 /usr/local/
启动SAMPLE服务
cd /usr/local/terracotta-2.6.4/samples
./start-demo-server.sh

打开terracotta welcome
打开Terracotta Administrator Console
连接到服务器的IP,可以查看到server和client的情况和日志

5、修改terracotta-lucene-examples的例子的配置文件
build.xml文件如下:
<project name="lucene-examples" default="jar" basedir=".">
<!-- IMPORTANT: uncomment and edit the tcinstall property according to the location of your terracotta installation -->
        <!-- <property name="tcinstall" value="/PATH/TO/YOUR/TERRACOTTA/INSTALLATION"/> -->

<!-- Don't edit anything below here. -->
<property name="tcjava" value="D:/tool/Terracotta/terracotta-2.6.4/bin/dso-java.bat"/>
        <property name="tcconfig" value="tc-config.xml"/>

<property file="${user.home}/.m2/maven.properties" />
<property name="maven.build.output" value="target/classes" />
<property name="maven.build.directory" value="target" />
<property name="maven.build.final.name" value="terracotta-lucene-examples-1.1" />
<property name="maven.test.reports" value="${maven.build.directory}/test-reports" />
<property name="maven.test.output" value="target/test-classes" />
<property name="maven.repo.local" value="${user.home}/.m2/repository" />
<path id="build.classpath">
   <fileset dir="${maven.repo.local}">
    <include name="org/apache/lucene/lucene-core/2.0.0/lucene-core-2.0.0.jar" />
   </fileset>
</path>

<target name="run" depends="jar" description="Runs the example">
   <echo message=""/>
   <echo message="!!! IMPORTANT !!!"/>
   <echo message="Make sure you start the Terracotta server:"/>
   <echo message=" ${tcinstall}/dso/samples/start-demo-server.sh"/>
   <echo message=""/>
   <java fork="true" classpathref="build.classpath"
    classname="org.terracotta.lucene.example.RAMDirectoryExample" jvm="${tcjava}">
    <classpath>
     <pathelement location="${maven.build.directory}/${maven.build.final.name}.jar"/>
     <pathelement path="${build.classpath}"/>
    </classpath>
    <jvmarg value="-Dtc.config=${tcconfig}"/>
     <!-- Uncomment this if you want to see verbose GC -->
    <!-- <jvmarg value="-verbose:gc"/> -->
   </java>
</target>

<target name="clean" description="Clean the output directory">
   <delete dir="${maven.build.directory}" />
</target>

<target name="compile" depends="get-deps" description="Compile the code">
   <mkdir dir="${maven.build.output}" />
 
   <javac destdir="${maven.build.output}"
    excludes="**/package.html"
    debug="true"
    deprecation="true"
    optimize="false">
    <src>
     <pathelement location="src/main/java" />
    </src>
    <classpath refid="build.classpath" />
   </javac>
 
   <copy todir="${maven.build.output}">
    <fileset dir="src/main/resources" />
   </copy>
</target>

<target name="jar" depends="compile"
   description="Clean the JAR">
   <jar jarfile="${maven.build.directory}/${maven.build.final.name}.jar"
    basedir="${maven.build.output}"
    excludes="**/package.html" />
</target>

<target name="get-deps" description="Download all dependencies" unless="maven.mode.offline">
   <mkdir dir="${maven.repo.local}" />
   <get src="http://repo1.maven.org/maven2/org/apache/lucene/lucene-core/2.0.0/lucene-core-2.0.0.jar"
    dest="${maven.repo.local}/org/apache/lucene/lucene-core/2.0.0/lucene-core-2.0.0.jar"
    usetimestamp="true" ignoreerrors="true" />
</target>
</project>
主要修改了
<property name="tcjava" value="D:/tool/Terracotta/terracotta-2.6.4/bin/dso-java.bat"/>
修改为了自己的安装目录,同时,我的client用的是WINDOWS操作系统,所以用bat

修改配置文件tc-config.xml,文件内容如下:
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Note that logs for this demo are stored under your temporary directory
(for example, /tmp on Un*x-style systems), under a new, empty
directory each time this demo is run. Watch the program's startup
output; it will print out the name of the log file when it starts.
-->
<tc:tc-config xmlns:tc="http://www.terracotta.org/config">
<system>
    <configuration-model>development</configuration-model>
</system>
<servers>
    <server name="www.sillycat.com" host="www.sillycat.com">
    <dso-port>9510</dso-port>
   <jmx-port>9520</jmx-port>
   <data>terracotta/server-data</data>
   <logs>terracotta/server-logs</logs>
    </server>
</servers>
<clients>
    <logs>%d/client-logs-%h</logs>
    <dso>
      <debugging>
        <runtime-logging>
          <lock-debug>false</lock-debug>
        </runtime-logging>
        <runtime-output-options>
          <full-stack>true</full-stack>
        </runtime-output-options>
      </debugging>
    </dso>
    <modules>
      <module name="clustered-lucene-2.0.0" version="2.6.4"/>
    </modules>
</clients>
<application>
    <dso>
      <instrumented-classes>
        <include>
          <class-expression>org.terracotta.lucene.example..*</class-expression>
        </include>
      </instrumented-classes>
      <roots>
        <root>
          <field-name>org.terracotta.lucene.example.RAMDirectoryExample.clusteredDirectory</field-name>
        </root>
      </roots>
      <locks>
        <autolock>
          <method-expression>* *..*.*(..)</method-expression>
        </autolock>
      </locks>
    </dso>
</application>
</tc:tc-config>
主要修改了这个服务器地址:
<server name="www.sillycat.com" host="www.sillycat.com">
    <dso-port>9510</dso-port>
<jmx-port>9520</jmx-port>
<data>terracotta/server-data</data>
<logs>terracotta/server-logs</logs>
</server>
还修改了配置的版本
<module name="clustered-lucene-2.0.0" version="2.6.4"/>

编译源码mvn clean package
执行    ant run
可以开启多个CMD窗口执行,各个窗口(client)能共享数据。在公司部署了没有任何问题。
在家部署的就没有共享到。一样的环境。嘿嘿。不知道是不是JDK版本问题。继续查找原因中...

你可能感兴趣的:(eclipse,windows,SVN,ubuntu,Lucene)