centos7.4下安装oracle12c
环境:openjdk version "1.8.0_161",centos7.4,oracle12c
1.安装所需要的依赖
yum install -y binutils.x86_64compat-libcap1.x86_64 gcc.x86_64 gcc-c++.x86_64 glibc.i686glibc.x86_64 \
glibc-devel.i686 glibc-devel.x86_64ksh compat-libstdc++-33 libaio.i686 libaio.x86_64 libaio-devel.i686libaio-devel.x86_64 \
libgcc.i686 libgcc.x86_64libstdc++.i686 libstdc++.x86_64 libstdc++-devel.i686 libstdc++-devel.x86_64libXi.i686 libXi.x86_64 \
libXtst.i686libXtst.x86_64 make.x86_64 sysstat.x86_64
2.添加用户和组
groupadd oinstall
groupadd dba
useradd -g oinstall -G dba oracle
passwd oracle
3.配置内核参数
vim /etc/sysctl.conf
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 900065500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048586
需要先查看这些系统参数对照。
sysctl -p
sysctl -a
vim /etc/security/limits.conf
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
4.安装gui环境
yumgroupinstall -y "X Window System"
yumgroupinstall -y "GNOME Desktop"
5.下载oracle12c
1.获取oracle12c
wget http://download.oracle.com/otn/linux/oracle12c/122010/linuxx64_12201_database.zip
2.解压oracle12c到/stage目录(目录可选)
unziplinuxx64_12201_database.zip -d /stage
3.为目录设置访问权限oinstall组的oracle用户才能访问
chown -Roracle:oinstall /stage/
4.创建安装目录,并设置权限
mkdir -p /u01 /u02
chown -R oracle:oinstall /u01 /u02
chmod -R 775 /u01 /u02
chmod g+s /u01 /u02
5.切换到oracle用户,运行安装程序
切换到oracle用户
ssh -X [email protected]
切换到database目录
cd /stage/database/
执行安装程序
./runInstaller
6.GUI安装流程
1.Configure Security Updates 下一步
2.Installation Option 选择create and configure a database 下一步
3.System Class 选择Desktop Class 下一步
4.Typical Installation
5.Create Inventory
库存目录: / u01 / app / oraInventory
oraInventory组名称:使用' oinstall '组
6.Prerequisite Check 有时检查stack会报错,改了还报错的话可以忽略
7.接下来进入漫长的安装时间
7.设置环境变量
vim /etc/profile
export ORACLE_BASE=/u01/app/oracle/
export ORACLE_SID=orcl
export ORACLE_HOME=/u01/app/oracle/product/12.2.0/dbhome_1/
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export PATH=$PATH:$HOME/BIN:$ORACLE_HOME/bin
source /etc/profile
8.访问数据库
sqlplus / as sysdba
9.设置远程访问
cd /u01/app/oracle/product/12.2.0/dbhome_1/network/admin
下面的修改的两个文件的ip 192.168.145.130 都必须要换成本机的ip
vim listener.ora
将文件修改成
# listener.ora Network Configuration File: /u01/app/oracle/product/12.2.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST =192.168.145.130 )(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
(SID_DESC =
(GLOBAL_DBNAME=orcl)
(ORACLE_HOME = /u01/app/oracle/product/12.2.0/dbhome_1/)
(SID_NAME = orcl)
)
~
vim tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/12.2.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
LISTENER_ORCL =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.145.130)(PORT = 1521))
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.145.130)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
接下来创建用户
su - oracle
sqlplus sys/oracle as sysdba;
create user c##test02 identified by test02;
grant connect,resource,create session to c##test02;
退出数据库管理员登陆刚才创建的用户
exit
sqlplus c##test02/[email protected]/orcl
语法:sqlplus 用户名/密码 as sysdba 作为管理员登陆;
语法:create user 用户名 identified by 密码; 用户名前面需要加上c##,这是oracle12c的新特性
语法:grant connect,resource,create session to c##test02;为当前的test02用户添加权限
语法:sqlplus c##test02/[email protected]/orcl;用户登录,12c版本需要加c##,@ip可以不加
这里使用windows7访问centos7.4系统
到http://www.oracle.com/technetwork/topics/winsoft-085727.html下载32bit的client,重点32bit,不然会报错
安装之后我的home目录是D:\Downloads\instantclient_12_2。
在该目录下创建文件夹network/admin,然后在admin下创建tnsnames.ora的文件
文件中添加
LISTENER_ORCL =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.145.130)(PORT = 1521))
CentosOracle =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.145.130)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
这里的ip 192.168.145.130需要更换成centos7的ip
在windows7上添加环境变量
添加一个环境变量,名为TNS_ADMIN,值为tnsnames.ora文件所在路径D:\Downloads\instantclient_12_2\network\admin,plsql通过这个找到orcl连接字符串
添加一个环境变量NLS_LANG = SIMPLIFIED CHINESE_CHINA.ZHS16GBK
打开PLSQL,不用登陆,工具-首选项-ORACLE-连接():
勾选检查连接
Oracle主目录: D:\Downloads\instantclient_12_2
OCI库:D:\Downloads\instantclient_12_2\oci.dll
此时回到centos7
su - oralce
lsnrctl stop #先关闭监听服务
lsnrctl start #开启监听服务
sqlplus / as sysdba #登入
startup #开启数据库服务
alter system register; #注册
quit #登出
lsnrctl status #查看监听状态
此时回到windows中打开PLSQL输入账号密码
随后登录就可以了