The painful summary of Oracle11g For Win7 installation process

Since entering the industry, one of the most feared is Oracle. . It was installed silently on Linux some time ago, and now it is installed on Windows, and the process is also full of hardships. . The whole person has been tortured countless times and is on the verge of collapse. I think it is a lucky thing to be able to successfully install it. Well, let's start recording some things. Maybe you can refer to it later!

 

=============================== The above is the dividing line for complaints =============== =====================

 

1. Start with completely uninstalling Oracle

The reason why I say it first is because I have repeated it 10+ times. . Completely uninstall oracle to try the installation again to have a chance of success.

1) Computer->Management->Services and Applications->Services: Stop all Oracle-related services;

2) In Start->Programs, find the Universal Installer to uninstall all components except dbhome_1 (and maybe dbhome_2/dbhome_3);

3) Find the directory where dbhome_1 is located and delete it;

4) Registry delete

Delete the HKEY_LOCAL_MACHINE/SOFTWARE/ORACLE directory.

Delete all keys starting with oracle or OraWeb in HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services.

Delete all keys starting with oracle in HKEY_LOCAL_MACHINE/SYSETM/CurrentControlSet/Services/Eventlog/application.

Delete all keys starting with oracle or OraWeb in HKEY_LOCAL_MACHINE/SYSTEM/ControlSet001/Services.

Delete all keys starting with oracle in HKEY_LOCAL_MACHINE/SYSETM/ControlSet001/Services/Eventlog/application.

Delete all keys starting with oracle or OraWeb in HKEY_LOCAL_MACHINE/SYSTEM/ControlSet002/Services.

Delete all keys starting with oracle in HKEY_LOCAL_MACHINE/SYSETM/ControlSet002/Services/Eventlog/application.

Delete all keys prefixed with Ora, Oracle, Orcl or EnumOra in the HKEY_CLASSES_ROOT directory.

Delete all keys starting with oracle in HKEY_CURRENT_USER/SOFTWARE/Microsoft/windows/CurrentVersion/Explorer/MenuOrder/Start Menu/Programs.

Delete all Oracle-containing keys in HKDY_LOCAL_MACHINE/SOFTWARE/ODBC/ODBCINST.INI except the Microsoft ODBC for Oracle registry key.

5) Delete all Oracle related directories

c:\Program file\Oracle directory, ORACLE_HOME directory, c:\Documents and Settings\system username, C:\Users\xxxx\Oracle (xxxx is the username), C:\Windows\System32\config\systemprofile\Oracle

6) Start -> all oracle-related shortcuts in the program

 

Make sure to delete all of the above and restart your computer.

 

2. Install Oracle

2.1 安装Oracle Database

1) The first thing to note is that the decompression package is as follows:



 Please select these two compressed packages at the same time and then decompress them. If you only select one to decompress and then decompress the other to the same directory, it will be easy to cause confusion in the directory.

2) Please run the decompressed setup.exe "as an administrator". From experience, it will be killed by various permission problems. .

3)步骤2的安装选项最好是「仅安装数据库软件」,这样可以把Oracle Database配置工作与安装过程解耦。这样做是因为在Oracle Database配置工作时很容易出错,如果你忽略或中止,整个安装过程没有成功完成就会退出,下次你再安装又会创建一个dbhome,造成紊乱;

4)步骤3选择「单实例数据库安装」,步骤6的安装目录可以自己指定,但基目录后面的目录结构最好不要修改。字符什么的最好用默认的即可~

5)安装完成Oracle数据库产品后,我们就开始着手数据库实例的安装与配置工作。

 

2.2 数据库实例安装与配置

6)开始->程序->Oracle->配置和移植工具:选择Database Configuration Assistant(最好以管理员身份运行,否则安装过程可能会提示:insufficient privilege权限不足)开始实例安装工作。

7)安装过程到Oracle Database Configuration Assistant时可能会出现如下错:



 

解决办法:开始->程序->Oracle->配置和移植工具:选择Net Manager->本地->概要文件->Oracle安全特性->所选方法中去掉NTS

等待安装过程完成即可。安装后的「口令管理」千万别忘了,解锁被锁的所有用户并为sys和system用户设置你自己的密码~

(PS:安装成功真的要靠运气……)

 

3、使用PL/SQL Developer

好了,如果足够幸运成功安装Oracle,那么我接下来使用PL/SQL developer(以下简称PL/SQL)又是一顿折腾。

PL/SQL的使用要特别注意位数(bite)的概念,如果你的PL/SQL是32位的话,是无法加载64位的oci.dll的。

要注意以下概念:

“如果我plsql是32位的,说明它无法支持64位的oci.dll所以我就需要“曲线救国”,手动再安装一个32位的客户端供32位的plsql连接(32位的instant_client或win32_11gR2_client.zip),这时候我本地就相当于安装了2个oracle客户端,一个32位一个64位”

——你在安装oracle的时候客户端也一并安装的,但由于我安装的是64位的,如果PL/SQL不是64位的就麻烦了。。正确安装位数对应的PL/SQL很重要!!!

 

正确安装好位数对应的PL/SQL后,不要登录,先配置:



 

这样,你在tnsnames.ora里面配置的数据库别名就可以直接被使用了。如:

E:\app\xxxxxx\product\11.2.0\dbhome_1\NETWORK\ADMIN\tnsnames.ora:

 

#ORCL为数据库别名
ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )

 这样,你在登录PL/SQL时,Database那一项就会有你已经配置好的数据库别名选项,而无需你自己输入IP和端口之类的参数了。

 

 

4、创建表空间和用户

创建表空间是需要最高权限的,一般是sys用户,我们先在dos里面登入:



 注意。sqlplus可能碰上中文乱码问题,别忘了设置环境变量:



 或者用PL/SQL登录,只不过Connect as选择SYSDBA罢了。

 

1)表空间和用户、表的关系:

一个表只能属于一个表空间。一个用户可以拥有多个表空间。 一个表空间可以有多个表。

一般情况下,一个用户对应一个表空间。

表空间分为:临时表空间和永久表空间。我们可以命名不同的永久表空间,把功能相似的表放在同一个表空间下。表空间相当于一个“盛放表的容器”。

所以有这种语法:create(select) table 用户名.表名……

2)创建表空间、用户的步骤如下:

/*创建临时表空间 ,可以不做*/

create temporary tablespace 临时表空间名(如:soacloud_temp)

tempfile 'E:\oracle\oradata\XE\临时表空间名.dbf'

size 50m

autoextend on

next 50m maxsize 20480m

extent management local;

 

/*创建数据表空间(dbf文件由你自己指定,无需事先创建,运行该语句后会自动生成) */

create tablespace 表空间名 logging

datafile 'F:\app\oracle\oradata\orcl\pdborcl3\表空间名.dbf'

size 300m

autoextend on

next 100m maxsize 20480m

extent management local;

 

/*创建用户并指定表空间 */

create user 用户名  identified by 密码

default tablespace 表空间名

temporary tablespace 临时表空间名;

 

 

/*第4步:给用户授予权限 */

grant connect,resource,dba to 用户名; (dab权限慎给)

 

3)sys用户和system用户

system是数据库内置的一个普通管理员,你手工创建的任何用户在被授予dba角色后都跟这个用户差不多。

 

sys用数据库的超级用户,数据库内很多重要的东西(数据字典表、内置包、静态数据字典视图等)都属于这个用户,sys用户必须以sysdba身份登录。

查看所有的用户:select username from dba_users; 

 

5、service_name和sid

service_name:是这个数据库对外宣称的名字,外面的人要想连接我这个数据库,你就在客户端的连接串里写上service_name;

sid:一个数据库可以有多个实例(如RAC),SID是用来标识这个数据库内部每个实例的名字

 

windows环境查看oracle的sid和services_name

1)查看sid:  

方法一:打开注册表(win+R输入regedit)->HKEY_LOCAL_MACHINE->SOFTWARE->ORACLE->KEY_OraDb11g_home1->ORACLE_SID

方法二:sys用户登录,运行sql语句select instance_name from v$instance;

2)查看某数据库的service_name:

方法一:E:\app\用户名\product\11.2.0\dbhome_1\NETWORK\tnsnames.ora里面的指定数据库的SERVICE_NAME对应的内容

方法二:sys用户登录,运行sql语句

show parameter service_names

所以一个数据库对应一个service_name,多个数据库实例。

一般情况下,一个数据库对应一个实例。windows下可以通过DBCA(Database Configuration Assistant工具)来创建一个instance实例。

 

jdbc的url用service_name和sid连接的不同方式

jdbc:oracle:thin:@<host>:<port>:<SID>

jdbc:oracle:thin:@//<host>:<port>/<service_name> 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326719536&siteId=291194637