2014年9月21日日曜日

Ubuntu14.04Server LXC上で OpenDolphin構築(2)

ビルド&テスト&実行環境用にシェルスクリプト作ってみる。
(M先生のソース用です)
UbuntuServer14.04のCloudImage(AWS)で試してます。
こちらのLXCでもOKでした。
github
https://gist.github.com/KunitoishiTomii/a337a19d9824fdb69f53

$ sudo apt-get update
$ sudo apt-get install -y git

$ git clone https://gist.github.com/a337a19d9824fdb69f53.git

$ cd a337a19d9824fdb69f53/

$ chmod +x *.sh

1.M先生のソース持ってきてビルド
$ sudo ./buildopendolphin.sh

2.PostgreSQLインストール&dolphinデータベース作成
$ sudo ./setpg.sh

3.Wildflyインストール+JDBCデプロイ、コネクションチェック
$ sudo ./setwfly.sh

4.DolphinDSのセット
$ sudo ./setdolphinDS.sh

5.warなどのデプロイ
$ sudo ./setwar.sh

6.自動起動設定
$ sudo ./setrcd.sh

7.起動
$ sudo service wildfly.sh start

8.リストア(新規導入時:M先生の導入書参照)
$ sudo ./restoredolphin.sh dolphinxxxx.dump

9.停止
$ sudo service wildfly.sh stop

10.再起動
$ sudo reboot

2014年6月15日日曜日

Ubuntu14.04Server LXC上で OpenDolphin構築(1)

Ubuntu14.04Server LXC上で OpenDolphin構築

$ sudo lxc-create -t ubuntu -n dolphin

$ sudo sh -c "echo 'net.ipv6.conf.all.disable_ipv6=1' >> /etc/sysctl.conf"
$ sudo sh -c "echo 'net.ipv6.conf.default.disable_ipv6=1' >> /etc/sysctl.conf"
$ sudo /sbin/sysctl -p

$ sudo sh -c 'echo "Acquire::http::Proxy \"http://192.168.xxx.xxx:3142/\";" >> /etc/apt/apt.conf.d/02proxy'

$ sudo apt-get update
$ sudo apt-get install -y postgresql ntp openjdk-7-jdk wget
$ sudo useradd dolphin -d /home/dolphin
$ getent passwd | grep dolphin
$ sudo -u postgres psql -c "create user dolphin with password 'dolphin';"
$ sudo -u postgres psql -c 'ALTER ROLE dolphin WITH SUPERUSER CREATEDB CREATEROLE REPLICATION;'
$ sudo -u postgres psql -c 'select rolname from pg_roles;'
$ sudo -u dolphin createdb -lC -Ttemplate0 -EUTF-8 dolphin
$ sudo -u dolphin psql -l
$ wget http://download.jboss.org/wildfly/8.1.0.Final/wildfly-8.1.0.Final.tar.gz
$ sudo tar zxvf ./wildfly-8.1.0.Final.tar.gz -C /usr/local/
$ sudo mv /usr/local/wildfly-8.1.0.Final /usr/local/jboss
$ sudo useradd jboss
$ sudo chown -R jboss.jboss /usr/local/jboss/
$ sudo /usr/local/jboss/bin/add-user.sh dolphin dolphin

Wildfly起動
$ sudo /usr/local/jboss/bin/standalone.sh -b=192.168.xxx.101 -bmanagement=192.168.xxx.101

ブラウザで管理コンソール
http://192.168.xxx.101:9990 user:dolphin pass:dolphin

Runtime
Manage Deployments
Add
postgresql-9.3-1101.jdbc41.jar
Enable

Configuration
Datasources
Add
Name:DolphinDS
Step 1 JNDI Name:java:jboss/datasources/DolphinDS
Step 2 JDBC Driver postgresql-9.3-1101.jdbc41.jar
Step 3 Connection Settings

Connection URL:jdbc:postgresql://localhost:5432/dolphin
Username:dolphin
Password:dolphin

Connection
Edit
Transaction Isolation TRANSACTION_READ_COMMITED
Use JTA
Save

一度wildfly終了、再起動。

Enable
Comfirm

Test Connection
確認。

後は導入書参考に
/usr/local/jboss/standalone/configuration/standalone.xmlコピーか編集、
ビルドしたwarをデプロイ等する。

LXCコンテナ移動

LXCコンテナ移動

移動先でもLXC環境を作っておく。

必要なデータバックアップとっておく。
一応コンテナシャットダウンしておく。

移動元
$ sudo -i
# cd /var/lib/lxc
# sudo tar cpzf orca.tar.gz orca
# scp orca.tar.gz ubuntu@192.168.xxx.100:

移動先
$ ssh ubuntu@192.168.xxx.100
$ sudo mv orca.tar.gz /var/lib/lxc

$ sudo -i
# cd /var/lib/lxc
# tar --numeric-owner -xpzf orca.tar.gz
# exit
$ sudo lxc-ls -f
$ sudo lxc-start -n orca -d
$ ps ax

参考:

ORCA,OpenDolphinとも移動できました。

LXCでブリッジ

#ブリッジを作成し、物理IFをブリッジポートへ紐付ける
$ sudo vi /etc/network/interfaces

auto lo
 iface lo inet loopback

auto br0
 iface br0 inet static
  address 192.168.xxx.192
  network 192.168.xxx.0
  netmask 255.255.255.0
  broadcast 192.168.xxx.255
  gateway 192.168.xxx.1
  dns-nameservers 192.168.xxx.1
  bridge_ports eth0
  bridge_stp off

auto eth0
 iface eth0 inet manual

$ sudo vi /etc/lxc/default.conf

#lxc.network.link=lxcbr0
lxc.network.link=br0

$ sudo vi /etc/default/lxc-net

#USE_LXC_BRIDGE="true"
USE_LXC_BRIDGE=“false”
..
#LXC_BRIDGE="lxcbr0"
#LXC_ADDR="10.0.3.1"
#LXC_NETMASK="255.255.255.0"
#LXC_NETWORK="10.0.3.0/24"
#LXC_DHCP_RANGE="10.0.3.2,10.0.3.254"

LXCでサーバー構築1

LXCで ORCA&OpenDolphin サーバー構築1

ubuntu14.04 server & ML115(メモリ1G:HDD250G)

ubuntu-14.04-server-amd64.isoとってくる

USBメモリを準備。dfでUSBメモリ確認。/dev/sdbだったら、
$ dd if=ubuntu-14.04-server-amd64.iso of=/dev/sdb bs=1M

USBメモリから起動、後はいつもと同じ。
opensshだけインストール

$ sudo vi /etc/sysctl.conf
net.ipv6.conf.all.disable_ipv6=1
net.ipv6.conf.default.disable_ipv6=1
$ sudo reboot

LXC導入
$ sudo apt-get install lxc

いきなり作ってみる、ここは時間かかる。
$ sudo MIRROR=http://ubuntutym.u-toyama.ac.jp/ubuntu/ lxc-create -t ubuntu -n u12 -- -d ubuntu -r precise -a amd64

ミラー設定はあった方が早いかも
$ sudo vi /etc/default/lxc
MIRROR="http://192.168.xxx.xxx:3142/archive.ubuntu.com/ubuntu"

起動
$ sudo lxc-start -n u12 -d

確認
$ sudo lxc-ls -f

ログインしてみる
$ ssh ubuntu@10.0.3.197

Welcome to Ubuntu 12.04.4 LTS (GNU/Linux 3.13.0-24-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

cupsで2枚印刷設定

ひさしぶりにCUPS設定機会があったので、備忘録。
当院では確認用に処方箋2枚印刷いるので。

$ sudo service cups stop

$ sudo vi /etc/cups/printers.conf

<Printer lp1>
UUID urn:uuid:208fa432-dbfc-3280-481a-a4b0d489c49a
Info 1F 5380DN *2
Location 1F
MakeModel Brother HL5380DN for CUPS
DeviceURI lpd://192.168.xxx.xxx/POSTSCRIPT_P1
State Idle
StateTime 1401861378 #1401861377から 1増やす。
Type 8392724
Accepting Yes
Shared No
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
OpPolicy default
ErrorPolicy retry-job
Option copies 2 #ここ挿入。
</Printer>

 $ sudo service cups restart
テスト印刷してみる。

2014年4月16日水曜日

Vagrant & PostgreSQL9.3で構築1

Vagrant使って、実験環境構築やってみる。

ubuntu.comにクラウド用のファイルが準備されている。


https://cloud-images.ubuntu.com/vagrant/precise/20140407/ のなかにある
precise-server-cloudimg-amd64-vagrant-disk1.box を指定。

boxファイルをリストに加える。
新しく仮想マシン設定して、立ち上げる。


$ mkdir precise64

$ cd precise64/

$ vagrant box add u12s-amd64  https://cloud-images.ubuntu.com/vagrant/precise/20140407/precise-server-cloudimg-amd64-vagrant-disk1.box

$ vagrant init u12s-amd64

A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on

`vagrantup.com` for more information on using Vagrant.

$ vagrant up

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'precise-server-amd64'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: precise64_default_1397574231693_73861
==> default: Clearing any previously set forwarded ports...
==> default: Fixed port collision for 22 => 2222. Now on port 2202.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 => 2202 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2202
    default: SSH username: vagrant
    default: SSH auth method: private key

    default: Warning: Connection timeout. Retrying...
...

ログインして構築開始。
passなしで入れるのはなんか拍子抜けだけど楽。

$ vagrant ssh

Welcome to Ubuntu 12.04.4 LTS (GNU/Linux 3.2.0-60-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

  System information as of Tue Apr 15 11:47:34 UTC 2014

  System load:  0.0               Processes:           72
  Usage of /:   4.0% of 39.37GB   Users logged in:     0
  Memory usage: 15%               IP address for eth0: 10.0.2.15
  Swap usage:   0%

  Graph this data and manage this system at:
    https://landscape.canonical.com/

  Get cloud support with Ubuntu Advantage Cloud Guest:
    http://www.ubuntu.com/business/services/cloud


PostgreSQL 9.3インストール



$ sudo vi /etc/apt/sources.list.d/pgdg.list


ファイルの1行目に以下を書く。

deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main



wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

$ sudo apt-get update

sudo apt-get install -y postgresql-9.3

$ sudo adduser dolphin -disabled-password

$ sudo -u postgres createuser -P --interactive --replication dolphin

$ sudo -u dolphin createdb -lC -Ttemplate0 -EUTF-8 dolphin

確認してみる

$ sudo -u dolphin psql dolphin

dolphin=# \du

dolphin=# \q

OpenJDKインストール


$ sudo apt-get -y install openjdk-7-jdk

Wildfly展開


作成メモ2と同様に作成。もしくは展開

$ tar zxvf jboss-as-7.2.0-hibernate-4.2.11-resteasy-3.0.7.tgz 

$ sudo mv jboss /usr/local/

$ sudo useradd jboss

$ sudo chown -R jboss.jboss /usr/local/jboss


hibernate 4.2.11とresteasy 3.0.7に上がってました。

管理ユーザー登録を作成メモ1同様にする。



$ sudo -i
# /usr/local/jboss/bin/add-user.sh

一度ログオフ。
# exit
$ exit

ホストからアクセスできるようにVagrantfile を編集


$ vi Vagrantfile
...
#config.vm.network "private_network", ip: "192.168.33.10"
...

コメント外して、「”」外して「:」に書き換え
config.vm.network :private_network, ip: "192.168.33.10"

$ vagrant reload

==> default: Attempting graceful shutdown of VM...
==> default: Clearing any previously set forwarded ports...
==> default: Fixed port collision for 22 => 2222. Now on port 2201.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 22 => 2201 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2201
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection timeout. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: The guest additions on this VM do not match the installed version of
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default: 
    default: Guest Additions Version: 4.1.12
    default: VirtualBox Version: 4.3
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
    default: /vagrant => /Users/dolphin/OD-ORCA

==> default: VM already provisioned. Run `vagrant provision` or use `--provision` to force it

$ vagrant ssh

Welcome to Ubuntu 12.04.4 LTS (GNU/Linux 3.2.0-60-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

  System information as of Tue Apr 15 12:40:14 UTC 2014

  System load:  0.0               Processes:           77
  Usage of /:   4.7% of 39.37GB   Users logged in:     0
  Memory usage: 12%               IP address for eth0: 10.0.2.15
  Swap usage:   0%                IP address for eth1: 192.168.33.10

ホスト側から192.168.33.10でアクセスできる。

$ sudo /usr/local/jboss/bin/standalone.sh -b=192.168.33.10 -bmanagement=192.168.33.10

ホストからブラウザで入ってみる。

http://192.168.33.10:8080