ORACE APEX 18.2 之三(安裝APEX)

ORACE APEX 18.2 之三(安裝APEX)

  1. 查看环境变量
[oracle@xag182 ~]$ cat /home/oracle/.bash_profile 
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
    . ~/.bashrc
fi

# User specific environment and startup programs
export DISPLAY=10.0.0.85:0.0
ORACLE_SID=MPAPEX;export ORACLE_SID 
ORACLE_UNQNAME=MPAPEX;export ORACLE_UNQNAME
#JAVA_HOME=/u01/java/jdk1.8.0_181; export JAVA_HOME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/12.2.0/db_1; export ORACLE_HOME
ORACLE_TERM=xterm; export ORACLE_TERM
NLS_DATE_FORMAT="YYYY:MM:DDHH24:MI:SS"; export NLS_DATE_FORMAT
NLS_LANG=American_America.AL32UTF8; export NLS_LANG
TNS_ADMIN=$ORACLE_HOME/network/admin; export TNS_ADMIN
ORA_NLS11=$ORACLE_HOME/nls/data; export ORA_NLS11
PATH=.:${JAVA_HOME}/bin:${PATH}:$HOME/bin:$ORACLE_HOME/bin:$ORA_CRS_HOME/bin
PATH=${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin
export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/oracm/lib
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib
export LD_LIBRARY_PATH
THREADS_FLAG=native; export THREADS_FLAG
export TEMP=/u01/tmp
export TMPDIR=/u01/tmp

alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'
#alias asmcmd='rlwrap asmcmd'

#设置环境变量,登录oracle会提示设置ORACLE_SID以免实例太多误操作
#/usr/local/bin/oraenv
#ORAENV_ASK=YES
#export ORAENV_ASK
umask 022
  1. 检查安装
-- check installation
[oracle@xag182 ~]$ sql / as sysdba
SQL> select COMP_ID, VERSION, STATUS from CDB_REGISTRY where COMP_ID='APEX' order by CON_ID;
no rows selected

SQL> select r.COMP_NAME, r.VERSION, c.NAME, c.CON_ID from CDB_REGISTRY r, V$CONTAINERS c where r.CON_ID=c.CON_ID and r.COMP_ID='APEX' order by CON_ID;
no rows selected

SQL> conn sys/[email protected]:1521/PDB1 as sysdba;

SQL> select COMP_ID, VERSION, STATUS from CDB_REGISTRY where COMP_ID='APEX' order by CON_ID;
no rows selected

SQL> select r.COMP_NAME, r.VERSION, c.NAME, c.CON_ID from CDB_REGISTRY r, V$CONTAINERS c where r.CON_ID=c.CON_ID and r.COMP_ID='APEX' order by CON_ID;
no rows selected
  1. 卸载旧版本
[oracle@XAG128 apex]$ cd $ORACLE_HOME/apex
[oracle@XAG128 apex]$ sqlplus / as sysdba
SQL> show pdbs;
    CON_ID CON_NAME           OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
     2 PDB$SEED           READ ONLY  NO
     3 PDB1               READ WRITE NO
     4 RECATPDB           READ WRITE NO
SQL> @apxremov.sql

  1. 检查要安装的pdb1 环境
[oracle@XAG128 apex]$ sql / as sysdba

SQL> show pdbs;
    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO        
         3 PDB1                           READ WRITE NO        
         4 RECATPDB                       READ WRITE NO        
SQL> alter session set container=PDB1;

SQL> show pdbs;
    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         3 PDB1                           READ WRITE NO        

SQL> SET SQLFORMAT ansiconsole

SQL> select tablespace_name,file_name,bytes/1024/1024 mb from dba_temp_files;
TABLESPACE_NAME  FILE_NAME                             MB   
TEMP1            /u02/oradata/MPAPEX/pdb1/TEMP1_1.dbf  256  
TEMP1            /u02/oradata/MPAPEX/pdb1/TEMP1_2.dbf  256  

SQL> select tablespace_name,file_name,bytes/1024/1024 mb from dba_data_files;
TABLESPACE_NAME  FILE_NAME                                MB   
SYSTEM           /u02/oradata/MPAPEX/pdb1/system01.dbf    260  
SYSAUX           /u02/oradata/MPAPEX/pdb1/sysaux01.dbf    360  
UNDOTBS1         /u02/oradata/MPAPEX/pdb1/undotbs01.dbf   100  
PDB1_UD          /u02/oradata/MPAPEX/pdb1/PDB1_UD1.dbf    128  
PDB1_UD          /u02/oradata/MPAPEX/pdb1/PDB1_UD2.dbf    128  
I_PDB1_UD        /u02/oradata/MPAPEX/pdb1/I_PDB1_UD1.dbf  64   
I_PDB1_UD        /u02/oradata/MPAPEX/pdb1/I_PDB1_UD2.dbf  64 

SQL> select * from dba_tablespace_groups;
      GROUP_NAME  TABLESPACE_NAME  
      TEMP_GP     TEMP1 

#创建 apex182,apex182_file 表空间
create tablespace apex182 DATAFILE '/u02/oradata/MPAPEX/pdb1/apex182.dbf' SIZE 256M REUSE AUTOEXTEND ON NEXT 128M MAXSIZE UNLIMITED;

create tablespace apex182_file DATAFILE '/u02/oradata/MPAPEX/pdb1/apex182_file.dbf' SIZE 256M REUSE AUTOEXTEND ON NEXT 128M MAXSIZE UNLIMITED;

create tablespace ords183 DATAFILE '/u02/oradata/MPAPEX/pdb1/ords183.dbf' SIZE 256M REUSE AUTOEXTEND ON NEXT 128M MAXSIZE UNLIMITED;

CREATE TEMPORARY TABLESPACE TEMP2 TEMPFILE '/u02/oradata/MPAPEX/pdb1/TEMP2_1.dbf' SIZE 256M REUSE AUTOEXTEND ON NEXT 128M  MAXSIZE 1G EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1M;
  1. 安装 Tomcat
[root@xag182/]# mkdir /u01/tomcat8
[root@xag182/]# chown -Rf oracle:oinstall /u01/tomcat8
[root@xag182/]# chmod -Rf 755 /u01/tomcat8/bin/*

[oracle@xag182 setup]$ pwd
/u01/setup

[oracle@xag182 setup]$ wget http://mirrors.shu.edu.cn/apache/tomcat/tomcat-8/v8.5.37/bin/apache-tomcat-8.5.37.zip

[oracle@xag182 setup]$ ls
apache-tomcat-8.5.37.zip

[oracle@xag182 setup]$ unzip apache-tomcat-8.5.37.zip

[oracle@xag182 setup]$ mv apache-tomcat-8.5.37/* /u01/tomcat8

[root@xag182 /]# cat /etc/init.d/tomcat
#!/bin/bash
# description: Tomcat Start Stop Restart
# processname: tomcat
# chkconfig: 234 20 80
JAVA_HOME=/u01/java/jdk1.8.0_181
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
CATALINA_HOME=/u01/tomcat8

case $1 in
start)
/bin/su oracle $CATALINA_HOME/bin/startup.sh
;;
stop)
/bin/su oracle $CATALINA_HOME/bin/shutdown.sh
;;
restart)
/bin/su oracle $CATALINA_HOME/bin/shutdown.sh
/bin/su oracle $CATALINA_HOME/bin/startup.sh
;;
esac
#. /root/firewall.sh
exit 0

[root@xag182 /]# chmod +x /etc/init.d/tomcat

[root@xag182 /]# chmod -Rf 755 /u01/tomcat8/bin/*
[root@xag182 /]# service tomcat start
Using CATALINA_BASE:   /u01/tomcat8
Using CATALINA_HOME:   /u01/tomcat8
Using CATALINA_TMPDIR: /u01/tomcat8/temp
Using JRE_HOME:        /u01/java/jdk1.8.0_181
Using CLASSPATH:       /u01/tomcat8/bin/bootstrap.jar:/u01/tomcat8/bin/tomcat-juli.jar
Tomcat started.

#测试tomcat
访问 http://192.168.40.182:8080   

完整的开发环境 - apexins.sql按所示顺序运行以下四个参数:
@ apexins.sql tablespace_apex  tablespace_files  tablespace_temp  images
哪里:
tablespace_apex 是Application Express应用程序用户的表空间的名称。
tablespace_files 是Application Express文件用户的表空间的名称。
tablespace_temp 是临时表空间或表空间组的名称。
images是Application Express映像的虚拟目录。要支持将来的Application Express升级,请将虚拟映像目录定义为/i/。
例如:
@ apexins.sql SYSAUX SYSAUX TEMP / i /

运行时环境 - apxrtins.sql按所示顺序运行以下四个参数:

@ apxrtins.sql tablespace_apex  tablespace_files  tablespace_temp  images
  1. 安装 APEX 18.2,安装过程可能会持续5-10分钟
[root@xag182 u01]# mkdir -p /u01/oracle/apex -p
[root@xag182 u01]# chown -R oracle:oinstall /u01/oracle/apex
[root@xag182 u01]# chown -R oracle:oinstall /u01/oracle

[oracle@xag182 setup]$ unzip apex_18.2.zip -d /u01/oracle

[oracle@xag182 setup]$ cd /u01/oracle/apex/

[oracle@xag182 apex]$ sqlplus / as sysdba
    
SQL> alter session set container=PDB1;
or
sqlplus sys/[email protected]:1521/PDB1 as sysdba

SQL> show pdbs;
    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         3 PDB1                           READ WRITE NO        

SQL> SET SQLFORMAT ansiconsole

-- run the script to install a full development environment
SQL>@apexins.sql APEX182 APEX182_FILE TEMP_GP /i/

-- create an instance administrator user and set their password
SQL> @apxchpwd.sql
Enter the administrator's username [ADMIN] apexadmin
User "apexadmin" does not yet exist and will be created.
Enter apexadmin's email [apexadmin] [email protected]
Enter apexadmin's password []   ------Xag#123
Created instance administrator APEXADMIN.

-- configure REST Data Services (needed for ORDS to serve workspaces and applications static files)
SQL> @apex_rest_config.sql
Enter password for the APEX_LISTENER user   [] 123456
Enter password for the APEX_REST_PUBLIC_USER user[] 123456
...set_appun.sql
...create APEX_LISTENER and APEX_REST_PUBLIC_USER users

-- 禁用数据库内置的PL/SQL网关
SQL> exec dbms_xdb.sethttpport(0);
SQL> exec dbms_xdb.setftpport(0);

-- unlock and set up APEX public user, this is needed for ORDS to be able to connect to APEX engine
-- 解锁ORDS用户账号
SQL> alter user apex_public_user account unlock;
SQL> alter user apex_public_user identified by "123456";

-- add ACL to enable outgoing connections for APEX internal user
-- this is needed for the APEX_EXEC and APEX_WEB_SERVICE APIs to function properly
-- change it for a more strict policy if needed
SQL> 
begin
    dbms_network_acl_admin.append_host_ace(
        host => '*',
        ace => xs$ace_type(
            privilege_list => xs$name_list('connect'),
            principal_name => 'APEX_180200',
            principal_type => xs_acl.ptype_db));
end;
/

SYS> Select dbms_xdb.gethttpport from dual;
GETHTTPPORT  
0  

#汉化
[oracle@XAG128 zh-cn]$ pwd
/u01/oracle/apex/builder/zh-cn
[oracle@XAG128 zh-cn]$ sqlplus sys/[email protected]:1521/PDB1 as sysdba

SQL> show pdbs;
    CON_ID CON_NAME           OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
     3 PDB1               READ WRITE NO
SQL> Alter session set current_schema=APEX_180200;

SQL> @/u01/oracle/apex/builder/zh-cn/load_zh-cn.sql
  1. 将静态文件部署到 tomcat
## 在 Tomcat 的 webapps 目录下新建一个名为`i`的文件夹
[oracle@xag182 ~]$ mkdir -p /u01/tomcat8/webapps/i/

## 将APEX静态文件部署到tomcat目录下
[oracle@xag182 ~]$ cp -a /u01/oracle/apex/images/* /u01/tomcat8/webapps/i/

## 授予相应权限
[root@xag182 ~]# chown -Rf oracle:oinstall /u01/tomcat8/webapps/
  1. 升级 ORDS 18.3
[root@xag182 u01]# mkdir -p /u01/ords -p
[root@xag182 u01]# chown -R oracle:oinstall /u01/ords
[oracle@xag182 setup]$ unzip ords-18.3.0.270.1456.zip -d /u01/ords/

#执行安装脚本
[oracle@xag182 setup]$ cd /u01/ords
[oracle@xag182 ords]$ ls
docs  examples  index.html  ords.war  params

[oracle@xag182 ords]$ java -jar ords.war install advanced
This Oracle REST Data Services instance has not yet been configured.
Please complete the following prompts

Enter the location to store configuration data:/u01/ords/config
Enter the name of the database server [localhost]:xag182
Enter the database listen port [1521]:1521
Enter 1 to specify the database service name, or 2 to specify the database SID [1]:1
Enter the database service name:PDB1
Enter 1 if you want to verify/install Oracle REST Data Services schema or 2 to skip this step [1]:1
Enter the database password for ORDS_PUBLIC_USER:123456
Confirm password:
Requires SYS AS SYSDBA to verify Oracle REST Data Services schema.

Enter the database password for SYS AS SYSDBA:123456
Confirm password:

Retrieving information.
Enter the default tablespace for ORDS_METADATA [SYSAUX]:ORDS183
Dec 28, 2018 1:51:44 AM oracle.dbtools.rt.config.setup.CdbPdbSetup isValidTablespace
INFO: Error the temporary tablespace TEMP does not exist. An existing tablespace is required for ORDS installation. 
Enter the temporary tablespace for ORDS_METADATA [SYSAUX]:TEMP_GP
Dec 28, 2018 1:54:04 AM oracle.dbtools.rt.config.setup.CdbPdbSetup isValidTablespace
INFO: Error the temporary tablespace TEMP_GP does not exist. An existing tablespace is required for ORDS installation. 
Enter the temporary tablespace for ORDS_METADATA [SYSAUX]:TEMP2
Enter the default tablespace for ORDS_PUBLIC_USER [SYSAUX]:ORDS183
Dec 28, 2018 1:59:55 AM oracle.dbtools.rt.config.setup.CdbPdbSetup isValidTablespace
INFO: Error the temporary tablespace TEMP does not exist. An existing tablespace is required for ORDS installation. 
Enter the temporary tablespace for ORDS_PUBLIC_USER [SYSAUX]:TEMP2
Enter 1 if you want to use PL/SQL Gateway or 2 to skip this step.
If using Oracle Application Express or migrating from mod_plsql then you must enter 1 [1]:
Enter the PL/SQL Gateway database user name [APEX_PUBLIC_USER]:
Enter the database password for APEX_PUBLIC_USER:123456
Confirm password:
Enter 1 to specify passwords for Application Express RESTful Services database users (APEX_LISTENER, APEX_REST_PUBLIC_USER) or 2 to skip this step [1]:
Enter the database password for APEX_LISTENER:123456
Confirm password:
Enter the database password for APEX_REST_PUBLIC_USER:123456
Confirm password:
Dec 28, 2018 2:04:10 AM  
INFO: reloaded pools: []
Installing Oracle REST Data Services version 18.3.0.r2701456
... Log file written to /home/oracle/ords_install_core_2018-12-28_020410_00782.log
... Verified database prerequisites
... Created Oracle REST Data Services schema
... Created Oracle REST Data Services proxy user
... Granted privileges to Oracle REST Data Services
... Created Oracle REST Data Services database objects
... Log file written to /home/oracle/ords_install_datamodel_2018-12-28_020419_00826.log
... Log file written to /home/oracle/ords_install_apex_2018-12-28_020421_00281.log
Completed installation for Oracle REST Data Services version 18.3.0.r2701456. Elapsed time: 00:00:12.158 

Enter 1 if you wish to start in standalone mode or 2 to exit [1]:2

为 tomcat 账号授权,确保 tomcat 账号可以读取/u01/ords/conf目录内文件。

[root@XAG128 ~]# chown -R oracle:oinstall /u01/ords/config

  1. 将 ords.war 部署到 Tomcat
[oracle@XAG128 ords]$ cp -a /u01/ords/ords.war /u01/tomcat8/webapps/

[root@XAG128 ~]# chown -Rf oracle:oinstall /u01/tomcat8/webapps/

## 重启 tomcat 服务
[root@xag182 /]# service tomcat restart

### 验证 ORDS 已部署成功

打开浏览器,访问 http://192.168.40.182:8080/ords/,如果部署成功,可以访问了。

http://192.168.40.182:8080/ords/
internal/apexadmin/Xag#123

or

http://192.168.40.182:8080/ords/apex_admin
apexadmin/Xag#123
[oracle@xag182 ~]$ sqlplus sys/[email protected]:1521/PDB1 as sysdba

SQL> select r.COMP_NAME, r.VERSION, c.NAME, c.CON_ID from CDB_REGISTRY r, V$CONTAINERS c where r.CON_ID=c.CON_ID and r.COMP_ID='APEX' order by CON_ID;

COMP_NAME                              VERSION          NAME        CON_ID
--------------------------------------------------------------------------------
Oracle Application Express       18.2.0.00.12       PDB1     3

-- creating a tablespace for our APEX workspaces
create tablespace apextb DATAFILE '/u02/oradata/MPAPEX/pdb1/apextb.dbf' SIZE 128M REUSE AUTOEXTEND ON NEXT 128M MAXSIZE UNLIMITED;
    
-- creating a schema for our APEX workspaces
create user apex identified by "123456" default tablespace apextb temporary tablespace TEMP_GP;
alter user apex quota unlimited on apextb;
grant unlimited tablespace to apex;
grant create session to apex;
grant create cluster to apex;
grant create dimension to apex;
grant create indextype to apex;
grant create job to apex;
grant create materialized view to apex;
grant create operator to apex;
grant create procedure to apex;
grant create sequence to apex;
grant create snapshot to apex;
grant create synonym to apex;
grant create table to apex;
grant create trigger to apex;
grant create type to apex;
grant create view to apex;
  1. 查看
[oracle@xag182 ~]$ sqlplus sys/[email protected]:1521/PDB1 as sysdba

SQL> select version_no from apex_release;

VERSION_NO
--------------------------------------------------------------------------------
18.2.0.00.12

你可能感兴趣的:(ORACE APEX 18.2 之三(安裝APEX))