centos7上安装oracle10g
2019-08-25 本文已影响0人
技术永无止境
1.检查host文件:
cat /etc/hosts
#显示结果
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
2.基本配置
#设置内核参数
vi /etc/sysctl.conf
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65500
net.core.rmem_default = 4194304
net.core.wmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_max = 262144
#让设置立即生效
sysctl -p
#系统资源限制:
vi /etc/security/limits.conf
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
#使限制生效 文件中添加如下内容
vi /etc/pam.d/login
session required /lib/security/pam_limits.so
#编辑系统环境配置文件/etc/profile,在最后添加如下内容:
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
#编辑/etc/csh.login,在最后添加如下内容:
if ( $USER == "oracle") then
limit maxproc 16384
limit descriptors 65536
endif
4.安装基础软件
yum -y install autoconf automake binutils-devel bison cpp dos2unix ftp gcc gcc-c++ lrzsz python-devel
yum -y install compat-db compat-gcc-34 compat-gcc-34-c++ compat-libstdc++-33 glibc-* glibc-*.i686 libXpm-*.i686 libXp.so.6 libXt.so.6 libXtst.so.6 libgcc_s.so.1 ksh libXp libaio-devel numactl numactl-devel unixODBC unixODBC-devel
5.创建用户目录:
groupadd oinstall
groupadd dba
useradd -g oinstall -G dba oracle
passwd oracle
usermod -g oinstall -G dba oracle
mkdir -p /usr/local/soft/oracle
chown -R oracle:oinstall /usr/local/soft/oracle
chmod -R 775 /usr/local/soft/oracle
6.设置环境变量
#编辑/home/oracle/.bash_profile,在最后添加如下内容:
export ORACLE_BASE=/usr/local/soft/oracle
export ORACLE_HOME=/usr/local/soft/oracle/product/10.2.0/db_1
export ORACLE_SID=ORCL
export PATH=$PATH:$HOME/.local/bin:$HOME/bin:$ORACLE_HOME/bin
#使生效
source .bash_profile
7.安装
#安装文件上传并解压
gunzip 10201_database_linux_x86_64.cpio.gz
cpio -idmv < 10201_database_linux_x86_64.cpio
#修改配置让oracle适用于新版linux 在“Certified Versions”的项目中添加“redhat-6”
vim /usr/local/setup/oracle/database/install/oraparam.ini
[Certified Versions]
Linux=rethat-6,redhat-3,SuSE-9,redhat-4,UnitedLinux-1.0,asianux-1,asianux-2
#创建/etc/oraInst.loc文件,否则安装时会报错
vi /etc/oraInst.loc
inventory_loc=/usr/local/setup/oracle/oraInventory
inst_group=oinstall
chown oracle:oinstall /etc/oraInst.loc
chmod 775 /etc/oraInst.loc
#设置默认安装脚本,复制到服务器
/usr/local/setup/oracle/database/response/enterprise.rsp
/usr/local/setup/oracle/database/response/dbca.rsp
#修改安装目录权限
chown -R oracle:oinstall /usr/local/setup/oracle
chown -R oracle:oinstall /usr/local/soft/oracle
#静默安装
/usr/local/setup/oracle/database/runInstaller -silent -responseFile /usr/local/setup/oracle/database/response/enterprise.rsp
#如果是高级设置还需设置数据库
$ORACLE_HOME/bin/dbca -silent -responseFile /usr/local/setup/oracle/database/response/dbca.rsp
#以root用户运行安装后环境所需脚本
/usr/local/soft/oracle/oraInventory/orainstRoot.sh
/usr/local/soft/oracle/product/10.2.0/db_1/root.sh
8.第一次登录和启动
sqlplus /nolog
conn system/system as sysdba
select sysdate from dual;
#如果第一次查询报错:
ORA-27125: unable to create shared memory segment
Cause: shmget() call failed
Action: contact Oracle support
#如果第一次连接
ERROR:
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux-x86_64 Error: 2: No such file or directory
#解决办法:
[oracle@zzm-yun-pc ~]$ id oracle
uid=1000(oracle) gid=1000(oinstall) groups=1000(oinstall),1001(dba)
#下面用root执行下面的命令,将dba组添加到系统内核中:
echo 1001 > /proc/sys/vm/hugetlb_shm_group
#或永久添加到/etc/sysctl.conf
vi /etc/sysctl.conf
vm.hugetlb_shm_group = 1001
#执行启动oracle指令(startup)如果报错
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/usr/local/soft/oracle/product/10.2.0/db_1/dbs/initORCL.ora'
#复制文件
cd /usr/local/soft/oracle/product/10.2.0/db_1/dbs
cp init.ora initORCL.ora
#执行启动oracle指令(startup)如果报错
ORA-00371: not enough shared pool memory, should be atleast 123232153 bytes
#查询内存设置情况
select 'SGA' AS NAME,ROUND(sum(value)/1024/1024,2)||'M' AS "SIZE(M)" from v$sga
UNION
select 'PGA' AS NAME,ROUND(value/1024/1024,2)||'M' AS "SIZE(M)" from v$pgastat where name='total PGA allocated'
UNION
select 'TOTAL' AS NAME,((SELECT ROUND(sum(value)/1024/1024,2) from v$sga)+(select ROUND(value/1024/1024,2) from v$pgastat where name='total PGA allocated'))||'M' AS "SIZE(M)" FROM DUAL
UNION
SELECT NAME,TO_CHAR(VALUE) FROM V$PGASTAT WHERE NAME='process count';
9.阿里云安全策略开启1521端口,这样就可以就可以外网连接我们的oracle库做开发和测试了。