- 安装系统依赖包
# yum -y install binutils compat-libcap1 compat-libstdc++-33 compat-libstdc++-33*.i686 elfutils-libelf-devel gcc gcc-c++ glibc*.i686 glibc glibc-devel glibc-devel*.i686 ksh libgcc*.i686 libgcc libstdc++ libstdc++*.i686 libstdc++-devel libstdc++-devel*.i686 libaio libaio*.i686 libaio-devel libaio-devel*.i686 make sysstat unixODBC unixODBC*.i686 unixODBC-devel unixODBC-devel*.i686 libXp
- 新增用户和用户组
# groupadd oinstall
# groupadd dba
# groupadd oper
# groupadd backupdba
# groupadd dgdba
# groupadd kmdba
# groupadd racdba
# useradd -g oinstall -G dba,oper,backupdba,dgdba,kmdba, racdba -m oracle
# echo "oracle" | passwd --stdin oracle
- 创建软件安装目录
mkdir -p /orcl/app/oracle/product/12.2.0/db_1
chown -R oracle:oinstall /orcl/app
chmod -R 775 /orcl/app
- 解除系统对oracle用户的资源限制(
vim /etc/security/limits.conf
)
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
- 优化内核参数
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 4091021312
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
vim /etc/pam.d/login
session required pam_limits.so
vim /etc/profile
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536a
else
ulimit -u 16384 -n 65536
fi
fi
配置 oracle 用户环境变量vim ~oracle/.bash_profile
ORACLE_BASE=/orcl/app/oracle
ORACLE_HOME=$ORACLE_BASE/product/12.1.0/db_1
ORACLE_SID=orcl
export ORACLE_BASE ORACLE_HOME ORACLE_SID
PATH=$ORACLE_HOME/bin:$PATH
export PATH
# su oracle
$ cd /orcl/app/oracle
$ unzip linuxx64_12201_database.zip
$ export LANG="en_US"
$ export DISPLAY=:0.0
$ xhost +
$ cd /orcl/app/oracle/database
$ ./runInstaller
接下来图形化界面安装,安装过程中会提示,需要手动执行以下两个自带的脚本。
# sh /orcl/app/oraInventory/orainstRoot.sh
# sh /orcl/app/oracle/product/12.2.0.1/dbhome_1/root.sh
解决Oracle SQL/Plus命令行写sql语句删除错误信息及上下翻历史命令异常问题
1、安装 readline
:http://tiswww.case.edu/php/chet/readline/rltop.html#Documentation
# tar -xf readline-8.0.tar.gz
# cd readline-8.0/
# make && make install
2、安装 rlwrap
:https://github.com/hanslub42/rlwrap/releases
安装依赖
# yum install libtermcap-devel
# tar -xf rlwrap-0.43.tar.gz
# cd rlwrap-0.43/
# ./configure
# make && make install
# find / -name libreadline.so.8
/usr/local/lib/libreadline.so.8
# echo "/usr/local/lib/" >> /etc/ld.so.conf
# ldconfig
验证进入SQL
$ rlwrap sqlplus / as sysdba
SQL*Plus: Release 12.2.0.1.0 Production on Fri Apr 12 11:37:56 2019
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL>
可选择配置命令别名
$ vi .bash_profile
加上:
alias sqlplus="rlwrap sqlplus"
alias rman="rlwrap rman"