1. After pushed the change of the pom.xml (inside I changed the postgres driver from 1002 to 1003), the server become out of service. have to run rhc app restart fr to make it available (though for now what I see is still an "internal error".  but if I push the change of a Root.war, as I remember it always restart automatically!
-- Sam 07:48 10/07/2014

 又吓了俺一身冷汗@@
今晚上传到test环境,发现不能打开首页。修改了两个地方,然后好了。目前仍然不知道是哪个导致的。
  1. 恢复了.setting 下面的org.eclipse.wst.common.component 文件(不知怎么回事被编程一种短的方式了,幸好当时有注意到,留了!!!标志。很方便的找回了以前的版本,并换了回去,但commit时好像忘了maven编译工程以及清空tomcat了。上传后扔不能打开。
  2. 然后又把tomcat7回复到tomcat6.53.(感觉应该跟tomcat没有关系啊),然后maven编译+清空tomcat。再上传,所幸好了。
  3. 下次有时间看看到底是因为tomcat7的原因还是那个配置文件的原因。
  4. 这次感谢上帝,没有退层皮。
-- Sam 20:19 06/06/2017
 OpenShift瘦身新招(目前除了snapshot/restore以外,唯一管用的招数了:
  1. rhc ssh test      ( 这个test是Openshit中应用的名字)
  2. rm -rf *                (需要先进入到 /app-root/repo目录,删除所有文件)
  3. cd into /git/test.git
  4. rm -rf 目录或文件名                 (进入 /git 目录,尽量删除所有文件目录,最后发现有个目录删除不掉。原文这一步说忽略所有错误)
  5. git init --bare     (不能省略这一步,否则gitclone时会报错远端没有找到git库)
  6. git clone              (将得到一个警报,下载了一个空的项目。
  7. 将事先备份的文件的除.git以外的其他目录拷贝过去,rdt_doit.cmd然后commit,push
-- Sam 13:02 08/05/2017
 How to connect to openshift with bitVise?
1/打开BitVise,输入主机:mon-bookmark.rhcloud.com 
                                    端口:22
                                    用户名:一串死老长的纯数字(5749d7767628e17849000077),一直一个账号下的三个应用分别对应一个数子,按个他们三个程序对应的ssh用户名。
                                    initial method:没有关系啦,估计slot1 slot2都行,应为bitVise试了一个不行会自行试另外的。
2/因为Openshift的SSH连接不是用密码登陆机制,而是用证书,所以得生成个公私钥证书
              点击user keypair manager 连接,弹出对话盒中点击第一个按钮generate证书。
              随便起个名字,确定!
              对话盒中选中刚生成的证书,单击第二行的“导出”按钮。
      * 这里要注意,选择共有证书,并导出成第二个选项OPENSSH格式。到桌面文件名随意tobikilledAnyWay.txt
3/打开导出的文本文件,拷贝内容,
4/登陆Openshift,在第一个Application的连接旁边是settings按钮,点击看到很多pablickey已经在那儿了,那就再加一个吧。
5/好了,现在大家互相认识了吧?那就登陆吧:)
-- Sam 09:23 23/11/2016
How to rhc to open shift without switching useraccount?
   use rhc setup -l [email protected], then rhc will set a new key for this account if it's not there yet. then you can operate the apps under this account.
-- Sam 12:56 05/05/2017
 从头建一个项目:
  1. 把现有的mon app 删了,新申请一个fr应用。
  2. 选择jboss 1.0+tomcat6.0.
  3. git clone ssh://[email protected]/~/git/fr.git/ 把代码下到本地。
  4. 增加一个数据库。postgreSQL 9.2
  5.    Root User: adminv8u88f6
       Root Password: KU8R9jLNwpbP
       Database Name: fr
  6. Connection URL: postgresql://$OPENSHIFT_POSTGRESQL_DB_HOST:$OPENSHIFT_POSTGRESQL_DB_PORT
  7. 修改deploy下的database.properties.
    database.driverClassName=org.postgresql.Driver
    database.url=jdbc\:postgresql\://${OPENSHIFT_POSTGRESQL_DB_HOST}\:${OPENSHIFT_POSTGRESQL_DB_PORT}/fr
    database.username=adminv8u88f6
    database.password=KU8R9jLNwpbP
  8. 拷贝postgresql-9.2-1004.jdbc4.jar到Web-INFO/lib
  9. 确保roostrap在tomcat运行正常,然后用rdt.bat 编译项目
  10. 并把打包好的***.war 重命名成Root.war,拷贝到winapps目录下。(其实是打包时同时命名为Root.war).
  11. 删掉src目录,删掉pom.xml 增加一个.gitignore文件(一个内容为“target”的纯文本文件)
  12. commit and push!(第一次可能需要先调用git add webapps\ROOT.war, 然后再运行 git commit -a. linix下会打开nino,提示你输入注释,随便输入点东西,然后按ctrol+x退出即可)
  13. connect and modifi the text(256):connect with Bitvise SSH Client (it's better than putty ssh), then input "psql" to enter the command line client.
  14. ALTER TABLE textcontent alter content type text;  改变列的类型为不定长文本,注意“;”不能少,否则不work 
    1. the basice commands: \d:  list all tables    \d [tablename]   list structure of a table.
    2. \q 退出psql

======================================================================================================
注意!!!!

  1. 一定要认准Tomcat标记,如果选择的是JBoss的话,会看到deployments目录,而不是wepapps目录,那么发布方法就不灵了。
  2. Jar命令要求所有目录事先建好(现在开始实现新的测试要求,要通过dropbox把一个jar传到Acer电脑上去,结果发现dropbox中的all-TheBest对应的jar没有生成,今天在dropbox/BK目录下建立了all/webapps/目录,再跑rds,就好了。说明jar cvf %GIT_ALLTHEBEST_CN_DIR%\webapps\ROOT.war WEB-INF styles images命令需要所有的目录事先建立好。
  3. 为什么我们目前使用Tomcat6.0
    • 我们使用tomcat6 而不用tomcat7是因为select 组件在tomcat7+IE情况下不work,下拉菜单的pupup不显示,只能用上下箭头来调整选项。
    • 而用了Tomcat6,就不能使用EL2.2标准,只能用EL2.0规范。例如:不能用if(“xxx”.endwiths("yyy")),要用if(fn:endwiths("xxx","yyy))...
  4. 每当rhcloud上空间不够了,可以使用rhc snapshot restore来吧空间回复到初始状态,从而使git中的记录情况,达到瘦身额目的。但是在此之前,一定要记住先备份git目录下的bigbang.*数据库文件,否则就死翘了。

-- Sam 07:53 24/05/2015
 不能上传图片到Openshift问题的解决!
  1. 看log, 发现说nullimage/big_slid_1.jpg 文件找不到,说明File dest = new File(httpServletRequest.getSession().getServletContext().getRealPath("/") + "images/" + httpServletRequest.getParameter("position") + tFormat); 中的 httpServletRequest.getSession().getServletContext().getRealPath("/")返回的是null 或者“null”。
  2. 实验:new File("/resources/images/"...看能不能用相对路径建File对象。失败。
  3. ("../" + httpServletRequest.getParameter("position") + tFormat) 成功!文件被创建到了D:\Program Files\eclipse_BigBang\..\promotion_1.png, 即(D:\Program Files\promotion_1.png)。说明相对路径能够创建文件,但文件位置不靠谱----很怀疑以前bigbang hsql数据库文件的位置就是这个路径啊?
  4. 改为用OpenShift提供的系统变量来定位:OPENSHIFT_DATA_DIR。
    1. 首先把Window的系统变量增加一个OPENSHIFT_DATA_DIR(经测试,这个系统变量work,user变量不知道是不是也行)
    2. 在database.properties中仿照database.url声明一个database.image,值为${OPENSHIFT_DATA_DIR}
    3. 在applicationContext.xml中配置一个bean,其属性用${database.image}进行赋值。(注意不能在web-mvc.xml中进行定义,否则发现database.image值没有被代入。<property name="dataPath" value="${database.image}" />
    4. 声明一个ServerInfo类,是个POJO,里面就一个dataPath属性。
    5. 在pom.xml中增加          <!-- inject -->
              <dependency>
                  <groupId>javax.inject</groupId>
                  <artifactId>javax.inject</artifactId>
                  <version>1</version>
              </dependency>
    6. 在MainPagecontroller中注入并使用这个bean      @Inject
          private ServerInfo serverInfo;
  5. 注意,系统增加了变量,要重启windows才能生效的。
  6. 仍然没有成功,即使在本地也不能显示任何用绝对路径定义的图片:(,外加考虑到app snapshot restore时不知道data下面的数据能不能保的住,所以最终决定还是存到数据库里。
  7. 发现HSQL里存图片很不方便(最终也没有实验成功。)
  8. 发现PostgresQL中存图片非常方便,就是在Entity中定义一个byte[]属性,该属性被JPA识别并映射到数据库中新建立的byte[]字段,都不用修改数据库结构!
  9. <img src=""/>的src属性改成“getImage/<key值>"的形式,让图片通过controller获得。controller根据key值从数据库中取。效果很好,而且连初始化图片的动作都省了。
  10. 为防止用户上传超大图片,上传的图片进行了尺寸转换。上传gallery图片时,自动生成Thum小图片,但发现图片质量降低了很多,后来改用另一种写法(号称是high quality),效果果然好了。
-- Sam 07:25 08/07/2014

-- Sam 05:52 01/08/2014
Openshift中如何重新生成应用?
用Bitvise SSH Client登陆应用,备份git/[appname].git/[dbname].property、git/[appname].git/[dbname].scirpt、git/[appname].git/[dbname].log 和webapp/Root.jar文件到本地。
登陆Openshift网站,删除现有应用
选择Tomcat6+jboss1,新建一个应用,使用于删掉的应用同样的名字。
记下提示的git clone的命令(git clone ssh://[email protected]/~/git/my.git/
cd my/),从Dos进入到本地D:/documentj/bigbang/目录下,运行之。
进入新建的目录,删除其中的src目录和pom.xml文件,并将ROOT.jar文件拷贝到其中webapp目录下。
修改WorkLog中的ID信息, 修改putty中的信息ID
新打开Bitvise SSH Client工具,将id换成新的git clone命令中的前面的ID。登陆。备份git目录到本地(留待以后大了瘦身用),并将数据库文件上传到git/[appname].git/下。
在D:\Documents\bigbang\serverBK\fr下run: rhc snapshot save mon 再次备份(得到压缩文件为80K, 以防止光替换git达不到瘦身效果)。
Dos进入c:\x目录,运行rds_en.bat,发布程序并重启服务器。(我用rds_fr命令后程序显示空白,服务器上git目录没有明显变大。后来重新建立新程序,到这步用了手工commit和push,一切正常,所以下次如果再运行rds_fr效果有问题的话,要检查下这个脚本)(我其实这时又备份了git目录并用rhc snapshot save mon又备份里一次,这次看到的尺寸正常,为git目录21.5M,压缩文件64,418K。)
登陆OpenShift,为其增加cartridge。并将登陆信息网页另存到serverBK/fr/postgresDB目录下。
Dos命令下运行rhc cartridge-storage postgresql-8.4 -a mon --set 2增大空间
ping新的应用,记录下其IP。
打开godaddy,打开domain,点具体域名后面的lunch按钮,滚动到下方的DNS Manager区域,再点launch,修改对应的子域名的ip,并点击SaveZonefile(24小时后域名才能匹配到新的IP上)。
增加别名:rhc alias add my en.sharethegoodones.com
-- Sam 06:50 26/03/2015
 The way to lose weight for git on openshift
  1. The normal way is:
    1. you log onto server with Bitvise SSH Client, run quota -s to check the space left.(to make sure it's really necessary to do the losing weight work.
    2. you run command to back up current database, and copy it to local computer.
    3. you do rhc snapshot restore [appname] (make sure you've logged in with right user account into window)
    4. you do rhc git-clone[appname] to generate the local git repository (make sure the old folder with appname under gitspace is deleted first)
    5. you run rdt_[appnme] from c:\x to generate the new war file, and do local commit with gitGUI, then push to server.
    6. you run command to restore database with the one you just backed up.
  2. if you reset(hard mode) local master version to an old version (no matter you locally commit  new version or not),  you can not push any more. git push will report an error to tell you to do git pull first.
  3. while now you can still do git clone (tested with seafood). and then you can locally commit new war to the new cloned git reponsitory, and push.
-------------------(历史)-----------------------------
如何清理OpenShift上的空间占用
1)putty 登陆到应用,然后输入:quota -s 目前我的状态:
    block:1191M   limit:3072M
    files:2188        limit:40000
2)回到WindowDos窗口运行:
    rhc app tidy -a you(该命令进行git garbage collection will be run, log files will be rotated, etc. 应用重启)
3)再次进入putty ,运行quota -s 发现状态改善有限:
    block:1142M   limit:3072M
    files:1999        limit:40000
分析原因,可能是因为openShift对git有特殊的设置,导致无法进行高效压缩? 或者Git的Server库和本地库是不一样的东西?
  1/本地的Git库压缩后由256M变成了22.9M。
  2/而且压缩后object目录下内容消失,多了个pack目录,里面两个文件分别以idx(4k)和pack(23,445k)为后缀。
  3/压缩前如果直接删除object下目录,导致gitGui不能启动。压缩后删除pack文件,不影响git GUI启动,但commit时报错。

结论:
还是得重新建一个库,并在使用前对Git目录进行备份。等库变大了,就用备份的小库替换,或许能够保持库的尺寸。

补充:
担心这样做不行,我试验了用fr的original的git目录去替换en的git目录(hook目录不能删除,其他目录都删除并用original的替换了)
结果发现1)git push可以正常执行  2)git push 后程序重启时,下载了大量的lib jar,并显示编译失败。程序不能访问。 3)用putty登陆后运行quota -a发现已经使用的空间仍然是1GB多。
所以我怀疑替换Git行不通。(除非问题出在git不是自己原生的Git?)
如果不行,剩下的方法只有,rhc snapshot save/restore 了。然后最后一招还有重新建程序!

-- Sam 06:42 26/03/2015
Why when pushed the new code, the space used on server changes from 234M to 943M immediatly?
that's because you saved a lot of history on local, when you pushed onto server, all histery versions are uploaded to server too, that's why it's huge.  to resolve it, reset local history to an early version, do a commit with latest version (in this way, to make all middle version deleted), then push!(not sure this idea will work). a sure work solution is: 
  1. login and backup the db.
  2. run rhc snapshot restore [appname] to make server small.
  3. run rhc git-clone [appname] to get a brand new baby git reponsitory on local
  4. copy the latest version of war into webapp. and push.
  5. login and restore the db.
-- Sam 06:43 26/03/2015
Can we crate website at home?
1,从上网的公司,例如CIK申请固定ip
2,在网上申请域名,指向自己的ip
3,设置自己的计算机为服务器,简单的方法是直接下载XAMPP
4,配置自己的计算机为申请的那个ip
5,猫或者路由器设置ip自动指向你的计算机

---------------------------
好像记得有人说家里的固定IP不是真正意义上的固定IP,不能用来作为架设网站用。 这种说法比较靠谱,IP4那么稀缺,家里申请的话还不得贵的要死?
-- Sam 06:45 26/03/2015
if it true? they said if recreate an application in openshift, don't use the same name! if you use the save name, it will not be visitable when you recreate it. e.g. fr-bookmark.rhcloud.com was lead to a https://fr-bookmark.rhcloud.com/app
---------------------------------------
while I remember it's OK to create a new app with same name.
-- Sam 06:44 26/03/2015

Please click here to login and add comments! || automatically refresh content every seconds