First we need to go to the official website to download the installation package
oracle19C download address
Oracle Database 19c Download for Linux x86-64
preinstall-19c download address
Oracle Linux 7 (x86_64) Latest | Oracle, Software. Hardware. Complete.
Partition and mount linux
Installation directory /opt/oracle Disk 40G File system type XFS Used to install the database
Data file directory /oradata disk 100G file system type XFS used to store data
Specific steps: (This step can also be used to learn how to add and mount disks)
Create directory /opt /oradata
Add two disks 40G (install Oracle software) 100G (data storage)
Then partition, format, and automatically mount when booting
First add the hard disk through the tool
After the addition is completed, you need to restart the virtual machine to take effect.
fdisk -l --View partition status
fdisk /dev/sdb to partition (set sdb as the primary partition of 40g)
The meaning of the command Menu operation instructions
m: Display menu and help information a: Active partition mark/boot partition
d: delete partition l: display partition type
n: Create a new partition p: Display partition information
q: Exit without saving t: Set partition number
v: Perform partition check w: Save changes
x: Extended applications, advanced functions
mkfs.xfs /dev/sdb -f formats and changes the file format of the disk to xfs
Same operation for /dev/sdc 100g disk
df -hT Check the disk status. If it is not mounted, you cannot check the status of the newly added disk.
Create the installation directory. Go back to the root directory and create the oradata folder [root@localhost /]# mkdir oradata
Set up automatic mounting at boot and change the configuration file vi /etc/fstab
Set automatic mounting mount -a
Use df -hT to check the disk status and see if it is mounted successfully.
Install data files
Turn off the firewall: systemctl stop firewalld.service
systemctl disable firewalld.service
Use rpm to install (the virtual machine must ensure that it can access the external network)
Installation media: yum localinstall -y oracle-database-preinstall-19c-1.0-3.el7.x86_64.rpm
Install database: yum localinstall -y oracle-database-ee-19c-1.0-1.x86_64.rpm
Wait for the installation. After the installation is completed, you can view the information of the current group through id oracle.
Modify the password of the oracle user through passwd oracle 123456
Go to the opt directory and change file permissions
Modify the users and groups of the oracle installation directory
chown -R oracle:oinstall /opt/oracle
chown -R oracle:oinstall /oradata
chmod -R 775 /opt/oracle
Check that the user belonging to oracle is oracle and is not root.
After the installation is complete, view the contents of the current folder through cd /etc/init.d ls
If the following content exists, the installation is successful
Modify this configuration file
First make a copy of cp oracledb_ORCLCDB-19c oracledb_oradb-19c
Go to the sysconfig folder
Copy a copy of cp oracledb_ORCLCDB-19c.conf oracledb_oradb-19c.conf (this is the database configuration file and the port is configured in this)
Change the folder oracledb_oradb-19c.conf vi oracledb_oradb-19c.conf
(This is the data storage path of oracle)
Go back to the directory cd /etc/init.d
Modify the configuration file vi oracledb_oradb-19c
Enter the command line %s/ORCLCDB/oradb/g (replace ORCLCDB globally with oradb)
Enter the command line: %s/ORCLPDB1/oradb/g (replace ORCLPDB1 globally with oradb)
Change the character set and whether to create a container
export ORACLE_VERSION=19c
export ORACLE_SID=oradb
export TEMPLATE_NAME=General_Purpose.dbc
export CHARSET=ZHS16GBK
export PDB_NAME=oradb
export LISTENER_NAME=LISTENER
export NUMBER_OF_PDBS=1
export CREATE_AS_CDB=false
Save Exit
/etc/init.d/oracledb_oradb-19c configure configure the database creation
Note: ./oracledb_oradb-19c executes the database command:
/etc/init.d/oracledb_oradb-19c config
/etc/init.d/oracledb_oradb-19c start open db
/etc/init.d/oracledb_oradb-19c stop stop db
/etc/init.d/oracledb_oradb-19c restart restart db
/etc/init.d/oracledb_oradb-19c delete delete
/etc/init.d/oracledb_oradb-19c configure configure create db
./oracledb_oradb-19c configure start configuration
View oracle uid and gid
# id oracle
The installation is complete and the instance name is oradb
Switch oracle user
su - oracle ls -a (-a can view all files in the current directory, including hidden files)
vi .bash_profile modify the configuration file
Insert at the end of the text
export LANG=en_US
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=$ORACLE_BASE/product/19c/dbhome_1
export ORACLE_UNQNAME=oradb
export ORACLE_SID=oradb
NLS_LANG=AMERICAN_AMERICA.ZHS16GBK; export NLS_LANG
export PATH=$ORACLE_HOME/bin:$PATH:$HOME/.local/bin:$HOME/bin
export ORACLE_HOME=$ORACLE_BASE/product/19c/dbhome_1
export PATH=$ORACLE_HOME/bin:$PATH
source ~/.bash_profile
Save and exit
source .bash_profile Execute the file just now
sqlplus / as sysdba login oracle
Create a trigger that automatically starts pdb
CREATE TRIGGER open_all_pdbs
AFTER STARTUP ON DATABASE
BEGIN
EXECUTE IMMEDIATE 'alter pluggable database all open';
END open_all_pdbs;
/
Prompt Trigger created. Indicates that the trigger was successfully created.
Exit the database, switch to root, and restart the virtual machine.
After the restart is complete
Switch oracle user
Start monitoring lsnrctl start View monitoring status lsnrctl status
Login database
sqlplus / as sysdba
startup
View currently existing users
select username from dba_users where account_status='OPEN';
Change the password of the sys user 123456
alter user sys identified by 123456;
Change system password 123456
alter user system identified by 123456;
Switch root and enable firewall
systemctl start firewalld.service
systemctl status firewalld (view firewall status)
Open port 1521
firewall-cmd --zone=public --add-port=1521/tcp --permanent
firewall-cmd --reload (requires restart to take effect)
# View open ports netstat -anp
Open the command window and use the netstat -an command to check whether port 1521 is open. If 0.0.0.0:1521 appears, you can connect to Oracle remotely. If there is only 127.0.0.1:1521, it means that you can only connect to Oracle locally. At this time, you need to reconfigure it. monitor;
At this time, tnsping may not work. You need to set the outbound rules of the connected host and configure the oracle port (the default is 1521).
If there is no 0.0.0.0:1521 this
Go to /opt/oracle/product/19c/dbhome_1/network/admin and find listener.ora
Change host to the current host name (the current host name can be viewed using vi /etc/hosts)
Then restart monitoring lsnrctl start
Check whether the following rule exists through netstat -anp
Set the monitoring and database to start automatically at boot. Enter the installation directory pwd to view the path.
/opt/oracle/product/19c/dbhome_1/bin
# vim /etc/rc.d/rc.local Add the following content:
Set up auto-start at power on
su oracle -lc '/opt/oracle/product/19c/dbhome_1/bin/lsnrctl start'
su oracle -lc '/opt/oracle/product/19c/dbhome_1/bin/dbstart'
If you have any questions about the article, you can message me privately or comment at any time. I will reply promptly when I see it.