macOS搭建Oracle虚拟机环境
程序员文章站
2022-06-30 10:33:36
...
软件环境:CentOS7.2 + Oracle11.2.0.1.0 + VMware Fusion8.5 + macOS10.12.4
一、配置CentOS环境
1. 创建用户和用户组
$groupadd oinstall
$groupadd dba
$useradd -g oinstall -g dba -m oracle
$passwd oracle
$id oracle
2. 创建Oracle安装目录
$mkdir -p /data/oracle
$mkdir -p /data/oraInventory
$mkdir -p /data/database
$chown -R oracle:oinstall /data/oracle
$chown -R oracle:oinstall /data/oraInventory
$chown -R oracle:oinstall /data/database
3. 修改系统标识
$cat /proc/version
$cat /etc/redhat-release
*CentOS Linux release 7.2.1511 (Core)
$vi /etc/redhat-release
$cat /etc/redhat-release
*redhat-7
4. 安装组件依赖
$yum -y install binutils compat-libcap1 gcc gcc-c++ glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++ libXi libXtst make sysstat
5. 关闭防火墙
$systemctl status firewalld.service
$systemctl stop firewalld.service
$systemctl disable firewalld.service
6. 关闭SELinux
$vi /etc/selinux/config
$cat /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 #此处修改为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
7. 修改内核参数
$vi /etc/sysctl.conf
$cat /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
$sysctl -p
8. 对oracle用户进行限制
$vi /etc/security/limits.conf
$cat /etc/security/limits.conf
->添加如下配置:
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
9. 配置环境变量
$vi /home/oracle/.bash_profile
$cat /home/oracle/.bash_profile
->添加如下配置:
export ORACLE_BASE=/data/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export ORACLE_SID=orcl
export ORACLE_TERM=xterm
export PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
$source /home/oracle/.bash_profile
10. 准备安装文件
$cd /usr/local/src
$unzip linux.x64_11gR2_database_1of2.zip -d /data/database/
$unzip linux.x64_11gR2_database_2of2.zip -d /data/database/
$chown -R oracle:oinstall /data/database/database/
二、在CentOS上安装Oracle
1. 切换用户至oracle,执行runInstaller安装程序
$cd /data/database/database/
$./runInstaller -jreLoc /usr/lib/jvm/jre-1.8.0
2. 先决条件检查
安装程序会检查当前系统环境是否满足安装要求,如果相应的依赖包没有安装,yum install package_name安装上即可,如果已安装的版本较高时,Oracle安装程序仍会提示不满足要求,忽视即可
3. 调整SWAP分区
$su root
$free -m
$dd if=/dev/zero of=/home/swap bs=1024 count=1024000
$mkswap /home/swap
$swapon /home/swap
$free -m
4. 安装失败解决方案
安装过程中可能出现错误提示框未正确显示的问题,如果无法根据显示内容跟踪安装情况,可以通过检查安装日志的方法来继续进行,日志保存在/data/oraInventory/logs目录下。如果遇到安装失败的情况,重启虚拟机,先清理之前安装遗留的文件,再进行下一步操作
$su root
$rm -rf /data/oracle/product
$rm -rf /data/oraInvenroty/*
本文操作时遇到的两个情况记录如下:
ins_ctx.mk
INFO: Exception thrown from action: make
Exception Name: MakefileException
Exception String: Error in invoking target 'install' of makefile '/data/oracle/product/11.2.0/dbhome_1/ctx/lib/ins_ctx.mk'. See '/data/oraInventory/logs/installActions2017-05-11_02-20-57PM.log' for details.
- 缺少compat-libstdc++-33-3.2.3-69.el6导致此问题
- 官网手动下载组件对应的rpm包,**http://vault.centos.org/6.3/os/x86_64/Packages/**
- 将依赖包迁移至虚拟机Downloads目录下
- 手动安装rpm包
$pwd
#/home/oracle/Downloads
$ls
#compat-libstdc++-33-3.2.3-69.el6.i686.rpm
#compat-libstdc++-33-3.2.3-69.el6.x86_64.rpm
#glibc-2.12-1.80.el6.i686.rpm
#glibc-2.12-1.80.el6.x86_64.rpm
#glibc-common-2.12-1.80.el6.x86_64.rpm
#glibc-devel-2.12-1.80.el6.i686.rpm
#glibc-devel-2.12-1.80.el6.x86_64.rpm
#glibc-headers-2.12-1.80.el6.x86_64.rpm
$su root
$rpm -ivh --force --nodeps *.rpm
ins_emagent.mk
INFO: Exception thrown from action: make
Exception Name: MakefileException
Exception String: Error in invoking target 'agent nmhs' of makefile '/data/oracle/product/11.2.0/db_1/sysman/lib/ins_emagent.mk'. See '/data/oraInventory/logs/installActions2017-05-12_11-49-32AM.log' for details.
- 调用ins_emagent.mk文件发生错误
- 手动修改ins_emagent.mk文件,然后点击错误提示框的Retry按钮即可
$cat /data/oracle/product/11.2.0/db_1/sysman/lib/ins_emagent.mk
$vi /data/oracle/product/11.2.0/db_1/sysman/lib/ins_emagent.mk
#将$(MK_EMAGENT_NMECTL)修改为$(MK_EMAGENT_NMECTL) -lnnz11
5. 执行脚本
安装完毕后,安装程序出现Successful字样,关闭安装程序,执行两个脚本程序
$su root
$pwd
#/data/oracle/product/11.2.0/db_1
$./root.sh
$cd /data/oraInventory
$./orainstRoot.sh
6. 进行监听服务配置和数据库实例创建
$netca
$lsnrctl start
$lsnrctl status
$dbca
7. 检查是否安装完成
$sqlplus / as sysdba
$startup
$show parameter service_names
$su -oracle
$emctl unsecure dbconsole
#with https
$emctl secure dbconsole
$with http
$emctl start dbconsole
三、在macOS上配置Oracle客户端
Oracle服务端安装完成后,在macOS上可以使用SQLDeveloper/Toad/DataGrip进行连接,现在开始配置在macOS中使用终端+SQLPlus连接服务端Orale
$sqlplus
zsh: sqlplus: command not found...
1. 确定服务端Oracle版本
$sqlplus / as sysdba
SQL> select * from v$version
2 /
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
2. 客户端文件配置
下载macOS平台适用的对应版本的Oracle客户端,将两个压缩包解压至同一目录
$unzip instantclient-basic-macos.x64-11.2.0.4.0.zip
$unzip instantclient-sqlplus-macos.x64-11.2.0.4.0.zip
# Tuple @ Johnson in /Applications/instantclient_11_2 [11:36:19]
$ cd /Applications/instantclient_11_2
# Tuple @ Johnson in /Applications/instantclient_11_2 [11:36:24]
$ ls
BASIC_README libclntsh.dylib.11.1 libsqlplus.dylib uidrvci
SQLPLUS_README libnnz11.dylib libsqlplusic.dylib xstreams.jar
adrci libocci.dylib.11.1 ojdbc5.jar
genezi libociei.dylib ojdbc6.jar
glogin.sql libocijdbc11.dylib sqlplus
3.环境变量配置
$vim .bash_profile
->添加如下信息
export ORACLE_HOME=/Applications/instantclient_11_2
export ORACLE_SID=oracent
export DYLD_LIBRARY_PATH=$ORACLE_HOME
export SQLPATH=$ORACLE_HOME
export TNS_ADMIN=$ORACLE_HOME/network/admin
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
export NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"
export PATH=$SQLPATH:$PATH
$vim .zshrc
->添加一行
source .bash_profiile
$env
4.配置tnsnames.ora
$mkdir -p Applications/instantclient_11_2/network/admin
vim $ORACLE_HOME/network/admin/tnsnames.ora
->新增如下内容
oracent=
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.31.236)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = oracent)
)
)
5.配置hosts文件
$ hostname
#Johnson.local
$sudo vim /etc/hosts
->将localhost修改与hostname一致
$cat /etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 Johnson.local
6.使用SQLPlus连接局域网Oracle
$sqlplus scott/[email protected]/oracent
转载于:https://www.jianshu.com/p/a06fe0019a6b
上一篇: 原来牛油果泥保存的方法有这么多
下一篇: C#实现刷新桌面的方法
推荐阅读
-
macOS下Spring Boot开发环境搭建教程
-
macOS下Spring Boot开发环境搭建教程
-
oracle安装环境搭建以及PLSQLDeveloper使用的教程
-
Linux+php+apache+oracle环境搭建之CentOS下安装Oracle数据库
-
PHP+Oracle本地开发环境搭建方法详解
-
CentOS7 LNMP+phpmyadmin环境搭建 第一篇虚拟机及centos7安装
-
使用Docker快速搭建Oracle开发环境的方法教程
-
Linux+php+apache+oracle环境搭建之CentOS下源码编译安装PHP
-
Linux+php+apache+oracle环境搭建之CentOS下安装Apache
-
Oracle编程:idea调用Oracle数据库环境搭建、java调用存储函数及存储过程