在开始之前,先介绍下Oracle Application Express(APEX)。
Oracle Application Express—APEX for short, or by its former name HTML DB — is a declarative, Web-based
RAD (Rapid Application development) tool. It is used to develop native Web-based, data
centric applications. It
requires no software to install on the client.
自2004年开始,Oracle已经开始这一款产品的开发,现在已升级到5.0。细心的人估计以前注意到,Oracle11g中自带了APEX开头的账户,它们是APEX内置schema, 并且已经绑定到Oracle安装中。也就是说,在你买了Oracle数据库情况下,不要额外的License,就可以放心使用APEX。
出了免费外,它的优势很明显,
1,一切基于web, 架构在Oracle 数据库上, 独立于软硬件环境
2,快速开发,极大缩短开发周期,支持html,css, javascript
2,相比OBIEE,SAPBO这样重量级BI报表工具,它更加灵活,可以作为轻量级的BI解决方案
至于我为甚用APEX,一句话领导不给力,不想买主流的 还让我们自己找免费的开发工具做报表,还要专业。擦,想让马儿跑,还不给喂草><||
还好,在以前的公司,接触过着APEX,当时还是版本3。虽然当时只是略懂皮毛,这回在选工具方面给了极大的帮助。 接下来,几个月,开始了死磕APEX的苦逼日子。
说了那么多废话,开始干正事,准备安装!
1,建立数据库环境, 创建两个表空间, 用于安装APEX, 以便日后的管理。
CREATE TABLESPACE APEX datafile‘/u01/app/oracle/oradata/APEX/apex.dbf’
SIZE 500M
EXTENT MANAGEMENT LOCAL
SEGMENT SPACE MANAGEMENT AUTO;
CREATE TABLESPACE APEX_FILES datafile‘/u01/app/oracle/oradata/APEX/apex_files.dbf’
SIZE 500M
EXTENT MANAGEMENT LOCAL
SEGMENT SPACE MANAGEMENT AUTO;
2,下载解压APEX 安装包, 具体下载地址
http://www.oracle.com/technetwork/developer-tools/apex/overview/index.html
3, 解压完后, 切换到解压后的目录,并以sys登陆数据库。 这一步目录切换很重要,在APEX安装过程中, 路径用的是相对路径,如果开始没切换目录的话, 过程中, 会报文件找不到的错误
4, 安装APEX, 命令如下
Full development environment. Run apexins.sql passingthe following four arguments in the order shown:
@apexins.sqltablespace_apex
tablespace_files tablespace_tempimages
Where:
- tablespace_apex is the name of
the tablespace for the Oracle Application Express application user.
- tablespace_files is the name of
the tablespace for the Oracle Application Express files user. - tablespace_temp is the name of
the temporary tablespace or tablespace group. - images is the virtual directory
for Oracle Application Express images. To support future Oracle Application Express upgrades, define the virtual image directory as /i/.
我采用的是开发环境的安装, 当然,在产品环境,可以选择Runtime environment 模式安装, sql 脚本换成 @apxrtins.sql
之前创建的两个表空间将tablespace_apex, tablespace_files 替换如下:
@apexins.sqlAPEX APEX_FILES TEMP /i/
这一步会花一段时间安装完如果一切安装顺利的话, 就会出现和截图一样
当安装完后, 一下三个schema 会被创建,有空的话,可以查看验证下
■ APEX_050000 - The account that owns the Oracle Application Express schema and
metadata.
■ FLOWS_FILES - The account that owns the Oracle Application Express uploaded
files.
■ APEX_PUBLIC_USER - The minimally privileged account is used for Oracle
Application Express configuration with Oracle REST Data Services or Oracle
HTTP Server and mod_plsql.
5, 运行apxchpwd.sql, 它的作用如下, 就是设置APEX的超级管理员。 运行完后, 重启数据库。
Running the apxchpwd.sql script enables your to create or update your Instance
Administrator account. You must run the apxchpwd.sql script in the following
scenarios:
■ New Oracle Application Express installations - Run apxchpwd.sql to create an
Instance Administrator account and password.
■ Converting of a runtime environment to a development environment - Run
apxchpwd.sql to change the Instance Administrator account password.
■ Changing Your Instance Administrator Password -Run apxchpwd.sql to change
the password for an existing Instance Administrator account.
■ Unlocking Your Instance Administrator Account - Run apxchpwd.sql to unlock
an existing Instance Administrator account.
6, 设置APEX_PUBLIC_USER, 为了下面配置ORDS 用
解锁
SQL>ALTER USER APEX_PUBLIC_USER ACCOUNT UNLOCK
重置密码
SQL>alter user apex_public_user identified by apex_public_user
7, 安装配置Oracle Rest Data Services(ORDS)
下载地址:http://www.oracle.com/technetwork/developer-tools/rest-data-services/downloads/
index.html
下载完后, 解压指定好的安装目录。 解压完后, 你可以发现ORDS这个就是个war包
7.1 Disabling Oracle XML DB Protocol Server
SQL>EXEC DBMS_XDB.SETHTTPPORT(0);
SQL>
7.2 configure RESTful Services in Oracle Application Express
SQL>@apex_rest_config.sql
When configuring RESTful Services in OracleApplication Express, it creates two
new database accounts.
■ APEX_LISTENER - The account used to query RESTfulServices definitions
stored in Oracle Application Express.
■ APEX_REST_PUBLIC_USER - The account used whencalling RESTful Services
definitions stored in Oracle Application Express.
SQL>@apex_rest_config.sql
Entera password for the APEX_LISTENER user []
Entera password for the APEX_REST_PUBLIC_USER user []
...createAPEX_LISTENER user
...createAPEX_REST_PUBLIC_USER user
SQL>
SQL>
7.3 Granting Connect Privileges, 这一步是赋连接的权限给web 主机, 使它能能够与ORDS进行连接
SQL>
SQL>DECLARE
2 ACL_PATH VARCHAR2(4000);
3 BEGIN
4 --Look for the ACL currently assigned to ‘*‘ and give APEX_050000
5 --the "connect" privilege if APEX_050000 does not have the privilegeyet.
6 SELECT ACL INTO ACL_PATH FROM DBA_NETWORK_ACLS
7 WHERE HOST = ‘*‘ AND LOWER_PORT IS NULL AND UPPER_PORT IS NULL;
8 IFDBMS_NETWORK_ACL_ADMIN.CHECK_PRIVILEGE(ACL_PATH, ‘APEX_050000‘,
9 ‘connect‘) IS NULL THEN
10 DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE(ACL_PATH,
11 ‘APEX_050000‘, TRUE, ‘connect‘);
12 ENDIF;
13 EXCEPTION
14 --When no ACL has been assigned to ‘*‘.
15 WHENNO_DATA_FOUND THEN
16 DBMS_NETWORK_ACL_ADMIN.CREATE_ACL(‘power_users.xml‘,
17 ‘ACLthat lets power users to connect to everywhere‘,
18 ‘APEX_050000‘, TRUE, ‘connect‘);
19 DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL(‘power_users.xml‘,‘*‘);
20 END;
21 /
COMMIT;
SQL>SQL>
7.3 Configuring Oracle Application Express Images
Copy the contents ofthe <apex directory>/images folder to <Tomcatdirectory>/webapps/i/.
Where:
–<apexdirectory> is the directory location of the Oracle Application Expressdistribution.
–<Tomcatdirectory> is the folder where Apache Tomcat is installed.
7.4 Configuring Oracle REST Data Services
a, copyords.war from ordspackage to tomcat webapps directory.
b, configure REST DATA Services
cd ../<tomcatdirecotory>/webapps
drwxrwxrwx 14 oracleoinstall 4096 Mar 27 14:04 docs
drwxrwxrwx 7 oracle oinstall 4096 Mar 27 14:04 examples
drwxrwxrwx 5 oracle oinstall 4096 Mar 27 14:04 host-manager
drwxrwxrwx 33 oracleoinstall 40960 May 11 02:56 i
drwxrwxrwx 5 oracle oinstall 4096 Mar 27 14:04 manager
-rw-r--r-- 1 oracle oinstall 28491706 May 11 20:17ords.war
drwxrwxrwx 3 oracle oinstall 4096 Mar 27 14:04 ROOT
7.5 配置ORDS连接
[[email protected]]$ java -jar ords.war setup
Jun 09, 201512:26:03 AM oracle.dbtools.common.config.file.ConfigurationFolderlogConfigFolder
INFO: Usingconfiguration folder: /tmp/apex
Enter the name ofthe database server [localhost]:
Enter the databaselisten port [1521]:
Enter 1 to specifythe database service name, or 2 to specify the database SID [1]:2
Enter the databaseSID [xe]:yang01
Enter the databaseuser name [APEX_PUBLIC_USER]:apex_public_user
Enter the databasepassword for apex_public_user:
Confirm password:
Enter 1 to enterpasswords for the RESTful Services database users(APEX_LISTENER,APEX_REST_PUBLIC_USER), 2 to use the same password as used forapex_public_user or, 3 to skip this step [1]:
Enter the databasepassword for APEX_LISTENER:
Confirm password:
Enter the databasepassword for APEX_REST_PUBLIC_USER:
Confirm password:
Jun 09, 201512:27:19 AM oracle.dbtools.common.config.file.ConfigurationFiles update
INFO: Updatedconfigurations: defaults, apex, apex_al, apex_rt
[[email protected]]$
启用Tomcat,访问报错,已经检查过,apex那3个数据账号并没有问题。
查了好久,注意到了页面这一行字,此实例使用……, 与上面配置默认给的路径
INFO: Using configuration folder: /tmp/apex,并不是一个路径。
既然这样,只能指定一个路径专门放配置信息
[[email protected]]$ java -jar ords.war configdir
Jun 09, 201512:55:30 AM oracle.dbtools.common.config.cmds.ConfigDir execute
INFO: The config.dirsetting is not set
[[email protected]]$ java -jar ords.war configdir/u01/app/apache-tomcat-7.0.61/webapps/ordsconfig
Jun 09, 2015 1:01:57AM oracle.dbtools.common.config.cmds.ConfigDir execute
INFO: Set config.dirto /u01/app/apache-tomcat-7.0.61/webapps/ordsconfig in:/u01/app/apache-tomcat-7.0.61/webapps/ords.war
配置完路径后,重新配置ORDS
[[email protected]]$ java -jar ords.war setup
Jun 09, 2015 1:03:05AM oracle.dbtools.common.config.file.ConfigurationFolder logConfigFolder
INFO: Usingconfiguration folder: /u01/app/apache-tomcat-7.0.61/webapps/ordsconfig/ords
Enter the name ofthe database server [localhost]:
Enter the databaselisten port [1521]:
Enter 1 to specifythe database service name, or 2 to specify the database SID [1]:2
Enter the databaseSID [xe]:yang01
Enter the databaseuser name [APEX_PUBLIC_USER]:apex_public_user
Enter the databasepassword for apex_public_user:
Confirm password:
Enter 1 to enterpasswords for the RESTful Services database users(APEX_LISTENER,APEX_REST_PUBLIC_USER), 2 to use the same password as used forapex_public_user or, 3 to skip this step [1]:
Enter the databasepassword for APEX_LISTENER:
Confirm password:
Enter the databasepassword for APEX_REST_PUBLIC_USER:
Confirm password:
Jun 09, 2015 1:03:59AM oracle.dbtools.common.config.file.ConfigurationFiles update
INFO: Updatedconfigurations: defaults, apex, apex_al, apex_rt
[[email protected]]$ ll
total 27924
drwxrwxrwx 14 oracleoinstall 4096 Mar 27 14:04 docs
drwxrwxrwx 7 oracle oinstall 4096 Mar 27 14:04 examples
drwxrwxrwx 5 oracle oinstall 4096 Mar 27 14:04 host-manager
drwxrwxrwx 33 oracleoinstall 40960 May 11 02:56 i
drwxrwxrwx 5 oracle oinstall 4096 Mar 27 14:04 manager
drwxr-xr-x 6 oracle oinstall 4096 Jun 9 01:02 ords
drwxr-xr-x 3 oracle oinstall 4096 Jun 9 01:02 ordsconfig
-rw-r--r-- 1 oracle oinstall 28491732 Jun 9 01:02 ords.war
drwxrwxrwx 3 oracle oinstall 4096 Mar 27 14:04 ROOT
重启tomcat,大功告成!
倒腾了这么久, 给大家展示下界面,以及它的一个示例应用。 真心推荐大家研究并使用这个工具,很不错~
版权声明:本文为博主原创文章,未经博主允许不得转载。