AWS で Vantage Express を実行する方法
https://clearscape.teradata.com/では、Vantageのホストされたインスタンスを無料で入手できるようになりました。 |
概要
このハウツーでは、AWS で Vantage Express を実行する方法を示します。Vantage Express は、完全に機能する Teradata SQL Engineを含む、設置面積が小さい構成です。
クラウド料金
Vantage Express は仮想マシン イメージとして配布されます。このハウツーでは EC2 より安価なオプションが必要な場合は、ネストされた仮想化をサポートし、安価なVMでVantage Expressを実行できるGoogle Cloud と Azure を試してください。 クラウド利用に対して料金を払いたくない場合は、https://clearscape.teradata.com/ でVantageの無料ホストインスタンスを入手できます。または、VMware、VirtualBox、または UTM を使用してVantage Expressをローカルにインストールすることもできます。 |
前提条件
-
AWS アカウント。新しいアカウントを作成する必要がある場合は、 AWS の公式手順 に従ってください。
-
awscli
コマンド ライン ユーティリティがマシンにインストールされ、設定されていること。インストール手順はここで見つけることができます。https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html
インストール
-
インターネットに接続するサブネットを持つVPCが必要です。利用可能なものがない場合は、以下の方法で作成できます。
# Copied from https://cloudaffaire.com/how-to-create-a-custom-vpc-using-aws-cli/ # Create VPC AWS_VPC_ID=$(aws ec2 create-vpc \ --cidr-block 10.0.0.0/16 \ --query 'Vpc.{VpcId:VpcId}' \ --output text) # Enable DNS hostname for your VPC aws ec2 modify-vpc-attribute \ --vpc-id $AWS_VPC_ID \ --enable-dns-hostnames "{\"Value\":true}" # Create a public subnet AWS_SUBNET_PUBLIC_ID=$(aws ec2 create-subnet \ --vpc-id $AWS_VPC_ID --cidr-block 10.0.1.0/24 \ --query 'Subnet.{SubnetId:SubnetId}' \ --output text) # Enable Auto-assign Public IP on Public Subnet aws ec2 modify-subnet-attribute \ --subnet-id $AWS_SUBNET_PUBLIC_ID \ --map-public-ip-on-launch # Create an Internet Gateway AWS_INTERNET_GATEWAY_ID=$(aws ec2 create-internet-gateway \ --query 'InternetGateway.{InternetGatewayId:InternetGatewayId}' \ --output text) # Attach Internet gateway to your VPC aws ec2 attach-internet-gateway \ --vpc-id $AWS_VPC_ID \ --internet-gateway-id $AWS_INTERNET_GATEWAY_ID # Create a route table AWS_CUSTOM_ROUTE_TABLE_ID=$(aws ec2 create-route-table \ --vpc-id $AWS_VPC_ID \ --query 'RouteTable.{RouteTableId:RouteTableId}' \ --output text ) # Create route to Internet Gateway aws ec2 create-route \ --route-table-id $AWS_CUSTOM_ROUTE_TABLE_ID \ --destination-cidr-block 0.0.0.0/0 \ --gateway-id $AWS_INTERNET_GATEWAY_ID \ --output text # Associate the public subnet with route table AWS_ROUTE_TABLE_ASSOID=$(aws ec2 associate-route-table \ --subnet-id $AWS_SUBNET_PUBLIC_ID \ --route-table-id $AWS_CUSTOM_ROUTE_TABLE_ID \ --output text | head -1) # Create a security group aws ec2 create-security-group \ --vpc-id $AWS_VPC_ID \ --group-name myvpc-security-group \ --description 'My VPC non default security group' \ --output text # Get security group ID's AWS_DEFAULT_SECURITY_GROUP_ID=$(aws ec2 describe-security-groups \ --filters "Name=vpc-id,Values=$AWS_VPC_ID" \ --query 'SecurityGroups[?GroupName == `default`].GroupId' \ --output text) && AWS_CUSTOM_SECURITY_GROUP_ID=$(aws ec2 describe-security-groups \ --filters "Name=vpc-id,Values=$AWS_VPC_ID" \ --query 'SecurityGroups[?GroupName == `myvpc-security-group`].GroupId' \ --output text) # Create security group ingress rules aws ec2 authorize-security-group-ingress \ --group-id $AWS_CUSTOM_SECURITY_GROUP_ID \ --ip-permissions '[{"IpProtocol": "tcp", "FromPort": 22, "ToPort": 22, "IpRanges": [{"CidrIp": "0.0.0.0/0", "Description": "Allow SSH"}]}]' \ --output text # Add a tag to the VPC aws ec2 create-tags \ --resources $AWS_VPC_ID \ --tags "Key=Name,Value=vantage-express-vpc" # Add a tag to public subnet aws ec2 create-tags \ --resources $AWS_SUBNET_PUBLIC_ID \ --tags "Key=Name,Value=vantage-express-vpc-public-subnet" # Add a tag to the Internet-Gateway aws ec2 create-tags \ --resources $AWS_INTERNET_GATEWAY_ID \ --tags "Key=Name,Value=vantage-express-vpc-internet-gateway" # Add a tag to the default route table AWS_DEFAULT_ROUTE_TABLE_ID=$(aws ec2 describe-route-tables \ --filters "Name=vpc-id,Values=$AWS_VPC_ID" \ --query 'RouteTables[?Associations[0].Main != `false`].RouteTableId' \ --output text) && aws ec2 create-tags \ --resources $AWS_DEFAULT_ROUTE_TABLE_ID \ --tags "Key=Name,Value=vantage-express-vpc-default-route-table" # Add a tag to the public route table aws ec2 create-tags \ --resources $AWS_CUSTOM_ROUTE_TABLE_ID \ --tags "Key=Name,Value=vantage-express-vpc-public-route-table" # Add a tags to security groups aws ec2 create-tags \ --resources $AWS_CUSTOM_SECURITY_GROUP_ID \ --tags "Key=Name,Value=vantage-express-vpc-security-group" && aws ec2 create-tags \ --resources $AWS_DEFAULT_SECURITY_GROUP_ID \ --tags "Key=Name,Value=vantage-express-vpc-default-security-group"
-
VMを作成するには、sshキーペアが必要です。まだ持っていない場合は、作成してください。
aws ec2 create-key-pair --key-name vantage-key --query 'KeyMaterial' --output text > vantage-key.pem
-
秘密キーへのアクセスを制限してください。
<path_to_private_key_file>
を前述のコマンドで返された秘密キーのパスに置き換えます。chmod 600 vantage-key.pem
-
リージョンの最新のUbuntuイメージのAMI IDを取得します。
AWS_AMI_ID=$(aws ec2 describe-images \ --filters 'Name=name,Values=ubuntu/images/hvm-ssd/ubuntu-*amd64*' \ --query 'Images[*].[Name,ImageId,CreationDate]' --output text \ | sort -k3 -r | head -n1 | cut -f 2)
-
4 つの CPU、8 GB の RAM、および 70 GB のディスクを備えた Ubuntu VM を作成します。
AWS_INSTANCE_ID=$(aws ec2 run-instances \ --image-id $AWS_AMI_ID \ --count 1 \ --instance-type c5n.metal \ --block-device-mapping DeviceName=/dev/sda1,Ebs={VolumeSize=70} \ --key-name vantage-key \ --security-group-ids $AWS_CUSTOM_SECURITY_GROUP_ID \ --subnet-id $AWS_SUBNET_PUBLIC_ID \ --query 'Instances[0].InstanceId' \ --output text)
-
VMにsshで接続します。
AWS_INSTANCE_PUBLIC_IP=$(aws ec2 describe-instances \ --query "Reservations[*].Instances[*].PublicIpAddress" \ --output=text --instance-ids $AWS_INSTANCE_ID) ssh -i vantage-key.pem ubuntu@$AWS_INSTANCE_PUBLIC_IP
-
VM に接続したら、
root
ユーザーに切り替えます。sudo -i
-
Vantage Express のダウンロード ディレクトリを準備します。
mkdir /opt/downloads cd /opt/downloads
-
VirtualBoxと7 zipをインストールします。
apt update && apt-get install p7zip-full p7zip-rar virtualbox -y
-
curlコマンドを取得して、Vantage Expressをダウンロードします。
-
Vantage Expess のダウンロード ページに移動します (登録が必要です)。
-
「Vantage Express 17.20」などの最新のダウンロードリンクをクリックします。使用許諾契約のポップアップが表示されます。まだライセンスを受け入れません。
-
ブラウザでネットワークビューを開きます。例えば、Chrome で F12 を押し「
Network
」タブに移動します。 -
`I Agree (同意する)`ボタンをクリックしてライセンスを受け入れ、ダウンロードをキャンセルします。
-
ネットワーク ビューで、 `VantageExpress`で始まる最後のリクエストを見つけます。それを右クリックして `Copy → Copy as cURL`を選択します。
-
-
ssh セッションに戻り、curl コマンドを貼り付けて Vantage Express をダウンロードします。ダウンロードを
ve.7z
という名前のファイルに保存するには、コマンドに-o ve.7z
を追加します。次のように、すべてのHTTPヘッダーを削除できます。curl -o ve.7z 'http://d289lrf5tw1zls.cloudfront.net/database/teradata-express/VantageExpress17.20_Sles12_202108300444.7z?Expires=1638719978&Signature=GKBkNvery_long_signature__&Key-Pair-Id=********************'
-
ダウンロードしたファイルを解凍します。数分かかります。
7z x ve.7z
-
VirtualBox で VM を起動しますコマンドはすぐに返されますが、VM の初期化プロセスには数分かかります。
export VM_IMAGE_DIR="/opt/downloads/VantageExpress17.20_Sles12" DEFAULT_VM_NAME="vantage-express" VM_NAME="${VM_NAME:-$DEFAULT_VM_NAME}" vboxmanage createvm --name "$VM_NAME" --register --ostype openSUSE_64 vboxmanage modifyvm "$VM_NAME" --ioapic on --memory 6000 --vram 128 --nic1 nat --cpus 4 vboxmanage storagectl "$VM_NAME" --name "SATA Controller" --add sata --controller IntelAhci vboxmanage storageattach "$VM_NAME" --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium "$(find $VM_IMAGE_DIR -name '*disk1*')" vboxmanage storageattach "$VM_NAME" --storagectl "SATA Controller" --port 1 --device 0 --type hdd --medium "$(find $VM_IMAGE_DIR -name '*disk2*')" vboxmanage storageattach "$VM_NAME" --storagectl "SATA Controller" --port 2 --device 0 --type hdd --medium "$(find $VM_IMAGE_DIR -name '*disk3*')" vboxmanage modifyvm "$VM_NAME" --natpf1 "tdssh,tcp,,4422,,22" vboxmanage modifyvm "$VM_NAME" --natpf1 "tddb,tcp,,1025,,1025" vboxmanage startvm "$VM_NAME" --type headless vboxmanage controlvm "$VM_NAME" keyboardputscancode 1c 1c
-
Vantage Express VM に ssh で接続します。
root
をパスワードとして使用します。ssh -p 4422 root@localhost
-
DBがアップしていることを確認します。
pdestate -a
コマンドが`PDE state is RUN/STARTED. DBS state is 5: Logons are enabled - The system is quiescent`を返す場合は、Vantage Expressが起動したことを意味します。 状態が異なる場合は、正しいステータスが得られるまで
pdestate -a
を繰り返します。 -
Vantage Expressが起動して実行されたら、
bteq
クライアントのコマンドラインクライアントを起動します。BTEQ (「ビーテック」と発音) は、Teradata Database に SQL クエリーを送信するために使用される、汎用のコマンド ベースのクライアント ツールです。bteq
-
bteqに入ったら、Vantage Expressインスタンスに接続します。パスワードを求められたら、 `dbc`を入力します。
.logon localhost/dbc
サンプル クエリーを実行する
-
`dbc`ユーザーを使用して、`HR`という新しいデータベースを作成します。このクエリーをコピー/貼り付けて、Enter を押して実行します。
CREATE DATABASE HR AS PERMANENT = 60e6, -- 60MB SPOOL = 120e6; -- 120MB
-
サンプルテーブルを作成し、データを挿入してクエリーを実行してみましょう。まず、従業員情報を保持するテーブルを作成する。
CREATE SET TABLE HR.Employees ( GlobalID INTEGER, FirstName VARCHAR(30), LastName VARCHAR(30), DateOfBirth DATE FORMAT 'YYYY-MM-DD', JoinedDate DATE FORMAT 'YYYY-MM-DD', DepartmentCode BYTEINT ) UNIQUE PRIMARY INDEX ( GlobalID );
-
次に、レコードを挿入する。
INSERT INTO HR.Employees ( GlobalID, FirstName, LastName, DateOfBirth, JoinedDate, DepartmentCode ) VALUES ( 101, 'Adam', 'Tworkowski', '1980-01-05', '2004-08-01', 01 );
-
最後に、データを取得できるかどうかを確認する。
SELECT * FROM HR.Employees;
以下の結果が得られるはずです。
GlobalID FirstName LastName DateOfBirth JoinedDate DepartmentCode -------- --------- ---------- ----------- ---------- -------------- 101 Adam Tworkowski 1980-01-05 2004-08-01 1
オプションを設定する
-
VM を停止して起動する場合は、Vantage Express を自動起動に追加することをお勧めします。 VM に ssh で接続し、以下のコマンドを実行します。
sudo -i cat <<EOF >> /etc/default/virtualbox VBOXAUTOSTART_DB=/etc/vbox VBOXAUTOSTART_CONFIG=/etc/vbox/autostart.cfg EOF cat <<EOF > /etc/systemd/system/vantage-express.service [Unit] Description=vm1 After=network.target virtualbox.service Before=runlevel2.target shutdown.target [Service] User=root Group=root Type=forking Restart=no TimeoutSec=5min IgnoreSIGPIPE=no KillMode=process GuessMainPID=no RemainAfterExit=yes ExecStart=/usr/bin/VBoxManage startvm vantage-express --type headless ExecStop=/usr/bin/VBoxManage controlvm vantage-express savestate [Install] WantedBy=multi-user.target EOF systemctl daemon-reload systemctl enable vantage-express systemctl start vantage-express
-
インターネットから Vantage Express に接続したい場合は、VM にファイアウォールの穴を開ける必要があります。また、デフォルトのパスワードを
dbc
ユーザーに変更する必要があります。-
dbc
ユーザーのパスワードを変更するには、VM に移動して bteq を開始します。bteq
-
ユーザー名とパスワードとして
dbc
を使用してデータベースにログインします。.logon localhost/dbc
-
dbc
ユーザーのパスワードを変更します。MODIFY USER dbc AS PASSWORD = new_password;
-
これで、ポート 1025 をインターネットに開くことができます。
aws ec2 authorize-security-group-ingress \ --group-id $AWS_CUSTOM_SECURITY_GROUP_ID \ --ip-permissions '[{"IpProtocol": "tcp", "FromPort": 1025, "ToPort": 1025, "IpRanges": [{"CidrIp": "0.0.0.0/0", "Description": "Allow Teradata port"}]}]'
-
クリーンアップする
課金を停止するには、すべてのリソースを削除します。
# Delete the VM
aws ec2 terminate-instances --instance-ids $AWS_INSTANCE_ID --output text
# Wait for the VM to terminate
# Delete custom security group
aws ec2 delete-security-group \
--group-id $AWS_CUSTOM_SECURITY_GROUP_ID
# Delete internet gateway
aws ec2 detach-internet-gateway \
--internet-gateway-id $AWS_INTERNET_GATEWAY_ID \
--vpc-id $AWS_VPC_ID &&
aws ec2 delete-internet-gateway \
--internet-gateway-id $AWS_INTERNET_GATEWAY_ID
# Delete the custom route table
aws ec2 disassociate-route-table \
--association-id $AWS_ROUTE_TABLE_ASSOID &&
aws ec2 delete-route-table \
--route-table-id $AWS_CUSTOM_ROUTE_TABLE_ID
# Delete the public subnet
aws ec2 delete-subnet \
--subnet-id $AWS_SUBNET_PUBLIC_ID
# Delete the vpc
aws ec2 delete-vpc \
--vpc-id $AWS_VPC_ID
さらに詳しく
ご質問がある場合、またはさらにサポートが必要な場合は、コミュニティ フォーラムにアクセスしてサポートを受け、他のコミュニティ メンバーと交流してください。 |