2018年1月15日月曜日

VagrantでApache Ignite2.3.0をインストールした仮想マシン(Debian Stretch/9.3)を構築する

以下のVagrantfileを使用して、Apache Ignite2.3.0をインストールした仮想マシンを構築する事が出来ます。

Vagrantfile
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "bento/debian-9.3"
  config.vm.hostname = "db93ignite230"
  config.vm.provider :virtualbox do |vbox|
     vbox.name = "db93ignite230"
     vbox.cpus = 2
     vbox.memory = 2048
     vbox.customize ["modifyvm", :id, "--nicpromisc2","allow-all"]
  end
  config.vm.network "private_network", ip: "192.168.55.105", :netmask => "255.255.255.0"
  config.vm.network "public_network", ip:"192.168.1.105", :netmask => "255.255.255.0"
  config.vm.provision "shell", inline: <<-SHELL
apt-get -y install task-japanese
sed -i -e 's/# ja_JP.UTF-8 UTF-8/ja_JP.UTF-8 UTF-8/' /etc/locale.gen
locale-gen
update-locale LANG=ja_JP.UTF-8
localectl set-locale LANG=ja_JP.UTF-8
localectl set-keymap jp106
apt-get update
#DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade

# install java
apt-get -y install openjdk-8-jdk

apt-get -y install unzip
wget http://ftp.meisei-u.ac.jp/mirror/apache/dist//ignite/2.3.0/apache-ignite-fabric-2.3.0-bin.zip
unzip apache-ignite-fabric-2.3.0-bin.zip
mv apache-ignite-fabric-2.3.0-bin /opt/ignite

cat << EOF > /etc/systemd/system/ignite.service
[Unit]
Description=Apache Ignite

[Service]
ExecStart=/opt/ignite/bin/ignite.sh
WorkingDirectory=/opt/ignite
KillMode=process
PrivateTmp=true

[Install]
WantedBy=multi-user.target
EOF
systemctl enable ignite.service
systemctl start ignite.service

# 11211ポートでlistenするまで待つ.
while netstat -lnt | awk '$4 ~ /:11211$/ {exit 1}'; do sleep 10; done
sleep 10

# サンプルSQLの実行
wget http://wiki.metawerx.net/attach/SJSQL/sjsql.java
wget http://wiki.metawerx.net/attach/SJSQL/sjsql.class

cat << EOF >> /home/vagrant/test.sql
create table test1 (test_id integer primary key, test_desc varchar(100));
insert into test1 (test_id, test_desc) values (1, 'test_id_001');
select * from test1;
EOF
java -cp .:/opt/ignite/libs/ignite-core-2.3.0.jar sjsql org.apache.ignite.IgniteJdbcThinDriver jdbc:ignite:thin://127.0.0.1/ test test /home/vagrant/test.sql

SHELL
end

○関連情報
・Apache Igniteに関する他の記事はこちらを参照してください。

0 件のコメント:

コメントを投稿