操作系统:CentOS7
Oracle: 19C
远程连接工具:Xmanager Power Suite 7
yum -y install vim tar net-tools wget perl python3 readline* deltarpm python-deltarpm \
zip unzip bc compat-libcap1* compat-libcap* binutils compat-libstdc++-33 \
elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc-2.5 glibc-common glibc-devel \
glibc-headers ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel make sysstat \
unixODBC unixODBC-devel binutils* compat-libstdc* elfutils-libelf* \
gcc* glibc* ksh* libaio* libgcc* libstdc* make* sysstat* libXp* glibc-kernheaders
# 修改主机名
hostnamectl set-hostname oracle
# 绑定主机名和IP映射
vim /etc/hosts
填写以下内容
192.168.126.141 oracle
建议重启服务器
reboot
vim /etc/sysctl.conf
追加以下内容
fs.file-max = 6815744
fs.aio-max-nr = 1048576
kernel.shmall = 67747971072
kernel.shmmax = 277495689510912
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048586
net.ipv4.tcp_max_tw_buckets = 6000
net.ipv4.ip_local_port_range = 9000 65500
net.ipv4.tcp_tw_recycle = 0
net.ipv4.tcp_tw_reuse = 1
net.core.netdev_max_backlog = 262144
net.ipv4.tcp_max_orphans = 262144
net.ipv4.tcp_max_syn_backlog = 262144
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 1
net.ipv4.tcp_fin_timeout = 1
net.ipv4.tcp_keepalive_time = 30
net.ipv4.tcp_keepalive_probes = 6
net.ipv4.tcp_keepalive_intvl = 5
net.ipv4.tcp_timestamps = 0
net.ipv4.conf.all.rp_filter = 2
net.ipv4.conf.default.rp_filter = 2
# net.core.somaxconn = 262144
修改后生成系统参数
sysctl -p
vim /etc/security/limits.conf
追加以下内容
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft nproc 16384
oracle hard nproc 16384
oracle soft stack 10240
oracle hard stack 32768
oracle hard memlock 134217728
oracle soft memlock 134217728
vim /etc/pam.d/login
追加以下内容
session required /lib/security/pam_limits.so
session required pam_limits.so
vim /etc/profile
追加以下内容
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
当前会话全局环境变量生效
source /etc/profile
groupadd oinstall
groupadd dba
groupadd oper
useradd -g oinstall -G dba,oper oracle
passwd oracle
mkdir -p /u01/app/oracle /u01/oraInventory /u01/app/oracle/product/19c/db_1
chown -R oracle:oinstall /u01
chmod -R 775 /u01/app/oracle
先切换到oracle用户
su - oracle
配置用户环境变量
vim .bash_profile
追加以下内容
export EDITOR=vim
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_SID=orcl
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/19c/db_1
export INVENTORY_LOCATION=/u01/oraInventory
export TNS_ADMIN=$ORACLE_HOME/network/admin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export NLS_LANG="AMERICAN_AMERICA.AL32UTF8"
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"
export PATH=$ORACLE_HOME/bin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11R6/bin:$PATH:$HOME/bin
umask 022
当前会话用户环境变量生效
source .bash_profile
Oracle安装包上传至$ORACLE_HOME路径下
如果使用非oracle用户上传,切换到root用户下修改oralce安装包所有者
chown -R oracle:oinstall LINUX.X64_193000_db_home.zip
切换到oracle用户下解压
su - oracle
cd $ORACLE_HOME
或者 使用绝对路径
cd /u01/app/oracle/product/19c/db_1
解压
unzip LINUX.X64_193000_db_home.zip
- 安装软件
- 创建监听
- DBCA创建数据库
使用oracle用户进入$ORACLE_HOME目录后进行安装
./runInstaller
根据提示:
As a root user, execute the following script(s): 1. /u01/oraInventory/orainstRoot.sh 2. /u01/app/oracle/product/19c/db_1/root.sh
需要使用root用户依次执行以下两个脚本
/u01/oraInventory/orainstRoot.sh
/u01/app/oracle/product/19c/db_1/root.sh
响应配置文件,可以下载到本地以备以后做静默安装使用
/u01/app/oracle/product/19c/db_1/install/response/db_2023-07-04_09-02-29AM.rsp
netca
检查监听状态
lsnrctl status
dbca
在Linux下面使用sqlplus很不方便,上下键,退格键都不能用,严重降低生产效率。
为了linux下的sqlplus方便调用历史命令和退格,安装rlwrap
下载源代码使用root用户编译安装
tar -zxvf rlwrap-0.45.2.tar.gz
cd rlwrap-0.45.2
./configure
make -j8
make install
切换到oracle用户配置用户环境变量支持rlwrap
su - oracle
vim /home/oracle/.bash_profile
追加以下内容:
alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'
alias lsnrctl='rlwrap lsnrctl'
当前会话用户环境变量生效
source /home/oracle/.bash_profile
使用oracle用户操作
sqlplus / as sysdba
conn / as sysdba;
conn sys/oracle@orcl as sysdba;
set linesize 300;
set pagesize 300;
select tname from tab;
select userenv('language') from dual;
select * from nls_database_parameters;
select * from V$NLS_PARAMETERS;
select status from v$instance;
# 关闭监听
lsnrctl stop
-- 关闭数据库
shutdown immediate;
-- 开启数据库
startup;
# 关闭监听
lsnrctl start
使用root用户
firewall-cmd --zone=public --add-port=1521/tcp --permanent
firewall-cmd --reload
–zone #作用域
–add-port=1521/tcp #添加端口,格式为:端口/通讯协议
–permanent #永久生效,没有此参数重启后失效
使用sys账户连接orcl实例