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

0 件のコメント:

コメントを投稿