Posted by at

2009年04月18日

再掲:OpenSim構築手順 (Linux版&OSGrid)

(2008年05月23日)OpenSimサーバ構築記録その1(Linuxに導入編)
http://pastel.slmame.com/e243880.html

1年ほど前に、OpenSimサーバ構築の記事を投稿しました。
でも、最近手順が微妙に変わっていて、うまくできないHELPメールを時々頂くようになりましたので、
簡単にまとめて書き直してみました。
それに閉じたSIMではつまらないので、ついでに、OSGridに接続する設定も。




● こんな手順になってます。

 1.設定値を決めておく
 2.パッケージのインストール
 3.MySQLデータベースの設定
 4.OpenSimソースコードのダウンロード
 5.OpenSimのコンパイルビルド
 6.OpenSim Standaloneモードで起動
 7.DBをSQLiteからMySQLに変更して起動
 8.DB内のテーブルを確認
 9.GridモードでOSGridに接続する
10.OpenSim用ファイアウォールスクリプトを作る



● 1.設定値を決めておく

 Ubuntuのバージョン:8.10
 ホスト名:ubuntu
 PCのグローバルIPアドレスを確認
 OpenSimのバージョン:0.6.4

 OSGridユーザ登録はこちらで。
http://osgrid.org/index/php?page=create&btn=4

 登録したファースト、ラストネーム、パスワードはOpenSimのリージョン設定ファイルでも指定します。


 OSGridマップの空きエリア座標XYの確認は、こちらで。
http://osgrid.org/index/index.php?&page=smodul&id=20&btn=20

 Simの名前、XY座標も、OpenSimのリージョン設定ファイル内で指定する事になります。


 UUID Generator
 OpenSimで複数リージョンを立ち上げる場合は、このサイトからUUIDを取得してもいいです。
http://www.famkruithof.net/uuid/uuidgen




● 2.パッケージのインストール

 (1) OpenSim構築に必要なパッケージのインストール

 root権限で、OpenSimのコンパイル・実行に必要なパッケージをインストールします。
 最近のバージョンから、libmono-oracleが必要になりました。
root:# apt-get  install  subversion
root:# apt-get  install  nant
root:# apt-get  install  libmono-microsoft8.0-cil  libmono-oracle2.0-cil ruby


 (2) MySQLデータベースのインストール

 MySQL5.0をインストールします。
 最近のMySQLは、インストールの途中でのroot管理者パスワードを設定する手順があります。
root:# apt-get  install  mysql-server




● 3.MySQLデータベースの設定

 (1) MySQLにログインします。
root:# mysql  -u  root  -p
Enter password:
mysql>


 (2) デフォルトのMySQLユーザアカウントを確認

 ユーザアカウントは、mysql.userテーブル内で設定されてます。
mysql> use  mysql;
Database changed

mysql> select  host,user,password  from  user;





 (3) userの無い、匿名アカウントは危険なので削除します。
mysql> delete  from  user  where  user='';
Query OK, 2 rows affected (0.11 sec)

mysql> flush  privileges;
Query OK, 0 rows affected (0.01 sec)

mysql> select  host,user,password  from  user;





 (4) データベース「opensim」の作成

 空のデータベース(データベース名:opensim)を作成します。
 データベース内のテーブルは、OpenSim起動時に自動的に作成されます。
mysql> create  database  opensim;
Query OK, 1 row affected (0.00 sec)

mysql> show  databases;



mysql> \q
Bye




● 4.OpenSimソースコードのダウンロード

 subversionコマンドで、リポジトリサイトからソースコードをダウンロードします。
 opensim構築は、一般ユーザー権限で作業します。
 脆弱性、セキュリティホールがあった場合、rootが所有者だと危険ですから。

 /home/foo/opensim/0.6.4/ ディレクトリ配下にインストールにします。

$ cd
$ mkdir  opensim
$ cd  opensim

opensim$
opensim$ svn  co  http://opensimulator.org/svn/opensim/tags/0.6.4-release  0.6.4

opensim$ cd  0.6.4
opensim/0.6.4$




● 5.OpenSimのコンパイルビルド

 (1) nant用のMakefileを作成します。 そのためのシェルスクリプト(runprebuild.sh)を実行します。
opensim/0.6.4$ ./runprebuild.sh

Creating Visual C# 2005 solution and project files
...Creating project: Prebuild


 (2) nantコマンドで、OpenSimをコンパイルします。 OpenSim本体は、bin配下にビルドされます。
opensim/0.6.4$ nant

BUILD SUCCEEDED
Total time: 161.6 seconds.

opensim/0.6.4$ cd  bin
opensim/0.6.4/bin$
 拡張子「.exe」のファイルがたくさんできます。




● 6.OpenSim Standaloneモードで起動

 (1) iniファイルのひな型をコピーします。
opensim/0.6.4/bin$ cp  OpenSim.ini.example  OpenSim.ini


 (2) iniファイルの物理エンジン(Open Dynamics Engine)の記述を有効にします。
;physics = basicphysics
physics = OpenDynamicsEngine


 (3) monoコマンドで、OpenSimを起動させてみます。
opensim/0.6.4/bin$ mono  OpenSim.exe


 (4) Sim情報の入力

 初回起動時にSim情報の入力を尋ねてきます。 あらかじめ、OSGrid用の値を入力しておきます。
 入力した値は、Region/defalut.xmlファイルに保存されます。
Region Name [OpenSim Test]: Simの名前
Grid Location (X Axis) [1000]:  OSGridマップで決めたX座標
Grid Location (Y Axis) [1000]:  OSGridマップで決めたY座標
Internal IP Address for incoming UDP client connections [0.0.0.0]: このまま
Internal IP Port for incoming UDP client connections [9000]:          このまま
External Host Name [127.0.0.1]:       OpenSIMを動かすPCのグローバルIPアドレス
First Name of Master Avatar [Test]:  OSGridに登録したファーストネーム
Last Name of Master Avatar [User]:   OSGridに登録したラストネーム
(Sandbox Mode Only)Password for Master Avatar account [test]: OSGridに登録したパスワード

 プロンプト(#)が表示されたらOK。
Currently selected region is Simの名前
22:38:53 - [STARTUP]: Startup took 0m 57s
Region (Simの名前) #


 (5) OpenSimをシャットダウンします。
Region (Simの名前) # shutdown




● 7.DBをSQLiteからMySQLに変更して起動

 (1) OpenSim.iniファイルをエディタで修正します。

 SQLiteの記述を無効(注釈)にして、MySQLの記述を有効にします。
 User ID は、root(MySQL管理者アカウント)
 Password は、rootのパスワードです。

; storage_plugin = "OpenSim.Data.SQLite.dll"
; storage_connection_string="URI=file:OpenSim.db,version=3";

storage_plugin="OpenSim.Data.MySQL.dll"
storage_connection_string="Data Source=localhost;Database=opensim;User ID=root;Password=パスワード;";

estate_connection_string="Data Source=localhost;Database=opensim;User ID=root;Password=パスワード;";

; asset_plugin = "OpenSim.Data.SQLite.dll"
asset_plugin = "OpenSim.Data.MySQL.dll" ; for mysql

asset_source = "Data Source=localhost;Database=opensim;User ID=root;Password=
パスワード;"

; inventory_plugin = "OpenSim.Data.SQLite.dll"
inventory_plugin = "OpenSim.Data.MySQL.dll"

inventory_source = "Data Source=localhost;Database=opensim;User ID=root;Password=
パスワード;"

; userDatabase_plugin = "OpenSim.Data.SQLite.dll"
userDatabase_plugin = "OpenSim.Data.MySQL.dll"

user_source = "Data Source=localhost;Database=opensim;User ID=root;Password=
パスワード;"

 DBへの接続文字列は、以前はmysql_connection.iniファイルに記述してましたが、
 最近はOpenSim.iniファイルに直接記述するようになりました。



 (2) 記述ミスさえなければ、問題なく立ち上がります。
opensim/0.6.4/bin$ mono  OpenSim.exe




● 8.DB内のテーブルを確認

 正常に起動できたら、データベース「opensim」の中身を確認してみます。
 SQLite内のデータが、MySQLに自動的に移行されています。
 Region/defalut.xmlファイルに記述したユーザアカウント情報も、データベースに登録されています。

opensim/0.6.4/bin$ mysql  -u  root  -p
Enter password:

mysql> use  opensim;
Database changed

mysql> show  tables;
mysql> select  username,lastname  from  users;





 閉じたネット環境で、テクスチャアップテストやSIM作りの勉強するなら、スタンドアロンモードで十分です。
 データベースも、MySQLに外出ししたので安心です。

 また、OSGridに登録したアカウント名を使っているので、Opensim.iniファイルを少し修正するだけで、
 すぐにOSGridに参加できます。




● 9.GridモードでOSGridに接続する

 OpenSim.iniファイルで、グリッドモードを有効にします。
 UGAIM(ユーザ・グリッド・アセット・インベントリ・メッセージ)サーバは、OSGridのサーバを指定します。

gridmode = true

asset_database = "grid"

grid_server_url = "http://osgrid.org:8001"
grid_send_key = "1234"
grid_recv_key = "1234"

user_server_url = "http://osgrid.org:8002"
user_send_key = "1234"
user_recv_key = "1234"

asset_server_url = "http://osgrid.org:8003"

inventory_server_url = "http://osgrid.org:8004"

messaging_server_url = "http://osgrid.org:8086"



 Hippo OpenSim Viewer初期画面にリージョンリストがあります。
 OpenSimを問題なく起動できたら、リージョンリストに登録されているのがわかります。
 OSGridホームページのマップにも表示されます。









● 10.OpenSim用ファイアウォールスクリプトを作る

 Linuxには、iptablesというファイアウォールのコマンドがありますので、OpenSim用のスクリプトを作ってみました。

 /etc/init.d/配下に、firewallという名前の空ファイルをつくります。
 所有者と実行権を与えます。
 update-rc.dコマンドで、firewallを有効にします。(/etc/rc2.d/配下にシンボリックリンクが作られる。)
root:# touch  /etc/init.d/firewall
root:# chown  root.root  /etc/init.d/firewall
root:# chmod  700  /etc/init.d/firewall
root:# update-rc.d  -f  firewall  defaults


 スクリプト「firewall」を記述します。
#!/bin/sh

# すべてのルールをクリアする
/sbin/iptables  -F
/sbin/iptables  -t  nat  -F
/sbin/iptables  -X
/sbin/iptables  -Z

# 全てのポリシー(パケット入力・出力・転送)を許可する
/sbin/iptables  -P  INPUT  ACCEPT
/sbin/iptables  -P  OUTPUT  ACCEPT
/sbin/iptables  -P  FORWARD  ACCEPT

# 引数に「clear」をつけて実行したら、スクリプト終了
if [ "$1" = "clear" ]; then
        exit
fi


# パケット入力を全て拒否する
/sbin/iptables  -P  INPUT  DROP

# ループバック(127.0.0.1)からの入力を許可する
/sbin/iptables  -A  INPUT  -i  lo  -j  ACCEPT

# 関連しているパケット、確立済みのパケットの入力は、必ず許可する
/sbin/iptables  -A  INPUT  -m  state  --state  RELATED,ESTABLISHED  -j  ACCEPT

# リモートメンテ用SSHのポートを開放する ( TCP/22)
/sbin/iptables  -A  INPUT  -p  tcp  -m  state  --state  NEW  --dport  22  -j  ACCEPT

# OpenSim用のポートを開放する
/sbin/iptables  -A  INPUT  -p  tcp  -m  state  --state  NEW  --dport  8001  -j  ACCEPT
/sbin/iptables  -A  INPUT  -p  tcp  -m  state  --state  NEW  --dport  8895  -j  ACCEPT
/sbin/iptables  -A  INPUT  -p  tcp  -m  state  --state  NEW  --dport  9000  -j  ACCEPT

# 1番目のリージョン用のポートを開放する(UDP/9000)
/sbin/iptables  -A  INPUT  -p  udp  --dport  9000  -j  ACCEPT

# 複数リージョンを立ち上げる場合は、通し番号でポート開放する
/sbin/iptables  -A  INPUT  -p  udp  --dport  9001  -j  ACCEPT
/sbin/iptables  -A  INPUT  -p  udp  --dport  9002  -j  ACCEPT


# 拒否されたINPUTパケットは、ログファイル(/ver/log/kern.log)に記録する
/sbin/iptables  -A  INPUT  -j  LOG  --log-prefix  '## UNDEFINED_INPUT ## '  --log-level=3


 本来はINPUTだけではなく、許可しないOUTPUTも拒否すべきなので、ちょっと手抜きのファイアウォールです。




● おしまい

 むかしはいくつも関連記事をダラダラ投稿しましたが、簡潔に書いたほうがわかりやすいですね。
 では、OSGridでお会いしましょう。 (って、ほとんど誰もいませんけど。。。 ^^;)  


Posted by ぱすてる at 19:33Comments(2)OpenSim

2008年12月07日

OpenSimサーバ構築記録10/OSX版MySQLで動かす

● データベースを、「SQLite」から「MySQL」に。

OpenSimインストール直後のデータベースは内蔵されているSQLiteです。
OpenSimをグリッドモードで公開するためには、MySQLにする必要があります。

まずは、スタンドアロンモードのままで、MySQLに切り替えてみました。

(使用しているOSは、前回と同じく、Mac OS X Leopard 10.5.5 です。)



● MySQLのダウンロードとインストール

MySQLの安定版、5.1を入れてみました。

mysql-5.1.30-osx10.5-x86.dmg
http://dev.mysql.com/downloads/mysql/5.1.html

(サンマイクロのロゴが、なんとも複雑な気分です。。。><)



途中で、ユーザ登録画面になりますが、登録不要の方は、その下にある
「私をダウンロードに連れてって」をクリックすればいいです。



パッケージをインストールします。
mysql-5.1.30-osx10.5-x86.pkg
MySQLStartupItem.pkg



途中で聞いてくる受信接続は、「許可」を選びます。
「システム環境設定」の「セキュリティ」でも、設定できます。



ペインファイルをインストールします。
MySQL.prefPane



MySQLの起動/停止画面が表示されます。



ペインファイルが、「システム環境設定」にインストールされました。





● ターミナルでも確認

MySQLは「/usr/local/」配下にインストールされます。
$ ls  /usr/local/
mysql@
mysql-5.1.30-osx10.5-x86/


「.profile」で、パスを通しておくと便利です。
$ cat  .profile
export  PATH="${PATH}:/usr/local/mysql/bin"
export  PKG_CONFIG_PATH="/Library/Frameworks/Mono.framework/Versions/Current/lib/
pkgconfig/:${PKG_CONFIG_PATH}"



プロセスが存在していることを確認します。
$ ps  -u  MySQL
  UID   PID TTY  TIME      CMD
   74  2325 ??    0:00.12 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql --log-error=/usr/local/mysql/





● MySQLの管理者アカウントの修正

MySQLに管理者権限でログインします。
パスワード無しでもログインできてしまいます。
$ mysql  -u  root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 140
Server version: 5.1.30 MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>


データベースの一覧を確認します。
mysql> show  databases;
+--------------------+
| Database
+--------------------+
| information_schema
| mysql
| test
+--------------------+
3 rows in set (0.00 sec)


今から操作するデータベースを「mysql」にします。
mysql> use  mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed


データベース「mysql」内の、テーブル一覧を表示します。
mysql> show  tables;
+---------------------------+
| Tables_in_mysql
+---------------------------+
| columns_priv
| db
| ・・・・・・・・・・
| ・・・・・・・・・・
| user
+---------------------------+
23 rows in set (0.00 sec)


テーブル「user」内の、管理者一覧を表示します。
userの無い匿名アカウントが2件あります。
全てのアカウントにパスワードがありません。
mysql> select  host,user,password  from  user;
+--------------------------------------+------+----------+
| host        | user         | password         |
+--------------------------------------+------+----------+
| localhost   | root     |          |
| マシン名    | root     |          |
| 127.0.0.1 | root     |          |
| localhost   |           |          |
| マシン名    |           |          |
+--------------------------------------+------+----------+
5 rows in set (0.00 sec)


匿名アカウント2件を、削除します。
mysql> delete  from  user  where  user='';
Query OK, 2 rows affected (0.00 sec)


管理者アカウント「root」に、全権限と、パスワードを登録します。
全て同じで、いいです。
mysql> grant  all  on  *.*  to  root@localhost  identified  by  'パスワード';
Query OK, 0 rows affected (0.00 sec)

mysql> grant  all  on  *.*  to  root@マシン名  identified  by  'パスワード';
Query OK, 0 rows affected (0.00 sec)

mysql> grant  all  on  *.*  to  root@127.0.0.1  identified  by  'パスワード';
Query OK, 0 rows affected (0.00 sec)


管理者一覧を、再確認。
パスワードはハッシュで暗号化されています。
mysql> select  host,user,password  from  user;
+--------------------------------------+------+-------------------------------------------+
| host        | user         | password         |
+--------------------------------------+------+-------------------------------------------+
| localhost   | root     | *B99937FFA12B418CF2216C5B84B899A343698672 |
| マシン名    | root     | *B99937FFA12B418CF2216C5B84B899A343698672 |
| 127.0.0.1 | root     | *B99937FFA12B418CF2216C5B84B899A343698672 |
+--------------------------------------+------+-------------------------------------------+
3 rows in set (0.00 sec)





● パスワードの確認と、データベース作成

MySQLに再ログインし、データベース「opensim」を作ります。
ログイン時には、パスワードが必要になってます。
mysql> quit
Bye

$ mysql  -u  root  -p
Enter password: ********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 548
Server version: 5.1.30 MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> create  database  opensim;
Query OK, 1 row affected (0.00 sec)

mysql> show  databases;
+--------------------+
| Database |
+--------------------+
| information_schema
| mysql
| opensim
| test
+--------------------+
4 rows in set (0.00 sec)


※データベース「opensim」内のテーブルは、OpenSim起動時に自動的に作成されます。




● データベース削除の方法

ちなみに、dropコマンドでデータベースを削除できます。
途中で失敗したら、何度でもやりなおせばいいです。
mysql> drop  database  opensim;





● OpenSim.iniファイルの修正

OpenSim.iniファイルの、SQLiteの記述部分をMySQLに変更します。
接続文字列が長いですけど、全て同じです。
パスワードを間違えないように。

【~/opensim/0.6.0/bin/OpenSim.ini】
[Startup]
gridmode = False

clientstack_plugin = OpenSim.Region.ClientStack.LindenUDP.dll

; ##
; ## STORAGE
; ##

;storage_plugin = OpenSim.Data.SQLite.dll
;storage_connection_string = "URI=file:OpenSim.db,version=3"
storage_plugin = OpenSim.Data.MySQL.dll
storage_connection_string = "Data Source=localhost;Database=opensim;User ID=root;Password=パスワード;"


estate_connection_string="Data Source=localhost;Database=opensim;User ID=root;Password=パスワード;"

;asset_database = "sqlite"
asset_database = "local"

see_into_this_sim_from_neighbor = True

; ##
; ## PHYSICS
; ##

meshing = ZeroMesher
;meshing = Meshmerizer
;physics = basicphysics
physics = OpenDynamicsEngine
physical_prim = True

startup_console_commands_file = "startup_commands.txt"
shutdown_console_commands_file = "shutdown_commands.txt"
serverside_object_permissions = False
storage_prim_inventories = True

; ##
; ## ScriptEngine
; ##

;DefaultScriptEngine = ScriptEngine.DotNetEngine
DefaultScriptEngine = XEngine

[StandAlone]
accounts_authenticate = False
welcome_message = "Welcome to OpenSimulator"

;asset_plugin = OpenSim.Data.SQLite.dll
asset_plugin = OpenSim.Data.MySQL.dll
asset_source = "Data Source=localhost;Database=opensim;User ID=root;Password=パスワード;"


;inventory_plugin = OpenSim.Data.SQLite.dll
inventory_plugin = OpenSim.Data.MySQL.dll
inventory_source = "Data Source=localhost;Database=opensim;User ID=root;Password=パスワード;"


;userDatabase_plugin = OpenSim.Data.SQLite.dll
userDatabase_plugin = OpenSim.Data.MySQL.dll
user_source = "Data Source=localhost;Database=opensim;User ID=root;Password=パスワード;"


dump_assets_to_file = False

[Network]
http_listener_port = 9000
remoting_listener_port = 8895
default_location_x = 1000
default_location_y = 1000
grid_server_url = http://127.0.0.1:8001
grid_send_key = null
grid_recv_key = null
user_server_url = http://127.0.0.1:8002
user_send_key = null
user_recv_key = null
asset_server_url = http://127.0.0.1:8003
inventory_server_url = http://127.0.0.1:8004
secure_inventory_server = true






● OpenSimを起動して、データベースを確認

iniファイルに間違いがなければ、問題なく起動するはずです。
$ mono  OpenSim.exe


データベース「opensim」を確認します。
テーブルが自動的に作成されています。
mysql> use  opensim;
Database changed

mysql> show  tables;
+-------------------+
| Tables_in_opensim |
+-------------------+
| agents
| assets
| avatarappearance
| avatarattachments
| estate_groups
| estate_managers
| estate_map
| estate_settings
| estate_users
| estateban
| inventoryfolders
| inventoryitems
| land
| landaccesslist
| migrations
| primitems
| prims
| primshapes
| regionban
| regionsettings
| terrain
| userfriends
| users
+-------------------+
23 rows in set (0.00 sec)


テーブル「user」を確認します。
一番最初に作ったユーザアカウントが、SQLiteから、MySQLにコピーされています。
mysql> select  username,lastname,passwordHash  from  users;
+----------+----------+----------------------------------+
| username | lastname | passwordHash
+----------+----------+----------------------------------+
| Master    | Parvathi   | 7e740d0406af6583543729a786bfd96a
+----------+----------+----------------------------------+
1 row in set (0.00 sec)





● つぎは、グリッドモードで

これでデータベースを外出しできたので、安心してもの作りができます。
OpenSimをアップグレードする時に、うっかりデータベースを上書きしてしまった〜
なんて、最悪ですから。
  


Posted by ぱすてる at 18:25Comments(1)OpenSim

2008年11月30日

OpenSimサーバ構築記録9(MacOSXコンパイル編)

● 久しぶりに、OpenSimの記事を。。。

MacOSXにOpenSimをコンパイルビルドしたのは随分前なんですけど、
その時のログを最近清書しましたので、アップします。

ここ(ソラマメ)では、コンソールでコマンドを叩くようなMacユーザさんは皆無に近いと思いますけど、
バイナリをダウンロードして実行するだけに物足りなさを感じてる方がおられましたら、
どうぞ参考にしてください。

使用しているOSは、
Mac OS X Leopard 10.5.5 です。




● OpenSimのソースコード入手

OpenSimソースコードの入手方法は、以下のURLに書かれています。
http://opensimulator.org/wiki/Download

ソースコードは、以下のURLにあります。
現時点では0.6.0-releaseが最新のようです。
http://opensimulator.org/svn/opensim/tags/





● ソースコードのダウンロード

「アプリケーション」ー>「ユーティリティ」フォルダにある「ターミナル」を起動します。



ホームディレクトリ直下に「opensim」フォルダを作成し、移動します。
(ターミナル起動直後は、ホームディレクトリにいます。)
Last login: Sat Nov 29 19:19:52 on console
$ mkdir  opensim
$ cd  opensim

svnコマンド(subversion)で、「0.6.0」フォルダ配下にチェックアウト(ダウンロード)します。
「0.6.0」フォルダは自動的に作成されます。
$ svn  co  http://opensimulator.org/svn/opensim/tags/0.6.0-release  0.6.0



(補足)
subversionは、レパード(10.5)以前には含まれていないので、別途インストールする必要があります。
Subversionの入手
http://www.collab.net/downloads/community/
http://www.moongift.jp/2008/06/versions/




● 必要なツールの入手

以下のURLを参考に、必要なツールをインストールします。
ただし、URLの内容は結構古いみたいでした。
http://opensimulator.org/wiki/Build_Instructions


(1) XCode Developers Tools

MacOS XのDVDから、開発環境XCodeをインストールします。



(2) X11

OpenSimのコンパイルには、X-Window(X11)が必要です。
レパード(10.5)では、標準でインストールされています。
(レパード以前の場合は、MacOS XのDVDから、X11をインストールします。)



(3-1) Mono Framework (.NET Framework互換環境)

Mono Frameworkの最新版パッケージを以下のサイトからダウンロードして、インストールします。
http://www.go-mono.com/mono-downloads/download.html




(3-2) 「大切な情報」

「大切な情報」には、インストールされるモジュール一覧やディレクトリが記載されているので、
保存しておくといいです。



(3-3) インストール先

monoは、「ライブラリ」ー>「Frameworks」配下にインストールされます。





● 環境変数の設定

ホームディレクトリ直下に、viエディタで「.profile」ファイルを作成し、環境変数PKG_CONFIG_PATHに
monoインストールディレクトリを追加をします。
「.profile」は、ターミナルを起動したときに読み込まれるファイルで、Windowsでいうところの
autoexec.batみたいなものです。
Last login: Sat Nov 29 20:43:07 on console
$ vi  .profile

この1行を追加
export  PKG_CONFIG_PATH="/Library/Frameworks/Mono.framework/Versions/Current/
lib/pkgconfig/:${PKG_CONFIG_PATH}"
※実際は1行です。




● 環境変数の確認

sourceコマンドで「.profile」ファイルを読み込んで、envコマンドで環境変数を確認します。
$ source  .profile
$ env

MANPATH=/usr/share/man:/usr/local/share/man:/usr/X11/man
TERM_PROGRAM=Apple_Terminal
TERM=xterm-color
SHELL=/bin/bash
TMPDIR=/var/folders/-D/-DI16ePMFTiqr7KoWIX9I++++TI/-Tmp-/
Apple_PubSub_Socket_Render=/tmp/launch-W2p5C3/Render
TERM_PROGRAM_VERSION=240
USER=technocore
COMMAND_MODE=unix2003
SSH_AUTH_SOCK=/tmp/launch-FpatMz/Listeners
__CF_USER_TEXT_ENCODING=0x1F5:1:14
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
PWD=/Users/technocore
LANG=ja_JP.UTF-8
SHLVL=1
HOME=/Users/technocore
LOGNAME=technocore

PKG_CONFIG_PATH=/Library/Frameworks/Mono.framework/Versions/Current/lib/pkgconfig/:
DISPLAY=/tmp/launch-EzhGOw/:0
SECURITYSESSIONID=6332d0
_=/usr/bin/env






● OpenSimのコンパイルビルド

「0.6.0」ディレクトリに移動します。
$ cd  opensim/0.6.0/

プレコンパイルスクリプト「runprebuild.sh」があることを確認します。
$ ls  *.sh
runprebuild.sh

Monoに含まれるコンパイルコマンド「nant」があることを確認します。
$ which  nant
/usr/bin/nant

$ nant  -v
NAnt 0.86 (Build 0.86.2898.0; beta1; 2007/12/08)
Copyright (C) 2001-2007 Gerry Shaw
http://nant.sourceforge.net

「runprebuild.sh」を実行します。
$ ./runprebuild.sh
Prebuild v2.0.3
Copyright (c) 2004-2008
.............
.............
Creating Visual C# 2005 solution and project files
...Creating project: Prebuild

正常終了したらメイクファイルが自動的に作成されるので、「nant」コマンドを実行するだけです。
$ nant
.............
.............
BUILD SUCCEEDED
Total time: 61.5 seconds.


「bin」ディレクトリ配下に各種ロードモジュール(exeファイル)が作成されたことを確認します。
$ cd   bin
$ ls  -1  *.exe
OpenSim.32BitLaunch.exe
OpenSim.Grid.AssetServer.exe
OpenSim.Grid.GridServer.exe
OpenSim.Grid.InventoryServer.exe
OpenSim.Grid.MessagingServer.exe
OpenSim.Grid.UserServer.exe
OpenSim.TestSuite.exe
OpenSim.exe
OpenSimExport.exe
Prebuild.exe
pCampBot.exe





● OpenSimの初回起動

monoコマンド経由で、OpenSim.exeを起動します。
初回起動時に訪ねてくる質問項目は、Returnキーで省略していいです。
$ mono  OpenSim.exe

02:02:00 - [LOADREGIONS]: Loading Region Info from filesystem
02:02:00 - [CONFIG]: Calling Configuration Load Function...
.............
.............
DEFAULT REGION CONFIG: Region Name [OpenSim Test]:
Parvathi
DEFAULT REGION CONFIG: Grid Location (X Axis) [1000]:
省略
DEFAULT REGION CONFIG: Grid Location (Y Axis) [1000]:
省略
DEFAULT REGION CONFIG: Internal IP Address for incoming UDP client connections [0.0.0.0]:
省略
DEFAULT REGION CONFIG: Internal IP Port for incoming UDP client connections [9000]:
省略
DEFAULT REGION CONFIG: External Host Name [127.0.0.1]:
省略
DEFAULT REGION CONFIG: First Name of Master Avatar [Test]:
Master
DEFAULT REGION CONFIG: Last Name of Master Avatar [User]:
Parvathi
DEFAULT REGION CONFIG: (Sandbox Mode Only)Password for Master Avatar account [test]:
********
02:03:48 - [CONFIG]: Calling Configuration Load Function...
.............
.............
02:10:20 - [!]:STARTUP COMPLETE
Currently selected region is root
02:10:20 - [STARTUP]: Startup took 0m 29s
Region (root) # :

プロンプトが表示されたら、起動成功です。
入力した項目は、Regions/default.xmlファイルに記録されます。

ヘルプの一覧を表示するには
Region (root) # :
help

OpenSimのシャットダウン
Region (root) # :
shutdown





● OpenSim.iniファイルの修正(物理属性を有効に)

デフォルトでは物理属性は無効になっています。
OpenSim.iniファイルで、物理エンジンを「ODE OpenDynamicsEngine」に変更します。
$ vi  OpenSim.ini
;physics = basicphysics (これをコメントにして)
physics = OpenDynamicsEngine (この行を追加)





● SLビューアの起動オプション(arguments)変更

OpenSim用のSLビューアを用意して、control+クリックします。



「パッケージの内容を表示」から「arguments.txt」ファイルを開いて、起動オプションを記述します。


-multiple  -loginuri  http://127.0.0.1:9000






● おしまい

今はMacOSXにMySQLデータベースをインストールして、OpenSIMをグリッドモードで起動する
手順を清書してます。 できたらアップしてみます。
(いつになるかわかりませんけど。。。。><)
  


Posted by ぱすてる at 16:10Comments(4)OpenSim

2008年09月07日

OpenSimサーバ構築記録8 (手作りファイアウォール編)

● OpenSimサーバがポートスキャンされてました。 わ~い。 ^^/

と、喜んでる場合ではないのですが、手作りのファイアウォールがしっかり働いている所を見るのは、
やっぱりはうれしいものです。
普通はルータでファイアウォールを構築するのが当然ですけど、
Linuxならファイアウォールのルールを一つずつ作り上げていく、という手作りの楽しみがあります。
ネットワークやTCP/IPの勉強にもなりますし。



● ポートスキャンされた記録

試験的に、スタンドアロンモードのOpenSimサーバを2ヶ月ほど公開してましたが、
8月10日の不正アクセスログの一部です。8000~10000のポート番号がスキャンされてました。

SRC=59.188.XXX.XXX   : アクセス元IPアドレス、APNICで調べたところ、59.188は香港です。
DPT=9000                    : アクセス先ポート番号、OpenSim Standaloneモードのポート番号です。

Aug 10 20:49:40 ns kernel: ## UNDEFINED_INPUT ## IN=eth0 OUT= SRC=59.188.XXX.XXX DST=221.999.999.999 LEN=48 TOS=0x00 PREC=0x00 TTL=128 ID=5039 DF PROTO=TCP SPT=3698 DPT=9000 WINDOW=65535 RES=0x00 SYN URGP=0

Aug 10 20:49:43 ns kernel: ## UNDEFINED_INPUT ## IN=eth0 OUT= SRC=59.188.XXX.XXX DST=221.999.999.999 LEN=48 TOS=0x00 PREC=0x00 TTL=128 ID=5041 DF PROTO=TCP SPT=3698 DPT=9000 WINDOW=65535 RES=0x00 SYN URGP=0

Aug 10 20:49:47 ns kernel: ## UNDEFINED_INPUT ## IN=eth0 OUT= SRC=59.188.XXX.XXX DST=221.999.999.999 LEN=48 TOS=0x00 PREC=0x00 TTL=128 ID=5044 DF PROTO=TCP SPT=3700 DPT=9000 WINDOW=65535 RES=0x00 SYN URGP=0

もちろんOpenSimを直接狙ったスキャンではないでしょうけれど、インターネットは危険がいっぱいです。
OpenSim自体にも必ず脆弱性・セキュリティホールはあるはずですから、セキュリティ対策は必要ですね~。



● Linuxカーネルのファイアウォール(Netfilter)の設定を確認

iptablesコマンドを使って、ファイアウォールの設定/確認ができます。
デフォルトで、3つのチェイン(ルールが繋がったもの)があります。

root@opensim1:~/bin# iptables -L

Chain INPUT (policy ACCEPT)
target     prot opt source     destination

Chain FORWARD (policy ACCEPT)
target     prot opt source     destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source     destination

INPUTチェイン       :カーネル空間に入ってくるパケットのルール
OUTPUTチェイン    :カーネル空間から出て行くパケットのルール
FORWARDチェイン :LANカード複数ざしの場合、パケットルーティングのルール

デフォルトでは、すべて許可(policy ACCEPT)になってます。
最近のLinuxはインストール時にGUIで設定できますけど、きめ細かい設定は、やっぱり
手作りが必要になってきます。





● 手作りファイアウォール(/etc/init.d/myfirewall.sh) B-Shell スクリプト

#!/bin/sh

#--------------------------------------------------------------------------------------------------
# シェル変数の設定:接続元(自分のパソコン)のIPアドレスを指定してます。
# スクリプト内では、$MYPCで参照できます。
#--------------------------------------------------------------------------------------------------
MYPC=999.999.999.999


#--------------------------------------------------------------------------------------------------
# チェインのクリア:ファイアウォールの設定を全て初期化します。
#--------------------------------------------------------------------------------------------------
iptables -F             # INPUT,OUTPUT,FORWARDチェインのクリア
iptables -F -t nat   # NATテーブルのクリア
iptables -X            # ユーザ定義チェインの削除
iptables -Z            # パケットカウントの0クリア


#--------------------------------------------------------------------------------------------------
# デフォルトポリシーの設定 : 全てのパケットの送受信を拒否(DROP)します。
#--------------------------------------------------------------------------------------------------
iptables -P INPUT       DROP
iptables -P OUTPUT    DROP
iptables -P FORWARD DROP


#--------------------------------------------------------------------------------------------------
# ユーザチェイン(SYNFLOOD)の作成 : SYNFlood/DoS攻撃チェック
# 「-N」でルールのサブルーチンを作ることができます。
# 短時間に大量のSYNパケット(一番目のパケット)が送られてきたら
# ログに記録して拒否します。
#--------------------------------------------------------------------------------------------------
iptables -N SYNFLOOD
iptables -A SYNFLOOD -m limit --limit 10/s --limit-burst 20 -j RETURN
iptables -A SYNFLOOD -m limit --limit 1/s --limit-burst 10 -j LOG --log-level=1 --log-prefix '## SYNFLOOD ## '
iptables -A SYNFLOOD -j DROP


#--------------------------------------------------------------------------------------------------
# INPUT/OUTPUTで許可(ACCEPT)する共通ルール(ステートフルパケットフィルタ)
# 許可したSYNパケット(一番目のパケット)に関係するパケットは、
# RELATED,ESTABLISHEDでまとめて表現して許可します。
#--------------------------------------------------------------------------------------------------
iptables -A INPUT    -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPT


#--------------------------------------------------------------------------------------------------
# INPUTチェイン1
# 自分自身(内部)からの受信「-i lo」は無条件で許可します。
# プロセス間の通信は無条件で許可します。
#--------------------------------------------------------------------------------------------------
iptables -A INPUT -i lo -j ACCEPT


#--------------------------------------------------------------------------------------------------
# INPUTチェイン2
# SYNフラグの立った第1パケット(--syn)は、SYNFLOODルールでチェックします。
# DoS(Deny of Service)攻撃と判断できたら拒否されます。
#--------------------------------------------------------------------------------------------------
iptables -A INPUT -p tcp --syn -j SYNFLOOD


#--------------------------------------------------------------------------------------------------
# INPUTチェイン3
# OpenSimサーバのメンテナンス/ファイル転送用にOpenSSH(TCP/22)を起動してます。
# 自分のパソコン($MYPC)から、(TCP/22)への接続(第一パケット --state NEW)を許可
# します。TelnetやFtpは暗号化しないのでパスワードや通信内容が丸見えです。
# なるべく使わないようにしましょう。
#--------------------------------------------------------------------------------------------------
iptables -A INPUT -i eth0 -p tcp -m state --state NEW -s $MYPC --dport 22 -j ACCEPT


#--------------------------------------------------------------------------------------------------
# INPUTチェイン (OpenSim用ポートの開放)
# スタンドアロンモード(9000)/グリッドモード(8002)どちらかを使い分けます。
# 一般開放していないので、接続元は自分のパソコン($MYPC)のみに限定。
# ちなみに、OpenSSHでポートフォーワードしているなら、上記TCP/22のみ
# 開放すればOK
#--------------------------------------------------------------------------------------------------
iptables -A INPUT -i eth0 -p tcp -m state --state NEW -s $MYPC --dport 8002 -j ACCEPT
iptables -A INPUT -i eth0 -p tcp -m state --state NEW -s $MYPC --dport 9000 -j ACCEPT
iptables -A INPUT -i eth0 -p udp                                  -s $MYPC --dport 9000 -j ACCEPT


#--------------------------------------------------------------------------------------------------
# INPUTチェイン (Ping, Traceroute用)
# ネットワークの疎通確認するときは有効にします。(普段はコメントにして拒否)
#--------------------------------------------------------------------------------------------------
#iptables -A INPUT -i eth0 -p icmp --icmp-type echo-request                  -j ACCEPT
#iptables -A INPUT -i eth0 -p icmp --icmp-type echo-reply                       -j ACCEPT
#iptables -A INPUT -i eth0 -p icmp --icmp-type destination-unreachable -j ACCEPT
#iptables -A INPUT -i eth0 -p icmp --icmp-type source-quench                -j ACCEPT
#iptables -A INPUT -i eth0 -p icmp --icmp-type time-exceeded                -j ACCEPT
#iptables -A INPUT -i eth0 -p icmp --icmp-type parameter-problem         -j ACCEPT


#--------------------------------------------------------------------------------------------------
# OUTPUTチェイン1
# 自分自身(内部)からの送信「-o lo」は無条件で許可します。
# プロセス間の通信は無条件で許可します。
#--------------------------------------------------------------------------------------------------
iptables -A OUTPUT -o lo -j ACCEPT


#--------------------------------------------------------------------------------------------------
# OUTPUTチェイン2
# インターネット上の、以下のサービスへのアクセスを許可します。
# HTTP(TCP/80)、HTTPS(TCP/443)、DNS(UDP/53)、TIME(UDP/123)
#--------------------------------------------------------------------------------------------------
iptables -A OUTPUT -o eth0 -p tcp -m state --state NEW --dport 80   -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp -m state --state NEW --dport 443 -j ACCEPT
iptables -A OUTPUT -o eth0 -p udp                                  --dport 53   -j ACCEPT
iptables -A OUTPUT -o eth0 -p udp                                  --dport 123 -j ACCEPT


#--------------------------------------------------------------------------------------------------
# Logに記録
# 上記ルールにマッチしない接続はカーネルログ(/var/log/kernel.log)に記録します。
#--------------------------------------------------------------------------------------------------
iptables -A INPUT    -j LOG --log-prefix '## UNDEFINED_INPUT ## '
iptables -A OUTPUT -j LOG --log-prefix '## UNDEFINED_OUTPUT ## '




● おしまい

まだまだ、鍛えるところはいっぱいありますけど、基本はこんなところでしょうか?
詳しい方がおられましたら、どんどん突っ込んでくださいませ~。 _O_

あ~、もうすぐ情報処理試験だ。TOEICも受けろと言われてるし、、
こんなことしてていいのか~。。><




【資料8.1】
OpenSim.iniファイル V0.5.8 -> V0.5.9差分


# diff OpenSim.ini.0.5.8 OpenSim.ini.0.5.9

28a29,32
> ; Maximum total size, and maximum size where a prim can be physical
> NonPhysicalPrimMax = 256
> PhysicalPrimMax = 10
>
45,54c49,51
<
< ; turn on experimental storage of prim inventories in the region database
<
< ; Prim inventory storage is now turned on by default
< ; However, this option remains in case it needs to be disabled
< ; More details of the current state of this can be found at
< ;
< ; http://opensimulator.org/wiki/OpenSim:Prim_Inventory_Persistence
< ;
< storage_prim_inventories = true
---
> ; If you want to use a different database/server for estate data, then
> ; uncomment and change this connect string. Defaults to the above if not set
> ; estate_connection_string="Data Source=localhost;Database=opensim;User ID=opensim;Password=*****;";
94a92,96
> allow_grid_gods = false
> ; This allows somne control over permissions
> ; please note that this still doesn't duplicate SL, and is not intended to
> ;region_owner_is_god = true
> ;parcel_owner_is_god = true
113,114c115,119
< ; This is the current and most stable ScriptEngine:
< script_engine = OpenSim.Region.ScriptEngine.DotNetEngine.dll
---
> ; This is the current ScriptEngine:
> script_engine = "OpenSim.Region.ScriptEngine.DotNetEngine.dll"
>
> ; This is the new XEngine
> ;script_engine = "OpenSim.Region.ScriptEngine.XEngine.dll"
117c122
< ;script_engine = OpenSim.Region.ScriptEngine.RemoteServer.dll
---
> ;script_engine = "OpenSim.Region.ScriptEngine.RemoteServer.dll"
129,130c134,135
< ; the Asset DB source. This only works for sqlite and nhibernate for now
< ; Asset Source SQLite Exampe
---
> ; the Asset DB source. This only works for sqlite, mysql, and nhibernate for now
> ; Asset Source SQLite example
132c137
< ; Asset Source NHibernate Example (DIALECT;DRIVER;CONNECTSTRING)
---
> ; Asset Source NHibernate example (DIALECT;DRIVER;CONNECTSTRING)
133a139,140
> ; Asset Source MySQL example
> ;asset_source = "Data Source=localhost;Database=opensim;User ID=opensim;Password=****;"
139c146
< ; Inventory Source NHibernate Example (DIALECT;DRIVER;CONNECTSTRING)
---
> ; Inventory Source NHibernate example (DIALECT;DRIVER;CONNECTSTRING)
140a148,149
> ; Inventory Source MySQL example
> ;inventory_source = "Data Source=localhost;Database=opensim;User ID=opensim;Password=****;"
148a158,159
> ; User Source MySQL example
> ;user_source = "Data Source=localhost;Database=opensim;User ID=opensim;Password=****;"
311a323,332
> ; ##
> ; ## Physics logging settings - logfiles are saved to *.DIF files
> ; ##
>
> ;physics_logging = true
> ;; every n simulation iterations, the physics snapshot file is updated
> ;physics_logging_interval = 50
> ;; append to existing physics logfile, or overwrite existing logfiles?
> ;physics_logging_append_existing_logfile = true
>
316a338,347
> ; the create_region XmlRpc call uses region_file_template to generate
> ; the file name of newly create regions (if they are created
> ; persistent). the parameter available are:
> ;   {0} - X location
> ;   {1} - Y location
> ;   {2} - region UUID
> ;   {3} - region port
> ;   {4} - region name with " ", ":", "/" mapped to "_"
>
> region_file_template = "{0}x{1}-{2}.xml"
326a358
>
330a363
> ;enabled = true ; you need to set this otherwise it won't connect
586a620,621
> ; Use the newer LSL to CS compiler (under test)
> UseNewCompiler = true
606c641
< AllowedCompilers = lsl
---
> AllowedCompilers = lsl,vb,js,cs
620c655,697
< AllowosConsoleCommand = false
\ No newline at end of file
---
> AllowosConsoleCommand = false
>
>
> [GridInfo]
>
> ; These settings are used to return information on a get_grid_info call.
> ; Client launcher scripts and third-party clients make use of this to
> ; autoconfigure the client and to provide a nice user experience. If you
> ; want to facilitate that, you should configure the settings here according
> ; to your grid or standalone setup.
> ;
> ; See http://opensimulator.org/wiki/GridInfo
>
> ; login uri: for grid this is the user server URI
> login = http://127.0.0.1:9000/
>
> ; long grid name: the long name of your grid
> gridname = "the lost continent of hippo"
>
> ; short grid name: the short name of your grid
> gridnick = "hippogrid"
>
>
> ; login page: optional: if it exists it will be used to tell the client to use
> ;            this as splash page
> welcome = http://127.0.0.1/welcome
>
> ; helper uri: optional: if it exists if will be used to tell the client to use
> ;            this for all economy related things
> economy = http://127.0.0.1:9000/
>
> ; web page of grid: optional: page providing further information about your grid
> about = http://127.0.0.1/about/
>
> ; account creation: optional: page providing further information about obtaining
> ;               a user account on your grid
> register = http://127.0.0.1/register
>
> ; help: optional: page providing further assistance for users of your grid
> help = http://127.0.0.1/help
>
> ; password help: optional: page providing password assistance for users of your grid
> password = http://127.0.0.1/password

  


Posted by ぱすてる at 11:14Comments(0)OpenSim

2008年08月03日

OpenSimサーバ構築記録その7(暗号化しなくちゃ編)


● きっかけ

私のボス: ところで、OpenSimって経路暗号化してるの?
    私: 普通のセカンドライフはSSLで暗号化してますけど、OpenSimは何もしてないです~。
    私: 設定はあるみたいですけど、やり方がよくわかりません><;
私のボス: じゃあ、とりあえず、SSHでトンネル掘って、OpenSimに繋がるか試してみたら?
    私: は~い。(´・ω・`)

というわけで、マイパソコンとOpenSimサーバをSSHのポートフォーワードで接続してみました。
今後OpenSimが普及する為には、やっぱり、暗号化とかセキュリティは必要ですよね~。




● SecondLifeはちゃんと、SSL(Secure HTTP)で暗号化してる(みたい)

パケットキャプチャソフトを起動して、ビューアでセカンドライフにログインしてみました。
マイパソコン(MyPC)と、ログインサーバ(login.agni.lindenlab.com)間のパケットのやり取りです。
キャプチャソフトのフィルタで、SSLのパケットだけ取り出してます。


09行目:MyPCです。こんにちは。SSLで話してます。
11行目:サーバです。こんにちは。TLSで話してます。
12行目:サーバです。TLSで会話しましょう。
14行目:MyPCです。鍵を交換しましょう。
15行目:サーバです。暗号化の方法をきめましょう。

、みたいなやり取りをしているのが、よくわかります。^^




● OpenSimは、暗号化していない?

実は、UserServer、MessagingServerを初めて起動するときに、SSLを使うかどうかたずねてくるのですが、、、

opensim1:/usr/local/opensim/0.5.8/bin# mono OpenSim.Grid.UserServer.exe
・・・・・・
・・・・・・
USER SERVER: Use SSL? true/false [False]:


opensim1:/usr/local/opensim/0.5.8/bin# mono OpenSim.Grid.MessagingServer.exe
・・・・・・
・・・・・・
MESSAGING SERVER: Use SSL? true/false [False]:


当然、これだけで暗号化できるわけありません。。 ><;
 ・ 暗号鍵はどうする?
 ・ サーバ証明書はどうする?
 ・ 認証局はどうする?

などなど、わからんことだらけです。。。
なので、OpenSimがSSLをサポートしていないなら、OpenSSHで経路を暗号化してみよう~、というワケです。




● OpenSSH (Secure SHell) の公開鍵方式で、経路の暗号化とポートフォーワードする

これは、普通のOpenSimへの接続図です。
グリッドモードなので、OpenSimサーバ側のポート番号は8002です。
暗号化されていないので、パケットの中身は丸見え状態です。 ><


OpenSSHを使うと、接続図はこうなります。
SSHで暗号化した経路を通って、OpenSimに接続します。
SLビューアの接続先は、OpenSimサーバではなく、MyPC(自分自身)、というところがミソです。
SSHがMyPCのポート18002に届いたパケットを、暗号化した経路を使って、OpenSimサーバに届けてくれます。
MyPCのWindows側は、PuTTYというSSHクライアントソフトを使ってます。

※ MyPC側のポート番号を18002にしているのは、キャプチャソフトで見分けやすくするためです。




● OpenSSHの設定 (OpenSimサーバ側)

ubuntuのapt-getコマンドで、OpenSSHをインストールします。

root@opensim1:~# apt-get install openssh-server


OpenSSHの設定ファイル(sshd_config)を修正します。 公開鍵認証のみを有効にします。

【/etc/ssh/sshd_config】
Protocol  2  #SSH2プロトコルを使用
PermitRootLogin  no  #Rootユーザのリモートログインを禁止
RSAAuthentication  no  #RSA認証(ssh1)を無効
PubkeyAuthentication  yes  #公開鍵認証を有効(ssh2)
PermitEmptyPasswords  no  #空パスワードを許可しない
PasswordAuthentication  no  #パスワード認証を無効





● SSHクライアント (MyPC Windows側)

Windows側は、定番のPuTTYを使います。 SSHが使えるターミナルソフトです。
鍵の作成には、PuTTYに付属している、Key Generator (puttygen.exe)を使います。




● 秘密鍵と公開鍵を作る

puttygen.exeを起動して、キャンバス上でマウスをグリグリ動かすと、乱数が発生して
自動的に鍵を作ってくれます。
パスフレーズを設定しておくと、接続時に聞いてくるので、より安全です。



「Save  public key」 id_dsa.pub という名前で公開鍵として保存します。 (OpenSim側に持って行く)
「Save private key」 id_dsa.PPK という名前で秘密鍵として保存します。 (MyPC側に保存)




● 公開鍵を変換して配置する (OpenSimサーバ側の作業)

puttygenコマンドで作成した公開鍵(id_dsa.pub)は、すこし形式が違うので、ssy-keygenコマンドで
OpenSSHが扱える形式に変換します。
配置する場所は、ホームディレクトリの「.ssh」ディレクトリ配下、鍵の名前は「authorized_keys2」、と決まってます。


opensim1:~$ ssh-keygen -i -f id_dsa.pub > /home/pastel/.ssh/authorized_keys2






● SSHクライアントPuttyの設定 (MyPC Windows側の作業)

【ポートフォーワードの設定】
ローカルポート18002への接続を、OpenSimポート8002へ転送します。



【秘密鍵の指定】
puttygen.exeコマンドで作った秘密鍵id_dsa.PPKを指定します。



【プロトコルの指定】
公開鍵方式だけを使うので、SSH2を指定します。



【接続開始】
接続先のホスト名と、接続先のポート番号(SSH:22)を指定して、接続開始。



【アカウント、パスフレーズの入力】
リモートターミナルが開くので、ログインアカウントと、公開鍵のパスフレーズを入力します。
ちゃんとリモートログインできたら、SSHでの接続は成功です。
このまま、OpenSimやLinuxの設定作業もできます。





● SLビューアのオプション変更

SLビューアの接続先とポート番号を、変更します。

【変更前】
SecondLife.exe -set SystemLanguage ja -loginuri http://opensim1:8002/


【変更後】
SecondLife.exe -set SystemLanguage ja -loginuri http://MyPC:18002/





● パケットの確認

ビューアでOpenSimにログインするときのパケットです。
全てのパケットが、SSHで暗号化(Encrypt)できました。






● おしまい

こんな風に高価なVPNルータなどなくても、個人で暗号化の実験が簡単にできてしまいます。
オープンソースはありがたいですね~。

いつかIBMとかが、仮想会議室や3Dショッピングモール、みたいなソリューションを出してくるでしょうから、
その頃はもっと簡単に暗号処理できるようになってると思います。
  


Posted by ぱすてる at 11:52Comments(4)OpenSim

2008年07月19日

OpenSimサーバ構築記録その6(ブレンダーで土地作り編)

● はじめに

OpenSimの基盤系やネット系の構築方法は大体理解できたので、
いいかげん、土地作りを勉強しないと。。。

Simオーナの皆様は、どんなツールで土地作りをしているのでしょう?

ここは、やっぱり使い慣れたブレンダーで作ってみました。




● Blenderで土地形状をつくる

スカルプじゃないので、頂点数とか気にせず、好き勝手にモデリングできますが、
とりあえず、練習なので基本的なピラミッド型を。(南米の階段ピラミッド風)

UV展開は、スカルプ作りでおなじみの手順です。

テクスチャは、XマップとYマップは不要です。 Z軸データをUV平面状にBakeすればいいので
Zマップのみ使えばいいです。

ちなみに、Blender 2.46 から、UVエディタに、トーンカーブツールが追加されました。
これが、UVテクスチャの調整に、なかなか役立つんですよ~ ^^

UVエディタで、256x256のイメージを作成して、BakeできたらPNG形式で保存します。






● 画像のアップロード

画像ファイルは、OpenSim.exeのある場所に、配置します。
( 私のLinuxの場合 )  /usr/local/opensim/0.58/bin/test-pyramid.png

OpenSimのコンソールから、terrainコマンドでロードします。(ロードの前に、fillオプションで平地にならします。)

Region# : terrain fill 10
Region# : terrain load test-pyramid.png


terrainコマンドはオプションがいっぱいあります。 勉強しよう。




● ど~ん、と出現

超巨大、ピラミッド型SIMのできあがりです~。 ^^;
でも、テクスチャが繰り返しでちょっと気になります。 Repeat数とか調整できるのかな?




だけど、これまたBlenderで、いろいろ遊べそうです。^^
シリンダーやスフィアなどイロイロなプリムを、Modifierのブーリアン演算で融合させて
いろんな形の土地を作ってみよう。
Sculp Paint モードも、土地作りに活用できますけど、タブレットがあったほうがいいかな。

それから、Blender以外の土地作りツールも捜そう。




【資料6.1】
terrainコマンド ヘルプ

Region# : terrain help


===Terrain===
* multiply - Multiplies the heightmap by the value specified.
* fill - Fills the current heightmap with a specified value.
* newbrushes - Enables experimental brushes which replace the standard terrain brushes.
        WARNING: This is a debug setting and may be removed at any time.
* elevate - Raises the current heightmap by the specified amount.
* lower - Lowers the current heightmap by the specified amount.
* load - Loads a terrain from a specified file.
* stats - Shows some information about the regions heightmap for debugging purposes.
* save - Saves the current heightmap to a specified file.
* load-tile - Loads a terrain from a section of a larger file.
* bake - Saves the current terrain into the regions revert map.
* effect - Runs a specified plugin effect
* revert - Loads the revert map terrain into the regions heightmap.

blender v2.46 Blender Foundation
  


Posted by ぱすてる at 00:07Comments(8)OpenSim

2008年07月08日

OpenSimサーバ構築記録その5(外部Simサーバ接続編)

● またまた間違いのお詫び (08.07.17)

この記事を読んでくださった方から、
「他サーバのOpenSimからつながりません。MySQLの接続不可のエラーがでます。」
と相談いただきました。
記事を読み返したら、肝心な2点を説明し忘れてました。。。。申し訳ない。  ><;

(1) MySQL設定ファイルmy.cnfで、外部からの接続を許可する。

 MySQLのデフォルトは、ローカル(127.0.0.1)のみから接続可、となってます。
 以下の項目をコメントにします。

 【/etc/mysql/my.cnf】

 (変更前)
 48: bind-address = 127.0.0.1

 (変更後)
 48: # bind-address = 127.0.0.1

(2) 外部から接続できるユーザアカウントを登録する

 SQLコマンドで、外部ユーザアカウント(+外部ホスト名)を、userテーブルに追加します。

 mysql> grant all on *.* to root@opensim2 identified by '********';



 修正後、MySQLの再起動をお忘れなく。




● タイトル変更 (08.07.08)

最初に、この記事を投稿したとき、タイトルを「グリッドサーバ間接続編」としたのですが、
よくよく仕組みを調べたら、グリッドサーバ同士を接続しているのではなく、
仮想サーバ2のOpenSimサーバのみをOpenSim1に接続しているのだと理解できました。
(仮想サーバ2で、UGAIサーバを動かす必要がなかった。。。。><;)
というわけで、タイトルを変更しました。
不適切なタイトルでゴメンナサイ。。。。_| ̄|○




● はじめに

VMWareを利用して、1台のPC内に複数の仮想PCを立てられる様になったので、
複数のOpenSimサーバでマルチレジョンを試してみました。

1台のPCで、マルチレジョンにするなら、bin/Regions/default.xmlを複数
作成するだけなのですが、やっぱり複数サーバどうしを接続していると、
OpenSimのネットワークを構築している、、という実感がして面白いです。




● 仮想サーバのネットワーク定義

【1台目の仮想サーバ】

① IPアドレス: 192.168.85.129/24

② ホスト名: opensim1

  /etc/hostsで定義してます。

③ OpenSim Region定義: bin/Regions/1000-1000.xml

  スタンドアロンの時から変更なし

   sim_name="OpenSim1"
   sim_location_x="1000"
   sim_location_y="1000"
   internal_ip_address="192.168.85.129"
   internal_ip_port="9000"
   external_host_name="opensim1

④ OpenSim定義:bin/OpenSim.ini

  変更なし




【2台目の仮想サーバ】

OpenSim1に接続します。

① IPアドレス: 192.168.85.130/24

② ホスト名: opensim2

③ OpenSim Region定義: bin/Regions/1001-1000.xml

   sim_name="OpenSim2"
   sim_location_x="1001"
   sim_location_y="1000"
   internal_ip_address="192.168.85.130"
   internal_ip_port="9000"
   external_host_name="opensim2

  ※ sim_UUIDは1台目のUUIDと競合しないように。
  ※ sim_locationは1台目と競合しないように。
  ※ internal_ip_portは、9000のままでいい。
    (1PCで複数Regionsを立てる場合は、競合しないように)

④ OpenSim定義: bin/OpenSim.ini

  ネットワークカテゴリで、opensim1を指定する。

  [Network]
  remoteDataPort = 20800
  grid_server_url = "http://opensim1:8001"
  user_server_url = "http://opensim1:8002"
  asset_server_url = "http://opensim1:8003"
  inventory_server_url = "http://opensim1:8004"




● ログで確認

 1台目のグリッドサーバのログには、2台目のopensim2が接続してきた事の記録が出力されてます。

 【bin/OpenSim.Grid.GridServer.log】

2008-07-06 21:14:39,021 INFO - [LOGIN BEGIN]: Received login request from simulator: OpenSim2
2008-07-06 21:14:39,029 DEBUG - [LOGIN]: Contacting http://opensim2:9000/simstatus/ for status of region OpenSim2
2008-07-06 21:14:39,081 INFO - [LOGIN END]: New sim login successful: OpenSim2





● VMWareの仮想グリッドに、ようこそ~

かなたに見えるのが、別サーバで動いているOpenSim2です。
次は、インターネット上のSIMともつないで見たいですね~。



でも、マメタンの様なSIMにはいいかげん見飽きてしまいました。^^;
土地造成や、画像から取り込む勉強をしよう。




● わかりません。 ><

検索とか、できないなぁ~
まだまだ、わからない事だらけです。。。


  


Posted by ぱすてる at 19:43Comments(0)OpenSim

2008年06月21日

OpenSimサーバ構築記録その4(Gridmode移行編)

● そのまえに

(http://opensimulator.org/svn/opensim/tags/)

OpenSim 0.5.8-releaseが出たので、緊張しながらアップデートしてみました。
MySQLデータベースとか移行できるかドキドキでしたが、ただコンパイルして、
default.xmlをコピーしただけで動いてしましました。 ヨカッタ。。。



● ポート TCP/8002の開放

Grid modeでは、SLビューワの接続先UserServerのポート番号は、TCP/8002なので、ファイアウォール起動シェル
に追加しました。

(/etc/init.d/myfirewall.sh)

/sbin/iptables -A INPUT -i $WANPORT -p tcp -m state --state NEW -s $TRUSTWAN --dport 9000 -j ACCEPT
/sbin/iptables -A INPUT -i $WANPORT -p udp -s $TRUSTWAN --dport 9000 -j ACCEPT
/sbin/iptables -A INPUT -i $WANPORT -p tcp -m state --state NEW -s $TRUSTWAN --dport 8002 -j ACCEPT


(補足)
myfirewall.sh は、私が組んだ自家製のFW起動用シェルスクリプトです。



● OpenSim.ini の修正

(http://opensimulator.org/wiki/OpenSim_Configuration)

とにかく、英語のサイトと格闘しながら、OpenSim.iniを、Grid mode用に変更しました。
あってるのかなぁ? まあ、とりあえず動いたし。 ^^;

(/usr/local/opensim/0.5.8/bin/OpenSim.ini)

5: gridmode = true
35: ; storage_plugin = "OpenSim.Data.Null.dll"  <--コメントにした
39: ;storage_connection_string="URI=file:OpenSim.db,version=3";  <--コメントにした
43: storage_plugin="OpenSim.Data.MySQL.dll"
44: storage_connection_string="Data Source=localhost;Database=opensim;User ID=root;Password=********;";
64: ;asset_database = "local"  <--コメントにした
65: asset_database = "grid"




● XEngine サポート

(http://opensimulator.org/wiki/XEngine)

OpenSim 0.5.8-releaseから、スクリプトエンジン(XEngine)がサポートされたので、追加してみました。
OpenSim.iniの[Startup]セクションに記述します。

(/usr/local/opensim/0.5.8/bin/OpenSim.ini)

116: ;Experimental remote ScriptServer plugin (does not currently work):
117: ;script_engine = OpenSim.Region.ScriptEngine.RemoteServer.dll  <--コメントにした
118: script_engine = OpenSim.Region.ScriptEngine.XEngine.dll  <--追加した


(補足)
知ったように書いてますが、何がどう良くなったのか、ぜんぜん調べてません。。。><



● サーバ起動の順番

Grid modeでは、次の順番で起動します。
正常に起動すると、コマンド入力待ち状態になり、コンソールをつかんでしまいますので注意です。

1.OpenSim.Grid.UserServer.exe
2.OpenSim.Grid.GridServer.exe
3.OpenSim.Grid.AssetServer.exe
4.OpenSim.Grid.InventoryServer.exe
5.OpenSim.exe



● 1.UserServerの起動

コンソールから、monoコマンドでUserServerを起動します。
途中の質問はとりあえず全てデフォルトですが、「Connection String for Databas」
には、MySQLへの接続コマンドを打ってみました。
ここを省略すると、./Regions/default.xmlを見に行きます。
どっちの方法がいいんだろう?

root@sv:/usr/local/opensim/0.5.8/bin# mono OpenSim.Grid.UserServer.exe

USER SERVER: Default Startup Message [Welcome to OGS]:
USER SERVER: Default Grid Server URI [http://127.0.0.1:8001/]:
USER SERVER: Key to send to grid server [null]:
USER SERVER: Key to expect from grid server [null]:
USER SERVER: Default Inventory Server URI [http://127.0.0.1:8004/]:
USER SERVER: DLL for database provider [OpenSim.Data.MySQL.dll]:

USER SERVER: Connection String for Database []:  <-- 省略しない
Data Source=localhost;Database=opensim;User ID=root;Password=********;

USER SERVER: Http Listener port [8002]:
USER SERVER: Use SSL? true/false [False]:
USER SERVER: Known good region X [1000]:
USER SERVER: Known good region Y [1000]:

20:40:12 - [REGION]: Establishing data connection
20:40:12 - [USERSTORAGE]: Attempting to load OpenSim.Data.MySQL.dll
20:40:12 - [USERSTORAGE]: Found 7 interfaces.
20:40:12 - Using obsoletely mysql_connection.ini, try using user_source connect string instead
20:40:12 - [MYSQL]: Connection established
20:40:12 - MIGRATION: Match: 001
20:40:12 - Resource 'UserStore' was not found
20:40:12 - [USERSTORAGE]: Added IUserData Interface
20:40:12 - [LIBRARY INVENTORY]: Loading library inventory
20:40:12 - [LIBRARY INVENTORY]: Loading libraries control file ./inventory/Libraries.xml
20:40:13 - [REGION]: Starting HTTP process
20:40:13 - [HTTPD]: Starting up HTTP Server
20:40:13 - [HTTPD]: Spawned main thread OK
20:40:13 - [SERVER]: Userserver 0.5 - Startup complete
Enter help for a list of commands

User# :  <-- コマンド入力待ちになったら(たぶん)OK.




● UserServerの初起動により、以下のファイルが作成されます。

./bin/UserServer_Config.xml
./bin/OpenSim.Grid.UserServer.log



● 起動途中の質問項目は、UserServer_Config.xmlファイルに記録されてました。

(/usr/local/opensim/0.5.8/bin/UserServer_Config.xml)

<Config default_startup_message="Welcome to OGS" default_grid_server="http://127.0.0.1:8001/"
grid_send_key="null" grid_recv_key="null" default_inventory_server="http://127.0.0.1:8004/"
database_provider="OpenSim.Data.MySQL.dll"
database_connect="Data Source=localhost;Database=opensim;User ID=root;Password=********;"
http_port="8002" http_ssl="False" default_X="1000" default_Y="1000" />




● 2.GridServerの起動

root@sv:/usr/local/opensim/0.5.8/bin# mono OpenSim.Grid.GridServer.exe

GRID SERVER: OGS Grid Owner [OGS development team]:
GRID SERVER: Default Asset Server URI [http://127.0.0.1:8003/]:
GRID SERVER: Key to send to asset server [null]:
GRID SERVER: Key to expect from asset server [null]:
GRID SERVER: Default User Server URI [http://127.0.0.1:8002/]:
GRID SERVER: Key to send to user server [null]:
GRID SERVER: Key to expect from user server [null]:
GRID SERVER: Key to send to a simulator [null]:
GRID SERVER: Key to expect from a simulator [null]:
GRID SERVER: DLL for database provider [OpenSim.Data.MySQL.dll]:

GRID SERVER: Database connect string []:  <-- 省略しない
Data Source=localhost;Database=opensim;User ID=root;Password=********;

GRID SERVER: Http Listener port [8001]:




● GridServerの初起動により、以下のファイルが作成されます。

./bin/OpenSim.Grid.GridServer.log
./bin/GridServer_Config.xml



● 3.AssetServerの起動

root@sv:/usr/local/opensim/0.5.8/bin# mono OpenSim.Grid.AssetServer.exe

ASSET SERVER: Default Startup Message [Welcome to OGS]:
ASSET SERVER: DLL for database provider [OpenSim.Data.MySQL.dll]:

ASSET SERVER: Database connection string []:  <-- 省略しない
Data Source=localhost;Database=opensim;User ID=root;Password=********;

ASSET SERVER: Http Listener port [8003]:



● AssetServerの初起動により、以下のファイルが作成されます。

./bin/AssetServer_Config.xml
./bin/OpenSim.Grid.AssetServer.log



● 4.InventoryServerの起動

なぜか、データベースのデフォルトが「SQLite」になってます。
よくわからないのですが、やっぱり、「MySQL」を指定した方がいいのかな?

root@sv:/usr/local/opensim/0.5.8/bin# mono OpenSim.Grid.InventoryServer.exe

INVENTORY: Default Startup Message [Welcome to OGS]:
INVENTORY: Default User Server URI [http://127.0.0.1:8002]:
INVENTORY: Key to send to user server [null]:
INVENTORY: Key to expect from user server [null]:

INVENTORY: DLL for database provider [OpenSim.Data.SQLite.dll]:
OpenSim.Data.MySQL.dll

INVENTORY: Database Connect String []:
Data Source=localhost;Database=opensim;User ID=root;Password=********;

INVENTORY: Http Listener port [8004]:




● InventoryServerの初起動により、以下のファイルが作成されます。

./bin/InventoryServer_Config.xml
./bin/OpenSim.Grid.InventoryServer.log



● 5.OpenSimの起動

これは、いつものとおり。

root@sv:/usr/local/opensim/0.5.8/bin# mono OpenSim.exe

23:20:01 - =========================================================
23:20:01 - ============== STARTING OPENSIM =========================
23:20:01 - =========================================================
23:20:01 - [OPENSIM MAIN]: Running in grid mode




● ログファイルを監視しましょう~

Linux(Unix)には、テキストファイルの末尾を表示するtailコマンドがありますが
「-f」オプションをつけると、ファイルの末尾に追加されるテキストデータを
リアルタイムに表示してくれるので、ログファイルの監視にとっても便利です。

OpenSim.Grid.UserServer.log
OpenSim.Grid.GridServer.log
OpenSim.Grid.AssetServer.log
OpenSim.Grid.InventoryServer.log
OpenSim.log

これら5つのログファイルを、まとめて監視してしまいます。
OpenSim.exe起動時や、ビューワログイン時に、UGAIサーバと連携する様子がコンソールに
出力されるので、参考になります。

root@sv:/usr/local/opensim/0.5.8/bin# tail -f *.log



● ビューワのポート変更を忘れずに

Grid mode は、TCP/8002、でしたね。

SecondLife.exe -set SystemLanguage ja -multiple -loginuri http://サーバ名:8002/



● つぎは

前回のMySQL移行に比べたら、今回はずいぶん簡単でした。(もちろんドキュメントはちゃんと読みましたけど)
つぎは、やっぱり、複数のSIMやRegion作りと接続ですね~。
VMWareの仮想ネットワークも準備できたし、いろいろ実験できそうです。
でも、夏に向けて熱暴走とか心配、それになんかエコによくない趣味だなぁ。。。。




【資料4.1】
OpenSim.iniファイル V0.5.7 -> V0.5.8差分

XEngine 定義が追加

447 [XEngine]
448: ; How many threads to keep alive even if nothing is happening
449: MinThreads = 2
450: ; How many threads to start at maximum load
451: MaxThreads = 100
452: ; Time a thread must be idle (in seconds) before it dies
453: IdleTimeout = 60
454: ; Thread priority ("Lowest", "BelowNormal", "Normal", "AboveNormal", "Highest")
455: Priority = "BelowNormal"
456: ; Maximum number of events to queue for a script (excluding timers)
457: MaxScriptEventQueue = 300
458: ; Stack size per thread created
459: ThreadStackSize = 262144
460: ; Rate to poll for asynchronous command replies (ms)
461: AsyncLLCommandLoopms = 50
462: ; Save the source of all compiled scripts
463: WriteScriptSourceToDebugFile = false
464: ; Default language for scripts
465: DefaultCompileLanguage = lsl
466: ; List of allowed languages (lsl,vb,js,cs)
467: AllowedCompilers = lsl
468: ; Compile debug info (line numbers) into the script assemblies
469: CompileWithDebugInformation = true
470: ; Allow the use of os* functions (some are dangerous)
471: AllowOSFunctions = false
472: ; Interval (s) between background save of script states
473: SaveInterval = 120
474: ; Interval (s) between maintenance runs (0 = disable)
475: MaintenanceInterval = 10
476: ; Time a script can spend in an event handler before it is interrupted
477: EventLimit = 30
478: ; If a script overruns it's event limit, kill the script?
479: KillTimedOutScripts = false
480: ; Allow OS console command functionality (VERY DANGEROUS!!)
481: AllowosConsoleCommand = false




【資料4.2】

Grid modeに移行したことで、データベース内のテープルが、15個になりました。



・テーブル名:land


・テーブル名:landaccesslist


・テーブル名:migrations


・テーブル名:primitems


・テーブル名:prims


・テーブル名:primshapes


・テーブル名:regions


・テーブル名:terrain

  


Posted by ぱすてる at 16:53Comments(10)OpenSim

2008年06月14日

OpenSimサーバ構築記録その3(VMWareで動かす編)


● Grid mode 勉強の準備

Standalone modeやMySQL連携の設定は理解できたので、次はGrid modeなのですが、
OpenSimが1台だけでは、いまいち盛り上がりません。
そんな時に、とても役立つのが、Webサイト構築の自己学習などで、以前からお世話になっている、
VMWare Workstationの出番です。


● WindowsXPで、OpenSim4台を動かす

XP上に、ubuntuで仮想サーバ2台、Debian/Gnu Linuxで仮想サーバ2台を作り、
Standalone modeで、OpenSim1~4を立ててみました。
プライベートアドレスの仮想ネットワークでOpenSim4台と、XPがつながっています。
グリッドモードのUGAI(User, Grid, Asset, Inventory)サーバがPC1台で作れてしまいます。 ^^




● 実際は、テキストモードで。

最初の画像はGUIモードで見栄えよく見えますど、サーバ専用なのでGUIはメモリやCPUを浪費
するだけで、実は無駄。 次の画像のようにテキストモードで起動させれば十分です。




● リソースの消費状況

仮想OS4台に、それぞれ 「たった」256MB割り当ててます。
4台合わせても1GBメモリで動いてますので、UGAI+Simの5サーバが余裕で起動できます。
仮想OSがWindowsだったら、こうはいきません。
やっぱり、Linuxは軽くてエコなOSです。 ^^




● スナップショットは強い味方

仮想OSの現在の状態を、名前をつけてハードディスクに保存できる、VMWareのスナップショット。
OSの改版作業の前にスナップショットしておけば、ミスして起動しなくなっても
元に戻せるので安心して作業できます。
どれだけスナップショットのお世話になった事か。。^^;




VMWareには、フリーソフトの「VMWare Player」がありますが、やっぱりこちらが重宝します。
約190$の価格ですけど、持っていて損はしません。

VMWareは30日限定の評価版が配布されていますので
興味のある方はぜひ試してみてください。
https://www.vmware.com/tryvmware/login.php?eval=workstation-w





【資料3.1】 Debian/Gnu Linuxでの、OpenSimコンパイルエラー対処

Debian/Gnu Linux 4.0 (Etch)の安定版(Stable)で、配布されている「nant」は
バージョンが古く、OpenSimコンパイル時にエラーがでます。

リポジトリ定義ファイルを変更し、テスト版(unstable)の「nant」をインストールします。

「/etc/apt/sources.lst」

(安定版定義を無効にする)
# deb http://ftp.nara.wide.ad.jp/debian/ etch main
# deb-src http://ftp.nara.wide.ad.jp/debian/ etch main

(テスト版定義を作成する)
deb http://ftp.nara.wide.ad.jp/debian/ unstable main
deb-src http://ftp.nara.wide.ad.jp/debian/ unstable main

この設定で、apt-getコマンドで、nantやmono関連をインストールする。




【資料3.2】 ubuntu起動時の、GUIモード/テキストモードの切り替え

● gdm(グラフィカルディスプレイマネージャ)の起動シェルを削除する

root@opensim1:~# update-rc.d -f gdm remove

Removing any system startup links for /etc/init.d/gdm ...
  /etc/rc0.d/K20gdm
  /etc/rc1.d/K20gdm
  /etc/rc2.d/S20gdm
  /etc/rc3.d/S20gdm
  /etc/rc4.d/S20gdm
  /etc/rc5.d/S20gdm
  /etc/rc6.d/K20gdm

● gdm を有効にする

root@opensim1:~# update-rc.d gdm defaults

Adding system startup for /etc/init.d/gdm ...
  /etc/rc0.d/K20gdm -> ../init.d/gdm
  /etc/rc1.d/K20gdm -> ../init.d/gdm
  /etc/rc6.d/K20gdm -> ../init.d/gdm
  /etc/rc2.d/S20gdm -> ../init.d/gdm
  /etc/rc3.d/S20gdm -> ../init.d/gdm
  /etc/rc4.d/S20gdm -> ../init.d/gdm
  /etc/rc5.d/S20gdm -> ../init.d/gdm




【資料3.3】 インストーラのバグ? (keymap配列異常)

私のパソコンでは、英語キーボード(PC101)を利用しているので、ubuntuインストール時に
英語キーボードを選択しました。
なのに、ubuntuをGUIモードで起動したら、keymapが日本語に。 記号が打てない~ ><

X Window Systemの設定ファイルを確認したら、レイアウトは「US」なのに、モデルが
日本語キーボードになってる。。 ーー;

「/etc/X11/xorg.confファイル」

Section "InputDevice"
 Identifier "Generic Keyboard"
 Driver   "kbd"
 Option   "XkbRules"  "xorg"
 Option   "XkbModel"  "jp106" <-- おかしい
 Option   "XkbLayout"  "us" <-- あってる
EndSection

【修正後】
 Option   "XkbModel"  "pc101"




【資料3.4】 VMWare Workstation 6 での、仮想マシン作成手順

















※ NATモードにすると、XPがNAT(NAPT)変換するブロードバンドルータの役目になります。
※ Bridgedモードにすると、仮想OSにグローバルIPアドレスを割り当てて、直接外部に公開できます。














※ 仮想CDROMデバイスにISOイメージファイルを指定することで、CDROM装置に
  インストールCDが挿入されているのと同じ意味になります。




※ これで、仮想マシンのできあがり。 CDROMにはubuntuのインストールディスクが
  挿入されている状態です。




※ 電源ボタンを押すと、ISOイメージのCDROMから起動します。
  


Posted by ぱすてる at 18:53Comments(0)OpenSim

2008年06月06日

OpenSimサーバ構築記録その2(MySQL移行編)


● まえがき

OpenSimのデータベースは、内蔵されているSQLiteがデフォルトなんですが、
グリッドモードで動かす為にも、データベースをMySQLに変更する必要があります。
英語のサイトと格闘しながらも、意外と苦労せず動いてしまいました~。 ^^

また、OpenSimは、今日現在最新の、0.5.7-releaseで動作確認しました。
環境ファイルOpenSim.iniファイルを確認すると、ODE(Open Dynamics Engine)物理や、LSL
関連のパラメタが、前回のVer0.5.6からずいぶん増えているので、今後が楽しみです。 ^^



● 手順書を確認

教えて君にならないように、説明書はちゃんと読みます。

 【OpenSim Database support】
 http://opensimulator.org/wiki/OpenSim_Database_support

 【MySQL configuration】
 http://opensimulator.org/wiki/Mysql-config

 【Mysql-config example】
 http://opensimulator.org/wiki/Mysql-config_example



● Mysqlサーバ Ver5.0 のインストール

(1) ubuntuインストール時には指定しなかったので、パッケージ指定で、MySQLをインストールします。

root@sv:~# apt-get install mysql-server-5.0



(2) MySQLサーバの、起動用シェルスクリプトの確認

MySQL起動用シェル本体は、/etc/init.d/ 配下に、自動的に作成されます。

root@sv:~# ls /etc/init.d/mysql*
/etc/init.d/mysql* /etc/init.d/mysql-ndb* /etc/init.d/mysql-ndb-mgm*

起動用シェル本体のエイリアス(ショートカット)が、ランレベル2起動用のディレクトリ/etc/rc2.d/
配下に、自動的に作成されます。

root@sv:~# ls /etc/rc2.d/*mysql*
/etc/rc2.d/S17mysql-ndb-mgm@ /etc/rc2.d/S18mysql-ndb@ /etc/rc2.d/S19mysql@

ubuntu(Debian/Gnu Linux系OS)は、通常、GUIモード、テキストモードにかかわらず、
ランレベル2なので、OS起動時に、/etc/rc2.d/配下のシェルスクリプトが実行されます。
(ちなみに、RedHat系Fedora、CentOS等は、テキストモードがランレベル3、GUIモードが
ランレベル5、ですね。)



● MySQLサーバ Ver5.0 の起動確認

(1) MySQLのインストールに問題なければ、自動的に起動しています。

root@sv:~# ps ax | grep -i mysql
5056 ?  S   0:00 /bin/sh /usr/bin/mysqld_safe
5098 ?  Sl  0:02 /usr/sbin/mysqld



● MySQLサーバ Ver5.0 の管理者(root)権限設定

MySQLインストール直後のユーザ権限は、
 ・アノニマスユーザが有効になっている。
 ・rootで、パスワード無しでログインできる。
と、問題だらけです。

MySQLにログインして、SQL文を発行します。(パスワード無しでログインできる。。。><)

root@sv:~# mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 5.0.51a-3ubuntu5 (Ubuntu)


mysql> select host,user,password from mysql.user;





(1) 全てのRootユーザにパスワードと権限を設定し、アノニマスユーザを削除します。

mysql> grant all on *.* to root@localhost identified by '********';
mysql> grant all on *.* to root@sv identified by '********';
mysql> grant all on *.* to root@127.0.0.1 identified by '********';

mysql> delete from mysql.user where user='';

mysql> flush privileges;



(2) 設定の確認

mysql> select host,user,password from mysql.user;



【補足】
 画面のパスワードは、ハッシュで暗号化されたものが表示されています。



(3) これで、パスワード無しでMysqlにログインできません。

root@sv:~# mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)



● データベースの作成

(1) 手順書にしたがって、SQLのcreateコマンドで、データベース(データベース名:opensim)を
  作成します。

mysql> create database opensim;
mysql> show databases;



【補足】
データベースで日本語データを扱う場合は、文字コードを指定する事が多いです。
mysql> create database データベース名 default character set utf8;



(2) テーブルは?

データベース内のテーブルはどうするんだ~?、というわけで、README.txtを読むと、
テーブルは、OpenSim起動時に自動的に作成されますよ。
と、書いてありました。 とりあえず、信じよう。

 【/usr/local/opensim/0.5.7/share/sql/mysql_README.txt】
 This directory used to contain sql files for mysql that needed to be manually sourced in order to
 set up the database tables required by OpenSim. This is no longer necessary - OpenSim now
 sets up these tables automatically.

 All you need to do is create the database that OpenSim is to use and set the configuration in
 bin/mysql_connection.ini (using bin/mysql_connection.ini.example as a reference).



● MySQL接続用環境ファイルの作成

(1) 環境ファイルのひな型が用意されているので、コピーして、viエディタで修正します。

root@sv:/usr/local/opensim/0.5.7/bin# cp mysql_connection.ini.example mysql_connection.ini
root@sv:/usr/local/opensim/0.5.7/bin# vi mysql_connection.ini

 【mysql_connection.ini】
 hostname=localhost
 database=opensim
 username=root
 password=******** <- パスワードを合わせる
 pooling=false
 port=3306



● OpenSim環境ファイルの修正

(1) OpenSim.iniは、インストール直後は、SQLiteの設定になってます。
  SQLiteの設定部分を無効(コメント化)にして、MySQLの設定部分を有効にします。

 【OpenSim.ini】
 ; asset_plugin = "OpenSim.Data.SQLite.dll"  (無効にする)
 asset_plugin = "OpenSim.Data.MySQL.dll" ; for mysql  (有効にする)
 ; inventory_plugin = "OpenSim.Data.SQLite.dll"  (無効にする)
 inventory_plugin = "OpenSim.Data.MySQL.dll"  (有効にする)
 ; userDatabase_plugin = "OpenSim.Data.SQLite.dll"  (無効にする)
 userDatabase_plugin = "OpenSim.Data.MySQL.dll"  (有効にする)



● さぁ、OpenSimの実行~。。。。。起動しませんでした。_| ̄|○

root@sv:/usr/local/opensim/0.5.7/bin# mono OpenSim.exe

14:26:20 - [ASSET SERVER]: Starting asset storage system
14:26:20 - [SQLAssetServer]: AssetStorage: Attempting to load OpenSim.Data.MySQL.dll
[APPLICATION]:
APPLICATION EXCEPTION DETECTED: System.UnhandledExceptionEventArgs
Exception: System.Exception: Error initialising MySql Database:
System.Exception: Connection error while using connection string
[Server=localhost;Port=3306;Database=opensim;User ID=root;Password=********;Pooling=false;]
---> System.NotSupportedException: CodePage 1252 not supported
 at System.
Text.Encoding.GetEncoding (Int32 codePage) [0x00000]
 at MySql.Data.MySqlClient.Driver..ctor (MySql.Data.MySqlClient.MySqlConnectionStringBuilder settings) [0x00000]
 at MySql.Data.MySqlClient.NativeDriver..ctor (MySql.Data.MySqlClient.MySqlConnectionStringBuilder settings) [0x00000]
 at MySql.Data.MySqlClient.Driver.Create (MySql.Data.MySqlClient.MySqlConnectionStringBuilder settings) [0x00000]
 at MySql.Data.MySqlClient.MySqlConnection.Open () [0x00000] --- End of inner exception stack trace ---



● エラーメッセージを見て、思い出す。

「---> System.NotSupportedException: CodePage 1252 not supported」
このエラーメッセージ、確かどこかで見かけたなぁ、と手順書を見直すと、

 【OpenSim Build Instructions】
 http://opensimulator.org/wiki/OpenSim_Build_Instructions

のページに、

 Ubuntu 8.04
 If you get an exception "System.NotSupportedException: CodePage 1252 not supported"
 running OpenSim with MySql, install also libmono-i18n2.0-cil.

OpenSim+Mysqlで、このエラーが出た場合は、libmono-i18n2.0-cil をインストールしなさい、
と、書いてあります。 ちゃんと読んどいて、よかったです。 ^^



● libmono-i18n2.0-cil のパッケージを検索して、インストール

(1) apt-cacheコマンドで、パッケージlibmono-i18n2.0-cilの検索

root@sv:~# apt-cache search libmono-i18n
libmono-i18n1.0-cil - Mono I18N libraries (1.0)
libmono-i18n2.0-cil - Mono I18N libraries (2.0)

よかった、ちゃんとありました。^^



(2) パッケージlibmono-i18n2.0-cilのインストール

root@sv:~# apt-get install libmono-i18n2.0-cil
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています
状態情報を読み取っています... 完了
以下のパッケージが新たにインストールされます:
 libmono-i18n2.0-cil




● OpenSimの起動

(1) これで、OpenSimが問題なく動きました。
  起動ログのMySQL接続部分です。コネクションが確立しています。

root@sv:/usr/local/opensim/0.5.7/bin# mono OpenSim.exe

14:38:20 - [ASSET SERVER]: Starting asset storage system
14:38:20 - [SQLAssetServer]: AssetStorage: Attempting to load OpenSim.Data.MySQL.dll
14:38:20 - [MYSQL]: Connection established
14:38:20 - [ASSETS DB]: Creating new database tables
14:38:20 - [AssetStorage]: Added MySQL Asset storage engine 1.0.0.0

14:38:21 - [AGENT INVENTORY]: Inventory storage: Attempting to load OpenSim.Data.MySQL.dll
14:38:21 - [MYSQL]: Connection established



(2) OpenSimデータベース内に、テーブルが自動的に作成されています。
  READMEに書かれているとおり、テーブルをわざわざ作る必要はありませんでしたね。

mysql> use opensim;
mysql> show tables;



【補足】
 「avatarappearance」は、Ver0.56では、外部データベースでしたが、
 Ver0.57からopensimデータベース内のテーブルに移行したようです。
 Ver0.56のOpenSim.iniファイルに存在したavatarappearanceの定義も、
 Ver0.57では無くなっています。



(3) ユーザテーブルを、確認します。
  一番最初に作った、OpenSimの管理者アカウントも、MySQLに引き継がれてます。
  なかなか親切だ。 ^^

mysql> select username,lastname,passwordHash from opensim.users;





● 一般ユーザ(自分)の作成

(1) OpenSimのコンソールから、ユーザアカウント(私ぱすてるさん)を作成します。

Region# : create user
First name [Default]:
Pastel
Last name [User]:
Flow
Password:
********



(2) MySQLにログインして、確認してみます。
  ちゃんと、ユーザアカウントができてました。

mysql> select username,lastname,passwordHash from opensim.users;





● ついにお友達ができました~、、って、ひとり二役ですけど。。。><





● ちょっと疑問

ところで、OpenSimをアップデートしたら、今あるMySQL内のデータベース(ユーザアカウントとか、
インベントリ)は引き継げるんだろうか?
OpenSimを最初にコンパイル、起動する時は、SQLiteだし。。。
アップデートのたびに、DB移行作業が発生するのはゴメンです。
要調査ですね~。



● 予定は未定

データベースをMySQLに移行した事で、Apache Web ServerとPerlやPHP、Rubyで、いろいろな、
Web-DB連携アプリが組めるようになりました。
さすがにテーブルを書き換えるような処理は危険だけど、インベントリを検索したり、一覧表示する
様なアプリを組んでみよう。
それから、やっぱり本命は、グリッドモードの仕組みや、移行方法を覚えないとね。
当分、英語と格闘です。。。><



● 補足

通常、データベースが稼動しているサーバに、グローバルIPアドレスを割り当てて、インターネットに
公開することは決してしません。 
セキュリティ対策を十分した上で、自己責任で。 (^^ゞ




【資料2.1】
データベース「opensim」内、テーブルカラム情報 (OpenSim Ver0.57)

・テーブル名:agents




・テーブル名:assets




・テーブル名:avatarappearance




・テーブル名:inventoryfolders




・テーブル名:inventoryitems




・テーブル名:userfrends




・テーブル名:users






【資料2.2】
OpenSim.iniファイル V0.5.6 -> V0.5.7差分

● V0.5.6から削除

34: ; Avatar appearance persistence
35: appearance_persist = false
36: appearance_database = "MySQL"
37: appearance_connection_string = "Data Source=localhost;Database=avatar_appearance;User ID=root;Password=xxxx;pooling=false;"


● V0.5.7から追加

71: ;permissionmodules = "DefaultPermissionsModule"
104: ; asset_plugin = "OpenSim.Data.NHibernate.dll" ; for nhibernate

115: ; inventory_plugin = "OpenSim.Data.NHibernate.dll" ; for nhibernate
116: ; Inventory Source NHibernate Example (DIALECT;DRIVER;CONNECTSTRING)
117: ; inventory_source = "SQLiteDialect;SqliteClientDriver;URI=file:Inventory.db,version=3"

123: ; userDatabase_plugin = "OpenSim.Data.NHibernate.dll" ; for nhibernate
124: ; User Source NHibernate Example (DIALECT;DRIVER;CONNECTSTRING)
125: ; user_source = "SQLiteDialect;SqliteClientDriver;URI=file:User.db,version=3"

156: [ODEPhysicsSettings]
157:
158: ;# World Settings
159:
160: ;Gravity. Feel like falling up? change world_gravityz to 9.8 instead of -9.8. m/s
161: world_gravityx = 0
162: world_gravityy = 0
163: world_gravityz = -9.8
164:
165: ; World Step size. (warning these are dangerous. Changing these will probably cause your scene to explode dramatically)
166: ; reference: fps = (0.09375/ODE_STEPSIZE) * 1000;
167: world_stepsize = 0.020
168: world_internal_steps_without_collisions = 10
169:
170: ;World Space settings. Affects memory consumption vs Collider CPU time for avatar and physical prim
171: world_hashspace_size_low = -4
172: world_hashSpace_size_high = 128
173:
174: ;Dynamic space settings Affects memory consumption vs Collider CPU time for static prim
175: meters_in_small_space = 29.9
176: small_hashspace_size_low = -4
177: small_hashspace_size_high = 66
178:
179: ; # Contact properties. (the stuff that happens when things come in contact with each other)
180:
181: ; surface layer around geometries other geometries can sink into before generating a contact
182: world_contact_surface_layer = 0.001
183:
184: ; Non Moving Terrain Contact (avatar isn't moving)
185: nm_terraincontact_friction = 255.0
186: nm_terraincontact_bounce = 0.1
187: nm_terraincontact_erp = 0.1025
188:
189: ; Moving Terrain Contact (avatar is moving)
190:
191: m_terraincontact_friction = 75.0
192: m_terraincontact_bounce = 0.05
193: m_terrainContact_erp = 0.05025
194:
195: ; Moving Avatar to object Contact
196:
197: m_avatarobjectcontact_friction = 75.0
198: m_avatarobjectcontact_bounce = 0.1
199:
200: ; Object to Object Contact and Non-Moving Avatar to object
201:
202: objectcontact_friction = 250.0
203: objectcontact_bounce = 0.2
204:
205: ; # Avatar Control
206:
207: ; PID Controller Settings. These affect the math that causes the avatar to reach the
208:
209: av_pid_derivative_linux = 3200.0
210: av_pid_proportional_linux = 1400.0
211:
212: av_pid_derivative_win = 2200.0
213: av_pid_proportional_win = 900.0;
214:
215:
216: ;girth of the avatar. Adds radius to the height also
217: av_capsule_radius = 0.37
218:
219: ; Max force permissible to use to keep the avatar standing up straight
220: av_capsule_standup_tensor_win = 550000
221: av_capsule_standup_tensor_linux = 2000000
222:
223: ; used to calculate mass of avatar.
224: ; float AVvolume = (float) (Math.PI*Math.Pow(CAPSULE_RADIUS, 2)*CAPSULE_LENGTH);
225: ; av_density * AVvolume;
226:
227: av_density = 80
228:
229: ; use this value to cut 52% of the height the sim gives us
230: av_height_fudge_factor = 0.52
231:
232: ; Movement. Smaller is faster.
233:
234: ; speed of movement with Always Run off
235: av_movement_divisor_walk = 1.3
236:
237: ; speed of movement with Always Run on
238: av_movement_divisor_run = 0.8
239:
240: ; # Object options
241: ; used in the mass calculation.
242: geometry_default_density = 10.000006836
243:
244: ; amount of ODE steps where object is non moving for ODE to automatically put it to sleep
245: body_frames_auto_disable = 20
246:
247: ; used to control llMove2Target
248: body_pid_derivative = 35
249: body_pid_gain = 25
250:
251: ; amount of time a geom/body will try to cross a region border before it gets disabled
252: geom_crossing_faiures_before_outofbounds = 5
253:
254: ; start throttling the object updates if object comes in contact with 3 or more other objects
255: geom_contactpoints_start_throttling = 3
256:
257: ; send 1 update for every x updates below when throttled
258: geom_updates_before_throttled_update = 15
259:
260: ; Used for llSetStatus. How rigid the object rotation is held on the axis specified
261: body_motor_joint_maxforce_tensor_linux = 2
262: body_motor_joint_maxforce_tensor_win = 5
263:
264: ; # Sculpted Prim settings
265:
266: ; Do we want to mesh sculpted prim to collide like they look?
267: mesh_sculpted_prim = true
268:
269: ; number^2 non-physical level of detail of the sculpt texture. 32x32 - 1024 verticies
270: mesh_lod = 32
271:
272: ; number^2 physical level of detail of the sculpt texture. 16x16 - 256 verticies
273: mesh_physical_lod = 16

279: [RestPlugins]
280: enabled = false
281: password = unknown
282: prefix = /admin
283:
284: [RestRegionPlugin]
285: enabled = false

451: ; Maximum number of llListen events we allow per script
452: ; Set this to 0 to have no limit imposed.
453: max_listens_per_script = 64


blender v2.46 Blender Foundation
  


Posted by ぱすてる at 22:13Comments(2)OpenSim

2008年05月23日

OpenSimサーバ構築記録その1(Linuxに導入編)


● きっかけ

私:     米IBMと米Linden Labが去年提携しましたね。
       これからはWebアプリケーションも仮想世界との連携とか必要になるかもしれませんね~
私のボス: テスト用サーバに余裕があれば、OpenSim入れてもいいよ。
私:     マジですか~!!!、仕事中に堂々とセカンドライフができる~ ^^
私のボス: 仕事だからね。 ちゃんと仕組みを勉強してよ。
私:     わ~いわ~い ^^/  (聞いてない)

というわけで、最近仕事中に堂々とOpenSimサーバを構築して、遊んでます。



● テスト用サーバ仕様

 CPU: Pentium4 3.2GHz
 メモリ: 2GB
 OS:  Ubuntu8.04 (Debian/GNU Linux系OS)

元々は、ホームページ、Webアプリケーションの動作確認用のサーバ機です。
テスト用とはいえ、DMZ上に配置された、立派な外部公開サーバ。
最初の頃はただの利用者だったのに、一番使う私が、いつの間にやら管理者に。。。 ーー;



● OpenSimインストール手順書の入手

(URL) http://opensimulator.org/wiki/User_Documentation

なんと、テスト機と同じOS(Ubuntu8.04)の手順が書かれているではないですか~。
すばらしい。 英語も(たぶん)簡単そうだ。 ^^;



● 手順書を参考に、各種パッケージのインストール

(1) 職場のテスト機にSSHでリモートログイン。
  rootユーザになって、/usr/local ディレクトリに移動して作業します。
  Linux/Unixでは、ソースからコンパイル・インストールするときは、/usr/local 配下に作成する事が多いので。

root@sv:/root# cd /usr/local

  Ubuntu、Knoppixなど、Debian系Linuxのパッケージは、apt-get または aptitudeコマンドで
  ネットワーク経由でパッケージのサイトからインストールします。



(2) subversion のインストール
  subversionは、ソースファイルなどのリポジトリ管理のツールです。
  OpenSim本体は、subversionを利用してリポジトリサイトからダウンロード(チェックアウト)します。

root@sv:/usr/local# apt-get install subversion
Suggested packages:
db4.6-util patch subversion-tools
The following NEW packages will be installed:
subversion
0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
Need to get 0B/243kB of archives.
After this operation, 3482kB of additional disk space will be used.

(以下省略)



(3) nant のインストール
  NAntは、JavaのAntを.NETで利用できるように移植したオープンソースのビルドツールです。

root@sv:/usr/local# apt-get install nant
The following extra packages will be installed:
libgdiplus libgif4 libglib2.0-dev libmono-accessibility1.0-cil libmono-dev
libmono-winforms1.0-cil libnunit2.2.6-cil mono-gmcs
Suggested packages:
libglib2.0-doc libnunit-doc
The following NEW packages will be installed:
libgdiplus libgif4 libglib2.0-dev libmono-accessibility1.0-cil libmono-dev
libmono-winforms1.0-cil libnunit2.2.6-cil mono-gmcs nant
0 upgraded, 9 newly installed, 0 to remove and 1 not upgraded.
Need to get 5997kB of archives.
After this operation, 23.0MB of additional disk space will be used.
Do you want to continue [Y/n]?

(以下省略)



(4) mono-gmcs のインストール
  Linux上で、.NETアプリケーションを動かすために、Monoランタイムを利用します。

root@sv:/usr/local# apt-get install mono-gmcs
mono-gmcs is already the newest version.
mono-gmcs set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.


※ nantのインストール時に、依存パッケージとして既にインストールされてました。



(5) libmono-microsoft8.0-cil のインストール
  こんな名前のファイルを入れるのは、イヤだ~。><

root@sv:/usr/local# apt-get install libmono-microsoft8.0-cil
The following NEW packages will be installed:
libmono-microsoft8.0-cil
0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
Need to get 130kB of archives.
After this operation, 422kB of additional disk space will be used.

(以下省略)



(6) libmono-system-runtime2.0-cil のインストール

root@sv:/usr/local# apt-get install libmono-system-runtime2.0-cil
The following NEW packages will be installed:
libmono-system-runtime2.0-cil
0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
Need to get 69.6kB of archives.
After this operation, 238kB of additional disk space will be used.

(以下省略)



(7) libgdiplus のインストール

root@sv:/usr/local# apt-get install libgdiplus
libgdiplus is already the newest version.
libgdiplus set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.


※ これも、nantが依存パッケージとして既にインストール済み。



● OpenSimの構築

(1) /usr/local 配下に、opensimディレクトリを作成し、その配下にOpenSIMを
  インストールします。

root@sv:/usr/local# mkdir opensim
root@sv:/usr/local# cd opensim/



(2) subversionで、OpenSIMリポジトリからチェックアウト(ダウンロード)します。

(URL) http://opensimulator.org/svn/opensim/tags/

(今日現在)版数が一番大きい、0.5.6-release を入れてみます。
ディスクに余裕があれば、0.4.5.3-stable(安定版)も入れておけばいいですね。

root@sv:/usr/local/opensim# svn co http://opensimulator.org/svn/opensim/tags/0.5.6-release 0.5.6
root@sv:/usr/local/opensim# ls
./  ../  0.4.5.3/  0.5.6/



(3) runprebuildスクリプトを実行して、NAnt用のビルドファイルを作ります。
  TarBall版からフリーソフトをコンパイルする時の./configureの代わりでしょうか。

root@sv:/usr/local/opensim# cd 0.5.6/
root@sv:/usr/local/opensim/0.5.6# ls *.sh
add-copyright.sh* runprebuild.sh*

root@sv:/usr/local/opensim/0.5.6# ./runprebuild.sh
Prebuild v2.0.3
Copyright (c) 2004-2008
Matthew Holmes (matthew@wildfiregames.com),
Dan Moorehead (dan05a@gmail.com),
David Hudson (jendave@yahoo.com),
Rob Loach (http://www.robloach.net),
C.J. Adams-Collier (cjac@colliertech.org),
See 'prebuild /usage' for help

(途中省略)
Creating Visual C# 2005 solution and project files
...Creating project: Prebuild




(4) OpenSIMのビルド
  ビルドファイルが正常に作成されたら、後はnantを実行するだけです。

root@sv:/usr/local/opensim/0.5.6# nant
NAnt 0.85 (Build 0.85.2478.0; release; 2006/10/14)
Copyright (C) 2001-2006 Gerry Shaw
http://nant.sourceforge.net

Buildfile: file:///usr/local/opensim/0.5.6/OpenSim.build
Target framework: Mono 2.0 Profile
Target(s) specified: build

(途中省略)
BUILD SUCCEEDED
Total time: 69.1 seconds.




(5) binディレクトリ配下に、OpenSIM.exe本体と、iniファイル見本ができてる事を確認します。

root@sv:/usr/local/opensim/0.5.6# cd bin
root@sv:/usr/local/opensim/0.5.6/bin# ls *.exe
OpenSim.32BitLaunch.exe*    OpenSim.Grid.InventoryServer.exe* OpenSim.Grid.UserServer.exe*
OpenSimExport.exe*        OpenSim.Grid.AssetServer.exe*   OpenSim.Grid.MessagingServer.exe*
OpenSim.TestSuite.exe*      Prebuild.exe*           OpenSim.Grid.GridServer.exe*
OpenSim.Grid.ScriptServer.exe* OpenSim.exe*            pCampBot.exe*

root@sv:/usr/local/opensim/0.5.6/bin# ls *ini*
OpenSim.ini.example mssql_connection.ini.example mysql_connection.ini.example



(6) 環境ファイル(OpenSim.ini)の雛形をコピーして、viエディタで修正します。
  フィジクスは当然、ODE(Open Dynamics Engine)を有効にします。

root@sv:/usr/local/opensim/0.5.6/bin# cp OpenSim.ini.example OpenSim.ini
root@sv:/usr/local/opensim/0.5.6/bin# vi OpenSim.ini

; Choose one of the physics engines below
;physics = basicphysics  ←これを無効にする
;physics = POS
physics = OpenDynamicsEngine  ←これを有効にする
;physics = modified_BulletX



● OpenSimの起動と初期設定

(1) binディレクトリ配下で、OpenSIM.exeを起動します。
  とうぜん、exeファイルはLinuxでは動きませんので、mono経由で起動させます。

root@sv:/usr/local/opensim/0.5.6/bin# mono OpenSim.exe
OpenSim 0.5, SVN build
Performing compatibility checks... Environment is compatible.
Starting...
12:42:28 - [OPENSIM MAIN]: Running in sandbox mode

(途中省略)



(2) 初回起動時、途中にたずねてくる質問項目に答えます。
  テスト機といえども、グローバルIPとDNSで外部公開しているので、
  アカウント、パスワードはデフォルトは使わない。

DEFAULT REGION CONFIG: Region Name [OpenSim Test]:
DEFAULT REGION CONFIG: Grid Location (X Axis) [1000]:
DEFAULT REGION CONFIG: Grid Location (Y Axis) [1000]:
DEFAULT REGION CONFIG: Internal IP Address for incoming UDP client connections [0.0.0.0]:
221.XXX.XXX.XXX <--- サーバのグローバルIPアドレスを指定。
DEFAULT REGION CONFIG: Internal IP Port for incoming UDP client connections [9000]:
DEFAULT REGION CONFIG: External Host Name [127.0.0.1]:
XXXXXXXX <--- サーバのホスト名(DNSに登録されている)を指定。
DEFAULT REGION CONFIG: First Name of Master Avatar [Test]:
XXXXXXXX <--- ファーストネーム
DEFAULT REGION CONFIG: Last Name of Master Avatar [User]:
XXXXXXXX <--- ラストネーム
DEFAULT REGION CONFIG: (Sandbox Mode Only)Password for Master Avatar account [test]:
XXXXXXXX <--- パスワード
(途中省略)
12:43:07 - [!]:STARTUP COMPLETE
Region# :

コマンド入力待ちになれば、起動完了




● Oracleモジュールのインストール ******** 2009/3/24 追加 ********

以下の警告が出て、OpenSimが起動できなかった場合は、libmono-oracleモジュールを
インストールしてください。(0.6.3-releaseで発生)

** (OpenSim.exe:6932): WARNING **: The following assembly referenced from
 /usr/local/opensim/0.6.3/bin/NHibernate.dll could not be loaded:
  Assembly:  System.Data.OracleClient  (assemblyref_index=4)
  Version:  2.0.0.0
  Public Key: b77a5c561934e089
The assembly was not found in the Global Assembly Cache, a path listed in the
 MONO_PATH environment variable, or in the location of the executing assembly

# apt-get install libmono-oracle2.0-cil




● ファイアウォールの設定(ポート開放)

(1) ポート番号の確認
  Mono (OpenSIM) のプロセス番号から、使用しているポート番号を確認します。
  (9000番ってわかってるけど、念のため)

root@sv:~# ps ax | grep mono
8257 pts/0 Sl+ 0:03 mono OpenSim.exe

root@sv:~# lsof -p 8257 | grep IP
mono 8257 root 6u IPv4 41525 TCP *:9000 (LISTEN)
mono 8257 root 10u IPv4 41526 UDP サーバ名:9000

Mono (OpenSIM) は、TCP/UDPの9000番を使用している事がわかります。



(2) ポートの開放
  このテスト用サーバは、Linuxカーネルが標準装備しているNetfilterで、ファイアウォールを動作させています。
  Netfilterの設定コマンド(iptables)で、TCP/UDPの9000番を開放(ACCEPT)します。

/sbin/iptables -A INPUT -i $WANPORT -p tcp -m state --state NEW -s $TRUSTWAN --dport 9000 -j ACCEPT
/sbin/iptables -A INPUT -i $WANPORT -p udp -s $TRUSTWAN --dport 9000 -j ACCEPT

※ $TRUSTWAN は、私の自宅のパソコンのIPアドレス
※ $WANPORTは、サーバのインターネット側のLANカードの事です。
(シェルスクリプトの先頭で、シェル変数として指定してます。)



(3) 設定の確認

root@sv:~# # iptables -L | grep 9000
ACCEPT tcp -- ホスト名/29 anywhere state NEW tcp dpt:9000
ACCEPT udp -- ホスト名/29 anywhere udp dpt:9000



● クライアントから接続~OpenSim終了

(1) 職場のLANからはつながりましたので、自宅に帰って、このテストサーバに接続確認。
  クライアントソフトのオプションに、接続先URL・ポートを指定して、接続テスト。

D:\SecondLife\SecondLife.exe -loginuri http://ホスト名:9000/ -loginpage http://ホスト名:9000/?method=login

文字ばかりの記事だと寂しいので、とりあえずSS。 ^^;



でも、SSの風景も寂しい。。。 ><;



(2) OpenSIMの終了
  コンソールから、shutdownを実行します。

Region# :shutdown

17:04:46 - [COMMANDFILE]: Running shutdown_commands.txt
17:04:46 - [COMMANDFILE]: Running 'backup'
17:04:46 - [SHUTDOWN]: Closing all threads
17:04:46 - [SHUTDOWN]: Killing listener thread
17:04:46 - [SHUTDOWN]: Killing clients
17:04:46 - [SHUTDOWN]: Closing console and terminating
17:04:46 - [SCENE]: Closing down the single simulator: OpenSim Test
17:04:46 - [Region]: Shutdown at 5/18/2008 5:04:46 PM
17:04:46 - [ScriptEngine.DotNetEngine]: ThreadAbortException while executing function.
17:04:46 - [ScriptEngine.DotNetEngine]: ThreadAbortException while executing function.

** (OpenSim.exe:8257): WARNING **: unknown MONO_PATCH_INFO_INTERNAL_METHOD
**
** ERROR:(mini.c:9326):mono_resolve_patch_target: code should not be reached
Aborted




● 予定は未定

さて、次はグリッドモード前準備で、データベースをSQLiteからMySQL5.0に変更してみよう。

他にも
 ・自宅の余っているMacOSXにもインストール。
 ・アカウントの作り方
 ・土地造成のお勉強
 ・アドオン(OpenLibrary)を試してみる
 ・スタンドアロンから、グリッドモードに移行
 ・パケット、セッションを解析してみる
 ・データベースの中を探検してみる。

などなどです。
  


Posted by ぱすてる at 19:04Comments(11)OpenSim