-
Notifications
You must be signed in to change notification settings - Fork 2
Oracle
William Zhang edited this page Apr 21, 2017
·
1 revision
Oracle的版本都是可以下载并试用的(商用需要注意版权): https://www.oracle.com/downloads/index.html 。 假设下载的是Oracle 12c的Linux 64位版本,文件为:linuxamd64_12c_database_1of2.zip和linuxamd64_12c_database_2of2.zip。
$ unzip linuxamd64_12c_database_1of2.zip $ unzip linuxamd64_12c_database_2of2.zip $ cd database $ ./runInstaller
它会检查系统最小要求,例如:swap最少150MB,tmp最少多少,显示器分辨率。Swap检查失败可以忽略掉,要用GUI显示的话可以安装VNC。安装过程中需要以root身份执行两个shell脚本。安装过程几乎不需要选择什么东西。
安装后,修改~/.bash_profile:
ORACLE_SID=orcl export ORACLE_SID ORACLE_HOME=$HOME/app/zedware/product/12.1.0/dbhome_1 export ORACLE_HOME PATH=$ORACLE_HOME/bin:$PATH export PATH
安装后应该就可以直接使用sqlplus来访问了。
- 修改配置文件,确保主机名不是localhost
$ more ./product/12.1.0/dbhome_1/network/admin/listener.ora <snipped> LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = myhost)(PORT = 1521)) # HOST后面默认是主机名。默认主机名可能是localhost ) ) $ more ./product/12.1.0/dbhome_1/network/admin/tnsnames.ora <snipped> ORCL = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = myhost)(PORT = 1521)) # 同上。 (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl.localdomain) ) ) #END_SRC 2. 确认防火墙设置,例如iptables是否打开。 3. JDBC测试程序 import java.sql.*; import oracle.jdbc.pool.OracleDataSource; class test { public static void main (String args[]) throws SQLException { OracleDataSource ods = new OracleDataSource(); ods.setURL("jdbc:oracle:thin:system/[email protected]:1521:orcl"); Connection conn = ods.getConnection(); // Create Oracle DatabaseMetaData object DatabaseMetaData meta = conn.getMetaData(); // gets driver info: System.out.println("JDBC driver version is " + meta.getDriverVersion()); } }
$ rlwrap sqlplus / as sysdba SQL> alter user system identified by manager; SQL> alter user sys identified by manager; SQL> connect system/manager; $ lsnrctl status | grep -w Service Service "orcl.localdomain" has 1 instance(s). Service "orclXDB.localdomain" has 1 instance(s). Service "pdborcl.localdomain" has 1 instance(s). $ sqlplus system/manager@localhost/orcl.localdomain $ sqlplus sys/manager as sysdba@localhost/orcl.localdomain SQL> startup SQL> shutdown
$ lsnrctl [status|services|stop|start] 等命令 $ lsnrctl LSNRCTL for Linux: Version 12.1.0.1.0 - Production on 07-DEC-2015 14:37:50 Copyright (c) 1991, 2013, Oracle. All rights reserved. Welcome to LSNRCTL, type "help" for information. LSNRCTL> help The following operations are available An asterisk (*) denotes a modifier or extended command: start stop status services version reload save_config trace spawn quit exit set* show*
- VM设置的是NAT模式,host和VM都有一个192的地址,host可以ping通VM,也可以ssh到VM,但是telent就是连接不到1521端口。可能是Windows防火墙设置导致的(修改设置需要管理员权限)。
- VM改成Bridge模式,但是DHCP无法或的独立的IP地址。可能是办公网络有什么限制。
- 更多备注
- 安装过程中选择了忽略swap检查失败(开发机没有swap),桌面配置(企业配置估计要求高),所有目录都默认到安装到~/下(包括oradata)。
- 安装过程中需要指定admin的密码(实际用的与VM那个密码一样)。
- 安装过程中需要以root身份执行两个shell脚本。
- Global Database Name:orcl.sqa.bjb
- System Identifier(SID): orcl
- Enterprise Manager: localhost:5500/em
Created by Wenliang Zhang.