Archive for 5月 2009

Glassfishのインストール

Hudsonを使いたいので、じゃあTOMCATを使うかー、と思っていたのだが。Hudsonのドキュメントを見ると

もう1つの方法として、Glassfish、Tomcat 5、JBossおよびJettyなどのServlet 2.4/JSP 2.0をサポートするサーブレットコンテナがあるなら、他のWARファイルと同様に hudson.war をデプロイすることもできます。

と、なんだかTomcatよりもGlassfishというのをいかにもお勧めで書いてある。
そもそもGlassfishとはなんぞや、とググるとどうやら開発コアメンバーっぽい人がGlassfishとTomcatの違いなんて記事を書いていた。

インストール

どうやらSunが気合い入れてるっぽいし、TOMCATじゃないのも触ってみたいなと思ったので導入することにした。

Glassfishの導入ページから、現時点の安定版のv2.1をダウンロードする。(ああ、wgetが面倒臭い・・)

wget http://java.net/download/javaee5/v2.1_branch/promoted/Linux/glassfish-installer-v2.1-b60e-linux.jar

ダウンロードしたらインストールします。

java -Xmx256m -jar glassfish-installer-v2.1-b60e-linux.jar

-Xmx256mの最大ヒープサイズ指定をしないと、OutOfMemmoryErrorで落ちます。

Accept or Decline? [A,D,a,d]

ライセンスについての説明が出るので同意する(Accept)の「A」を押すとファイルの解凍が始まります。
「installation complete」
と出たら、次にセットアップを行います。

cd glassfish
chmod -R +x lib/ant/bin
lib/ant/bin/ant -f setup.xml

設定はantでやるみたいなので、実行権限を与えてantを実行します。
「BUILD SUCCESSFUL」
と出たら設定成功です。

そしたら起動してみます。

/usr/local/glassfish/bin/asadmin start-domain domain1
Starting Domain domain1, please wait.
Default Log location is /usr/local/glassfish/domains/domain1/logs/server.log.
Redirecting output to /usr/local/glassfish/domains/domain1/logs/server.log
Domain domain1 is ready to receive client requests. Additional services are being started in background.
Domain [domain1] is running [Sun GlassFish Enterprise Server v2.1 (9.1.1) (build b60e-fcs)] with its configuration and logs at: [/usr/local/glassfish/domains].
Admin Console is available at [http://localhost:4848].
Use the same port [4848] for "asadmin" commands.
User web applications are available at these URLs:
[http://localhost:8080 https://localhost:8181 ].
Following web-contexts are available:
[/web1  /__wstx-services ].
Standard JMX Clients (like JConsole) can connect to JMXServiceURL:
[service:jmx:rmi:///jndi/rmi://%servername%:8686/jmxrmi] for domain management purposes.
Domain listens on at least following ports for connections:
[8080 8181 4848 3700 3820 3920 8686 ].
Domain does not support application server clusters and other standalone instances.

なんかApplicationServerがすでにあったら勝手に紐付してくれるようなメッセージだな・・・。

使用するポートは以下がデフォルトのようです。
(antでのbuildメッセージの最後に以下のようにメッセージが出ます)

create.domain:
     [exec] Using port 4848 for Admin.
     [exec] Using port 8080 for HTTP Instance.
     [exec] Using port 7676 for JMS.
     [exec] Using port 3700 for IIOP.
     [exec] Using port 8181 for HTTP_SSL.
     [exec] Using default port 3820 for IIOP_SSL.
     [exec] Using default port 3920 for IIOP_MUTUALAUTH.
     [exec] Using default port 8686 for JMX_ADMIN.

とりあえず、メインのポートが8080てのは、TOMCATとどこかで競合しそうなので、これを変更したいです。
この設定の変更はビルド後、以下ファイルで変更できます。

/usr/local/glassfish/domains/domain1/config/domain.xml

  <configs>
    <config dynamic-reconfiguration-enabled="true" name="server-config">
      <http-service>
        <access-log format="%client.name% %auth-user-name% %datetime% %request% %status% %response.length%" rotation-enabled="true" rotation-interval-in-minutes="15" rotation-policy="time" rotation-suffix="yyyy-MM-dd"/>
        <http-listener acceptor-threads="1" address="0.0.0.0" blocking-enabled="false" default-virtual-server="server" enabled="true" family="inet" id="http-listener-1" port="8080" security-enabled="false" server-name="" xpowered-by="true">
          <property name="proxiedProtocols" value="ws/tcp"/>
        </http-listener>

 

これの「8080」を「18080」に変更して再起動します。
「glassfish/bin/asadmin」のコマンドオプションが分からなかったので、ソースコードから追ってみたら、以下ファイルに記載があった。
glassfish\admin-cli\commands\src\java\com\sun\enterprise\cli\commands\CLIDescriptor.xml

って調べていたら「asadmin help」でヘルプが出ることに気づいた。
どちらにせよ、stop-domainしてstart-domainすればよさそうなので起動。

[root@%servername% bin]# ./asadmin stop-domain domain1
Domain domain1 stopped.

そしてスタートします。

[root@%servername% bin]# ./asadmin start-domain domain1
Starting Domain domain1, please wait.
Default Log location is /usr/local/glassfish/domains/domain1/logs/server.log.
Redirecting output to /usr/local/glassfish/domains/domain1/logs/server.log
Domain domain1 is ready to receive client requests. Additional services are being started in background.
Domain [domain1] is running [Sun GlassFish Enterprise Server v2.1 (9.1.1) (build b60e-fcs)] with its configuration and logs at: [/usr/local/glassfish/domains].
Admin Console is available at [http://localhost:4848].
Use the same port [4848] for "asadmin" commands.
User web applications are available at these URLs:
[http://localhost:18080 https://localhost:8181 ].
Following web-contexts are available:
[/web1  /__wstx-services ].
Standard JMX Clients (like JConsole) can connect to JMXServiceURL:
[service:jmx:rmi:///jndi/rmi://%servername%:8686/jmxrmi] for domain management purposes.
Domain listens on at least following ports for connections:
[18080 8181 4848 3700 3820 3920 8686 ].
Domain does not support application server clusters and other standalone instances.

これでなんとか起動した。

あと、iptablesを開ける設定とApacheと連携をしないといけないが、続く


CentOSでリモートGUI接続

sshでアクセス可能にはなったのだが、yumで取れないソフトウェアをサーバーにインストールするのが面倒臭い。
なぜなら、ssh接続ではroot権限の接続を許していないので、まず一般ユーザーでログインし、
(サーバーに)インストールするソフトウェアをクライアント(Windows)にダウンロードして
SCPでサーバーのホームディレクトリに転送し、サーバー側でsu – rootしてログインユーザーのホームディレクトリに移動して
対象ソフトウェアをchownなりchmodしたりしないといけないから。(面倒くさい・・・)
箇条書きにすると
(1)sshクライアントを起動して一般ユーザーでログイン
(2)クライアント側でブラウザを使用して目的のソフトウェアをダウンロード
(3)SCPクライアントを立ち上げて(1)のユーザーでログインし、(2)のソフトウェアをサーバーにアップロード
(4)(1)のsshクライアントでsu – rootする
(5)(3)でアップロードしたソフトウェアをchownやchmodしてインストール作業

これはやってみないとこの痒いとこに手が届かなさがわからないかもしれませんが・・・。

サーバー側でrootになってwgetでファイルを取得すればよいのかもしれないが、
URLを打ち込むのがどうも面倒臭い。またLynxというテキストベースのブラウザが
Linuxでは使用できるが、いちばん良いのはリモートからGUI環境を使用してFireFoxが使用出来れば簡単だ。

ということでリモートからGUI接続する設定をしたいと思います。

CentOS 5にはもともと「vnc server」というのが入っているのでまずはそれを起動させます。

[root@%servername% ~]# vncserver
 
You will require a password to access your desktops.
 
Password:
Verify:
 
New '%servername%:1 (yokoshima)' desktop is %servername%:1
 
Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/%servername%:1.log

さらに、このサーバの場合はiptablesが聞いているので、vncserverがどのポートで起動しているか確認して
そのポートを開けます。

[root@%servername% ~]# ps aux | grep vnc
root     12974  0.0  0.0   4984   772 pts/1    R+   17:20   0:00 grep vnc
root     26350  0.0  1.4  22104 14952 pts/1    S    16:30   0:00 Xvnc :1 -desktop %servername%:1 (yokoshima) -httpd /usr/share/vnc/classes -auth /root/.Xauthority -geometry 1024x768 -depth 16 -rfbwait 30000 -rfbauth /root/.vnc/passwd -rfbport 5901 -pn
root     26357  0.0  0.1   4268  1312 pts/1    S    16:30   0:00 vncconfig -iconic

この場合、5901番が空いているので、iptablesの設定をします。

#vnc設定
iptables -A INPUT -p tcp --dport 5901 -j ACCEPT_COUNTRY

#ACCEPT_COUNTRYは別関数で計算したIPアドレスのセットです。

vnc接続のためのパスワードを聞かれるので設定します。
そして、VNCクライアントをインストールしてアクセスしてみます。
VNCクライアントはtightvncにしてみました。
これで
%servername%:1を設定してアクセスします。

そして画面が出たのですが・・・FireFoxが使えるGUIではなかった。
しかもわざわざSSHでアクセスするように変更したのに、これだと単なるパスワード認証でアクセス出来てしまうので
中止しました。

vncserver -kill :1

ああ、やはり地道にやるしかないんだなぁ。


WP-Syntaxプラグインでを書く場合

先日の投稿で、phpのコードを書こうと思って以下のコードを書いたら

&lt;?php if(isset($wph))
    $wph-&gt;addHatena();

コードはWP-Syntaxプラグインを使用して表示しています。
>が&gt;等にエスケープされて表示されてしまっていましたが、
WP-Syntaxプラグインで以下のように指定すればも表示できることが分かりました。

<pre lang="php" escaped="true">
<?php if(isset($wph))
    $wph->addHatena();
    $wph->adddelicious();
    $wph->addLivedoor();
    $wph->addYahoo();
    $wph->addFC2();
    $wph->addNifty();
    $wph->addPOOKMARK();
    $wph->addBuzzurl();
    $wph->addChoix();
    $wph->addnewsing();
} ?> 
</pre>

初歩の初歩ってところですな。
あと、上記ではWP-Hatenaの設定をしているのですが、これがdel.icio.usにうまくブックマークされない現象がありました。
(del.icio.usの設定画面から遷移すると404画面になってしまう)
これはどうやらChromeの問題のようで、FireFoxからならば問題なく登録出来ました。