LINUX系统(CentOS7安装)四之Oracle的安装
ORcale的安装使用工具系统:CentOS7_64位(安装桌面形式便于操作)Oracle:虚拟机:Oracle VM VirtualBox文档编写工具:EditPlus连接Linux系统工具:Xshell5(推荐、但是慎用,收费软件)向日葵远程连接操作工具文件传输工具:FileZillaMysql连接工具:Navicat 12 for MySQL/SQLyog-64/Navi...
ORacle的安装
使用工具
- 系统:阿里云CentOS7服务器
- Oracle:11g
- 文档编写工具:EditPlus
- 连接Linux系统工具:Xshell5(推荐、但是慎用,收费软件)
- 文件传输工具:xftp
- Oracle连接工具:PLSQL
文件地址:
- oracle11g:https://pan.baidu.com/s/1An6VHanYS-6RwiWQ9OyuVw 提取码: woai
- plsql安装教程以及instantclient_12_1.zip:链接: https://pan.baidu.com/s/1ccdRozwXAs92-dPuB4TRdQ 提取码: java
- plsql安装包:链接: https://pan.baidu.com/s/1vk4zjqxe8LFXZUNYkzrvWg 提取码: plsq
- yum的rpm想对应文件:链接: https://pan.baidu.com/s/1oduZs4F91FBPujTq4JmREg 提取码: yum1
所需包如下(包顺序之间有依赖,建议按照顺序安装):
python-libs-2.7.5-58.el7.x86_64.rpm
python-2.7.5-58.el7.x86_64.rpm
python-iniparse-0.4-9.el7.noarch.rpm
python-pycurl-7.19.0-19.el7.x86_64.rpm
rpm-python-4.11.3-25.el7.x86_64.rpm
yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
yum-3.4.3-154.el7.centos.noarch.rpm
yum-plugin-fastestmirror-1.1.31-42.el7.noarch.rpm
上传文件
使用FileZilla将文件上传至/usr/local/下(可以自行更换上传位置)
1. 安装起步依赖
安装依赖
yum -y install binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel expat gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers libaio libaio-devel libgcc libstdc++ libstdc++-devel make pdksh sysstat unixODBC unixODBC-devel
安装完成后,显示以下画面
使用如下命令检查依赖是否安装完整
rpm -q binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel expat gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers libaio libaio-devel libgcc libstdc++ libstdc++-devel make pdksh sysstat unixODBC unixODBC-devel | grep "not installed"
这里会发现只有pdksh没有安装,由于centos7不包含所以需要根据链接下载
wget -O /tmp/pdksh-5.2.14-37.el5_8.1.x86_64.rpm http://vault.centos.org/5.11/os/x86_64/CentOS/pdksh-5.2.14-37.el5_8.1.x86_64.rpm
这快我现在到tmp中,进入tmprpm -ivh pdksh-5.2.14-37.el5_8.1.x86_64.rpm
执行命令添加rpm
再次使用命令检查完整性
2. 添加oracle用户组和用户
groupadd oinstall
groupadd dba
groupadd asmadmin
groupadd asmdba
useradd -g oinstall -G dba,asmdba oracle -d /home/oracle
添加完成后,查看oracle用户
id oracle
初始化oracle用户的密码
passwd oracle
3. 配置hostname(本机IP映射)
vim /etc/hosts
192.168.154.154 centos-orcl(不要改变后面配置监听时需用到,不然监听配不成功)
测试hostname
ping -c 3 centos-orcl
4. 优化OS内核参数
kernel.shmmax 参数设置为物理内存的一半
vim /etc/sysctl.conf
fs.aio-max-nr=1048576
fs.file-max=6815744
kernel.shmall=2097152
kernel.shmmni=4096
kernel.shmmax = 1073741824
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
使参数生效
sysctl -p
5. 限制oracle用户的shell权限
vim /etc/security/limits.conf
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
vim /etc/pam.d/login
session required /lib64/security/pam_limits.so
session required pam_limits.so
vim /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
6. 创建oracle安装目录
mkdir -p /usr/local/oracle/product/11.2.0
mkdir /usr/local/oracle/oradata
mkdir /usr/local/oracle/inventory
mkdir /usr/local/oracle/fast_recovery_area
chown -R oracle:oinstall /usr/local/oracle
chmod -R 775 /usr/local/oracle
7. 配置oracle用户环境变量
su - oracle
vim .bash_profile
umask 022
export ORACLE_HOSTNAME=centos-orcl
export ORACLE_BASE=/usr/local/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/
export ORACLE_SID=ORCL
export PATH=.:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$ORACLE_HOME/jdk/bin:$PATH
export LC_ALL="en_US"
export LANG="en_US"
export NLS_LANG="AMERICAN_AMERICA.ZHS16GBK"
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"
以上配置完成后,个人建议重启下系统
reboot
8. 解压文件
解压oracle压缩文件到 /db
cd /usr/local/
unzip linux.x64_11gR2_database_1of2.zip -d /usr/local
unzip linux.x64_11gR2_database_2of2.zip -d /usr/local
解压完成后
mkdir /usr/local/etc/
cp /usr/local/database/response/* /usr/local/etc/
修改数据
vim /usr/local/etc/db_install.rsp
oracle.install.option=INSTALL_DB_SWONLY
DECLINE_SECURITY_UPDATES=true
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/usr/local/oracle/inventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOSTNAME=centos-oracle
ORACLE_HOME=/usr/local/oracle/product/11.2.0
ORACLE_BASE=//usr/local/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.isCustomInstall=true
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=dba
9. 开始安装
su - oracle
cd /usr/local/database
可以看见database文件夹下有三个模板其中dbca.rsp是用来创建数据库的。db_install.rsp是用来安装Oracle软件的。netca.rsp是用来创建监听器的
./runInstaller -silent -ignorePrereq -responseFile /usr/local/etc/db_install.rsp
安装期间可以使用tail命令监看oracle的安装日志(可以不用看,不过我这里推荐看下)
tail -f /usr/local/oracle/inventory/logs/installActions2017-07-12_03-48-29PM.log
安装完成
su root
sh /usr/local/oracle/inventory/orainstRoot.sh
sh /usr/local/oracle/product/11.2.0/root.sh
10. 配置静默监听
su - oracle
netca /silent /responsefile /usr/local/etc/netca.rsp
出现错误未启动成功
解决方案:
oracle/product/10.2.0/db_1/NETWORK/ADMIN下打开listener.ora文件后将HOST后的主机名
(ADDRESS = (PROTOCOL = TCP)(HOST = SUZSOFT-8CB5627)(PORT = 1521))
改成IP即可解决上面遇到问题 (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.7.115)(PORT = 1521))
查看监听端口
netstat -tnulp | grep 1521(监听配置成功)
11. 静默创建数据库
TOTALMEMORY 设置为总内存的80%
vi /usr/local/etc/dbca.rsp
GDBNAME = "orcl"
SID = "orcl"
SYSPASSWORD = "oracle"
SYSTEMPASSWORD = "oracle"
SYSMANPASSWORD = "oracle"
DBSNMPPASSWORD = "oracle"
DATAFILEDESTINATION =/usr/local/oracle/oradata
RECOVERYAREADESTINATION=/usr/local/oracle/fast_recovery_area
CHARACTERSET = "AL32UTF8"
TOTALMEMORY = "1638"
执行静默建库
dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbName test -sysPassword oracle -systemPassword oracle
执行出现-bash: dbca: command not found
解决方案:
source .bash_profile
dbca
查看oracle实例进程
ps -ef | grep ora_ | grep -v grep
查看监听状态
lsnrctl status
报错:The listener supports no services
解决方案:修改/usr/local/oracle/product/11.2.0/network/admin/listener.ora
在LISTENER里添加内容:
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
#BEQUEATH CONFIG
(GLOBAL_DBNAME=orcl)
(SID_NAME=orcl)
(ORACLE_HOME=/u01/app/oracle/product/11.2)
#PRESPAWN CONFIG
(PRESPAWN_MAX=20)
(PRESPAWN_LIST=
(PRESPAWN_DESC=(PROTOCOL=tcp)(POOL_SIZE=2)(TIMEOUT=1))
)
)
)
重启监听器,问题解决。
http://blog.csdn.net/snowfoxmonitor/article/details/47705885
12. 登录sqlplus,查看实例状态
ORA-01081: 无法启动已在运行的 ORACLE - 请首先关闭它
SQL> startup nomount
sql>shutdown immediate关闭再进行
sql>startup nomount重新开启就可以了
sqlplus / as sysdba
select status from v$instance;
报错:ORA-01034: ORACLE not available
解决方案:startup
报错:ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/usr/local/oracle/product/11.2.0/dbs/initORCL.ora'
解决方案:将/usr/local/oracle/admin/test/pfile/init.ora.1014201721194修改名称放到/usr/local/oracle/product/11.2.0/dbs/initORCL.ora
再次startup命令解决
Linux下Oracle11gR2的ORA-00845错误解决方法:http://www.ha97.com/5175.html
查看数据库编码
select userenv('language') from dual;
查看数据库版本信息
select * from v$version;
激活scott用户
alter user scott account unlock;
alter user scott identified by tiger;
select username,account_status from all_users;
13.设置Oracle开机启动
vi /usr/local/oracle/product/11.2.0/bin/dbstart
ORACLE_HOME_LISTNER=$ORACLE_HOME
vi /usr/local/oracle/product/11.2.0/bin/dbshut
ORACLE_HOME_LISTNER=$ORACLE_HOME
vi /etc/oratab
orcl:/usr/local/oracle/product/11.2.0:Y
vi /etc/rc.d/init.d/oracle
#! /bin/bash
# oracle: Start/Stop Oracle Database 11g R2
#
# chkconfig: 345 90 10
# description: The Oracle Database is an Object-Relational Database Management System.
#
# processname: oracle
. /etc/rc.d/init.d/functions
LOCKFILE=/var/lock/subsys/oracle
ORACLE_HOME=/db/app/oracle/product/11.2.0
ORACLE_USER=oracle
case "$1" in
'start')
if [ -f $LOCKFILE ]; then
echo $0 already running.
exit 1
fi
echo -n $"Starting Oracle Database:"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl start"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/emctl start dbconsole"
touch $LOCKFILE
;;
'stop')
if [ ! -f $LOCKFILE ]; then
echo $0 already stopping.
exit 1
fi
echo -n $"Stopping Oracle Database:"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl stop"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbshut"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/emctl stop dbconsole"
rm -f $LOCKFILE
;;
'restart')
$0 stop
$0 start
;;
'status')
if [ -f $LOCKFILE ]; then
echo $0 started.
else
echo $0 stopped.
fi
;;
*)
echo "Usage: $0 [start|stop|status]"
exit 1
esac
exit 0
开机启动oracle
systemctl enable oracle
开机启动问题
oracle ORA-12547: TNS:lost contact
cd /usr/local/oracle/product/11.2.0/bin/
chmod 6751 oracle
TNS-12555: TNS:permission denied
cd /var/tmp
chown -R oracle:oinstall .oracle
oracle.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig oracle on
cd /etc/init.d
cat oracle
#!/bin/bash
# chkconfig: 345 90 10
# description: The Oracle Database is an Object-Relational Database Management System.
有(# chkconfig:和# description: )这两个选项说明文件是正确的
再看oracle文件权限问题
修改权限chmod +x /etc/init.d/oracle
更多推荐
所有评论(0)