配置初始化参数
1、下载Oracle安装包
如果本地有11g的安装包,则直接上传到/usr/local/src目录下。
2、创建Oracle用户及组
使用root用户登录到ssh远程窗口
[root@localhost ~]# su root
创建oinstall用户组
shell [root@localhost ~]# groupadd oinstall
创建dba用户组
shell [root@localhost ~]# groupadd dba
创建oracle用户并将用户加入到oinstall组和dba组中
shell [root@localhost ~]# useradd -g oinstall -g dba -m oracle
配置oracle用户的登录密码
shell [root@localhost ~]# passwd oracle
查看oracle用户的组权限
shell [root@localhost ~]# id oracle
3、创建Oracle存储目录
创建Oracle的安装目录以及数据存储目录。生产环境中,需要找一个磁盘空间比较大的目录。
创建安装oracle数据库的目录
shell [root@localhost ~]# mkdir -p /home/oracle
创建oracle产品清单目录
shell [root@localhost ~]# mkdir -p /home/oraInventory
oracle会将数据库的版本、注册等信息写入到此文件中。
创建oracle安装包的目录
shell [root@localhost ~]# mkdir -p /home/database
将这些目录及子目录授权给刚刚创建的oracle用户
shell [root@localhost home]# chown -R oracle:oinstall /home/oracle [root@localhost home]# chown -R oracle:oinstall /home/oraInventory [root@localhost home]# chown -R oracle:oinstall /home/database
4、修改OS系统标识
oracle默认是不支持CentOS系统的,我们需要将配置文件中的系统系统改为redhat才能够正常安装(因为CentOS就是redhat的下游发行版,现在上游发行版了)。
编辑redhat-7文件
shell [root@localhost home]# vim /etc/redhat-release redhat-7
5、安装依赖包
在外网环境(能够访问百度直接下载资源)中可以直接访问配置源中指定的链接下载,但是在内网环境(无法访问百度直接下载资源)中需要YUM源或者手动上传依赖包安装。 如果需要配置本地YUM源,可以参考:配置本地YUM源
安装oracle需要的依赖包
shell [root@localhost home]# yum install binutils* compat* gcc* glibc* ksh* libaio* libgcc* libstdc* libXi* libXtst* make* sysstat* elfutils*
6、开放firewalld端口和禁用selinux
如果你的环境能够关闭防火墙也可以直接关闭防火墙,我这里开放1521的端口。
检查firewalld防火墙的状态
shell [root@localhost home]# systemctl status firewalld.service
默认情况下是有启动的(active (running)),如果状态不是active (running),则firewalld防火墙异常。
永久开放firewalld的1521端口
shell [root@localhost home]# firewall-cmd --permanent --zone=public --add-port=1521/tcp
oracle的默认端口是1521,如果数据库的端口不是1521,则开放相应的端口。
重启firewalld
shell [root@localhost home]# systemctl restart firewalld
禁用selinux
shell [root@localhost home]# setenforce 0
此命令会立即禁用selinux,但服务器重启后还是会启用selinux。
禁止selinux开机启动
```shell [root@localhost home]# vim /etc/selinux/config
This file controls the state of SELinux on the system.
SELINUX= can take one of these three values:
enforcing - SELinux security policy is enforced.
permissive - SELinux prints warnings instead of enforcing.
disabled - No SELinux policy is loaded.
SELINUX=disabled
SELINUXTYPE= can take one of three two values:
targeted - Targeted processes are protected,
minimum - Modification of targeted policy. Only selected processes are protected.
mls - Multi Level Security protection.
SELINUXTYPE=targeted 将此处SELINUX=enforcing改为SELINUX=disabled,表示禁用selinux策略。 ```
7、配置内核参数
配置内核参数文件
shell [root@localhost home]# vim /etc/sysctl.conf net.ipv4.icmp_echo_ignore_broadcasts = 1 net.ipv4.conf.all.rp_filter = 1 fs.file-max = 6815744 fs.aio-max-nr = 1048576 kernel.shmall = 2097152 kernel.shmmax = 2147483648 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
配置介绍:
fs.file-max 最大打开文件数 kernel.shmall 共享内存的总量,8G内存设置:2097152*4k/1024/1024 kernel.shmmax 最大共享内存的段大小,一般设置为服务器的80%内存总大小 net.ipv4.ip_local_port_range 可使用的ipv4端口范围 其他参数有时间再去研究,这里暂时先写这几个重要的。如果你的服务器只运行单个实例(数据库),我这里给出一个大概的建议值参考:
shell 内存为12G kernel.shmall = 3145728 kernel.shmmax = 12884901887 内存为16G kernel.shmall = 4194304 kernel.shmmax = 17179869183 内存为32G kernel.shmall = 8388608 kernel.shmmax = 34359738367 内存为64G kernel.shmall = 16777216 kernel.shmmax = 68719476735
重加载参数文件
shell [root@localhost home]# sysctl -p
配置完参数别忘记重新加载一次文件,不然配置还是上一次的参数。
8、限制用户使用资源
编辑limits.conf文件
shell [root@localhost home]# vim /etc/security/limits.conf oracle soft nproc 2047 oracle hard nproc 16384 oracle soft nofile 1024 oracle hard nofile 65536
配置介绍:
shell oracle soft nproc 单个用户可用进程数软限制 oracle hard nproc 单个用户可用进程数硬限制 oracle soft nofile 打开文件描述符软限制 oracle hard nofile 打开文件描述符硬限制
9、配置用户环境变量
配置用户环境变量
```shell [root@localhost home]# vim /home/oracle/.bash_profile
export ORACLEBASE=/home/oracle export ORACLEHOME=/home/oracle/app/oracle/product/11.2.0/dbhome1 export ORACLESID=orcl export ORACLETERM=xterm export PATH=$ORACLEHOME/bin:/usr/sbin:$PATH export LDLIBRARYPATH=$ORACLEHOME/lib:/lib:/usr/lib export LANG=C export NLSLANG=AMERICAN_AMERICA.ZHS16GBK ```
配置介绍:
ORACLE_BASE 数据库基目录 ORACLE_HOME 数据库安装目录 ORACLE_SID 数据库SID ORACLE_TERM 窗口模式安装 PATH 系统环境变量 LD_LIBRARY_PATH 链接库环境变量 LANG 避免乱码 NLS_LANG 设置客户端的字符集 重加载环境变量
[root@localhost home]# source /home/oracle/.bash_profile
配置完参数别忘记重新加载,不然配置的环境变量不会生效