暂无图片
暂无图片
暂无图片
暂无图片
暂无图片
Tutorial 6 – Introduction to Lambda III:Serverless Databases.pdf
170
19页
5次
2022-11-21
免费下载
1
TCSS 562: Software Engineering School of Engineering and Technology
for Cloud Computing University of Washington Tacoma
Fall 2021
http://faculty.washington.edu/wlloyd/courses/tcss562
Tutorial 6 Introduction to Lambda III:
Serverless Databases
Disclaimer: Subject to updates as corrections are found
Version 0.11
Scoring: 20 pts maximum
The purpose of this tutorial is to introduce the use of relational databases from AWS Lambda. This tutorial will
demonstrate the use of SQLite, an in-memory file-based database that runs inside a Lambda function to
provide a “temporary” relational database that lives for the lifetime of the Lambda container. Secondly, the
tutorial demonstrates the use of the Amazon Relational Database Service (RDS) to create a persistent relational
database using Serverless Aurora MySQL 5.6 for data storage and query support for Lambda functions.
Goals of this tutorial include:
1. Introduce the Sqlite database using the command line “sqlite3” tool.
2. Deploy a Lambda Function that uses a file-based SQLite3 database in the “/tmp directory of the
Lambda container that persists between client function invocations
3. Compare the difference between using file-based and in-memory SQLite DBs on Lambda.
4. Create an Amazon RDS Aurora MySQL Serverless database
5. Launch an EC2 instance and install the mysql command line client to interface with the Aurora
serverless database.
6. Deploy an AWS Lambda function that uses the MySQL Serverless database.
1. Using the SQLite Command Line
To begin, create a directory called “saaf_sqlite”.
Then clone the git repository under the new directory:
git clone https://github.com/wlloyduw/saaf_sqlite3.git
If using Windows or Mac, download the “Precompiled binaries” as a zip file from:
https://www.sqlite.org/download.html
On Windows/Mac, unzip the zip file, and then run the sqlite3 program.
On Ubuntu Linux, the package sqlite3 can be installed which is version ~3.31.1 on Ubuntu 20.04 LTS. Then
launch the sqlite3 database client:
sudo apt update
sudo apt install sqlite3
# navigate to your java project directory first
cd {base directory where project was cloned}/saaf_sqlite3/java_template/
sqlite3
2
Check out the version of the db using “.version”.
Check out available commands using “.help”.
sqlite> .version
SQLite 3.31.1 2020-01-27 19:55:54
zlib version 1.2.11
gcc-9.3.0
sqlite> .quit
Start by saving a new database file, and then exit the tool:
sqlite> .save new.db
sqlite> .quit
Then, check the size of an empty sqlite db file:
$ ls -l new.db
total 3848
-rw-r--r-- 1 wlloyd wlloyd 4096 Nov 1 19:05 new.db
It is only 4096 bytes, very small!
Next, work with data in the database:
$ sqlite3 new.db
SQLite version 3.31.1 2020-01-27 19:55:54
Enter ".help" for usage hints.
sqlite> .databases
main: /home/wlloyd/git/tutorial6/saaf_sqlite3/new.db
sqlite> .tables
There are initially no tables.
Create a table and insert some data:
sqlite> create table newtable (name text, city text, state text);
sqlite> .tables
newtable
sqlite> insert into newtable values('Susan Smith','Tacoma','Washington');
sqlite> insert into newtable values('Bill Gates','Redmond','Washington');
sqlite> select * from newtable;
Susan Smith|Tacoma|Washington
Bill Gates|Redmond|Washington
Now check how the database file has grown after adding a table and a few rows:
sqlite> .quit
$ ls -l new.db
Question 1. After creating the table ‘newtable’ and loading data to sqlite, what is the size of the new.db
database file?
of 19
免费下载
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文档的来源(墨天轮),文档链接,文档作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。
关注
最新上传
暂无内容,敬请期待...
下载排行榜
Top250 周榜 月榜