Open main menu

CDOT Wiki β

Changes

OPS345 Lab 4

1,331 bytes added, 06:16, 4 January 2022
Set up Nextcloud
We're going to install a handy web application in order to get some practice setting up our database. Nextcloud has all kinds of capabilities, the most obvious one is that you can use it to share files (of any size) with specific users or make them public for anyone to access.
The subnet-ops345-db ops345db RDS instance you created is called a database, which is confusing, because inside it you're going to make a '''database'''. subnet-ops345-db ops345db is actually more akin to an '''RDBMS ''' (Relational Database Management System). Like installing MariaDB on a linux box. It would be better called a '''database server'''. Inside the RDBMS you create what's more commonly called a database by more technical people. You can have many databased databases on one database server. But you cannot have any database inside another database - that just doesn't make sense, at least not with SQL databases.
There are graphical applications for managing databases, and sometimes they're quite helpful. But for you it wouldn't be worth learning their interface for the basic things you need to do for the lab. Also the command-line commands you will learn in this lab are good because they will work on almost any MySQL/MariaDB database server.
You'll need some extra software to be able to connect to subnetops345db from your www server. * Use ssh to connect to www.* Install '''mariadb'''. This is the client software for MariaDB. You do not need the server software, the server is already set up in AWS.* Note that in order to install anything with yum: www needs to connect to the internet. So create a temporary elastic IP and assign it to www, just as you did in the end of the previous lab.* Disassociate the elastic IP from www after your yum install. You will need it again later, so don't delete it yet. {{Admon/tip|Don't be lazy|The only way to learn this stuff is to practice it. So practice it, don't skip steps. In fact: make up your own extra steps to give yourself more practice (a.k.a. experience). That's what employers pay for. Nobody in the industry will care what grades you got in school. They will care quite a bit about what you are able to do, and how willing and able you are to learn more.}} * As a fundamental security principle: do the rest of the lab as a regular user, don't use root.* To run the MariaDB client you need to know what to connect to. Find the FQDN ("endpoint") for ops345db in the web interface:[[File:AWSDBFQDN.png|800px|border|center]]* And connect to it from www:<source>mysql -u dbroot -pyourdbpassword -h ops345db.cnjsjcelkwzu.us-east-ops3451.rds.amazonaws.com</source>* It will almost certainly time out. That's because ops345db is behind a firewall, with rules defined in the ops345dbsg security group.* Find your way to the Inbound rules of ops345dbsg.** Delete the existing rule.** Add a new rule for MySQL (TCP port 3306), with the source ops345wwsg. That's the only machine that needs direct access to the database server.* Try again to connect using the mysql client software. It should work this time.** If you get an error like this then double-db from check the master username under RDS/ops345db/Configuration and you can reset the password via the Modify button on the same page (the password change might take a few minutes to complete).<source>ERROR 1045 (28000): Access denied for user 'root'@'10.3.45.11' (using password: YES)</source>[[File:AWSDBUserPass.png|800px|border|center]]* See also [https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_Troubleshooting.html Troubleshooting for Amazon RDS]. 
* Assign temporary elastic IP to yum install mariadb, no need for server.
** Will disassociate and release the elastic ip at the end of the lab.
* Do the rest of the lab as the regular user, don't use root.
* In the AWS Console go to RDS, and find the FQDN ("Endpoint") for the database. Such as ops345db.cobdogt5aykb.us-east-1.rds.amazonaws.com - record that.
* Try to connect: mysql -u root -plongdbpassword -h ops345db.cobdogt5aykb.us-east-1.rds.amazonaws.com
** It won't work, the firewall (SG) won't allow it. Modify ops345sgprivate to allow incoming TCP port 3306 (MySQL) from ops345sgprivate.
* Should be able to log in now. If you get something like this: "ERROR 1045 (28000): Access denied for user 'root'@'10.3.45.11' (using password: YES)" then double-check the master username under RDS/ops345db/Configuration and you can reset the password via Modify (might take a few minutes to propagate).
** See also https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_Troubleshooting.html
* Most mysql commands need to have a semicolon at the end.
* The mysql commandline is nothing like the linux shell. Have to use mysql (or plain SQL) commands.