一般设置
-
关闭防火墙
检查防火墙状态
systemctl status firewalld.service
暂时关闭防火墙,下次启动时防火墙仍随系统启动而启动
systemctl stop firewalld.service
彻底永久关闭防火墙
systemctl disable firewalld.service -
关闭SELINUX防火墙!
vi /etc/selinux/config
将内容SELINUX=enforcing更改为SELINUX=disabled -
将 ip地址和主机名添加到 : /etc/hosts
例如添加:
192.168.136.136 centos7-19c centos7-19c.localdomain
二 配置先决条件的yum源
- 挂载光盘镜像
注:在虚拟机挂载光盘镜像以后,务必使用某个用户进入到虚拟机LINUX下看到桌面弹出小光盘为止(图形界面)
mkdir /yums
cd /run/media/root/CentOS 7 x86_64/Packages
cp * /yums
cd /yums
CENTOS7(这个目前适用于CENTOS7.4以及以下版本,如果你使用的是高版本的话,请自己注意具体包的名称,实在不知道就用tab键补全)
rpm -ivh deltarpm-3.6-3.el7.x86_64.rpm
rpm -ivh python-deltarpm-3.6-3.el7.x86_64.rpm
rpm -ivh createrepo-0.9.9-28.el7.noarch.rpm
createrepo .
切换到yum的配置目录里
cd /etc/yum.repos.d/
删除所有系统默认的yum源配置文件
rm -rf *
建立本地yum源配置文件
vi yum.local.repo
[local]
name=yum local repo
baseurl=file:///yums
gpgcheck=0
enable=1
保存退出
yum clean all
测试一下
yum install gcc
如果有反应就说明你的yum服务器配置成功了
安装先决条件包:
yum install -y bc
yum install -y compat-libcap1*
yum install -y compat-libcap*
yum install -y binutils
yum install -y compat-libstdc++-33
yum install -y elfutils-libelf
yum install -y elfutils-libelf-devel
yum install -y gcc
yum install -y gcc-c++
yum install -y glibc-2.5
yum install -y glibc-common
yum install -y glibc-devel
yum install -y glibc-headers
yum install -y ksh libaio
yum install -y libaio-devel
yum install -y libgcc
yum install -y libstdc++
yum install -y libstdc++-devel
yum install -y make
yum install -y sysstat
yum install -y unixODBC
yum install -y unixODBC-devel
yum install -y binutils*
yum install -y compat-libstdc*
yum install -y elfutils-libelf*
yum install -y gcc*
yum install -y glibc*
yum install -y ksh*
yum install -y libaio*
yum install -y libgcc*
yum install -y libstdc*
yum install -y make*
yum install -y sysstat*
yum install -y libXp*
yum install -y glibc-kernheaders
yum install -y net-tools-*
yum install -y iscsi-initiator-utils
yum install -y udev
yum install -y xclock*
三 内核参数
vi /etc/sysctl.conf
kernel.shmmax = 277495689510912
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048586
fs.file-max = 6815744
kernel.shmall = 67747971072
net.ipv4.tcp_max_tw_buckets = 6000
net.ipv4.ip_local_port_range = 9000 65500
net.ipv4.tcp_tw_recycle = 0
net.ipv4.tcp_tw_reuse = 1
net.core.somaxconn = 262144
net.core.netdev_max_backlog = 262144
net.ipv4.tcp_max_orphans = 262144
net.ipv4.tcp_max_syn_backlog = 262144
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 1
net.ipv4.tcp_fin_timeout = 1
net.ipv4.tcp_keepalive_time = 30
net.ipv4.tcp_keepalive_probes = 6
net.ipv4.tcp_keepalive_intvl = 5
net.ipv4.tcp_timestamps = 0
fs.aio-max-nr = 1048576
net.ipv4.conf.all.rp_filter = 2
net.ipv4.conf.default.rp_filter = 2
生成系统参数
sysctl -p
四.添加下列参数到/etc/security/limits.conf
vim /etc/security/limits.conf
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft nproc 16384
oracle hard nproc 16384
oracle soft stack 10240
oracle hard stack 32768
oracle hard memlock 134217728
oracle soft memlock 134217728
grid soft nofile 1024
grid hard nofile 65536
grid soft nproc 16384
grid hard nproc 16384
grid soft stack 10240
grid hard stack 32768
grid hard memlock 134217728
grid soft memlock 134217728
五.添加下列条目到/etc/pam.d/login
vim /etc/pam.d/login
session required /lib/security/pam_limits.so
session required pam_limits.so
六.环境变量中添加下列语句
vim /etc/profile
if [ $USER = "oracle" ] || [ $USER = "grid" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
生成环境变量
source /etc/profile
七.创建文件目录和相应的用户
增加用户与组:
groupadd -g 601 oinstall
groupadd -g 602 dba
groupadd -g 603 oper
groupadd -g 604 backupdba
groupadd -g 605 dgdba
groupadd -g 606 kmdba
groupadd -g 607 asmdba
groupadd -g 608 asmoper
groupadd -g 609 asmadmin
useradd -u 601 -g oinstall -G asmadmin,asmdba,dba,asmoper grid
useradd -u 602 -g oinstall -G dba,backupdba,dgdba,kmdba,asmadmin,oper,asmdba oracle
我们用这种最安全的方法修改grid和oracle用户密码
passwd grid
passwd oracle
以root用户,创建Oracle Inventory 目录
mkdir -p /u01/app/oraInventory
chown -R grid:oinstall /u01/app/oraInventory
chmod -R 775 /u01/app/oraInventory
以root用户,创建GRID HOME目录
mkdir -p /u01/app/grid
mkdir -p /u01/app/19c/grid
chown -R grid:oinstall /u01/app/grid
chmod -R 775 /u01/app/grid
chown -R grid:oinstall /u01/app/19c
chmod -R 775 /u01/app/19c/
以root用户,创建Oracle Base目录
mkdir -p /u01/app/oracle
mkdir /u01/app/oracle/cfgtoollogs
chown -R oracle:oinstall /u01/app/oracle
chmod -R 775 /u01/app/oracle
以root用户,创建Oracle RDBMS Home目录
mkdir -p /u01/app/oracle/product/19c/db_1
chown -R oracle:oinstall /u01/app/oracle/product/19c/db_1
chmod -R 775 /u01/app/oracle/product/19c/db_1
--> 从这里开始做
八.GRID用户好ORACLE用户添加环境变量
su - grid
grid用户的环境变量如下:
vim ~/.bash_profile(千万不能沾入到文件中)
PS1="[whoami
@hostname
:"'$PWD]$'
export PS1
umask 022
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_SID=+ASM
export ORACLE_TERM=xterm;
export ORACLE_BASE=/u01/app/grid
export ORACLE_HOME=/u01/app/19c/grid
export NLS_LANG="AMERICAN_AMERICA.AL32UTF8"
export NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"
export TNS_ADMIN=$ORACLE_HOME/network/admin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export PATH=.:$PATH:$HOME/bin:$ORACLE_HOME/bin
export THREADS_FLAG=native
if [ $USER = "oracle" ] || [ $USER = "grid" ]; then
if [ $SHELL = "/bin/ksh" ];then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
umask 022
fi
alias sqlplus='rlwrap sqlplus'
alias asmcmd='rlwrap asmcmd'
alias rman='rlwrap rman'
生成环境变量
source ~/.bash_profile
su - oracle
oracle用户的环境变量如下:
vim ~/.bash_profile
PS1="[whoami
@hostname
:"'$PWD]$'
export PS1
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_HOSTNAME=oracle19c-asm (这个地方请填写你的主机名)
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/19c/db_1
export ORACLE_SID=orcl1
export NLS_LANG="AMERICAN_AMERICA.AL32UTF8"
export NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"
export TNS_ADMIN=$ORACLE_HOME/network/admin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export PATH=.:$PATH:$HOME/bin:$ORACLE_BASE/product/19c/db_1/bin:$ORACLE_HOME/bin
export THREADS_FLAG=native;export THREADS_FLAG
if [ $USER = "oracle" ] || [ $USER = "grid" ]; then
if [ $SHELL = "/bin/ksh" ];then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
umask 022
fi
alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'
生成环境变量
source ~/.bash_profile
关闭内存大页
Oracle官方建议关闭内存透明大页Transparent Huge Page
1 修改grub文件
cp /etc/default/grub /etc/default/grub.bak
vi /etc/default/grub
2 增加一行transparent_hugepage=never到尾部
GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet transparent_hugepage=never"
3 执行命令
grub2-mkconfig -o /boot/grub2/grub.cfg
4 不重启生效
echo never > /sys/kernel/mm/transparent_hugepage/enabled
5 查看是否禁用透明大页
cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]
grep AnonHugePages /proc/meminfo
AnonHugePages: 0 kB---------->>>返回值若是零代表关闭
建议重新启动。我试过了 好像不重启不行
挂载硬盘
关闭虚拟机,向虚拟机添加额外三块硬盘,分别是25G,30G,35G。
重新开启虚拟机。