ラベル ApacheIgnite の投稿を表示しています。 すべての投稿を表示
ラベル ApacheIgnite の投稿を表示しています。 すべての投稿を表示

2019年9月5日木曜日

VagrantでApache Ignite2.7.5/AdoptOpenJDK11をインストールした仮想マシン(Debian Buster/10)を構築する

Apache Igniteはメモリ指向の分散データベースです。

○構築方法
以下のVagrantfileを使用して、Apache Ignite2.7.5をインストールした仮想マシン(Debian Buster/10)を構築する事が出来ます。

Vagrantfile
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "bento/debian-10"
  config.vm.hostname = "db10ignite"
config.vm.network "public_network", ip:"192.168.1.103", :netmask => "255.255.255.0"
config.vm.network "private_network", ip: "192.168.55.103", :netmask => "255.255.255.0"
  config.vm.provider :virtualbox do |vbox|
     vbox.name = "db10ignite"
     vbox.gui = true
     vbox.cpus = 2
     vbox.memory = 2048
  end
  config.vm.provision "shell", inline: <<-SHELL
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
apt-get -y install task-japanese gawk
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
timedatectl set-timezone Asia/Tokyo

# install AdoptOpenJDK11
cd /opt
wget https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.3%2B7/OpenJDK11U-jdk_x64_linux_hotspot_11.0.3_7.tar.gz
tar xvfz OpenJDK11U-jdk_x64_linux_hotspot_11.0.3_7.tar.gz
cat << EOF > /etc/profile.d/jdk.sh
export JAVA_HOME=/opt/jdk-11.0.3+7
export PATH=\\$PATH:\\$JAVA_HOME/bin
EOF

# install Apache Ignite
sudo apt-get -y install unzip
wget http://mirrors.advancedhosters.com/apache//ignite/2.7.5/apache-ignite-2.7.5-bin.zip
unzip apache-ignite-2.7.5-bin.zip
mv apache-ignite-2.7.5-bin /opt/ignite

sed -i -e 's#JVM_OPTS="-Xms1g -Xmx1g -server -XX:MaxMetaspaceSize=256m"#JVM_OPTS="-Xms1g -Xmx1g -server -XX:MaxMetaspaceSize=256m --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED --add-exports=java.base/sun.nio.ch=ALL-UNNAMED"#' /opt/ignite/bin/ignite.sh
cat << EOF > /etc/systemd/system/ignite.service
[Unit]
Description=Apache Ignite

[Service]
Environment=JAVA_HOME=/opt/jdk-11.0.3+7
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

# wait unitl 11211 port is opened.
while netstat -lnt | awk '$4 ~ /:11211$/ {exit 1}'; do sleep 10; done
sleep 10

# execute a sample 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
/opt/jdk-11.0.3+7/bin/java --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED --add-exports=java.base/sun.nio.ch=ALL-UNNAMED -cp .:/opt/ignite/libs/ignite-core-2.7.5.jar sjsql org.apache.ignite.IgniteJdbcThinDriver jdbc:ignite:thin://127.0.0.1/ test test /home/vagrant/test.sql

SHELL
end


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

2019年8月14日水曜日

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

Apache Igniteはメモリ指向の分散データベースです。

○構築方法
以下のVagrantfileを使用して、Apache Ignite2.7.0をインストールした仮想マシン(Debian Stretch/9.6)を構築する事が出来ます。

Vagrantfile
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "bento/debian-9.6"
  config.vm.hostname = "db96ignite27adoptopenjdk11"
config.vm.network :public_network, ip:"192.168.1.109"
  config.vm.provider :virtualbox do |vbox|
     vbox.name = "db96ignite27adoptopenjdk11"
     vbox.cpus = 2
     vbox.memory = 2048
  end
  config.vm.provision "shell", inline: <<-SHELL
apt-get update
export DEBIAN_FRONTEND=noninteractive
apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
apt-get -y install language-pack-ja
localectl set-locale LANG=ja_JP.UTF-8
localectl set-keymap jp106
apt-get update
timedatectl set-timezone Asia/Tokyo
apt-get -y install unzip

# install AdoptOpenJDK11
cd /opt
wget https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.3%2B7/OpenJDK11U-jdk_x64_linux_hotspot_11.0.3_7.tar.gz
tar xvfz OpenJDK11U-jdk_x64_linux_hotspot_11.0.3_7.tar.gz
cat << EOF > /etc/profile.d/jdk.sh
export JAVA_HOME=/opt/jdk-11.0.3+7
export PATH=\\$PATH:\\$JAVA_HOME/bin
EOF

# install Apache Ignite
wget https://www-eu.apache.org/dist//ignite/2.7.0/apache-ignite-2.7.0-bin.zip
unzip apache-ignite-2.7.0-bin.zip
mv apache-ignite-2.7.0-bin /opt/ignite

sed -i -e 's#JVM_OPTS="-Xms1g -Xmx1g -server -XX:MaxMetaspaceSize=256m"#JVM_OPTS="-Xms1g -Xmx1g -server -XX:MaxMetaspaceSize=256m --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED --add-exports=java.base/sun.nio.ch=ALL-UNNAMED"#' /opt/ignite/bin/ignite.sh
cat << EOF > /etc/systemd/system/ignite.service
[Unit]
Description=Apache Ignite

[Service]
Environment=JAVA_HOME=/opt/jdk-11.0.3+7
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

# wait unitl 11211 port is opened.
while netstat -lnt | awk '$4 ~ /:11211$/ {exit 1}'; do sleep 10; done
sleep 10

# execute a sample 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
/opt/jdk-11.0.3+7/bin/java --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED --add-exports=java.base/sun.nio.ch=ALL-UNNAMED -cp .:/opt/ignite/libs/ignite-core-2.7.0.jar sjsql org.apache.ignite.IgniteJdbcThinDriver jdbc:ignite:thin://127.0.0.1/ test test /home/vagrant/test.sql

SHELL
end

〇関連情報
・プロジェクトWebサイト
https://ignite.apache.org/index.html

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

2019年7月31日水曜日

VagrantでApache Ignite2.7.0/AdoptOpenJDK11をインストールした仮想マシン(CentOS7.6)を構築する

Apache Igniteはメモリ指向の分散データベースです。

○構築方法
以下のVagrantfileを使用して、Apache Ignite2.7.0をインストールした仮想マシン(CentOS7.6)を構築する事が出来ます。

Vagrantfile
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "bento/centos-7.6"
  config.vm.hostname = "co76ignite27adoptopenjdk11"
  config.vm.provider :virtualbox do |vbox|
     vbox.name = "co76ignite27adoptopenjdk11"
     vbox.gui = true
     vbox.cpus = 2
     vbox.memory = 2048
  end
config.vm.network "public_network", ip: "192.168.1.104", :netmask => "255.255.255.0"
  config.vm.provision "shell", inline: <<-SHELL
localectl set-locale LANG=ja_JP.UTF-8
yum install -y epel-release
yum check-update
yum -y update
timedatectl set-timezone Asia/Tokyo
yum -y install unzip

# install AdoptOpenJDK11
cd /opt
wget https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.3%2B7/OpenJDK11U-jdk_x64_linux_hotspot_11.0.3_7.tar.gz
tar xvfz OpenJDK11U-jdk_x64_linux_hotspot_11.0.3_7.tar.gz
cat << EOF > /etc/profile.d/jdk.sh
export JAVA_HOME=/opt/jdk-11.0.3+7
export PATH=\\$PATH:\\$JAVA_HOME/bin
EOF

# install Apache Ignite
wget https://www-eu.apache.org/dist//ignite/2.7.0/apache-ignite-2.7.0-bin.zip
unzip apache-ignite-2.7.0-bin.zip
mv apache-ignite-2.7.0-bin /opt/ignite

sed -i -e 's#JVM_OPTS="-Xms1g -Xmx1g -server -XX:MaxMetaspaceSize=256m"#JVM_OPTS="-Xms1g -Xmx1g -server -XX:MaxMetaspaceSize=256m --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED --add-exports=java.base/sun.nio.ch=ALL-UNNAMED"#' /opt/ignite/bin/ignite.sh
cat << EOF > /etc/systemd/system/ignite.service
[Unit]
Description=Apache Ignite

[Service]
Environment=JAVA_HOME=/opt/jdk-11.0.3+7
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

# wait unitl 11211 port is opened.
while netstat -lnt | awk '$4 ~ /:11211$/ {exit 1}'; do sleep 10; done
sleep 10

# execute a sample 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
/opt/jdk-11.0.3+7/bin/java --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED --add-exports=java.base/sun.nio.ch=ALL-UNNAMED -cp .:/opt/ignite/libs/ignite-core-2.7.0.jar sjsql org.apache.ignite.IgniteJdbcThinDriver jdbc:ignite:thin://127.0.0.1/ test test /home/vagrant/test.sql

SHELL
end

〇関連情報
・プロジェクトWebサイト
https://ignite.apache.org/index.html

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

2019年7月19日金曜日

VagrantでApache Ignite2.7.0/AdoptOpenJDK11をインストールした仮想マシン(Ubuntu18.04)を構築する

Apache Igniteはメモリ指向の分散データベースです。

○構築方法
以下のVagrantfileを使用して、Apache Ignite2.7.0をインストールした仮想マシン(Ubuntu18.04)を構築する事が出来ます。

Vagrantfile
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "bento/ubuntu-18.04"
  config.vm.hostname = "ub1804ignite27adoptopenjdk11"
  config.vm.provider :virtualbox do |vbox|
     vbox.name = "ub1804ignite27adoptopenjdk11"
     vbox.cpus = 2
     vbox.memory = 2048
     vbox.customize ["modifyvm", :id, "--nicpromisc2","allow-all"]
  end
  config.vm.network "private_network", ip: "192.168.55.109", :netmask => "255.255.255.0"
  config.vm.network "public_network", ip:"192.168.1.109", :netmask => "255.255.255.0"
  config.vm.provision "shell", inline: <<-SHELL
apt-get update
export DEBIAN_FRONTEND=noninteractive
apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
apt-get -y install language-pack-ja
localectl set-locale LANG=ja_JP.UTF-8
localectl set-keymap jp106
apt-get update
timedatectl set-timezone Asia/Tokyo
sudo apt-get install unzip

# install AdoptOpenJDK11
cd /opt
wget https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.3%2B7/OpenJDK11U-jdk_x64_linux_hotspot_11.0.3_7.tar.gz
tar xvfz OpenJDK11U-jdk_x64_linux_hotspot_11.0.3_7.tar.gz
cat << EOF > /etc/profile.d/jdk.sh
export JAVA_HOME=/opt/jdk-11.0.3+7
export PATH=\\$PATH:\\$JAVA_HOME/bin
EOF

# install Apache Ignite
wget https://www-eu.apache.org/dist//ignite/2.7.0/apache-ignite-2.7.0-bin.zip
unzip apache-ignite-2.7.0-bin.zip
mv apache-ignite-2.7.0-bin /opt/ignite

sed -i -e 's#JVM_OPTS="-Xms1g -Xmx1g -server -XX:MaxMetaspaceSize=256m"#JVM_OPTS="-Xms1g -Xmx1g -server -XX:MaxMetaspaceSize=256m --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED --add-exports=java.base/sun.nio.ch=ALL-UNNAMED"#' /opt/ignite/bin/ignite.sh
cat << EOF > /etc/systemd/system/ignite.service
[Unit]
Description=Apache Ignite

[Service]
Environment=JAVA_HOME=/opt/jdk-11.0.3+7
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

# wait unitl 11211 port is opened.
while netstat -lnt | awk '$4 ~ /:11211$/ {exit 1}'; do sleep 10; done
sleep 10

# execute a sample 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
/opt/jdk-11.0.3+7/bin/java --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED --add-exports=java.base/sun.nio.ch=ALL-UNNAMED -cp .:/opt/ignite/libs/ignite-core-2.7.0.jar sjsql org.apache.ignite.IgniteJdbcThinDriver jdbc:ignite:thin://127.0.0.1/ test test /home/vagrant/test.sql

init 5
SHELL
end


〇関連情報
・プロジェクトWebサイト
https://ignite.apache.org/index.html

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

2019年2月24日日曜日

VagrantでApache Ignite2.7.0/JDK11をインストールした仮想マシン(CentOS7.6)を構築する

Apache Igniteはメモリ指向の分散データベースです。

○構築方法
以下のVagrantfileを使用して、Apache Ignite2.7.0をインストールした仮想マシン(CentOS7.6)を構築する事が出来ます。

Vagrantfile
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "bento/centos-7.6"
  config.vm.hostname = "co76ignite270"
config.vm.network :public_network, ip:"192.168.1.117"
config.vm.network "private_network", ip: "192.168.55.117", :netmask => "255.255.255.0"
  config.vm.provider :virtualbox do |vbox|
    vbox.name = "co76ignite270"
    vbox.cpus = 2
    vbox.memory = 2048
    vbox.customize ["modifyvm", :id, "--nicpromisc2","allow-all"]
  end
  config.vm.provision "shell", inline: <<-SHELL
localectl set-locale LANG=ja_JP.UTF-8
yum install -y epel-release
yum check-update
yum -y update
timedatectl set-timezone Asia/Tokyo
yum -y install unzip

# install JDK11
wget --no-cookies --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie"   "http://download.oracle.com/otn-pub/java/jdk/11.0.2+9/f51449fcd52f4d52b93a989c5c56ed3c/jdk-11.0.2_linux-x64_bin.rpm"
yum -y install jdk-11.0.2_linux-x64_bin.rpm

wget https://www-eu.apache.org/dist//ignite/2.7.0/apache-ignite-2.7.0-bin.zip
unzip apache-ignite-2.7.0-bin.zip
mv apache-ignite-2.7.0-bin /opt/ignite

sed -i -e 's#JVM_OPTS="-Xms1g -Xmx1g -server -XX:MaxMetaspaceSize=256m"#JVM_OPTS="-Xms1g -Xmx1g -server -XX:MaxMetaspaceSize=256m --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED --add-exports=java.base/sun.nio.ch=ALL-UNNAMED"#' /opt/ignite/bin/ignite.sh
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

# wait unitl 11211 port is opened.
while netstat -lnt | awk '$4 ~ /:11211$/ {exit 1}'; do sleep 10; done
sleep 10

# execute a sample 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 --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED --add-exports=java.base/sun.nio.ch=ALL-UNNAMED -cp .:/opt/ignite/libs/ignite-core-2.7.0.jar sjsql org.apache.ignite.IgniteJdbcThinDriver jdbc:ignite:thin://127.0.0.1/ test test /home/vagrant/test.sql

SHELL
end


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

2019年2月22日金曜日

VagrantでApache Ignite2.7.0/JDK11をインストールした仮想マシン(Ubuntu18.04)を構築する

Apache Igniteはメモリ指向の分散データベースです。

○構築方法
以下のVagrantfileを使用して、Apache Ignite2.7.0をインストールした仮想マシン(Ubuntu18.04)を構築する事が出来ます。

Vagrantfile
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "bento/ubuntu-18.04"
  config.vm.hostname = "ub1804ignite270"
  config.vm.provider :virtualbox do |vbox|
     vbox.name = "ub1804ignite270"
     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
sed -i.bak -e "s#http://archive.ubuntu.com/ubuntu/#http://ftp.riken.jp/pub/Linux/ubuntu/#g" /etc/apt/sources.list
apt-get update
apt-get -y install language-pack-ja
localectl set-locale LANG=ja_JP.UTF-8
localectl set-keymap jp106
timedatectl set-timezone Asia/Tokyo
apt-get -y install unzip

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


wget https://www-eu.apache.org/dist//ignite/2.7.0/apache-ignite-2.7.0-bin.zip
unzip apache-ignite-2.7.0-bin.zip
mv apache-ignite-2.7.0-bin /opt/ignite

sed -i -e 's#JVM_OPTS="-Xms1g -Xmx1g -server -XX:MaxMetaspaceSize=256m"#JVM_OPTS="-Xms1g -Xmx1g -server -XX:MaxMetaspaceSize=256m --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED --add-exports=java.base/sun.nio.ch=ALL-UNNAMED"#' /opt/ignite/bin/ignite.sh
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

# wait unitl 11211 port is opened.
while netstat -lnt | awk '$4 ~ /:11211$/ {exit 1}'; do sleep 10; done
sleep 10

# execute a sample 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 --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED --add-exports=java.base/sun.nio.ch=ALL-UNNAMED -cp .:/opt/ignite/libs/ignite-core-2.7.0.jar sjsql org.apache.ignite.IgniteJdbcThinDriver jdbc:ignite:thin://127.0.0.1/ test test /home/vagrant/test.sql

SHELL
end


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

2019年2月20日水曜日

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

Apache Igniteはメモリ指向の分散データベースです。

○構築方法
以下のVagrantfileを使用して、Apache Ignite2.7.0をインストールした仮想マシン(Debian Stretch/9.6)を構築する事が出来ます。

Vagrantfile
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "bento/debian-9.6"
  config.vm.hostname = "db96ignite270"
  config.vm.provider :virtualbox do |vbox|
     vbox.name = "db96ignite270"
     vbox.cpus = 2
     vbox.memory = 2048
     vbox.customize ["modifyvm", :id, "--nicpromisc2","allow-all"]
  end
config.vm.network "private_network", ip: "192.168.55.106", :netmask => "255.255.255.0"
config.vm.network "public_network", ip:"192.168.1.106", :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 OpenJDK11
cat <<EOF | sudo tee /etc/apt/sources.list.d/stretch-backports.list
deb http://http.debian.net/debian stretch-backports main contrib non-free
EOF
apt-get update
apt-get -y install openjdk-11-jdk

apt-get -y install unzip
wget https://www-eu.apache.org/dist//ignite/2.7.0/apache-ignite-2.7.0-bin.zip
unzip apache-ignite-2.7.0-bin.zip
mv apache-ignite-2.7.0-bin /opt/ignite

sed -i -e 's#JVM_OPTS="-Xms1g -Xmx1g -server -XX:MaxMetaspaceSize=256m"#JVM_OPTS="-Xms1g -Xmx1g -server -XX:MaxMetaspaceSize=256m --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED --add-exports=java.base/sun.nio.ch=ALL-UNNAMED"#' /opt/ignite/bin/ignite.sh
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

# wait unitl 11211 port is opened.
while netstat -lnt | awk '$4 ~ /:11211$/ {exit 1}'; do sleep 10; done
sleep 10

# execute a sample 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 --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED --add-exports=java.base/sun.nio.ch=ALL-UNNAMED -cp .:/opt/ignite/libs/ignite-core-2.7.0.jar sjsql org.apache.ignite.IgniteJdbcThinDriver jdbc:ignite:thin://127.0.0.1/ test test /home/vagrant/test.sql 

SHELL
end


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

2018年6月14日木曜日

VagrantでJupyter LabとApache Igniteをインストールした仮想マシン(Ubuntu18.04)を構築する

Jupyter Labでインタラクティブなコンピューティング環境を提供する事ができます。

○Jupyter Labの画面


構築方法

以下のVagrantfileで、Jupyter LabとApache Igniteをインストールした仮想マシン(Ubuntu18.04)を構築する事ができます。
Jupyter LabからApache IgniteにODBCプロトコルで接続します。

Vagrantfile
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "bento/ubuntu-18.04"
  config.vm.hostname = "ub1804jupyterlabignite"
  config.vm.provider :virtualbox do |vbox|
     vbox.name = "ub1804jupyterlabignite"
     vbox.cpus = 2
     vbox.memory = 2048
     vbox.customize ["modifyvm", :id, "--nicpromisc2","allow-all"]
  end
config.vm.network "private_network", ip: "192.168.55.101", :netmask => "255.255.255.0"
config.vm.network "public_network", ip:"192.168.1.101", :netmask => "255.255.255.0"
  config.vm.provision "shell", inline: <<-SHELL
# update packages
apt-get update
#DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
locale-gen ja_JP.UTF-8
localectl set-locale LANG=ja_JP.UTF-8


# 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.4.0/apache-ignite-fabric-2.4.0-bin.zip
unzip apache-ignite-fabric-2.4.0-bin.zip
mv apache-ignite-fabric-2.4.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

# wait until it starts to listen on 11211 port.
while netstat -lnt | awk '$4 ~ /:11211$/ {exit 1}'; do sleep 10; done
sleep 10

# execute sample statements.
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, 'hello world!');
insert into test1 (test_id, test_desc) values (2, 'テストだよ');
select * from test1;
EOF
export LC_ALL=ja_JP.UTF-8 && java -cp .:/opt/ignite/libs/ignite-core-2.4.0.jar sjsql org.apache.ignite.IgniteJdbcThinDriver jdbc:ignite:thin://127.0.0.1/ test test /home/vagrant/test.sql


# install anaconda & jupyterlab
wget https://repo.continuum.io/archive/Anaconda3-5.1.0-Linux-x86_64.sh
chmod +x Anaconda3-5.1.0-Linux-x86_64.sh
./Anaconda3-5.1.0-Linux-x86_64.sh -b -p /opt/anaconda
source /opt/anaconda/bin/activate
pip install --upgrade pip
pip install jupyterlab

# install ignite driver
pip install ignite


useradd py
mkdir -p /home/py
chown -R py:py /home/py
sudo -u py bash -c "mkdir /home/py/.jupyter"
sudo -u py bash -c "cat << EOF > /home/py/.jupyter/jupyter_notebook_config.py
conf = get_config()
conf.NotebookApp.ip = '*'
conf.NotebookApp.open_browser = False
conf.NotebookApp.port = 8080
conf.NotebookApp.token = 'jupyter'
EOF"

cat << EOF > /etc/systemd/system/jupyter.service
[Unit]
Description=Jupyter notebook
[Service]
Type=simple
EnvironmentFile=/opt/anaconda/bin/activate
ExecStart=/opt/anaconda/bin/jupyter lab
User=py
Group=py
WorkingDirectory=/home/py
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl enable jupyter
sudo systemctl start jupyter

# build odbc driver and install
apt-get -y install build-essential libtool m4 automake unixodbc unixodbc-dev
cd /opt/ignite/platforms/cpp/
libtoolize && aclocal && autoheader && automake --add-missing && autoreconf
./configure --enable-odbc --disable-node --disable-core
make
make install
odbcinst -i -d -f /opt/ignite/platforms/cpp/odbc/install/ignite-odbc-install.ini
echo '/usr/local/lib' >> /etc/ld.so.conf.d/ignite.conf
ldconfig

echo 'access -> http://192.168.55.101:8080/?token=jupyter'

SHELL
end

〇動作確認用コード
import pyodbc
conn = pyodbc.connect('DRIVER={Apache Ignite};Address=127.0.0.1:10800;CACHE=MyCache',autocommit=True)
conn.setdecoding(pyodbc.SQL_CHAR, 'utf-8')
conn.setdecoding(pyodbc.SQL_WCHAR, 'utf-8')
cur = conn.cursor()
cur.execute("select * from test1")
rows = cur.fetchall()
for row in rows:
  print("%d %s" % (row[0], row[1]))

関連情報

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

2018年5月31日木曜日

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

Apache Igniteはメモリ指向の分散データベースです。

○構築方法
以下のVagrantfileを使用して、Apache Ignite2.4.0をインストールした仮想マシン(Debian Stretch/9.4)を構築する事が出来ます。

Vagrantfile
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "bento/debian-9.4"
  config.vm.hostname = "db94ignite240"
  config.vm.provider :virtualbox do |vbox|
     vbox.name = "db94ignite240"
     vbox.cpus = 2
     vbox.memory = 2048
     vbox.customize ["modifyvm", :id, "--nicpromisc2","allow-all"]
  end
config.vm.network "private_network", ip: "192.168.55.106", :netmask => "255.255.255.0"
config.vm.network "public_network", ip:"192.168.1.106", :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.4.0/apache-ignite-fabric-2.4.0-bin.zip
unzip apache-ignite-fabric-2.4.0-bin.zip
mv apache-ignite-fabric-2.4.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.4.0.jar sjsql org.apache.ignite.IgniteJdbcThinDriver jdbc:ignite:thin://127.0.0.1/ test test /home/vagrant/test.sql

SHELL
end

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

2018年5月3日木曜日

LXDでApache Ignite2.4.0がインストールされたコンテナ(Ubuntu18.04)を構築する

Apache Igniteはメモリ指向の分散データベースです。

〇コンテナの構築
LXDで以下のコマンドを実行して、Apache Ignite2.4.0がインストールされたコンテナを構築します。
lxc init ubuntu:18.04 ub1804apacheignite240
lxc config set ub1804apacheignite240 user.user-data - < config.yml
lxc start ub1804apacheignite240

config.yml
#cloud-config

package_upgrade: true

hostname: ub1804apacheignite240
manage_etc_hosts: true

write_files:
  - path: /etc/systemd/system/ignite.service
    content: |
      [Unit]
      Description=Apache Ignite

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

      [Install]
      WantedBy=multi-user.target

  - path: /tmp/test.sql
    content: |
      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;

runcmd:
  - 'apt-get update'
  - 'apt-get -y install openjdk-8-jdk'
  - 'apt-get -y install unzip'
  - 'wget http://ftp.meisei-u.ac.jp/mirror/apache/dist//ignite/2.4.0/apache-ignite-fabric-2.4.0-bin.zip'
  - 'unzip apache-ignite-fabric-2.4.0-bin.zip'
  - 'mv apache-ignite-fabric-2.4.0-bin /opt/ignite'
  - systemctl enable ignite.service
  - systemctl start ignite.service
  - "while netstat -lnt | awk '$4 ~ /:11211$/ {exit 1}'; do sleep 10; done"
  - "sleep 10"
  - "wget http://wiki.metawerx.net/attach/SJSQL/sjsql.java"
  - "wget http://wiki.metawerx.net/attach/SJSQL/sjsql.class"
  - "java -cp .:/opt/ignite/libs/ignite-core-2.4.0.jar sjsql org.apache.ignite.IgniteJdbcThinDriver jdbc:ignite:thin://127.0.0.1/ test test /tmp/test.sql"
final_message: "completed."

〇コンテナに入る
lxc exec ub1804apacheignite240 /bin/bash

〇ホストマシンの外部からコンテナにアクセスしたい場合
以下のコマンドを実行します。
PORT=11211 PUBLIC_IP=<ホストのIP> CONTAINER_IP=<コンテナのIP> sudo -E bash -c 'iptables -t nat -I PREROUTING -i eth0 -p TCP -d $PUBLIC_IP --dport $PORT -j DNAT --to-destination $CONTAINER_IP:$PORT -m comment --comment "container"'

〇コンテナのIPを調べる
コンテナのIPは以下のコマンドで調べることができます。
lxc list

〇コンテナの停止
lxc stop ub1804apacheignite240

〇コンテナの削除
lxc delete ub1804apacheignite240

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

2018年4月16日月曜日

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

Apache Igniteはメモリ指向の分散データベースです。
以下のVagrantfileを使用して、Apache Ignite2.4.0をインストールした仮想マシン(Debian Stretch/9.3)を構築する事が出来ます。

Vagrantfile
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "bento/debian-9.3"
  config.vm.hostname = "db93ignite240"
  config.vm.provider :virtualbox do |vbox|
     vbox.name = "db93ignite240"
     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.4.0/apache-ignite-fabric-2.4.0-bin.zip
unzip apache-ignite-fabric-2.4.0-bin.zip
mv apache-ignite-fabric-2.4.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.4.0.jar sjsql org.apache.ignite.IgniteJdbcThinDriver jdbc:ignite:thin://127.0.0.1/ test test /home/vagrant/test.sql

SHELL
end


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

2018年4月13日金曜日

VagrantでJupyter LabとApache Igniteをインストールした仮想マシン(Debian Stretch/9.3)を構築する

Jupyter Labでインタラクティブなコンピューティング環境を提供する事ができます。
以下のVagrantfileで、Jupyter LabとApache Igniteをインストールした仮想マシン(Debian Stretch/9.3)を構築する事ができます。
Jupyter LabからApache IgniteにODBCプロトコルで接続します。

Vagrantfile
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "bento/debian-9.3"
  config.vm.hostname = "db93jupyterlabignite240"
  config.vm.provider :virtualbox do |vbox|
     vbox.name = "db93jupyterlabignite240"
     vbox.cpus = 2
     vbox.memory = 2048
     vbox.customize ["modifyvm", :id, "--nicpromisc2","allow-all"]
  end
config.vm.network "private_network", ip: "192.168.55.101", :netmask => "255.255.255.0"
config.vm.network "public_network", ip:"192.168.1.101", :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.4.0/apache-ignite-fabric-2.4.0-bin.zip
unzip apache-ignite-fabric-2.4.0-bin.zip
mv apache-ignite-fabric-2.4.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, 'hello world!');
insert into test1 (test_id, test_desc) values (2, 'テストだよ');
select * from test1;
EOF
java -cp .:/opt/ignite/libs/ignite-core-2.4.0.jar sjsql org.apache.ignite.IgniteJdbcThinDriver jdbc:ignite:thin://127.0.0.1/ test test /home/vagrant/test.sql


# install anaconda & jupyterlab
wget https://repo.continuum.io/archive/Anaconda3-5.1.0-Linux-x86_64.sh
chmod +x Anaconda3-5.1.0-Linux-x86_64.sh
./Anaconda3-5.1.0-Linux-x86_64.sh -b -p /opt/anaconda
source /opt/anaconda/bin/activate
pip install --upgrade pip
pip install jupyterlab

# install ignite driver
pip install ignite

useradd py
mkdir -p /home/py
chown -R py:py /home/py
sudo -u py bash -c "mkdir /home/py/.jupyter"
sudo -u py bash -c "cat << EOF > /home/py/.jupyter/jupyter_notebook_config.py
conf = get_config()
conf.NotebookApp.ip = '*'
conf.NotebookApp.open_browser = False
conf.NotebookApp.port = 8080
conf.NotebookApp.token = 'jupyter'
EOF"

cat << EOF > /etc/systemd/system/jupyter.service
[Unit]
Description=Jupyter notebook
[Service]
Type=simple
ExecStartPre=source /opt/anaconda/bin/activate
ExecStart=/opt/anaconda/bin/jupyter lab
User=py
Group=py
WorkingDirectory=/home/py
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl enable jupyter
sudo systemctl start jupyter

# build odbc driver and install
apt-get -y install build-essential libtool m4 automake unixodbc unixodbc-dev
cd /opt/ignite/platforms/cpp/
libtoolize && aclocal && autoheader && automake --add-missing && autoreconf
./configure --enable-odbc --disable-node --disable-core
make
make install
odbcinst -i -d -f /opt/ignite/platforms/cpp/odbc/install/ignite-odbc-install.ini
echo '/usr/local/lib' >> /etc/ld.so.conf.d/ignite.conf
ldconfig

echo 'url for jupyter lab -> http://192.168.55.101:8080/?token=jupyter'

SHELL
end

〇動作確認用コード
import pyodbc

conn = pyodbc.connect('DRIVER={Apache Ignite};Address=127.0.0.1:10800;CACHE=MyCache',autocommit=True)
conn.setdecoding(pyodbc.SQL_CHAR, 'utf-8')
conn.setdecoding(pyodbc.SQL_WCHAR, 'utf-8')
cur = conn.cursor()
cur.execute("select * from test1")
rows = cur.fetchall()
for row in rows:
  print("%d %s" % (row[0], row[1]))

〇Jupyter Labの画面

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

2018年4月11日水曜日

VagrantでApache Ignite2.4.0をインストールした仮想マシン(CentOS7.4)を構築する

Apache Igniteはメモリ指向の分散データベースです。
以下のVagrantfileを使用して、Apache Ignite2.4.0をインストールした仮想マシン(CentOS7.4)を構築する事が出来ます。

Vagrantfile
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "bento/centos-7.4"
  config.vm.hostname = "co74ignite240"
config.vm.network :public_network, ip:"192.168.1.117"
config.vm.network "private_network", ip: "192.168.55.117", :netmask => "255.255.255.0"
  config.vm.provider :virtualbox do |vbox|
    vbox.name = "co74ignite240"
    vbox.cpus = 2
    vbox.memory = 2048
    vbox.customize ["modifyvm", :id, "--nicpromisc2","allow-all"]
  end
  config.vm.provision "shell", inline: <<-SHELL

# install OpenJDK8
yum -y install java-1.8.0-openjdk

# install ignite
yum -y install unzip
wget https://dist.apache.org/repos/dist/release/ignite/2.4.0/apache-ignite-fabric-2.4.0-bin.zip
unzip apache-ignite-fabric-2.4.0-bin.zip
mv apache-ignite-fabric-2.4.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.4.0.jar sjsql org.apache.ignite.IgniteJdbcThinDriver jdbc:ignite:thin://127.0.0.1/ test test /home/vagrant/test.sql

SHELL
end


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

2018年3月28日水曜日

VagrantでJupyter LabとApache Igniteをインストールした仮想マシン(Ubuntu16.04)を構築する

Jupyter Labでインタラクティブなコンピューティング環境を提供する事ができます。
以下のVagrantfileで、Jupyter LabとApache Igniteをインストールした仮想マシンを構築する事ができます。
Jupyter LabからApache IgniteにODBCプロトコルで接続します。

Vagrantfile
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "bento/ubuntu-16.04"
  config.vm.hostname = "ub1604jupyterlabmonetdb"
  config.vm.provider :virtualbox do |vbox|
     vbox.name = "ub1604jupyterlabmonetdb"
     vbox.cpus = 2
     vbox.memory = 2048
     vbox.customize ["modifyvm", :id, "--nicpromisc2","allow-all"]
  end
config.vm.network "private_network", ip: "192.168.55.101", :netmask => "255.255.255.0"
config.vm.network "public_network", ip:"192.168.1.101", :netmask => "255.255.255.0"
  config.vm.provision "shell", inline: <<-SHELL
# update packages
apt-get update
#DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
locale-gen ja_JP.UTF-8
localectl set-locale LANG=ja_JP.UTF-8


# 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.4.0/apache-ignite-fabric-2.4.0-bin.zip
unzip apache-ignite-fabric-2.4.0-bin.zip
mv apache-ignite-fabric-2.4.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, 'hello world!');
insert into test1 (test_id, test_desc) values (2, 'テストだよ');
select * from test1;
EOF
java -cp .:/opt/ignite/libs/ignite-core-2.4.0.jar sjsql org.apache.ignite.IgniteJdbcThinDriver jdbc:ignite:thin://127.0.0.1/ test test /home/vagrant/test.sql


# install anaconda & jupyterlab
wget https://repo.continuum.io/archive/Anaconda3-5.1.0-Linux-x86_64.sh
chmod +x Anaconda3-5.1.0-Linux-x86_64.sh
./Anaconda3-5.1.0-Linux-x86_64.sh -b -p /opt/anaconda
source /opt/anaconda/bin/activate
pip install --upgrade pip
pip install jupyterlab

# install ignite driver
pip install ignite


useradd py
mkdir -p /home/py
chown -R py:py /home/py
sudo -u py bash -c "mkdir /home/py/.jupyter"
sudo -u py bash -c "cat << EOF > /home/py/.jupyter/jupyter_notebook_config.py
conf = get_config()
conf.NotebookApp.ip = '*'
conf.NotebookApp.open_browser = False
conf.NotebookApp.port = 8080
conf.NotebookApp.token = 'jupyter'
EOF"

cat << EOF > /etc/systemd/system/jupyter.service
[Unit]
Description=Jupyter notebook
[Service]
Type=simple
ExecStartPre=source /opt/anaconda/bin/activate
ExecStart=/opt/anaconda/bin/jupyter lab
User=py
Group=py
WorkingDirectory=/home/py
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl enable jupyter
sudo systemctl start jupyter

# build odbc driver and install
apt-get -y install build-essential libtool m4 automake unixodbc unixodbc-dev
cd /opt/ignite/platforms/cpp/
libtoolize && aclocal && autoheader && automake --add-missing && autoreconf
./configure --enable-odbc --disable-node --disable-core
make
make install
odbcinst -i -d -f /opt/ignite/platforms/cpp/odbc/install/ignite-odbc-install.ini
echo '/usr/local/lib' >> /etc/ld.so.conf.d/ignite.conf
ldconfig

echo 'access -> http://192.168.55.101:8080/?token=jupyter'

SHELL
end

〇動作確認用コード
import pyodbc
conn = pyodbc.connect('DRIVER={Apache Ignite};Address=127.0.0.1:10800;CACHE=MyCache',autocommit=True)
conn.setdecoding(pyodbc.SQL_CHAR, 'utf-8')
conn.setdecoding(pyodbc.SQL_WCHAR, 'utf-8')
cur = conn.cursor()
cur.execute("select * from test1")
rows = cur.fetchall()
for row in rows:
  print("%d %s" % (row[0], row[1]))

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

2018年3月27日火曜日

VagrantでApache Ignite2.4.0をインストールした仮想マシン(Ubuntu16.04)を構築する

Apache Igniteはメモリ指向の分散データベースです。
以下のVagrantfileを使用して、Apache Ignite2.4.0をインストールした仮想マシンを構築する事が出来ます。

Vagrantfile
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "bento/ubuntu-16.04"
  config.vm.hostname = "ub1604ignite240"
  config.vm.provider :virtualbox do |vbox|
     vbox.name = "ub1604ignite240"
     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
# update packages
apt-get update
#DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
locale-gen ja_JP.UTF-8
localectl set-locale LANG=ja_JP.UTF-8
apt-get -y install unzip

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

wget http://www-us.apache.org/dist//ignite/2.4.0/apache-ignite-fabric-2.4.0-bin.zip
unzip apache-ignite-fabric-2.4.0-bin.zip
mv apache-ignite-fabric-2.4.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.4.0.jar sjsql org.apache.ignite.IgniteJdbcThinDriver jdbc:ignite:thin://127.0.0.1/ test test /home/vagrant/test.sql

SHELL
end


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

2018年3月21日水曜日

VagrantでApache Ignite2.4.0がインストールされた仮想マシン(Ubuntu16.04)の3ノードクラスタを構築する

Apache Igniteはメモリ指向の分散データベースです。
以下のVagrantfileを使用して、Apache Igniteがインストールされた3ノードクラスタを構築する事ができます。

Vagrantfile
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.define "ignode1" do |server|
    server.vm.box = "bento/ubuntu-16.04"
    server.vm.hostname = "ignode1"
server.vm.network :public_network, ip:"192.168.1.91"
server.vm.network "private_network", ip: "192.168.55.91", :netmask => "255.255.255.0"
    server.vm.provider :virtualbox do |vbox|
      vbox.name = "ignode1"
      vbox.cpus = 2
      vbox.memory = 2048
      vbox.customize ["modifyvm", :id, "--nicpromisc2","allow-all"]
    end
    server.vm.provision "shell", inline: <<-SHELL
# add host entries...
sed -i -e 's/^.*ignode1$//' /etc/hosts
cat << EOF >> /etc/hosts
192.168.55.91    ignode1
192.168.55.92    ignode2
192.168.55.93    ignode3
EOF

# update packages
apt-get update
#DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
locale-gen ja_JP.UTF-8
localectl set-locale LANG=ja_JP.UTF-8
apt-get -y install unzip

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

# download and install zookeeper
wget http://ftp.riken.jp/net/apache/zookeeper/zookeeper-3.4.11/zookeeper-3.4.11.tar.gz
tar xvfz zookeeper-3.4.11.tar.gz
mv zookeeper-3.4.11 /opt/zookeeper

# create configuration file.
cat << EOF > /opt/zookeeper/conf/zoo.cfg
tickTime=2000
dataDir=/var/zookeeper
clientPort=2181
initLimit=5
syncLimit=2
server.1=ignode1:2888:3888
server.2=ignode2:2888:3888
server.3=ignode3:2888:3888
EOF

mkdir -p /var/zookeeper
echo '1' >> /var/zookeeper/myid

# register as a service.
cat << EOF > /etc/systemd/system/zookeeper.service
[Unit]
Description=Apache Zookeeper
Requires=network.target
After=network.target

[Service]
Type=forking
ExecStart=/opt/zookeeper/bin/zkServer.sh start /opt/zookeeper/conf/zoo.cfg
ExecStop=/opt/zookeeper/bin/zkServer.sh stop
WorkingDirectory=/opt/zookeeper

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

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

# Apache Igniteのインストール
wget http://www-us.apache.org/dist//ignite/2.4.0/apache-ignite-fabric-2.4.0-bin.zip
unzip apache-ignite-fabric-2.4.0-bin.zip
mv apache-ignite-fabric-2.4.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

SHELL
  end
  #----------------------------------------------------------------------------------------
  config.vm.define "ignode2" do |server|
    server.vm.box = "bento/ubuntu-16.04"
    server.vm.hostname = "ignode2"
server.vm.network :public_network, ip:"192.168.1.92"
server.vm.network "private_network", ip: "192.168.55.92", :netmask => "255.255.255.0"
    server.vm.provider :virtualbox do |vbox|
      vbox.name = "ignode2"
      vbox.cpus = 2
      vbox.memory = 2048
      vbox.customize ["modifyvm", :id, "--nicpromisc2","allow-all"]
    end
    server.vm.provision "shell", inline: <<-SHELL
# add host entries...
sed -i -e 's/^.*ignode2$//' /etc/hosts
cat << EOF >> /etc/hosts
192.168.55.91    ignode1
192.168.55.92    ignode2
192.168.55.93    ignode3
EOF

# update packages
apt-get update
#DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
locale-gen ja_JP.UTF-8
localectl set-locale LANG=ja_JP.UTF-8
apt-get -y install unzip

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

# download and install zookeeper
wget http://ftp.riken.jp/net/apache/zookeeper/zookeeper-3.4.11/zookeeper-3.4.11.tar.gz
tar xvfz zookeeper-3.4.11.tar.gz
mv zookeeper-3.4.11 /opt/zookeeper

# create configuration file.
cat << EOF > /opt/zookeeper/conf/zoo.cfg
tickTime=2000
dataDir=/var/zookeeper
clientPort=2181
initLimit=5
syncLimit=2
server.1=ignode1:2888:3888
server.2=ignode2:2888:3888
server.3=ignode3:2888:3888
EOF

mkdir -p /var/zookeeper
echo '2' >> /var/zookeeper/myid

# register as a service.
cat << EOF > /etc/systemd/system/zookeeper.service
[Unit]
Description=Apache Zookeeper
Requires=network.target
After=network.target

[Service]
Type=forking
ExecStart=/opt/zookeeper/bin/zkServer.sh start /opt/zookeeper/conf/zoo.cfg
ExecStop=/opt/zookeeper/bin/zkServer.sh stop
WorkingDirectory=/opt/zookeeper

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

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

# Apache Igniteのインストール
wget http://www-us.apache.org/dist//ignite/2.4.0/apache-ignite-fabric-2.4.0-bin.zip
unzip apache-ignite-fabric-2.4.0-bin.zip
mv apache-ignite-fabric-2.4.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


SHELL
  end
  #----------------------------------------------------------------------------------------
  config.vm.define "ignode3" do |server|
    server.vm.box = "bento/ubuntu-16.04"
    server.vm.hostname = "ignode3"
server.vm.network :public_network, ip:"192.168.1.93"
server.vm.network "private_network", ip: "192.168.55.93", :netmask => "255.255.255.0"
    server.vm.provider :virtualbox do |vbox|
      vbox.name = "ignode3"
      vbox.cpus = 2
      vbox.memory = 2048
      vbox.customize ["modifyvm", :id, "--nicpromisc2","allow-all"]
    end
    server.vm.provision "shell", inline: <<-SHELL
# add host entries...
sed -i -e 's/^.*ignode3$//' /etc/hosts
cat << EOF >> /etc/hosts
192.168.55.91    ignode1
192.168.55.92    ignode2
192.168.55.93    ignode3
EOF


# update packages
apt-get update
#DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
locale-gen ja_JP.UTF-8
localectl set-locale LANG=ja_JP.UTF-8
apt-get -y install unzip

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

# download and install zookeeper
wget http://ftp.riken.jp/net/apache/zookeeper/zookeeper-3.4.11/zookeeper-3.4.11.tar.gz
tar xvfz zookeeper-3.4.11.tar.gz
mv zookeeper-3.4.11 /opt/zookeeper

# create configuration file.
cat << EOF > /opt/zookeeper/conf/zoo.cfg
tickTime=2000
dataDir=/var/zookeeper
clientPort=2181
initLimit=5
syncLimit=2
server.1=ignode1:2888:3888
server.2=ignode2:2888:3888
server.3=ignode3:2888:3888
EOF

mkdir -p /var/zookeeper
echo '3' >> /var/zookeeper/myid

# register as a service.
cat << EOF > /etc/systemd/system/zookeeper.service
[Unit]
Description=Apache Zookeeper
Requires=network.target
After=network.target

[Service]
Type=forking
ExecStart=/opt/zookeeper/bin/zkServer.sh start /opt/zookeeper/conf/zoo.cfg
ExecStop=/opt/zookeeper/bin/zkServer.sh stop
WorkingDirectory=/opt/zookeeper

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

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

# Apache Igniteのインストール
wget http://www-us.apache.org/dist//ignite/2.4.0/apache-ignite-fabric-2.4.0-bin.zip
unzip apache-ignite-fabric-2.4.0-bin.zip
mv apache-ignite-fabric-2.4.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/test1.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');
EOF
java -cp .:/opt/ignite/libs/ignite-core-2.4.0.jar sjsql org.apache.ignite.IgniteJdbcThinDriver jdbc:ignite:thin://ignode1/ test test /home/vagrant/test1.sql

cat << EOF >> /home/vagrant/test2.sql
insert into test1 (test_id, test_desc) values (2, 'test_id_002');
EOF
java -cp .:/opt/ignite/libs/ignite-core-2.4.0.jar sjsql org.apache.ignite.IgniteJdbcThinDriver jdbc:ignite:thin://ignode2/ test test /home/vagrant/test2.sql

cat << EOF >> /home/vagrant/test3.sql
insert into test1 (test_id, test_desc) values (3, 'test_id_003');
select * from test1;
EOF
java -cp .:/opt/ignite/libs/ignite-core-2.4.0.jar sjsql org.apache.ignite.IgniteJdbcThinDriver jdbc:ignite:thin://ignode3/ test test /home/vagrant/test3.sql


SHELL
  end
  #----------------------------------------------------------------------------------------

end


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

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に関する他の記事はこちらを参照してください。

2017年12月6日水曜日

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

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

Vagrantfile
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "bento/ubuntu-16.04"
  config.vm.hostname = "ub1604ignite"
  config.vm.provider :virtualbox do |vbox|
     vbox.name = "ub1604ignite"
     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
# update packages
apt-get update
#DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
locale-gen ja_JP.UTF-8
localectl set-locale LANG=ja_JP.UTF-8
apt-get -y install unzip

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

wget http://www-us.apache.org/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に関する他の記事はこちらを参照してください。

2017年11月22日水曜日

VagrantでApache Igniteがインストールされた仮想マシン(Ubuntu16.04)の3ノードクラスタを構築する

以下のVagrantfileを使用して、Apache Igniteがインストールされた3ノードクラスタを構築する事ができます。

Vagrantfile
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.define "ignode1" do |server|
    server.vm.box = "bento/ubuntu-16.04"
    server.vm.hostname = "ignode1"
    server.vm.network :public_network, ip:"192.168.1.91"
    server.vm.network "private_network", ip: "192.168.55.91", :netmask => "255.255.255.0"
    server.vm.provider :virtualbox do |vbox|
      vbox.name = "ignode1"
      vbox.cpus = 2
      vbox.memory = 2048
      vbox.customize ["modifyvm", :id, "--nicpromisc2","allow-all"]
    end
    server.vm.provision "shell", inline: <<-SHELL
# add host entries...
sed -i -e 's/^.*ignode1$//' /etc/hosts
cat << EOF >> /etc/hosts
192.168.55.91    ignode1
192.168.55.92    ignode2
192.168.55.93    ignode3
EOF

# update packages
apt-get update
#DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
locale-gen ja_JP.UTF-8
localectl set-locale LANG=ja_JP.UTF-8
apt-get -y install unzip

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

# download and install zookeeper
wget http://ftp.riken.jp/net/apache/zookeeper/zookeeper-3.4.11/zookeeper-3.4.11.tar.gz
tar xvfz zookeeper-3.4.11.tar.gz
mv zookeeper-3.4.11 /opt/zookeeper

# create configuration file.
cat << EOF > /opt/zookeeper/conf/zoo.cfg
tickTime=2000
dataDir=/var/zookeeper
clientPort=2181
initLimit=5
syncLimit=2
server.1=ignode1:2888:3888
server.2=ignode2:2888:3888
server.3=ignode3:2888:3888
EOF

mkdir -p /var/zookeeper
echo '1' >> /var/zookeeper/myid

# register as a service.
cat << EOF > /etc/systemd/system/zookeeper.service
[Unit]
Description=Apache Zookeeper
Requires=network.target
After=network.target

[Service]
Type=forking
ExecStart=/opt/zookeeper/bin/zkServer.sh start /opt/zookeeper/conf/zoo.cfg
ExecStop=/opt/zookeeper/bin/zkServer.sh stop
WorkingDirectory=/opt/zookeeper

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

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

# Apache Igniteのインストール
wget http://www-us.apache.org/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

SHELL
  end
  #----------------------------------------------------------------------------------------
  config.vm.define "ignode2" do |server|
    server.vm.box = "bento/ubuntu-16.04"
    server.vm.hostname = "ignode2"
    server.vm.network :public_network, ip:"192.168.1.92"
    server.vm.network "private_network", ip: "192.168.55.92", :netmask => "255.255.255.0"
    server.vm.provider :virtualbox do |vbox|
      vbox.name = "ignode2"
      vbox.cpus = 2
      vbox.memory = 2048
      vbox.customize ["modifyvm", :id, "--nicpromisc2","allow-all"]
    end
    server.vm.provision "shell", inline: <<-SHELL
# add host entries...
sed -i -e 's/^.*ignode2$//' /etc/hosts
cat << EOF >> /etc/hosts
192.168.55.91    ignode1
192.168.55.92    ignode2
192.168.55.93    ignode3
EOF

# update packages
apt-get update
#DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
locale-gen ja_JP.UTF-8
localectl set-locale LANG=ja_JP.UTF-8
apt-get -y install unzip

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

# download and install zookeeper
wget http://ftp.riken.jp/net/apache/zookeeper/zookeeper-3.4.11/zookeeper-3.4.11.tar.gz
tar xvfz zookeeper-3.4.11.tar.gz
mv zookeeper-3.4.11 /opt/zookeeper

# create configuration file.
cat << EOF > /opt/zookeeper/conf/zoo.cfg
tickTime=2000
dataDir=/var/zookeeper
clientPort=2181
initLimit=5
syncLimit=2
server.1=ignode1:2888:3888
server.2=ignode2:2888:3888
server.3=ignode3:2888:3888
EOF

mkdir -p /var/zookeeper
echo '2' >> /var/zookeeper/myid

# register as a service.
cat << EOF > /etc/systemd/system/zookeeper.service
[Unit]
Description=Apache Zookeeper
Requires=network.target
After=network.target

[Service]
Type=forking
ExecStart=/opt/zookeeper/bin/zkServer.sh start /opt/zookeeper/conf/zoo.cfg
ExecStop=/opt/zookeeper/bin/zkServer.sh stop
WorkingDirectory=/opt/zookeeper

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

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

# Apache Igniteのインストール
wget http://www-us.apache.org/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


SHELL
  end
  #----------------------------------------------------------------------------------------
  config.vm.define "ignode3" do |server|
    server.vm.box = "bento/ubuntu-16.04"
    server.vm.hostname = "ignode3"
    server.vm.network :public_network, ip:"192.168.1.93"
    server.vm.network "private_network", ip: "192.168.55.93", :netmask => "255.255.255.0"
    server.vm.provider :virtualbox do |vbox|
      vbox.name = "ignode3"
      vbox.cpus = 2
      vbox.memory = 2048
      vbox.customize ["modifyvm", :id, "--nicpromisc2","allow-all"]
    end
    server.vm.provision "shell", inline: <<-SHELL
# add host entries...
sed -i -e 's/^.*ignode3$//' /etc/hosts
cat << EOF >> /etc/hosts
192.168.55.91    ignode1
192.168.55.92    ignode2
192.168.55.93    ignode3
EOF


# update packages
apt-get update
#DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
locale-gen ja_JP.UTF-8
localectl set-locale LANG=ja_JP.UTF-8
apt-get -y install unzip

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

# download and install zookeeper
wget http://ftp.riken.jp/net/apache/zookeeper/zookeeper-3.4.11/zookeeper-3.4.11.tar.gz
tar xvfz zookeeper-3.4.11.tar.gz
mv zookeeper-3.4.11 /opt/zookeeper

# create configuration file.
cat << EOF > /opt/zookeeper/conf/zoo.cfg
tickTime=2000
dataDir=/var/zookeeper
clientPort=2181
initLimit=5
syncLimit=2
server.1=ignode1:2888:3888
server.2=ignode2:2888:3888
server.3=ignode3:2888:3888
EOF

mkdir -p /var/zookeeper
echo '3' >> /var/zookeeper/myid

# register as a service.
cat << EOF > /etc/systemd/system/zookeeper.service
[Unit]
Description=Apache Zookeeper
Requires=network.target
After=network.target

[Service]
Type=forking
ExecStart=/opt/zookeeper/bin/zkServer.sh start /opt/zookeeper/conf/zoo.cfg
ExecStop=/opt/zookeeper/bin/zkServer.sh stop
WorkingDirectory=/opt/zookeeper

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

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

# Apache Igniteのインストール
wget http://www-us.apache.org/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/test1.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');
EOF
java -cp .:/opt/ignite/libs/ignite-core-2.3.0.jar sjsql org.apache.ignite.IgniteJdbcThinDriver jdbc:ignite:thin://ignode1/ test test /home/vagrant/test1.sql

cat << EOF >> /home/vagrant/test2.sql
insert into test1 (test_id, test_desc) values (2, 'test_id_002');
EOF
java -cp .:/opt/ignite/libs/ignite-core-2.3.0.jar sjsql org.apache.ignite.IgniteJdbcThinDriver jdbc:ignite:thin://ignode2/ test test /home/vagrant/test2.sql

cat << EOF >> /home/vagrant/test3.sql
insert into test1 (test_id, test_desc) values (3, 'test_id_003');
select * from test1;
EOF
java -cp .:/opt/ignite/libs/ignite-core-2.3.0.jar sjsql org.apache.ignite.IgniteJdbcThinDriver jdbc:ignite:thin://ignode3/ test test /home/vagrant/test3.sql


SHELL
  end
  #----------------------------------------------------------------------------------------

end

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

2017年11月12日日曜日

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

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

Vagrantfile
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "bento/centos-7.4"
  config.vm.hostname = "co74ignite"
  config.vm.network :public_network, ip:"192.168.1.117"
  config.vm.network "private_network", ip: "192.168.55.117", :netmask => "255.255.255.0"
  config.vm.provider :virtualbox do |vbox|
    vbox.name = "co74ignite"
    vbox.cpus = 2
    vbox.memory = 2048
    vbox.customize ["modifyvm", :id, "--nicpromisc2","allow-all"]
  end
  config.vm.provision "shell", inline: <<-SHELL

# install OpenJDK8
yum -y install java-1.8.0-openjdk

# install ignite
wget http://www-us.apache.org/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に関する他の記事はこちらを参照してください。