This is a continuation of the previous article (↓).
This time, install Oracle Database 19c and build the DB.
Also, the motivation for writing this article is also to catch up with the latest knowledge (because 11g, 12c was the last one used), so you may feel that the prerequisite knowledge is old, but please Please understand.
Also, as I wrote in the previous article, the purpose of the series of articles is to build a learning database for the purpose of linking with .NET 5.0 (C #) programs, so it is not very complicated and it is exactly There may be some parts that are not. I hope you understand that (although I welcome your suggestions).
TL;DR In the past you had to create a dedicated user (oracle) or group (oinstall) yourself, then run the installer and do a manual install, but now you can do it with a package (RPM). With it, it's almost automated, so you can work efficiently.
So, as a work to do
It will be.
Oracle Preinstallation RPM
It automates pre-tasks such as automatic installation of prerequisite packages and automatic creation of installation users.
Install with the following command.
$ sudo dnf install oracle-database-preinstall-19c.x86_64
When confirmed, press "y" to confirm that it was successful. Let's check if the oracle user is created.
$ id oracle
It's done properly.
-About Oracle Preinstallation RPM --[Overview of Configuring Oracle Linux with Oracle Preinstallation RPM](https://docs.oracle.com/cd/F19136_01/ladbi/overview-of-oracle-linux-configuration-with-oracle-rpms.html# GUID-693599D4-BD32-4E6A-9689-FA7D1CD75653)
Download. The URL of the RPM package can be obtained from the following page.
You'll need to create an account, so if you haven't already done so.
Once downloaded, I'll put rpm in my home directory for now.
Check the file for corruption (with SHA256).
The hash value is posted on the download page earlier.
Create a file called checksum.txt
and give it the content hash value [half-width space] file name
.
$ sha256sum -c checksum.txt
Execute.
When you see "Complete", it's OK. If the file is corrupted or tampered with (which is unlikely), you'll probably get the phrase "doesn't match".
Install with the command below.
$ sudo dnf localinstall oracle-database-ee-19c-1.0-1.x86_64.rpm
When you get confirmation, click "y" (well, you can skip the confirmation with the -y option, but I want to be careful). Has completed.
Since building the Database itself is not a study this time, I will create a database with a basic configuration that is not for special purposes (I will write data files, tablespaces, PDBs, etc. again if I have time).
First, set environment variables such as ORACLE_HOME. You can add it to each individual user (.profile), but since it is all users, add it to a common place.
$ sudo nano /etc/profile
Add the following at the bottom. SID is an identifier and is the database to be created this time. Add the character code setting as well.
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=/opt/oracle/product/19c/dbhome_1
export PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_SID=orcl
export NLS_LANG=Japanese_Japan.AL32UTF8
Save it and apply it with the following command.
$ source /etc/profile
Execute echo $ ORACLE_HOME
to check if it is done properly.
** DBCA (Database Configuration Assistant) ** is a tool for creating Databases.
So, this is done as the oracle
user, but the oracle
user does not have a password, so set it.
$ sudo passwd oracle
Then log out of the GUI and log in as the oracle
user (otherwise the window will not pop up).
Set the language setting to "English". This is because the characters become "□□" and become garbled in Japanese. Well, it's okay to use Japanese, but since you have to put in a Java execution environment separately and it will take more time to edit the DBCA startup script, this time we will do it in English as it is (because it is just a test DB creation) ..
By the way, if you want to display Japanese correctly, install the latest Oracle JDK (free for personal use), open $ ORACLE_HOME / bin / DBCA with vi or nano, and change the path of JRE_DIR
. is needed.
Returning to the story, log in to the English GUI environment, open a terminal, and start dbca
.
$ dbca
Select "** Create a database **" above (for some reason, the radio check is strange, but it seems to be selected).
Select "** Advanced configuration **" below and click "Next".
Select ** General Purpose or Transaction Processing ** and click Next.
Change only the following parts (well, but you can name it as you like).
PDB is an abbreviation for pluggable database and is a mechanism introduced from 12c.
Simply put, there is a parent container called a CDB, which contains one or more PDBs. Although the PDB is a conventional tablespace / schema, it is a set. This makes it possible to streamline individual tasks such as patch application.
Keep in mind that the SID orcl
will be used again later (by the way, this orcl is often used in Oracle).
Select ** Use template file for database stroage attributes ** and click Next.
Select "** Specify Fast Recovery Area **", leave the defaults, and click "Next".
Check "** Create a new listener **" and set the following. A listener is a service that accepts processing requests from clients. The port number (1521) specified here is used when connecting from a client.
Do not select any "Data Vault Config Option" and click "Next".
"Configuration Options" has several setting items. For Memory, select "** User Automatic Shared Memory Management **" (the value remains the same).
Character sets -** Select User Unicode (AL32UTF8) **
For Connection mode, select "** Dedicated server mode **".
If you need a sample schema, check "Add sample schemas to the database" (literally, it will contain sample data).
Leave the default "Management Options" and click "Next". Enterprise Manager is a tool that allows you to check the status of the DB from the browser.
The administrator can use different passwords, but this time we will use the same password. There are multiple admin users in Oracle, such as SYS and SYSTEM.
Make sure that "Create database" is checked by default, and press "Next".
Press "Finish". Then, database creation will start. It's a long task, so wait patiently.
Let's wait patiently.
If it finishes without any problem, this screen will be displayed. The information on this screen will be used later, so please refrain from it or take a screenshot, and close it with "Close".
This completes the database construction.
Since the listener is not started, run the lsnrctl
command as the oracle user and run start
.
LSNRCTL> start
The Command completed successfully
When it comes out, it's OK.
Exit lsnrctl with exit
.
As the oracle user, connect to the idle instance with sqlplus.
$ sqlplus / as sysdba
Start up with startup
.
SQL> startup
When it says that the database has been opened, it's OK.
Add an identifier to connect to PDB1 (the client may also do this in some cases). If you add this, you will be able to connect by specifying the identifier without writing the IP address or port number of the server each time.
In nano, open the config file
$ nano /opt/oracle/product/19c/dbhome_1/network/admin/tnsnames.ora
Add the following PDB1 identifier (used to connect from the client). In the next and subsequent articles, we will create tables and data for this PDB1.
PDB1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = pdb1)
)
)
The whole looks like this.
Let's try it out.
$ sqlplus sys/[password]@PDB1 as sysdba
If you get "Connected" like this, it's OK.
However, the PDB cannot be used as it is, so make it available. The PDB has a state of ** open mode **, and MOUNTED cannot write or read. The open mode must be ** READ WRITE ** (change OPEN MODE from MOUNTED to OPEN).
Run the following command:
SQL>alter pluggable database open;
OPEN MODE is now READ WRITE.
Now you can build the database without any problems.
Since SYS and SYSTEM are administrator users, let's create a general user and schema (concept that represents an area in Oracle) for everyday use.
SQL> create user yuki identified by [password]
default tablespace USERS
temporary tablespace TEMP;
Give authority. ** connect ** is a set of permissions (called roles) required to connect, but at a minimum this is required. ** resource ** can be created / modified / deleted in the associated schema (essentially a general user). By the way, there is a DBA role for administrators.
-[Database administrator in 2 days --7 Manage user accounts and security](https://docs.oracle.com/cd/F19136_01/admqs/administering-user-accounts-and-security.html#GUID-7FC1D8BE -4BB9-4642-A4CE-29CD2B8A5F23)
SQL> grant connect to yuki;
SQL> grant resource to yuki;
When executed, it should look like this.
Postscript ('20 / 11/22): ↓ is also required.
$ GRANT UNLIMITED TABLESPACE TO yuki;
Let's try connecting.
$ sqlplus yuki@pdb1
You can also specify the password by using sqlplus [username] / [password] @ [connection identifier]
.
If you can connect, it should look like this.
Yes. This completes the construction.
Execute the following with root privileges, such as promotion with su
.
$ firewall-cmd --zone=public --add-port=1521/tcp --permanent
$ firewall-cmd --zone=public --add-port=5500/tcp --permanent
$ firewall-cmd --reload
This completes the database construction. It takes a lot of time ...
If I do it at work, I will also test whether it is possible to connect to the DB from the client side, but since the client side uses the ODP.NET Managed Driver to create a program in C #, I will do that from the next time onwards.
By the way, to access the management tool called Enterprise Manager, open https: // DB server IP address: 5500 / em /
in your browser.
that's all. Next time, it's time to write the code that connects to Oracle Database 19c from .NET 5.0 (C #).
Reference link
--Database Installation Guide for Linux (Oracle) -Yuji & Gyota's Practical Database Course Let's Use Oracle Database 12c Multi-Tenant Architecture
Recommended Posts