This is the third day of my participation in the More text Challenge. For details, see more text Challenge

About the author:

LuciferLiu is a member of China DBA alliance (ACDU). Currently, I am working as Oracle DBA and used to be engaged in the development of Oracle database, mainly serving the manufacturing, auto finance and other industries. Now he has Oracle OCP and OceanBase OBCA certifications. He is good at Oracle database operation and maintenance development, backup and recovery, installation and migration, Linux automatic operation and maintenance script writing, etc.

preface

I believe you first contact Oracle, mostly in Windows installation, more convenient and quick, basically has been the next step can be installed successfully. However, enterprise-class databases, which are basically installed on Linux servers, are safe and efficient.

For those of you who don’t have access to Linux, don’t be afraid to follow this step-by-step guide. Installing Oracle is as simple and standard as drinking water.

I’m going to show you how to install the Oracle database on Linux.

First, early preparation

1. Install the VM

Windows host recommend a virtual machine: VMware Workstation download address: https://www.vmware.com/go/getworkstation-win MacOS host recommend a virtual machine: 16 Parallels Desktop for Mac download address: https://www.parallels.cn/products/desktop/trial/Copy the code

2. Oracle software installation package

Oracle's website to download address: https://www.oracle.com/database/technologies/oracle-database-software-downloads.html oracle account: [email protected] Oracle password: Oracle123 Notes: You can download only the latest version of Oracle 19C. If you need other versions of Oracle, you can obtain them from private bloggers.Copy the code

3. Linux system installation package

There are three Linux oss commonly used: RedHat, OracleLinux, and Centos.

RedHat download: https://developers.redhat.com/products/rhel/download OracleLinux download: Centos download: https://yum.oracle.com/oracle-linux-isos.html https://vault.centos.org/Copy the code

The installation package can be downloaded from the official website or obtained by private bloggers.

Linux system installation can refer to the article, this article will not be detailed installation method:

Here are three steps to installing Linux on MacOS

How can Windows hosts play with virtual Machine Linux installations, just read this article

4. Linux remote connection tool

This article will use XShell and Xftp tools. The installation package can be downloaded from the official website or obtained by private bloggers.

Other tools are available, such as putty, SecureCRT, etc.

This blog demonstrates the installation of Oracle 11GR2 database for RedHat Linux 7.6.

The host memory is 2 GB and the hard disk is 50 GB.

2. Linux host configuration

Connect to user root of the Linux host using XShell:

1. Configure the host name

If the host name is not configured during the installation, or you want to change the host name, run the following command:

hostnamectl set-hostname orcl
Copy the code

2. Network configuration

If the network is not configured during the installation, or you want to change the network, run the following command:

Nmcli connection modify eth0 ipv4.addresses 10.211.55.188/24 ipv4. Gateway 10.211.55.1 ipv4. Method Manual Autoconnect yes  nmcli connection up eth0Copy the code

3. Configure the Hosts file

Based on the host name and IP address configured above, configure the hosts file:

cat <<EOF >>/etc/hosts ##OracleBegin## ##Public IP 10.211.55.188 orcl ##OracleEnd## EOF
Copy the code

4. Configure the firewall

systemctl stop firewalld
systemctl disable firewalld
Copy the code

5. Configure Selinux

Selinux The modification takes effect only after the host is restarted.

sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
Copy the code

6. Configure the ISO image source

The host image must be mounted first:

Parallels Desktop Mounting a Linux host image:

If VMware Workstation mounts a Linux image:

mount /dev/cdrom /mnt

cat <<EOF>/etc/yum.repos.d/local.repo
[local]
name=local
baseurl=file:///mnt
gpgcheck=0
enabled=1
EOF
Copy the code

7. Install Oracle dependency packages

You are advised to obtain the following dependency packages from the Oracle official documentation:

yum install -y bc \ binutils \ compat-libcap1 \ compat-libstdc++-33 \ gcc \ gcc-c++ \ elfutils-libelf \ elfutils-libelf-devel \ glibc \ glibc-devel \ ksh \ libaio \ libaio-devel \ libgcc \ libstdc++ \ libstdc++-devel \ libxcb \ libX11 \ libXau \ libXi \ libXtst \ libXrender \ libXrender-devel \ make \ net-tools \ nfs-utils \ smartmontools \ sysstat \ e2fsprogs \ e2fsprogs-libs \ fontconfig-devel \ expect \ unzip \ openssh-clients \ readline* \  psmisc --skip-brokenCopy the code

Check whether the installation is successful:

rpm -q bc binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ elfutils-libelf elfutils-libelf-devel glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libxcb libX11 libXau libXi libXtst libXrender libXrender-devel make net-tools nfs-utils smartmontools sysstat e2fsprogs e2fsprogs-libs fontconfig-devel expect unzip openssh-clients readline
Copy the code

Compat-libstdc ++ dependencies for Linux7:

The RPM - the ivh compat - libstdc++ - 33-3.2.3-72. El7. X86_64. RPMCopy the code

8. Configure ZeroConf

## Close the service daemon of Zeroconf Service
systemctl stop avahi-daemon.socket
systemctl stop avahi-daemon.service
systemctl disable avahi-daemon.service
systemctl disable avahi-daemon.socket

Closed NOZEROCONF # #
cat <<EOF >>/etc/sysconfig/network
#OracleBegin
NOZEROCONF=yes
#OracleEnd
EOF
Copy the code

9. Close the transparency page and NUMA

sed -i 's/quiet/quiet transparent_hugepage=never numa=off/' /etc/default/grub
grub2-mkconfig -o /boot/grub2/grub.cfg
Copy the code

10. Configure the system parameter file

## Calculate the shmall and shmmax values
memTotal=$(grep MemTotal /proc/meminfo | awk '{print $2}')
totalMemory=$((memTotal / 2048))
shmall=$((memTotal / 4))
if [ $shmall -lt 2097152 ]; then
  shmall=2097152
fi
shmmax=$((memTotal * 1024 - 1))
if [ "$shmmax" -lt 4294967295 ]; then
  shmmax=4294967295
fi
echo $shmall
echo $shmmax

## Set system parameters
cat <<EOF >>/etc/sysctl.conf #OracleBegin ##shmmal's Calculation formula: Physical memory 8G: (8*1024*1024*1024)/4096=2097152 ## Shmmax's Calculation formula: Physical memory 8 g: (8/2)*1024*1024*1024 -1=4294967295 fs.aio-max-nr = 1048576 fs.file-max = 6815744 kernel.shmall = $shmall kernel.shmmax =  $shmmax kernel.shmmni = 4096 kernel.sem = 250 32000 100 128 net.ipv4.ip_local_port_range = 9000 65500 net.core.rmem_default = 262144 net.core.rmem_max = 4194304 net.core.wmem_default = 262144 net.core.wmem_max = 1048576 EOF

## System parameters take effect
sysctl -p
Copy the code

11. Configure system resource limits

cat <<EOF >>/etc/security/limits.conf #OracleBegin oracle soft nofile 1024 oracle hard nofile 65536 oracle soft stack 10240 oracle hard stack 32768 oracle soft nproc 2047 oracle hard nproc 16384 oracle hard memlock 134217728 oracle soft memlock  134217728 #OracleEnd EOF

cat <<EOF >>/etc/pam.d/login #OracleBegin session required pam_limits.so session required /lib64/security/pam_limits.so #OracleEnd EOF
Copy the code

12. Create users and groups

/usr/sbin/groupadd -g 54321 oinstall
/usr/sbin/groupadd -g 54322 dba
/usr/sbin/groupadd -g 54323 oper

/usr/sbin/useradd -u 54321 -g oinstall -G dba,oper oracle
echo oracle | passwd --stdin oracle
Copy the code

13. Create an Oracle installation directory

The mkdir -p/u01 / app/oracle/product / 11.2.0 / db mkdir -p/u01 / app/oraInventory mkdir -p/oradata chown -r oracle: oinstall /oradata chown -R oracle:oinstall /u01/app chmod -R 775 /u01/appCopy the code

14. Configure user environment variables

cat <<EOF >>/home/oracle/.bash_profile ################OracleBegin######################### umask 022 export TMP=/tmp export TMPDIR=\$TMP export NLS_LANG=AMERICAN_AMERICA.AL32UTF8 export ORACLE_BASE=/u01/app/oracle export ORACLE_HOME = / u01 / app/oracle/product / 11.2.0 / db export ORACLE_HOSTNAME = former export ORACLE_TERM = xterm export TNS_ADMIN=\$ORACLE_HOME/network/admin export LD_LIBRARY_PATH=\$ORACLE_HOME/lib:/lib:/usr/lib export ORACLE_SID=orcl export PATH=/usr/sbin:\$PATH export PATH=\$ORACLE_HOME/bin:\$ORACLE_HOME/OPatch:\$PATH alias sas='sqlplus / as sysdba' export PS1="[\`whoami\`@\`hostname\`:"'\$PWD]\$ ' EOF
Copy the code

Install Oracle software

1. Upload the Oracle software package

[root@orcl soft]# ll
-rw-r--r--. 1 root root 1395582860 May 31 16:56 p13390677_112040_Linux-x86-64_1of7.zip
-rw-r--r--. 1 root root 1151304589 May 31 16:56 p13390677_112040_Linux-x86-64_2of7.zip
Copy the code

2. Decompress the Oracle software installation package

Decompress installation package 1,2 in sequence:

cd /soft
unzip -q p13390677_112040_Linux-x86-64_1of7.zip
unzip -q p13390677_112040_Linux-x86-64_2of7.zip

Authorize /soft to grant read/write permission to Oracle
chown -R oracle:oinstall /soft
Copy the code

3. Install VNC

yum install -y tigervnc*

su - oracle
vncserver
## Enter your password
Copy the code

4. Connect to the VNC remote tool or directly open the VM GRAPHICAL user interface (GUI)

Right click to open terminal tool:

Enter /soft/database to install the Oracle software.

. / runInstaller jreLoc/etc/alternatives/jre_1. 8.0Copy the code

Upload the pdksh-5.2.14-37.el5.x86_64. RPM dependency package and install it:

RPM -e ksh-20120801-142.el7.x86_64 RPM -ivh pdksh-5.2.14-37.el5.x86_64.rpmCopy the code

Click Check again and ignore the swap warning:

Solution:

su - oracle
sed -i 's/^\(\s*\$(MK_EMAGENT_NMECTL)\)\s*$/\1 -lnnz11/g' $ORACLE_HOME/sysman/lib/ins_emagent.mk
Copy the code

After executing, click Retry:

Run the script as user root:

/ u01 / app/oraInventory/orainstRoot. Sh/u01 / app/oracle/product / 11.2.0 / db/root. ShCopy the code

Reboot Restarts the host.

Create database

1. Turn on the monitor

su - oracle
lsnrctl start
lsnrctl status
Copy the code

2. Connect to the VNC remote tool or directly open the VM GRAPHICAL user interface (GUI)

dbca
Copy the code

Enter database instance name and DBname here, and enter ORCL this time.

The EM tool is not installed.

Enter the passwords of the SYS and SYSTEM users.

Select the /oradata directory you created earlier to store the data files.

Do not enable flashback log and archive log. You can manually change them after the database is built.

Database memory allocation: Select manual memory allocation, which occupies about 70% of the physical memory.

Block_size Specifies the value based on actual conditions. The value cannot be changed once the database is created. The default value is 8K.

The character set can be selected as required. The default character set is AL32UTF8.

Wait for the completion of the library.

Connect to the database

Ensure that the listener starts properly and listens to the database:

1. Connect to the database host

su - oracle
sqlplus / as sysdba
select sysdate from dual;

## Create database user
create user test identified by test;
grant dba to test;
conn test/test

# # to create tables
create table test (id number not null,name varchar2(100));
insert into test values (1,'lucifer');
commit;
Copy the code

2. Connect to user test using PL/SQL

If you think the article is helpful to you, please like, collect, follow, comment, and support with four keys. Your support is the biggest motivation for my creation. Thank you

Ink wheel: Lucifer think before you act CSDN: Lucifer think before you act wechat public number: Lucifer think before you act \