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

0 件のコメント:

コメントを投稿