代写COMP 315: Cloud Computing for E-Commerce Lab 1: Introduction to RHEL Shell and Docker 2024代做Java程序
- 首页 >> Database作业Lab 1: Introduction to RHEL Shell and Docker
COMP 315: Cloud Computing for E-Commerce
February 7, 2024
1 Introduction
This lab session is designed to introduce you to the basics of the Red Hat Enterprise Linux (RHEL) and Docker. You will learn fundamental commands and concepts that are essential for navigating and performing operations in RHEL, as well as basic Docker operations.
2 Objectives
By the end of this lab, you will be able to:
• Understand the basic concepts of the RHEL command line and Docker.
• Navigate through directories and manage files using command line.
• Perform basic Docker operations such as running and managing containers.
3 Lab Exercises
3.1 RHEL Shell Exercises
Often when working with cloud computing systems, you will remotely connect to some form of server. This is typically a Linux system, and the Linux farm the university has happens to run RHEL. If you are unfamiliar with Linux, then this section will serve as a general introduction.
3.1.1 Exercise 1: Connecting to the Linux farm
1. Search in the application menu to see if ’MobaXterm’ is installed. If it is then launch the application, if not then navigate to the ’Install University Applications’ icon and install then launch it.
2. Right click on the side panel, and select ’New session’ .
3. Press the ’SSH’ button at the top left of the pop-up.
4. There are 8 Linux farms from lxfarm01.csc.liv.ac.uk to lxfarm08.csc.liv.ac.uk. Enter an address into the ’Remote host’ field. If one is busy then you can connect to another.
5. Tick ’Specify username’, then enter your MWS username into the corresponding text box and press the ’OK’ button.
6. Press ’Accept’, then enter your password, and save the details.
7. You are now connected to your RHEL user session.
3.1.2 Exercise 2: Navigating Directories
1. Use the ’cd ~ ’ command to navigate to your home directory.
2. Type ’mkdir --help’ to learn more about the ’mkdir’ command.
3. Try ’man mkdir’ to learn more about the ’mkdir’ command.
4. Create a new directory named ’LabWork’ using ’mkdir’ .
5. Navigate into the ’LabWork’ directory using the ’cd’ command from above.
3.1.3 Exercise 3: Working with Files
Two common cloud computing task are altering configuration files and the creation of short scripts. One way of doing this is to use Linux’s built in terminal text editor, called ’vi’ which is present on every Linux installation.
1. Inside ’LabWork’, create a new file named ’notes.txt’ using ’touch’ .
2. Open ’notes.txt’ with the text editor ’vi’ and add some text (you can search online to find the command to save a file).
3. In order to exit ’vi’ press escape and then type ’:q!’ .
4. Open ’notes.txt’ with the text editor ’nano’ and remove some text (you can get out of nano by pressing control and ’x’).
5. Display the content of ’notes.txt’ using ’cat’ .
3.1.4 Exercise 4: Exploring More Commands
1. List all files in the current directory using ’ls’ .
2. Use ’ls -l’ to view detailed file information.
3. Learn about command history using ’history’ .
3.1.5 Exercise 5: Shell Scripts and File Permissions
Shell scripts allow you to group commands together, and is often used for automating common tasks and debugging.
1. Create a shell script called ’helloworld.sh’ with this command: echo "echo ’Hello world’" > helloworld .sh.
2. Try to run the script. with the command ./helloworld .sh. What happens? Why? How can you fix it? (Hint: you might need the chmod command, which you can learn about with ’man chmod’, or by searching for it online).
3.2 Docker Exercises
In lecture 1 we introduced the concept of virtual machines, which virtualises an entire system including an operating system and it’s applications. In lecture 2 we will introduce the concept of containers, which share the same operating system and kernel as it’s host. In this way they can be much smaller and lightweight. Docker is a very popular example of this.
3.2.1 Exercise 1: Running a Simple Docker Container
1. Pull the latest Rocky Linux image: docker pull rockylinux/rockylinux
2. Run a Docker container using this image: docker run -it rockylinux/rockylinux /bin/bash
3. Explore the container’s bash shell. Try commands like ls, pwd, or echo "Hello from Docker!"
4. Exit the container’s shell by typing exit.
3.2.2 Exercise 2: Exploring Docker Images and Containers
1. List all available Docker images: docker images
2. Run a temporary Docker container: docker run --rm -it rockylinux/rockylinux:latest
3. Within the container, install the curl utility: yum update && yum install -y curl
4. Use curl to make a simple HTTP request, e.g., curl https://www .example .com
5. Exit the container and observe that it gets automatically removed (--rm flag).
4 Conclusion
In this lab, you have learned the basics of navigating the RHEL shell and performing simple Docker operations. These skills are essential for further exploration into the world of cloud computing.