Add new exercises

Also added indexes for AWS and Linux.
This commit is contained in:
abregman
2022-07-08 16:14:35 +03:00
parent a9dc2202ca
commit 94b3bc3520
13 changed files with 2633 additions and 2272 deletions

View File

@@ -0,0 +1,26 @@
# Containerized DB
1. Run a container with a database of any type of you prefer (MySql, PostgreSQL, Mongo, etc.)
2. Verify the container is running
3. Access the container and create a new table (or collection, depends on which DB type you chose) for students
4. Insert a row (or document) of a student
5. Verify the row/document was added
## Solution
```
# Run the container
podman run --name mysql -e MYSQL_USER=mario -e MYSQL_PASSWORD=tooManyMushrooms -e MYSQL_DATABASE=university -e MYSQL_ROOT_PASSWORD=MushroomsPizza -d mysql
# Verify it's running
podman ps
# Add student row to the database
podman exec -it mysql /bin/bash
mysql -u root
use university;
CREATE TABLE Students (id int NOT NULL, name varchar(255) DEFAULT NULL, PRIMARY KEY (id));
insert into Projects (id, name) values (1,'Luigi');
select * from Students;
```

View File

@@ -0,0 +1,24 @@
# Containerized DB with Persistent Storage
1. Run a container with a database of any type of you prefer (MySql, PostgreSQL, Mongo, etc.)
1. Use a mount point on the host for the database instead of using the container storage for that
2. Explain why using the host storage instead of the container one might be a better choice
2. Verify the container is running
## Solution
```
# Create the directory for the DB on host
mkdir -pv ~/local/mysql
sudo semanage fcontext -a -t container_file_t '/home/USERNAME/local/mysql(/.*)?'
sudo restorecon -R /home/USERNAME/local/mysql
# Run the container
podman run --name mysql -e MYSQL_USER=mario -e MYSQL_PASSWORD=tooManyMushrooms -e MYSQL_DATABASE=university -e MYSQL_ROOT_PASSWORD=MushroomsPizza -d mysql -v /home/USERNAME/local/mysql:/var/lib/mysql/db
# Verify it's running
podman ps
```
It's better to use the storage host because in case the container ever gets removed (or storage reclaimed) you have the DB data still available.