本教程所使用的环境是阿里云服务器+oracle11g数据库
1.第一步先添加主机名与IP对应记录
vim /etc/hosts # 编辑 hosts
本机ip 本机名称 例如:127.0.0.1 oracle
2.如果内存不足的情况下可以进行设置swap分区使用root用户操作,如果够可以选择跳过
dd if=/dev/zero of=/home/swapfile bs=1M count=512
mkswap /home/swapfile
swapon /home/swapfile
然后在/etc/fstab,然后编辑
/home/swapfile swap swap defaults 0 0
3.首先先去下载Oracle 11gR2位安装包,这个自行去官网进行下载
linux.x64_11gR2_database_1of2.zip
linux.x64_11gR2_database_2of2.zip
4.关闭防火墙
操作用户:root
查看防火墙状态 systemctl status firewalld
关闭防火墙 systemctl stop firewalld
-------------或者-------------------
systemctl stop firewalld.service
systemctl disable firewalld.service
5.安装依赖包
操作用户:root
yum install -y automake autotools-dev binutils bzip2 elfutils expat \
gawk gcc gcc-multilib g++-multilib lib32ncurses5 lib32z1 \
ksh less lib32z1 libaio1 libaio-dev libc6-dev libc6-dev-i386 \
libc6-i386 libelf-dev libltdl-dev libodbcinstq4-1 libodbcinstq4-1:i386 \
libpth-dev libpthread-stubs0-dev libstdc++5 make openssh-server rlwrap \
rpm sysstat unixodbc unixodbc-dev unzip x11-utils zlibc unzip cifs-utils \
libXext.x86_64 glibc.i686
如果不全面西面也可以
yum -y install xz wget gcc-c++ ncurses ncurses-devel \
cmake make perl openssl openssl-devel gcc* libxml2 \
libxml2-devel curl-devel libjpeg* libpng* freetype* \
make gcc-c++ cmake bison perl perl-devel perl perl-devel \
glibc-devel.i686 glibc-devel libaio readline-devel \
zlib.x86_64 zlib-devel.x86_64 libcurl-* net-tool* \
sysstat lrzsz dos2unix telnet.x86_64 iotop unzip \
ftp.x86_64 xfs* expect vim psmisc openssh-client* \
libaio bzip2 epel-release automake binutils bzip2 \
elfutils expat gawk gcc ksh less make openssh-server \
rpm sysstat unzip unzip cifs-utils libXext.x86_64 \
glibc.i686 binutils compat-libstdc++-33 \
elfutils-libelf elfutils-libelf-devel \
expat gcc gcc-c++ glibc glibc-common \
glibc-devel glibc-headers libaio \
libaio-devel libgcc libstdc++ libstdc++-devel \
make sysstat unixODBC unixODBC-devel libnsl
6.创建Oracle用户
操作用户:oracle
groupadd -g 502 oinstall
groupadd -g 503 dba
groupadd -g 504 oper
groupadd -g 505 asmadmin
useradd -u 502 -g oinstall -G oinstall,dba,asmadmin,oper -s /bin/bash -m oracle
passwd oracle
7.解压Oracle数据库安装包
操作用户:oracle
操作目录:/home/oracle
使用xftp工具或者其他工具将安装包上传到home/oracle目录然后按照顺序进行解压
unzip linux.x64_11gR2_database_1of2.zip
unzip linux.x64_11gR2_database_2of2.zip
8.修改操作系统配置
操作用户:root
操作文件:/etc/security/limits.conf
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
9.创建oracle安装目录
操作用户:oracle
操作目录:/home/oracle
mkdir ~/tools/oracle11g
10.修改环境便令
操作用户:oracle
操作目录:/home/oracle
vim ~/.bash_profile
末尾添加:
export ORACLE_BASE=/home/oracle/tools/oracle11g
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export ORACLE_SID=orcl
export ORACLE_UNQNAME=orcl
export NLS_LANG=.AL32UTF8
export PATH=${PATH}:${ORACLE_HOME}/bin/:$ORACLE_HOME/lib64
使环境便令生效:
source ~/.bash_profile
11.修改Oracle配置文件:
操作用户:oracle
操作目录:/home/oracle
复制文件模板
cp /home/oracle/database/response/db_install.rsp .
对db_install.rsp文件进行编辑。
vim db_install.rsp
需要修改的配置项如下
oracle.install.option=INSTALL_DB_AND_CONFIG
ORACLE_HOSTNAME=localhost #实际上可以修改成你自己的主机名或者域名(IP)
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/home/oracle/tools/oraInventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/home/oracle/tools/oracle11g/product/11.2.0/dbhome_1
ORACLE_BASE=/home/oracle/tools/oracle11g
oracle.install.db.InstallEdition=EE
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oper
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
oracle.install.db.config.starterdb.globalDBName=orcl
oracle.install.db.config.starterdb.SID=orcl
oracle.install.db.config.starterdb.characterSet=AL32UTF8
oracle.install.db.config.starterdb.memoryOption=true
oracle.install.db.config.starterdb.memoryLimit=1024 #这里参数不要超过可用
oracle.install.db.config.starterdb.installExampleSchemas=false
oracle.install.db.config.starterdb.password.ALL=Oracle#123456
oracle.install.db.config.starterdb.control=DB_CONTROL
oracle.install.db.config.starterdb.dbcontrol.enableEmailNotification=false
oracle.install.db.config.starterdb.dbcontrol.emailAddress=test@qq.com #可以填写你自己的邮箱地址
oracle.install.db.config.starterdb.automatedBackup.enable=false
oracle.install.db.config.starterdb.storageType=FILE_SYSTEM_STORAGE
oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=/home/oracle/tools/oracle11g/oradata
oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=/home/oracle/tools/oracle11g/fast_recovery_area
oracle.install.db.config.starterdb.automatedBackup.enable=false
DECLINE_SECURITY_UPDATES=true
12.静默安装Oracle
操作用户:oracle
操作目录:/home/oracle/database
./runInstaller -silent -ignoreSysPrereqs -responseFile /home/oracle/db_install.rsp
接下来,就是默认安装oracle,需要等待一段时间出现下面表示安装成功
/home/oracle/tools/oraInventory/orainstRoot.sh
/home/oracle/tools/oracle11g/product/11.2.0/dbhome_1/root.sh
To execute the configuration scripts:
1. Open a terminal window
2. Log in as "root"
3. Run the scripts
4. Return to this window and hit "Enter" key to continue
Successfully Setup Software.
13.安装完成
操作用户:root
/home/oracle/tools/oraInventory/orainstRoot.sh
/home/oracle/tools/oracle11g/product/11.2.0/dbhome_1/root.sh
14.创建链接用户
sqlplus /nolog
conn /as sysdba
startup
接下来,执行如下命令。
alter user system identified by system;
alter user sys identified by sys;
创建连接用户。
create user SYNC identified by SYNC;
grant connect,resource,dba to SYNC;
15.验证安装结果
启动监听:
lsnrctl start
启动数据库过程如下
sqlplus /nolog
使用dba权限连接Oralce
connect / as sysdba
启动数据库
startup
参考链接:Oracle安装报错 Checking swap space: 0 MB available, 150 MB required_海绵十七号的博客-CSDN博客