〇CockroachDBのコンソール画面
〇構築方法
以下のVagrantfileを使用して、CockroachDB2.0.0がインストールされた仮想マシン(Debian Strech/9.3)を構築する事ができます。
Vagrantfile
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "bento/debian-9.3"
config.vm.hostname = "db93cockroarchdb200"
config.vm.provider :virtualbox do |vbox|
vbox.name = "db93cockroarchdb200"
vbox.cpus = 2
vbox.memory = 2048
vbox.customize ["modifyvm", :id, "--nicpromisc2","allow-all"]
end
config.vm.network "private_network", ip: "192.168.55.108", :netmask => "255.255.255.0"
config.vm.network "public_network", ip:"192.168.1.108", :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 cockroachdb
wget https://binaries.cockroachdb.com/cockroach-v2.0.0.linux-amd64.tgz
tar xvfz cockroach-v2.0.0.linux-amd64.tgz
mv cockroach-v2.0.0.linux-amd64 /opt/cockroach
cat << EOF > /etc/systemd/system/cockroachdb.service
[Unit]
Description=cockroachdb
Requires=network.target
After=zookeepepr.service
[Service]
Type=forking
WorkingDirectory=/opt/cockroach
ExecStart=/opt/cockroach/cockroach start --insecure --host=192.168.55.108 --background
ExecStop=/opt/cockroach/cockroach quit
[Install]
WantedBy=multi-user.target
EOF
systemctl enable cockroachdb.service
systemctl start cockroachdb.service
# execute sample sql statements
/opt/cockroach/cockroach sql --insecure --host=192.168.55.108 << EOF
CREATE DATABASE test;
CREATE TABLE test.messages (id INT PRIMARY KEY, message varchar(100));
INSERT INTO test.messages VALUES (1, 'hello world.');
select * from test.messages;
EOF
echo 'access to http://192.168.55.108:8080/'
SHELL
end
○関連情報
・CockroachDBに関する他の記事はこちらを参照してください。
0 件のコメント:
コメントを投稿