1-2 Oracle12c单实例部署
最后更新于:2022-04-02 07:44:34
### 注意事项
- swap分区需要16GB以上
- 需要配置hosts文件
- Centos 6.8 x86_64
#### YUM源配置
```shell
#clean OS default repo
mkdir /etc/yum.repos.d/old && mv /etc/yum.repos.d/C* /etc/yum.repos.d/old/
yum clean all
#add extend repo
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
```
#### 创建组并指定用户所属组
```shell
groupadd oinstall
groupadd dba
useradd -g oinstall -G dba oracle
```
#### 创建目录
```shell
mkdir -p /app/oracle12c
```
#### 修改数据库权限
```shell
chown -R oracle.oinstall /app/
```
#### 内核参数初始化
在/etc/sysctl.conf末尾增加以下内容
```shell
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 4195045376
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 = 1048586
```
#### 文件描述符修改
在/etc/security/limits.conf末尾增加
```shell
oracle soft nofile 65536
oracle hard nofile 65536
oracle soft nproc 16384
oracle hard nproc 16384
```
#### 切换oracle用户,配置环境变量
```shell
su - oracle
vim ~/.bash_profile
```
文件末尾追加,注意修改实例名称和位置
```shell
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR
ORACLE_BASE=/app/oracle12c; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/12.1.0/db_1; export ORACLE_HOME
ORACLE_SID=dingdb; export ORACLE_SID
NLS_LANG=American_America.zhs16gbk; export NLS_LANG
ORA_NLS10=$ORACLE_HOME/nls/data; export ORA_NLS10
TNS_ADMIN=$ORACLE_HOME/network/admin; export TNS_ADMIN
ORACLE_TERM=xterm; export ORACLE_TERM
PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
SHLIB_PATH=$LD_LIBRARY_PATH; export SHLIB_PATH
CLASSPATH=$ORACLE_HOME/jre:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH
```
#### 增加hosts
```shell
echo "192.168.2.20 odb01.prod.ding" >> /etc/hosts
```
#### 上传程序文件,并解压
```shell
cd /opt
unzip linuxamd64_12102_database_1of2.zip
unzip linuxamd64_12102_database_2of2.zip
cd /opt/database
```
#### 安装必要软件
```shell
yum install binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ glibc glibc-devel ksh libgcc libstdc++ libstdc++-devel libaio libXext libX11 libXau libxcb libXi make sysstat libaio-devel -y
```
#### 切换到图形界面
root用户执行,或sudo执行
```shell
xhost +
```
#### netca
选择"Listen Configuration"然后一直下一步
完成后查看 1521端口是否启动
#### dbca
> 数据库字符集(database character set):
American_America.ZHS16GBK;
**第9步时,自定义字符集。
我们开发一般选择:ZHS16GBK
**
### 启动Oracle EM(Web管理)
```
su - oracle
/app/oracle11g/product/11.2.0/dbhome_1/bin/emctl start dbconsole
```
### 注意!!!
### 关闭deferred_segment_creation特性,否则空表无法导出
```sql
alter system set deferred_segment_creation=false
```
#### 监听的启动和停止
```shell
su - oracle
启动
/app/oracle12c/product/12.1.0/db_1/bin/lsnrctl start
停止
/app/oracle12c/product/12.1.0/db_1/bin/lsnrctl stop
```
#### 数据库的启动和停止
```shell
命令行登录
sqlplus / as sysdba
启动
startup
停止
shutdown immediate
```
';