All the Interesting ThingsThis is a personal web log. All information posted here does not represent my employer. I do not speak for my employer. |
|
Sunday Apr 19, 2009
Linux操作系统中JVM内存2GB的限制
有些客户反映在Linux操作系统中运行的Java应用,内存只能使用到2GB,在Java虚拟机中如果把-Xmx参数设置到2GB左右(实际约1.5-1.8GB),java进程就根本启动不了。我们通常使用的JVM都是32位的(64位的JVM会损失10-20%的性能,一般不建议使用),而32位应用程序的寻址空间应该是4GB才对,为什么在Linux上的JVM只能使用到2GB的内存呢? 经过和JDK研发组人员的沟通,终于弄清楚了一些相关的原因。这个问题存在于早期的一些Linux版本中,特别是内核2.5以前的版本,2.6以后的版本就基本上没有这个问题了。原来这些Linux版本对进程有个对内存2GB的限制,是一个地址连续的内存块大小的上限,而JVM的堆空间(heap size)需要连续的地址空间,因此,2GB就是java进程的理论使用的内存上限。 如果java应用需要使用较大的内存,建议使用较新版本的linux,或者修改Linux的应用/内核内存比配置为3GB:1GB。还有就是选择如Solaris等的UNIX操作系统。象Solaris这样的操作系统,在内存管理上没有2GB的限制,因此可以把heap size设置到3.5-3.6GB左右。 本文最早发表于这里:Linux操作系统中JVM内存2GB的限制 --------------------------------------------
Posted at 11:43PM Apr 19, 2009 by morningstar in Java |
Saturday Apr 18, 2009
Solaris 10中WebLogic 8.1应注意的最大文件数设置
最近,在Solaris 10上做了一些关于WebLogic的性能测试。测试的WebLogic版本为8.1SP6,虽然是个比较旧的版本,但这是客户的应用部署环境,所以需要在上面测试性能等指标。 在性能测试中,当应用服务器的压力加大时,由于并发连接数大,往往需要把操作系统允许的每个进程文件数加大。最常用的做法就是在/etc/system里面增加以下2行: set rlim_fd_cur=65535 set rlim_fd_max=65535 在重新启动操作系统后,就可以生效。另外可以用ulimit命令来设定该值,该命令无需重启系统,但在shell退出后就无效。 但是实际中却发现上述的文件句柄数目的调整对Weblogic 8.1SP6无效,日志中还是出现文件句柄不够的错误。用plimit命令观察Weblogic对应的java进程,发现它的文件句柄的上限仍然为1024。在使用下面命令之后,java进程的文件数上限才加大了: # plimit -n 65535,65535 [pid] 通过跟踪,我们发现WL8.1的启动脚本里面把文件句柄数限制为1024了!实在想不出为什么会有这么个限制,可能是WL8.1盛行的时代,机器硬件的处理能力低,1024个文件就够用了吧。如今,象T5440这类型超级CMT的机器,单个进程1024个文件的上限是远远不能发挥出系统的能力。更正这个缺陷也很简单,在WL8.1的目录里面,有一个commEnv.sh文件,它的最后一行是调用一个文件句柄数的功能,注释掉这行即可: #resetFd 本文最早发表于这里:Solaris 10中WebLogic 8.1应注意的最大文件数设置 Free Canadian Citizenship Test Posted at 06:50AM Apr 18, 2009 by morningstar in Java |
Sunday Feb 15, 2009
Storage 7000 (Amber Road) Automated CLI Tool
When I was working on a POC for a customer, I found that I needed a tool to change some configuration of a Storage 7000(aka Amber Road) device automatically. There are two kinds of interfaces provided by the Storage 7000: BUI and CLI. BUI is for a user to manage the device in a browser. S7000's CLI is a shell like command line interface. CLI can be accessed by a SSH client. The CLI is good way for repetitive administration tasks. However, there is one shortcoming on this CLI. Though Stroage 7000 has OpenSolaris as its OS, it does not allow administrators to access its underlying OS directly. Therefore, unlike other CLI interfaces, this is no way to start the S7000's CLI automatically on its OS. This implies we must login remotely(via SSH) to S7000 and then perform the CLI tasks. There is a tool called "Expect" can help us in automating the CLI tasks. However, it is written in Tcl and need to know some syntax of Tcl. It may also has cross platform issues. My customer did not know Tcl well. They also had a Java application that needed to invoke the CLI features. So I wrote a Java program to allow automatic execution of S7000's CLI commands. It can be used on any plaftform that supports Java, such as Solaris, Windows, Linux. This program basically connects to a S7000 via SSH and issues a sequence of pre-defined commands. The commands to send are contained in a text file. By running a script on a normal Solaris box, we can change the configuration of the S7000. Some examples of functions can be achieved by using this tool:
1) Enable/disable NFS/CIFS/FTP/HTTP services during a period of time in a day Here is an example of how to use this tool to disable ftp service on a SS7410(129.208.91.11). First we create a file called ftp.txt. The content of the file contains the commands we are going to issue to the SS7410: bash-3.0# cat ftp.txt ########################################## ## lines start with ## will be ignored ## ## disable ftp service ## ########################################## configuration services ftp disable commit Suppose the admin userid and password on the SS7410 is root/password, then on a remote Solaris machine, we run this tool as followed: bash-3.0# java -jar amberroad.jar 129.208.91.11 root password ftp.txt Connecting to 129.208.91.11 ... Authenticating with userName: root ... Connected to 129.208.91.11 ... Starting to send commands ... Last login: Fri Feb 13 23:00:35 2009 from 129.208.91.88 ss7410:> configuration services ftp ss7410:configuration services ftp> disable ss7410:configuration services ftp> commit ss7410:configuration services ftp> Connection closed. bash-3.0# Another advantage of this tool is that it can be integrated into a Java application. For example, my customer has a web page that allows a user to change his/her LDAP password. They modified their java code to update a local user's password in S7000 at the same time the LDAP password is changed. In this way, CIFS service can "authenticate" via LDAP user id. In my opinion, the next release of S7000 may need to consider a standard API( such as WS-RPC call, java api) for the ease of automated use of CLI. This tool can be downloaded here. JDK 1.5+ is support, and possibly works for JDK1.4 or 1.3.
Posted at 04:37PM Feb 15, 2009 by morningstar in Java | Comments[3]
Sunday Dec 07, 2008
JavaFX Demo Game: PAC MAN I recently spent some time in learning the JavaFX script programming. I was writing the classic game PAC MAN. Though it is still under development, 80% of the code is completed. People can play with it now. Source code will be released once I finish all the code. When I have more time, I will continue to work on it. Click on the below image or button to start playing:
Overall, I think the JavaFX SDK 1.0 had been improved from the preview version. Not only it includes bug fixes, but also it had increased performance.
See James Gosling's Blog on more of the launch of JavaFX 1.0 SDK. Posted at 12:15AM Dec 07, 2008 by morningstar in Java |
Sunday Jul 23, 2006
amadmin command line tool trick amadmin is a command line admin tool for Access Manager. We can use it to register or remove a service in AM. Normally, it takes a few seconds to remove a service in AM. However, when the number of entries in LDAP is very large( in my case, > 1 Million), the removal of a service became very slow. The slowness may be caused by the time needed to delete entries in LDAP, which is a very slow operation. So we took another approach. We first export the core data from the production DS. Then we replicate this environment in a testing machine. The testing machine now has the same config as the production machine, but less data entry. We then perform the remove/add operation on the testing machine. This are done pretty quick. After that, we export the data from test machine and import it into the production machine. Problem solved! Posted at 01:45AM Jul 23, 2006 by morningstar in Java |
Sunday Jun 11, 2006
Directoy Server Schema In a recent implementation, I found out that there is a good feature of DS. We have a customer that has two DS instances running as multi-master replicas. We wanted to add in some new schema/object classes to the LDAP. We orignally thought we need to configurate each instance. In an experiment, we found out that the schema change can be replicated from one instance to another. This means we don't need to make changes on both machines. I think this is good, but couldn't find this feature anywhere in the document. I will try to find out more on it. P.S.:
Thanks to Ludovic Poitou, I found it in the document, it contains the complete info:
Tags: LDAP, Directory Server
Posted at 12:18AM Jun 11, 2006 by morningstar in Java |
Friday Jan 06, 2006
Blog for LDAP and Access Manager I am building a blog for Access Manager and Directory Manager based on project experience. Hope to help people who need information. If you are interested in the content, please visit Directory Server and Access Manager Article list:
Find out the number of entries in a directory server Posted at 08:02AM Jan 06, 2006 by morningstar in Java |
Saturday Sep 10, 2005
NetBeans Workaround When I was delveoping a web application using NetBeans 4.1, I used the bundled JES App Server 8.1 PE version. I create the resources(like JDBC connection pool, etc) in the project and deloy the application to the bundled the App Server. In theory, NetBeans should be able to register/create the server resources in the App Server. Sometimes it failes without any reasons. So I suggest you create the resources mannually in the App Server's admin console. Another "got you" is the JNDI look up for server resources. For a JDBC data source, the document says it is like "java:comp/env/jdbc/something", but if you use this in your lookup java code, you will get an exception. The correct way is use only "jdbc/something". I don't know why, but it works at JES App Server PE 8.1 version.
Posted at 09:32AM Sep 10, 2005 by morningstar in Java | NetBeans bundled PE version admin password I installed NetBeans 4.1 with the bundled JES application server PE version. It has a default admin password. The last dialog window after the installation displays this password. But since I am very eager to use NetBeans, I just clicked "ok" without reading details of the dialog window. When I try to start the admin console of the PE version, it prompts me for the password. What it is? I don't know!! What can I do? After searching on web for some time, I finally figure out what it is. If you don't know, just see below:
admin user id: admin I suggest the installation program of NetBeans makes this more obvious to users during the installation process.
Posted at 09:20AM Sep 10, 2005 by morningstar in Java | |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||