Centos7 complete steps to install oracle database

oracle database official documentation

1. Check the environment

[root@node82 ~]# cat /etc/centos-release
CentOS Linux release 7.6.1810 (Core)

Verify that the processor architecture matches the Oracle software version to be installed. If you do not see the expected output, you cannot install the software on this system.
Check the memory and swap partition
free -m or free -g
Insert picture description here
Note: If you deploy the oralce database, also ensure that there is a swap partition and the space is greater than 128M.

Second, the database installation

2.1 Database version

(Enterprise Edition): Oracle Database 11g Enterprise Edition Release 11.2.0.4.0-64bit Production
installation package see the attached compressed package name as follows:Insert picture description here

2.2 Parameter modification

2.2.1 Modify the limits.conf file Modify the
user's SHELL limits, modify the /etc/security/limits.conf file
Enter the command vi /etc/security/limits.conf i key to enter the edit mode to add the following content (recommended to copy directly)

oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536 

2.2.2 Login file modification
Modify the /etc/pam.d/login file.
Enter the command: vi /etc/pam.d/login, enter the edit mode with the i key, and add the following to the end of the file
.

session required /lib64/security/pam_limits.so
session required pam_limits.so 

2.2.3 Modification of sysctl.conf file
Input command: vi /etc/sysctl.conf, i key to enter edit mode, add the following content to the file:

fs.file-max = 6815744
fs.aio-max-nr = 1048576
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 4194304
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576 

Refresh input:

#sysctl -p

** 2.2.4 / etc / profile file modification **
Enter the command: vi / etc / profile, i key to enter edit mode, add the following content to the file.

if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
 ulimit -p 16384
 ulimit -n 65536
else
 ulimit -u 16384 -n 65536
fi
fi 

3. Installation preparation

3.1 Improve dependency packages For
different versions, please refer to the official documentation

sudo yum -y install binutils compat-libstdc++ elfutils-libelf
elfutils-libelf-devel elfutils-libelf-devel-static gcc gcc-c++ glibc
glibc-common glibc-devel glibc-headers kernel-headers libaio libaio-devel
libgcc libgomp libstdc++ libstdc++-devel make sysstat unixODBC
unixODBC-devel compat-libstdc++-33.x86_64 ksh

If you check that compat-libstdc ++ has not been installed
Solution: sudo yum list all | grep "compat-libstdc ++"
Insert picture description here
** 3.2 Create users and groups **
Create related users and groups as the owner of the software installation and support group.
Create an Oracle user and password, enter the following command:

 groupadd dba
 groupadd oinstall
 useradd oracle -g oinstall -G dba ##使Oracle用户同时属于这两个组
 passwd oracle 

Then you will be asked to enter the password. The password can be entered twice arbitrarily, but it must be consistent and press Enter to confirm.
tips: Linux to view the user's genregroups <user1> <user2> <user3>

3.3 Create a database software directory
Create a database software directory and a data file storage directory. The location of the directory is determined according to your own situation. Pay
attention to the disk space and enter the following command:

mkdir -p /home/oracle/app/{oracle,oraInventory,oradata}

3.4 Change Directory Ownership To
change the directory owner is owned by the Oracle user, enter the command:

chown -R oracle:oinstall /home/oracle/app

3.5 Configure environment variables To configure the environment variables of the
oracle user, first, switch to the newly created oracle user, enter: su-oracle, and then directly enter: vi .bash_profile i key to enter the edit mode, add the following content to the end of the file.

export ORACLE_BASE=/home/oracle/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export ORACLE_SID=orcl
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib 

Fourth, the installation process

4.1 Unzip the package
First copy the downloaded Oracle installation package to Linux:

sudo yum -y install unzip --安装解压包(可忽略)
unzip p13390677_112040_Linux-x86-64_1of7.zip
unzip p13390677_112040_Linux-x86-64_2of7.zip 

After the decompression is completed, cd enters its decompressed directory database. You can also use the ls command to view the files contained in the decompressed database

cd database

4.2 Copy the response template file
Oracle user login, su-oracle, enter the following command:

mkdir etc
cp /home/oracle/database/response/* /home/oracle/etc/ 

** 4.3 Set the permissions of the response file **
Switch to the root user, su-root, enter the following command:

chown -R oracle.dba /home/oracle/etc
chmod 700 /home/oracle/etc/*.rsp 

** 4.4 Silently install the oracle software **
Switch back to the oracle user, su-oracle
modify the response file to install the Oracle software /home/oracle/etc/db_install.rsp
/ home / oracle / app can be changed to a custom data directory, enter The following command:

vi /home/oracle/etc/db_install.rsp

The parameters to be modified are as follows:

oracle.install.option=INSTALL_DB_SWONLY //29 行 安装类型
ORACLE_HOSTNAME=localdomain //37 行 主机名称,通过 hostname 命令获得
UNIX_GROUP_NAME=oinstall//42 行 安装组
INVENTORY_LOCATION=/home/oracle/app/oraInventory //47 行 INVENTORY 目
录
SELECTED_LANGUAGES=en,zh_CN,zh_TW //78 行 选择语言
ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_1 //83 行
oracle_home 和上面配置环境变量里的目录保持一致
ORACLE_BASE=/home/oracle/app/oracle //88 行 oracle_base,和 INVENTORY 目
录要同级
oracle.install.db.InstallEdition=EE //99 行 oracle 版本,EE 为企业版
oracle.install.db.DBA_GROUP=dba //142 行 dba 用户组
oracle.install.db.OPER_GROUP=oinstall //147 行 oper 用户组
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE //160 行 数据
库类型
oracle.install.db.config.starterdb.globalDBName=orcl //165 行
globalDBName
oracle.install.db.config.starterdb.SID=orcl //170 行 SID
oracle.install.db.config.starterdb.characterSet=ZHS16GBK//指定字符集
oracle.install.db.config.starterdb.installExampleSchemas=false// 是 否
载入模板示例
oracle.install.db.config.starterdb.enableSecuritySettings=true// 是 否
启用安全设置
oracle.install.db.config.starterdb.memoryLimit=512 //192/200 行 自动管
理内存的最小内存(M)
oracle.install.db.config.starterdb.password.ALL=LINKCLD_ORCL //23 行设
定所有数据库用户使用同一个密码
DECLINE_SECURITY_UPDATES=true //385 行 设置安全更新 

Under the oracle user, su-oracle switches to the cd database under the database directory and enter the following command:

./runInstaller -silent -force -responseFile /home/oracle/etc/db_install.rsp

Start the installation. During the installation, if you prompt [WARNING], don't pay attention. At this time, the installation program is still in progress. If
[FATAL] appears, the installation program has been stopped. Perform until the following page appears:

The following configuration scripts need to be executed as the "root"
user.
#!/bin/sh
#Root scripts to run
/home/oracle/app/oraInventory/orainstRoot.sh
/home/oracle/app/product/11.2.0/db_1/root.sh
To execute the configuration scripts:
1. Open a terminal window 
2. 2. Log in as "root"
3. Run the scripts
4. Return to this window and hit "Enter" key to continue
Successfully Setup Software. 

Open a new window, switch to the root user, su-root
and then execute the above two scripts, the command is as follows:

sh /home/oracle/app/oraInventory/orainstRoot.sh
sh /home/oracle/app/product/11.2.0/db_1/root.sh

After the script execution is completed, return to the above interface, press Enter to
increase the environment variable of
the oracle user. Under the oracle user, su-oracle, edit the document, enter the following command: vi ~/.bash_profile
key i to enter the editing mode, and directly add the following content at the end:

export TNS_ADMIN=$ORACLE_HOME/network/admin
export PATH=.:${PATH}:$HOME/bin:$ORACLE_HOME/bin
export PATH=${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/lib
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/oracm/lib
export
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib
export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/JRE
export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/JRE/lib
export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/jlib
export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/rdbms/jlib
export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/network/jlib
export LIBPATH=${CLASSPATH}:$ORACLE_HOME/lib:$ORACLE_HOME/ctx/lib
export ORACLE_OWNER=oracle
export SPFILE_PATH=$ORACLE_HOME/dbs
export ORA_NLS10=$ORACLE_HOME/nls/data 

Enter the following command to make the above settings take effect:

source /home/oracle/.bash_profile

4.6 Configure the silent network
Oracle user, su-oracle, enter the following command:

$ORACLE_HOME/bin/netca /silent /responseFile
/home/oracle/etc/netca.rsp
##配置静默监听程序

If the following error is reported:

UnsatisfiedLinkError exception loading native library: njni11 java.lang.UnsatisfiedLinkError:
/home/oracle/app/oracle/product/11.2.0/db_1/lib/libnjni11.so: libclntsh.so.11.1: cannle: No such file or directory 

Solution:

cp /home/oracle/app/oracle/product/11.2.0/db_1/inventory/Scripts/ext/lib/libcl
ntsh.so.11.1 /home/oracle/app/oracle/product/11.2.0/db_1/lib

Execute the following command again:

netca /silent /responseFile /home/oracle/etc/netca.rsp

The prompt is as follows:

Listener started successfully.
Listener configuration complete.
Oracle Net Services configuration successful. The exit code is 0 

Enter the following command to view:

ss -antp|grep 1521

4.7 Modify the silent installation configuration To
modify the response file for installing the database only, enter the following command:

vi /home/oracle/etc/dbca.rsp

Modify the following parameters:

GDBNAME="orcl.localdomain " //78 行 全局数据库的名字=SID+主机域名
SID="orcl" //149 行 SID
CHARACTERSET="ZHS16GBK" //415 行 编码
NATIONALCHARACTERSET="AL16UTF16" //425 行 编码
DATAFILEDESTINATION = /home/oracle/app/oradata //356 行 

** 4.8 Install the database silently ** For
Oracle users, enter the following command with su-oracle and press Enter:

$ORACLE_HOME/bin/dbca -silent -responseFile /home/oracle/etc/dbca.rsp

After executing the above command, the screen will turn into a whiteboard. In fact, at this time, enter
the passwords of sys and system of oracle , enter it twice, and then it will display the progress of the percentage of execution and will prompt: The log file of oracle is / u01 / app / oracle / cfgtoollogs / dbca / orcl / orcl.log and then check and modify the permissions of the oracle command (6751). If the permissions are incorrect, enter the following command to modify:

chmod 6751 $ORACLE_HOME/bin/oracle

4.9 Instance check after building the database
Start the listening port and enter the following command: lsnrctl start
Instance check after building the database, enter the following command:

ps -ef | grep ora | grep -v grep | wc -l
ps -ef | grep ora | grep -v grep
ps -ef|grep oracle|egrep -v "bash|su|grep|ps" 

Check that the sqlplus process is normal, you can configure the following service file

oracle 3695 3413 0 14:46 pts/1 00:00:00 sqlplus
oracle 11082 1 0 15:19 ? 00:00:00 /u01/app/oracle/product/11.2.0/db_1/bin/tnslsnr LISTENER -inherit 

After building the library, listen to the status check and enter the following command:lsnrctl status

Five, start up

5.1 Configuration modification
Switch to root user, su-root, enter the following command:

vi /home/oracle/app/oracle/product/11.2.0/dbhome_1/bin/dbstart 

Add the following content to the file:

ORACLE_HOME_LISTNER=$ORACLE_HOME //在 65 行添加

Enter the following command after saving and exiting:

vi /home/oracle/app/oracle/product/11.2.0/dbhome_1/bin/dbshut 

Add the following content to the file:

ORACLE_HOME_LISTNER=$ORACLE_HOME //在 39 行添加

Save and exit, then enter: vi /etc/oratabchange the N at the end to Y, as follows:

orcl:/home/oracle/app/oracle/product/11.2.0/dbhome_1:Y

5.2 Create a startup file
Modify the file configuration, switch to the root user, su-root, enter the following command:
vi /etc/rc.d/init.d/oracled
paste the following content into a new file, ORACLE_HOME = self-installed directory

#! /bin/bash
# chkconfig: 345 90 10
# description: The Oracle Database is an Object-Relational Database
Management System.
#
# processname: oracle
. /etc/rc.d/init.d/functions
LOCKFILE=/var/lock/subsys/oracle
ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_1
ORACLE_USER=oracle
case "$1" in
'start')
 if [ -f $LOCKFILE ]; then
 echo $0 already running.
 exit 1
 fi 
 echo -n $"Starting Oracle Database:"
 su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl start"
 su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
 ##su - $ORACLE_USER -c "$ORACLE_HOME/bin/emctl start dbconsole"
 touch $LOCKFILE
 ;;
'stop')
 if [ ! -f $LOCKFILE ]; then
 echo $0 already stopping.
 exit 1
 fi
 echo -n $"Stopping Oracle Database:"
 su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl stop"
 su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbshut"
 ##su - $ORACLE_USER -c "$ORACLE_HOME/bin/emctl stop dbconsole"
 rm -f $LOCKFILE
 ;;
'restart')
 $0 stop
 $0 start
 ;;
'status')
 if [ -f $LOCKFILE ]; then
 echo $0 started.
 else
 echo $0 stopped.
 fi
 ;; 
 *)
 echo "Usage: $0 [start|stop|status]"
 exit 1
esac
exit 0 

To modify the permission configuration, also under the root user, su-root, enter the following command:

chown oracle.dba /etc/init.d/oracled
chmod a+x /etc/init.d/oracled
chkconfig --add oracled
chkconfig oracled on //添加 oracled 服务开机启动 

Set the sudo permission of the oracle user, use the systemctl command to manage the oracled service, enter the following
command:chattr -i /etc/sudoers

visudo

Press the i key to enter edit mode, add a line around the 95th line of the file as follows:

oracle   ALL=(ALL)   NOPASSWD:  /etc/init.d/oracled,/usr/bin/systemctl * oracled*

The Oracle server startup, shutdown, and restart commands are as follows:

su - oracle //su – root 也可以
sudo systemctl start oracled
sudo systemctl stop oracled
sudo systemctl restart oracled 

Possible problems

Published 10 original articles · Likes0 · Visits 959

Guess you like

Origin blog.csdn.net/weixin_43572702/article/details/102500658