Centos7 安装Oracle 11g

2020-11-30  本文已影响0人  我问你瓜保熟吗
hostnamectl set-hostname oracledb

cat /etc/hosts
192.168.*.*  oracledb
sed 's/SELINUX=.*/SELINUX=disabled/g' -i /etc/selinux/config
setenforce 0 # 立即生效

systemctl stop firewalld.service
systemctl disable firewalld.service
groupadd oinstall
groupadd dba
useradd -g oinstall -G dba oracle
passwd oracle
oracle
echo "oracle ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
yum -y install binutils compat-libcap1 compat-libstdc++-33 compat-libstdc++-33*i686 compat-libstdc++-33*.devel compat-libstdc++-33 compat-libstdc++-33*.devel gcc gcc-c++ glibc glibc*.i686 glibc-devel glibc-devel*.i686 ksh libaio libaio*.i686 libaio-devel libaio-devel*.devel libgcc libgcc*.i686 libstdc++ libstdc++*.i686 libstdc++-devel libstdc++-devel*.devel libXi libXi*.i686 libXtst libXtst*.i686 make sysstat unixODBC unixODBC*.i686 unixODBC-devel unixODBC-devel*.i686
mkdir -p /opt/oracle
chown oracle:oinstall /opt/oracle
chmod 755 /opt/oracle
mkdir -p /opt/oraInventory
chown oracle:oinstall /opt/oraInventory
chmod 755 /opt/oraInventory
echo >> /home/oracle/.bashrc << EOM

export ORACLE_BASE=/opt/oracle # oracle安装目录
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1 # oracle home目录
export ORACLE_SID=orcl # oracle实例名
export ORACLE_PID=oracle11g.pid 
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export LANG="zh_CN.UTF-8"
export NLS_LANG="SIMPLIFIED CHINESE_CHINA.AL32UTF8"
export NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss'
export PATH=$PATH:$ORACLE_HOME/bin
EOM

source ~/.bash_profile
echo >> /etc/sysctl.conf << EOM
fs.aio-max-nr = 1048576
fs.file-ax = 6815744
kernel.shmall = 2097152
kernel.shmmax = 4294967295
kernel.shmmni = 4096
kernel.sem = 250 32000 100128
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 = 1048586
EOM
sysctl -p # 立即生效内核参数
echo >> /etc/security/limits.conf << EOM
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
EOM
tar xf linux.x64_11gR2_database_1of2.zip -C /home/oracle
tar xf linux.x64_11gR2_database_2of2.zip -C /home/oracle
chown -R oracle:oinstall /home/oracle/database
oracle.install.option=INSTALL_DB_SWONLY     # 安装类型
ORACLE_HOSTNAME=oracledb                      # 主机名称(hostname查询)
UNIX_GROUP_NAME=oinstall                    # 安装组
INVENTORY_LOCATION=/opt/oraInventory    # INVENTORY目录(不填就是默认值)
SELECTED_LANGUAGES=en,zh_CN          # 选择语言
ORACLE_HOME=/opt/oracle/product/11.2.0/db_1    # oracle_home
ORACLE_BASE=/opt/oracle                        # oracle_base
oracle.install.db.InstallEdition=EE       # oracle版本
oracle.install.db.isCustomInstall=false    # 自定义安装,否,使用默认组件
oracle.install.db.DBA_GROUP=dba             # dba用户组
oracle.install.db.OPER_GROUP=oinstall       # oper用户组
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE   # 数据库类型
oracle.install.db.config.starterdb.globalDBName=orcl      # globalDBName
oracle.install.db.config.starterdb.SID=orcl             # SID
oracle.install.db.config.starterdb.memoryLimit=81920      # 自动管理内存的内存(M)
oracle.install.db.config.starterdb.password.ALL=oracle    # 设定所有数据库用户使用同一个密码
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false
DECLINE_SECURITY_UPDATES=true
/home/oracle/database/runInstaller  -silent -responseFile /home/oracle/database/response/db_install.rsp
su
/opt/oraInventory/orainstRoot.sh
/opt/oracle/product/11.2/db_1/root.sh

su - oracle

export DISPLAY=localhost:0.0
netca -silent -responseFile /home/database/response/netca.rsp
lsnrctl start
lsnrctl status
netstat -tnulp | grep 1521
su

vim /home/oracle/database/response/dbca.rsp

修改一下参数

GDBNAME = "orcl"
SID = "orcl"
# 密码,根据情况自己设置,也可以不设置,
SYSPASSWORD = "sys"
SYSTEMPASSWORD = "system"
SYSMANPASSWORD = "sysman"
DBSNMPPASSWORD = "dbsnmp"
DATAFILEDESTINATION =/opt/oracle/oradata
RECOVERYAREADESTINATION=/opt/oracle/fast_recovery_area
# 最好设置
CHARACTERSET = "AL32UTF8"
TOTALMEMORY = "4096"
su - oracle

dbca -silent -responseFile /home/database/response/dbca.rsp
 dbca -silent -deleteDatabase -sourcedb orcl
lsnrctl status      # 查看监听程序状态
lsnrctl start       # 启动监听程序
lsnrctl stop        # 停止监听程序
sqlplus / as sysdba      # 无口令登录,Oracle采用的是操作系统认证方式,当属于操作系统DBA组用户登陆到数据库服务器,那么Oracle认为这样的用户就可以授权以SYSDBA身份登录数据库 
startup                  # 启动实例
shutdown immediate       # 卸载实例
# 创建 test 表空间,大小为 1G(1024m)
CREATE TABLESPACE test DATAFILE '/home/oracle/data/test.ora' SIZE 1024m;

# 创建 test 用户,密码为 test,关联 test 表空间
CREATE USER test IDENTIFIED BY "test" DEFAULT TABLESPACE test QUOTA 1024m ON USERS;

# 给 test 用户授予权限
GRANT CONNECT,DBA,RESOURCE TO test;
上一篇 下一篇

猜你喜欢

热点阅读