Amazon Linux 2023 に cqlsh をインストールして、ユーザー名/パスワードで Amazon KeySpaces に接続して CQL を発行する手順。
インストール
- pyenv
- pip
- cqlsh
$ pip install cqlsh==6.0.0 $ cqlsh --version cqlsh 6.0.0
設定
cqlshr の設定を行う
- cqlshrc のテンプレートをダウンロードする
$ mkdir .cassandra $ cd .cassandra/ $ curl -o cqlshrc -L https://raw.githubusercontent.com/aws-samples/amazon-keyspaces-toolkit/master/cqlsh-expansion/cqlsh_expansion/cqlshrc_template
- ${HOME}/.cassandra/cqlshrc を編集する
[connection] port = 9142 factory = cqlshlib.ssl.ssl_transport_factory [ssl] validate = true certfile = ~/.cassandra/sf-class2-root.crt [copy-from] chunksize=50
Starfield デジタル証明書をダウンロード
$ pwd /home/ec2-user/.cassandra $ curl https://certs.secureserver.net/repository/sf-class2-root.crt -O
接続する
$ cqlsh cassandra.ap-northeast-1.amazonaws.com 9142 -u "keyspaces_user+1-at-123456789012" -p "********" --ssl /home/ec2-user/.local/bin/cqlsh:460: DeprecationWarning: Legacy execution parameters will be removed in 4.0. Consider using execution profiles. /home/ec2-user/.local/bin/cqlsh:460: DeprecationWarning: Using ssl_options without ssl_context is deprecated and will result in an error in the next major release. Please use ssl_context to prepare for that release. /home/ec2-user/.local/bin/cqlsh:490: DeprecationWarning: Setting the consistency level at the session level will be removed in 4.0. Consider using execution profiles and setting the desired consistency level to the EXEC_PROFILE_DEFAULT profile. Connected to Amazon Keyspaces at cassandra.ap-northeast-1.amazonaws.com:9142 [cqlsh 6.0.0 | Cassandra 3.11.2 | CQL spec 3.4.4 | Native protocol v4] Use HELP for help. keyspaces_user+1-at-123456789012@cqlsh> SELECT * FROM tutorialkeyspace.tutorialtable; email | age | name ------------------+-----+---------- john@example.com | 21 | John p@muramura.com | 1 | murata yusuke@oyama.jp | 28 | Oyama bob@example.com | 22 | Bob chrai@co2.com | 1 | shiotsu shohei@otani.com | 29 | Otani e@co2.com | 1 | shiotsu chrai@co22.com | 1 | shiotsu2 (8 rows) keyspaces_user+1-at-123456789012@cqlsh> exit $
環境
- AMI ID: ami-0a21e01face015dd9
$ cat /etc/system-release Amazon Linux release 2023 (Amazon Linux) $ uname -r 6.1.49-69.116.amzn2023.x86_64