使用云服务器Centos7.9 安装Oracle 11g

释放双眼,带上耳机,听听看~!
之前写过oracle在虚拟机上运行,随着云服务器不断的应用到生产环境。我们很多环境的都是云主机,并且有云服务器安装oracle的需求。这篇文章主要介绍在华为云服务器上安装oracle11g
🤖 由 ChatGPT 生成的文章摘要

Oracle不在介绍,有需要可以参考我之前写的

Oracle 11G 安装图解

服务器配置
使用云服务器Centos7.9 安装Oracle 11g

修改主机名

hostnamectl set-hostname abcdocker

添加hosts解析

cat >>/etc/hosts<<EOF
127.0.0.1   abcdocker
127.0.0.1   orcl
EOF

防火墙配置

systemctl stop firewalld
systemctl disable firewalld

关闭selinux

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

安装oracle依赖包

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-broken

还需要单独为pdksh安装5.2.14版本依赖包

wget https://d.frps.cn/file/tools/pdksh/pdksh-5.2.14-37.el5.x86_64.rpm
rpm -ivh pdksh-5.2.14-37.el5_8.1.x86_64.rpm

如果出现安装包冲突,请卸载下面的包
使用云服务器Centos7.9 安装Oracle 11g

oracle需要单独生成swap分区,swap分区最好是8g以上

[root@abcdocker ~]#cd /tmp &&  dd if=/dev/zero of=swap bs=1M count=8096
[root@abcdocker tmp]# mkswap /tmp/swap -f
[root@abcdocker tmp]# swapon /tmp/swap
[root@abcdocker tmp]# free -mh
              total        used        free      shared  buff/cache   available
Mem:           7.4G        206M        130M        8.5M        7.1G        6.9G
Swap:          7.9G          0B        7.9G

内核优化

#配置系统参数文件
##计算shmall和shmmax值
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

##配置系统参数
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 8G:(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

##系统参数生效
sysctl -p

配置系统资源限制

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

创建用户和组

groupadd -g 54321 oinstall
groupadd -g 54322 dba
groupadd -g 54323 oper

useradd -u 54321 -g oinstall -G dba,oper oracle
echo oracle | passwd --stdin oracle

创建oracle安装目录

创建Oracle安装目录
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/app

配置用户环境变量

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=orcl
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

上传oracle软件包

#百度云
链接:https://pan.baidu.com/s/1o5a636AkDctpX58WvcPFTg  密码:0z0y

解压压缩包

unzip p10404530_112030_Linux-x86-64_1of7.zip
unzip p10404530_112030_Linux-x86-64_2of7.zip

接下来我们安装vncserver

[root@abcdocker tmp]# yum install tigervnc-server -y

切换普通用户,创建vnc窗口

[root@abcdocker ~]# su - oracle
[oracle@abcdocker:/home/oracle]$ vncserver

#这里的vnc主要是用于oracle本地调用,也可以当做vnc连接信息配置

使用云服务器Centos7.9 安装Oracle 11g

连接服务器有多种方式,可以使用xmanager,或者远程vnc

我本地使用Mac, 所以没有xmanager我这边直接使用华为云控制台

安装GNOME桌面环境

安装GNOME桌面环境
 yum -y groups install "GNOME Desktop"

启动桌面

startx 

这里需要注意,执行startx窗口不能关闭

使用云服务器Centos7.9 安装Oracle 11g

开通安全组
然后我们使用vncserver连接

使用云服务器Centos7.9 安装Oracle 11g

连接成功后我们打开终端
使用云服务器Centos7.9 安装Oracle 11g

设置DISPLAY变量
使用云服务器Centos7.9 安装Oracle 11g

在vnc窗口中,切换oracle用户,并且设置DISPLAY变量

su - oracle
exporter DISPLAY=abcdocker:1

#这里的DISPLAY后面的值是我们输入vncserver中打印的,一般为主机名:1 (后面的1位累加的)

启动oracle脚本
使用云服务器Centos7.9 安装Oracle 11g

使用云服务器Centos7.9 安装Oracle 11g

直接下一步,忽略提示即可

使用云服务器Centos7.9 安装Oracle 11g

使用云服务器Centos7.9 安装Oracle 11g

只安装oracle数据库

使用云服务器Centos7.9 安装Oracle 11g

单节点即可
使用云服务器Centos7.9 安装Oracle 11g

选择第一个
使用云服务器Centos7.9 安装Oracle 11g

安装目录等直接默认即可

使用云服务器Centos7.9 安装Oracle 11g

用户和用户组我们也不修改

使用云服务器Centos7.9 安装Oracle 11g

使用云服务器Centos7.9 安装Oracle 11g

开始健康检查

使用云服务器Centos7.9 安装Oracle 11g

开始安装
使用云服务器Centos7.9 安装Oracle 11g

等待安装完毕

使用云服务器Centos7.9 安装Oracle 11g

使用root用户执行下面目录的脚本
使用云服务器Centos7.9 安装Oracle 11g

[root@abcdocker ~]# sh /u01/app/oraInventory/orainstRoot.sh
Changing permissions of /u01/app/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.

Changing groupname of /u01/app/oraInventory to oinstall.
The execution of the script is complete.
[root@abcdocker ~]#
[root@abcdocker ~]# sh /u01/app/oracle/product/11.2.0/db/root.sh
Performing root user operation for Oracle 11g

The following environment variables are set as:
    ORACLE_OWNER= oracle
    ORACLE_HOME=  /u01/app/oracle/product/11.2.0/db

Enter the full pathname of the local bin directory: [/usr/local/bin]:
   Copying dbhome to /usr/local/bin ...
   Copying oraenv to /usr/local/bin ...
   Copying coraenv to /usr/local/bin ...

Creating /etc/oratab file...
Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root script.
Now product-specific root actions will be performed.
Finished product-specific root actions.

当我们脚本执行完毕后,后台自动退出
使用云服务器Centos7.9 安装Oracle 11g

接下来我们配置监听器

使用netca配置

[oracle@abcdocker ~]# netca

配置监听器

使用云服务器Centos7.9 安装Oracle 11g

添加监听器
使用云服务器Centos7.9 安装Oracle 11g

默认下一步即可
使用云服务器Centos7.9 安装Oracle 11g

监听端口号: 这里默认1521
使用云服务器Centos7.9 安装Oracle 11g

当然也可以使用其它端口号

使用云服务器Centos7.9 安装Oracle 11g

配置完成后会提示我们是否继续配置,我们点击否即可
使用云服务器Centos7.9 安装Oracle 11g

然后我们退出窗口就可以了,配置完成就可以使用命令控制

su - oracle
lsnrctl start
lsnrctl status

创建oracle数据库

执行dbca命令
使用云服务器Centos7.9 安装Oracle 11g

使用云服务器Centos7.9 安装Oracle 11g

创建数据库

使用云服务器Centos7.9 安装Oracle 11g

选择第二个

使用云服务器Centos7.9 安装Oracle 11g

填写orcl即可
使用云服务器Centos7.9 安装Oracle 11g

使用云服务器Centos7.9 安装Oracle 11g

这里输入SYS和SYSTEM用户的密码
设置密码123456
使用云服务器Centos7.9 安装Oracle 11g

默认数据存储目录,我这默认就可以
使用云服务器Centos7.9 安装Oracle 11g

略过的步骤全都下一步即可
使用云服务器Centos7.9 安装Oracle 11g

使用云服务器Centos7.9 安装Oracle 11g

点击ok
使用云服务器Centos7.9 安装Oracle 11g

开始创建
使用云服务器Centos7.9 安装Oracle 11g

等待建库完成即可
使用云服务器Centos7.9 安装Oracle 11g

安全组开放1521端口,启动监听

su - oracle
lsnrctl start

创建用户和数据库

create tablespace abcdocker datafile '/u01/app/oracle/oradata/abcdocker.dbf' size 2000M reuse autoextend on next 4024M maxsize unlimited extent management local;

#创建用户
create user abcdocker identified by abcdocker default tablespace abcdocker temporary tablespace temp profile default;

#授权
grant EXP_FULL_DATABASE,IMP_FULL_DATABASE,resource,connect,create view,create session to abcdocker;

Navicat连接测试

给TA打赏
共{{data.count}}人
人已打赏
Oracle

Oracle 11G 安装图解

2017-1-3 21:01:21

Oracle

Oracle 创建只读角色 - 创建只读用户(所有表可访问)

2022-7-21 14:51:04

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索