For learning OSS-DB Silver, we built an environment on a Windows PC. It is a record of the process.
I can't find an article written by a programming beginner, probably because OSS-DB Silver is a qualification for those who are already working as programmers. I wrote this article for "** beginners of programming who are learning to acquire OSS-DB Silver **" like me.
[Last failure] I installed the packaged version of PostgreSQL for OSS-DB Silver learning, but eventually uninstalled it
Based on the previous failure, this time we will build a Linux environment on a Windows PC and install PostgreSQL from the source code there. How to install from the source code is explained in Chapter 3 of Textbook (Green Book).
In this article, I will write ** about environment construction before installing PostgreSQL **.
The environment construction work is in the following three stages. ** Task 1: Install VirtualBox and build a virtual environment on your PC Task 2: Install Vagrant to get VirtualBox to work with CUI Task 3: Install CentOS on Vagrant and create a Linux environment **
[Point of stumbling] ・ Whether to use Vagrant or not (My memo: ← I can't make a link in the page) -Command prompt, where should I write the command?
First, I investigated what is needed to build a Linux environment for installing PostgreSQL from source code. I referred to the following two experiences.
Real machine learning Configuration file (postgresql.conf / pg_hba.conf) settings and For checking operation management commands and SQL. Install PostgreSQL 10.4 on VirtualBox + CentOS as in the example.
It seems that CentOS 7 is required to create a Linux environment. Both are "creating a CentOS environment and installing PostgreSQL". However, it is different from "VirtualBox" or "Vagrant" that is used to create the CentOS environment.
In addition, the above said, "This is because the procedure for compiling and installing the source code and the subsequent setup procedure are included in the test range." However, the textbook (Chapter 3, Installation p48) states that "The installation method itself is. It is not within the test range of OSS-DB Exam Silver, but it was. " Is it okay that it is not included in the test range?
** CentOS7 **: One of the Linux types. The OS used when building a Linux server. (Reference: [Series in 3 minutes] What is CentOS?) → There are different types of Linux⁉ What do you mean? ?? I thought, so I read this article. → [Rough summary] Compare Linux distributions
** VirtualBox **: Free software that builds a virtual environment on your PC. Virtualization software. An indispensable (?) Tool when trying various OSs.
** Vagrant **: Vagrant. A tool to use with virtualization software such as VirtualBox. Software that operates virtualization software with "CUI (character user interface)". (Reference: ・ Vagrant seems to be popular, but what is convenient? -Build a development environment on Windows quickly with Vagrant + VirtualBox ・ [Linux environment construction] What are Vagrant and VirtualBox? Explain how to use for beginners! )
** Compile **: Converting a character string (source code) written in a programming language into a format (object code) that can be executed on a computer (Source: What is compilation?)
I wasn't sure if I should or shouldn't use Vagrant. It seems that it can be used only with VirtualBox without Vagrant, and I could not judge whether this Vagrant is necessary or not for learning OSS-DB Silver this time. The installation premise specified in [Chapter 3 Installation] of the textbook was only "Linux environment", so I want to run it in the simplest possible environment, so why not try it without using Vagrant first? I thought, but after reading this article, I decided to install Vargrant after all.
In other words, building an environment with VirtualBox is quite difficult. Vagrant, on the other hand, makes it easy to solve all these problems! (Quote: [Linux environment construction] What are Vagrant and VirtualBox? Explaining how to use it for beginners!)
So, in order to install PostgreSQL from the source code, we will build the environment.
What is a "virtual environment"?
Create a virtual PC with VirtualBox in your own PC Install CentOS7 (= Linux) as the OS on the virtual PC. Try PostgreSQL or whatever on the resulting virtual Linux PC. That way, your PC environment will not get dirty and it will be easy to use!
That's what it means. What kind of environment will it be? First Linux. I'm looking forward to it!
We will install VirtualBox, Vagrant, and CentOS7.
I referred to this article. "[Linux environment construction] What are Vagrant and VirtualBox? Explaining how to use it for beginners!"-Fox Planet-2020/3/27 Article
It was a beginner-friendly article that explained about Vagrantfile and how to check the bit of the PC, so that it would not trip over. Thank you.
Go to VirtualBox Official Site and select Windows hosts.
Launch the downloaded installer. Click as instructed and the installation is complete.
When you click Finish to complete the installation, VisualBox will start automatically and you will see this screen.
Proceed to work 2.
Access Vagrant Official Site. A screen like this will open. Since the Windows 64-bit version is displayed, just click Download. (Download time is about 6 minutes on my PC)
Launch the downloaded installer. Click as instructed to complete the installation.
Click Finish and a dialog box like this will appear. Click Yes to automatically restart your PC. So if you're doing something in another window before clicking Yes, close that window.
When the PC is restarted, proceed to Task 3.
We will proceed by referring to the "How to use Vagrant" section in the article by Mr. Planet of the Fox.
In the article, it is written to enter the code instructed at the command prompt, In the article
Using the command prompt, go to the "C: \ Users \ user_name \ training \ vagrant" you created earlier. Enter the following at the command prompt and execute.``` [Move folder] $ cd C:\Users\user_name\training\vagrant
However, when I started the command prompt according to the article, my screen looked like this.
![cmd.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/498057/021f765a-8546-dbf5-b368-3821e6300669.png)
In what part should I enter the command instructed?
And how should "execution" be done? Should I press Enter?
First of all, what is a command prompt?
** Command Prompt **: Windows-based CUI (screen interface operated only by the board) that executes commands (commands). In Linux and MacOS it is called a "terminal". It is this screen that is often referred to as the "black screen"!
#### Command prompt, where should I write the command?
1. First, "\ training \ vagrant" to the right of the displayed "C: \ Users \ (user name)>"
I added "" and pressed Enter.
→ Error. \ Is displayed as \ (as in the article by Fox Planet), "The specified path cannot be found" is displayed on the next line, and "C: \ Users \" is newly displayed on the lower line. miho> "was displayed. As follows.
(* The entered part is enclosed in ★. I wanted to make it bold, but it seems that markup such as "Enclose in **" does not work in the code block, so it is a compromise.)
Microsoft Windows [Version 10.0.18363.1256] (c) 2019 Microsoft Corporation. All rights reserved.
C:\Users\username>★\training\vagrant★ The specified path can not be found.
C:\Users\username>
2. Next, when I tried to delete the part I just added at the command prompt and enter it again, it seemed that I could not delete it with Delete or Back Space, so I closed the command prompt and then reopened it. I added "$ cd C: \ Users \ user_name \ training \ vagrant" to the right of "C: \ Users \ (user name)>". Also an error. As follows.
Microsoft Windows [Version 10.0.18363.1256] (c) 2019 Microsoft Corporation. All rights reserved.
C:\Users\username>★$ cd C:\Users\user_name\training\vagrant★ '$'Is an internal or external command, It is not recognized as an operable program or batch file.
C:\Users\username>
3. I'm honest for the third time. Try pasting other than "$" in the same position. The new line shows "C: \ Users \ miho \ training \ vagrant>".
Microsoft Windows [Version 10.0.18363.1256] (c) 2019 Microsoft Corporation. All rights reserved.
C:\Users\miho>★cd C:\Users\miho\training\vagrant★
C:\Users\miho\training\vagrant>
Is it okay to say that this state is "a state where you can move to" C: \ Users \ user_name \ training \ vagrant "?" do not know.... I will proceed assuming that I was able to move for the time being.
>If you can move it, execute the following command to create a Vagrantfile.```
[Create Vagrantfile]
$ vagrant init
By the way, "vagrant init" is only executed once at the beginning. If you already have a Vagrantfile, you don't need it!
So, at the command prompt, enter "vagrant in it". I didn't enter "$" because it would cause an error again. Then, it became like this.
Microsoft Windows [Version 10.0.18363.1256]
(c) 2019 Microsoft Corporation. All rights reserved.
C:\Users\username>cd C:\Users\username\training\vagrant
C:\Users\username\training\vagrant>★vagrant init★
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
C:\Users\username\training\vagrant>
"A ~" was displayed. When I read it, it seems that the Vagrantfile was created successfully. For the time being, when I checked the contents of drive C from the desktop of the PC, the file was created properly as training → vagrant → Vagrantfile. It is completed successfully.
Next, proceed after "Vagrantfile settings". As mentioned in the article, when I opened the Vagrantfile with Notepad, it looked like this.
[Wording displayed when opening Vagrantfile with Notepad]
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
# Every Vagrant development environment requires a box. You can search for
# boxes at https://vagrantcloud.com/search.
config.vm.box = "base"
# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
# `vagrant box outdated`. This is not recommended.
# config.vm.box_check_update = false
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
# NOTE: This will enable public access to the opened port
# config.vm.network "forwarded_port", guest: 80, host: 8080
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine and only allow access
# via 127.0.0.1 to disable public access
# config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"
# Create a private network, which allows host-only access to the machine
# using a specific IP.
# config.vm.network "private_network", ip: "192.168.33.10"
# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# config.vm.network "public_network"
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
# config.vm.synced_folder "../data", "/vagrant_data"
# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
#
# config.vm.provider "virtualbox" do |vb|
# # Display the VirtualBox GUI when booting the machine
# vb.gui = true
#
# # Customize the amount of memory on the VM:
# vb.memory = "1024"
# end
#
# View the documentation for the provider you are using for more
# information on available options.
# Enable provisioning with a shell script. Additional provisioners such as
# Ansible, Chef, Docker, Puppet and Salt are also available. Please see the
# documentation for more information about their specific syntax and use.
# config.vm.provision "shell", inline: <<-SHELL
# apt-get update
# apt-get install -y apache2
# SHELL
end
I erased all the above written in Notepad according to the article and overwrote Article code. Proceed to "Start Virtual Machine" (https://kitsune.blog/linux-environment#%E4%BB%AE%E6%83%B3%E3%83%9E%E3%82%B7%E3%83%B3%E3%82%92%E8%B5%B7%E5%8B%95). Following the command prompt I entered so far, I added "vagrant up" as in the article. ("$" Is omitted.)
I want to install version 7 of CeontOS, so I write "config.vm.box =" centos/7 "" in it.
Then, a number of lines appeared in the continuation of the command prompt, and the countdown was displayed on the bottom line. The "Do you want to allow changes?" Dialog box appears twice on the PC, and I clicked "Yes" both times. After a while, the command at the command prompt stopped working, so I checked the contents of the C drive with the mouse.
[Contents of vagrant file]
As mentioned above, the number of ".vagrant" files has increased. When I opened this ↑, he was like this ↓.
I thought that there was a "centos7" file in it, but when I opened the "machines" file, it had the following contents, and there was no "centos" character anywhere.
PC> Windows (C :)> User> Username> trainimg> vagrant> .vagrant> machines> default> virtualbox [↓ Contents of virrualbox file] ↑ Is "Centos 7" included in any of these? At first glance, I didn't know.
Proceed to "Login to Virtual Machine" (https://kitsune.blog/linux-environment#%E4%BB%AE%E6%83%B3%E3%83%9E%E3%82%B7%E3%83%B3%E3%81%AB%E3%83%AD%E3%82%B0%E3%82%A4%E3%83%B3). I added "vagrant ssh" to the command prompt as in the article, and after a few seconds I got "[vagrant @ localhost ~] $" in the line below. Did you log in?
The command is displayed on the command prompt, but since there is no corresponding window open on the PC, I'm not sure if it's actually working. I had the image that a new window would open, so I feel indigestion.
I won't do it right now, but the article also explained the commands "Stop Virtual Machine" and "Delete Virtual Machine", so I'd like to do it when needed.
(My memo: Final command prompt screen = Recorded in the learning file)
I stopped working here and shut down my PC. When I restarted my PC again, the shortcut icon for "Oracle VM VirtualBox" was displayed on the desktop as shown below. Maybe it was displayed even before shutting down. I didn't notice at that time. Clicking on this icon opened a window similar to the following.
It says "training --interrupted". Click to open it. There was an icon called "Start", so I clicked it. Then a black window similar to the command prompt appeared, the commands were displayed one after another, and then stopped. When I tried to close the window with an "x", I got the following: If you select "Power off virtual machine (P)" and click "OK" It became "training --power off". It seems to work normally. happy!
・ It has been quite a few days (12/13 (Sun) to 12/22 (Tue)) while building the Linux environment. I am relieved to be able to complete it somehow.
・ I recorded the process to complete not only the correct answer (?) But also the wrong path in the article, so I feel that the article has become difficult to read. I can't find an article written by a programming beginner, probably because OSS-DB Silver is a qualification for those who are already working as programmers. Even if I googled "OSS-DB Silver environment construction" etc. before starting the environment construction work, the appropriate article did not hit, so I thought that it would be helpful for non-programmers like me. did.
・ When I'm investigating Cent OS, it seems that it's just rushing. It is said that 8 will end. This time, I installed 7 which seems to end support before 8. There is a lot of information that I can't understand right now, such as not starting a production server on Cent OS and managing files with Git. I'll learn more and more! !!
・ Next, we will challenge "Installing PostgreSQL from source code". I would like to proceed while outputting to the article.
・ Rzi's diary --2018/7/21 Article "About pgAdmin4" -Programming Style --2019/11/29 Article "Uninstall PostgreSQL (Windows)" ・ Nemigi Log --2018/7/15 Article "OSS-DB Silver Passing Experience" ・ Tsurezure Tech --2018/10/2 Article "OSS-DB Silver Study Method" ・ Engineer's entrance --2016/6/25 Article "[Series in 3 minutes] What is CentOS?" ・ Engineer's entrance --2019/7/4 article "[Rough summary] Compare Linux distributions" ・ Developers.IO --2013/7/31 article "Vagrant seems to be popular, but what is convenient?" ・ Qiita "Building a development environment on Windows quickly with Vagrant + VirtualBox" ・ ☆ Fox Planet -2020/3/27 Article "[Linux environment construction] What are Vagrant and VirtualBox? Explanation for beginners!" ・ En job change --2016/11/26 article "What is compilation?" ・ Engineer's entrance --2017/2/28 article [Even beginners can understand] Learn more about how to install VirtualBox! ・ Engineer's entrance --2020/8/31 article "[Even beginners can understand] Linux CentOS installation method summary" -How to link in Qiita page
Recommended Posts