- 检查安装
[oracle@XAG143 ~]$ sql sys/[email protected]:1521/MYCDB as sysdba
SQL> set sqlformat ansiconsole
SQL> select * from dba_registry where comp_id = 'APEX';
COMP_ID COMP_NAME VERSION STATUS MODIFIED NAMESPACE CONTROL SCHEMA PROCEDURE STARTUP PARENT_ID OTHER_SCHEMAS
APEX Oracle Application Express 5.0.4.00.12 VALID 02-NOV-2018 23:39:54 SERVER SYS APEX_050000 VALIDATE_APEX APEX_PUBLIC_USER,FLOWS_FILES
SQL> select COMP_ID, VERSION, STATUS from CDB_REGISTRY where COMP_ID='APEX' order by CON_ID;
COMP_ID VERSION STATUS
APEX 5.0.4.00.12 VALID
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 5.0.4.00.12 CDB$ROOT 1
- 卸載舊版本
[oracle@XAG143 apex]$ cd $ORACLE_HOME/apex
[oracle@XAG143 apex]$ sqlplue sys/[email protected]:1521/MYCDB as sysdba
-bash: sqlplue: command not found
[oracle@XAG143 apex]$ sqlplus sys/[email protected]:1521/MYCDB as sysdba
#默认APEX用如下方法卸载
SQL> @apxremov_con.sql
#更高版本的APEX用如下方法卸载
SQL> @apxremov.sql
[oracle@XAG143 apex]$ sqlplus sys/[email protected]:1521/MYCDB as sysdba
SQL> select * from dba_registry where comp_id = 'APEX';
no rows selected
[oracle@XAG143 apex]$ sqlplus sys/[email protected]:1521/MYPDB1 as sysdba
SQL> select * from dba_registry where comp_id = 'APEX';
no rows selected
- 检查要安装的pdb1 环境
[oracle@XAG143 apex]$ sql sys/[email protected]:1521/MYPDB1 as sysdba
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
3 MYPDB1 READ WRITE YES
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/MYCDB/MYPDB1/TEMP1_1.dbf 256
TEMP1 /u02/oradata/MYCDB/MYPDB1/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/MYCDB/MYPDB1/system01.dbf 370
SYSAUX /u02/oradata/MYCDB/MYPDB1/sysaux01.dbf 850
UNDOTBS1 /u02/oradata/MYCDB/MYPDB1/undotbs01.dbf 1400
MYPDB1_UD /u02/oradata/MYCDB/MYPDB1/MYPDB1_UD1.dbf 128
MYPDB1_UD /u02/oradata/MYCDB/MYPDB1/MYPDB1_UD2.dbf 128
I_MYPDB1_UD /u02/oradata/MYCDB/MYPDB1/I_MYPDB1_UD1.dbf 64
I_MYPDB1_UD /u02/oradata/MYCDB/MYPDB1/I_MYPDB1_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/MYCDB/MYPDB1/apex182.dbf' SIZE 256M REUSE AUTOEXTEND ON NEXT 128M MAXSIZE UNLIMITED;
create tablespace apex182_file DATAFILE '/u02/oradata/MYCDB/MYPDB1/apex182_file.dbf' SIZE 256M REUSE AUTOEXTEND ON NEXT 128M MAXSIZE UNLIMITED;
4 . 上傳&解壓
[oracle@XAG143 apex]$ cd $ORACLE_HOME/apex
[oracle@XAG143 apex]$ pwd
/u01/app/oracle/product/12.2.0/db_1/apex
[oracle@XAG143 apex]$ rm -rf *
[oracle@XAG143 apex]$ ls
[oracle@XAG143 setup]$ ls
apex_18.2.zip
[oracle@DB01 setup]$ unzip apex_18.2.zip -d /u01/app/oracle/product/12.2.0/db_1/
[oracle@XAG143 apex]$ ls
apex_epg_config_cdb.sql apexins.sql apxdevrm.sql apxremov1.sql apxrtins_nocdb.sql coreins5.sql
...
apexins_nocdb.sql apxdevrm_nocdb.sql apxpatch.sql apxrtins_cdb_upg.sql coreins4.sql
5.安装 APEX 18.2
[oracle@XAG143 apex]$ sqlplus sys/[email protected]:1521/MYPDB1 as sysdba
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.
#Create the APEX_LISTENER and APEX_REST_PUBLIC_USER users
SQL> @apex_rest_config.sql
#Make sure the APEX_PUBLIC_USER account is unlocked.
SQL> ALTER USER APEX_PUBLIC_USER IDENTIFIED BY 123456 ACCOUNT UNLOCK;
- Embedded PL/SQL Gateway (EPG) Configuration
[oracle@XAG143 apex]$ sqlplus sys/[email protected]:1521/MYPDB1 as sysdba
#如下為 apex 目錄所在的上級目錄
SQL> @apex_epg_config.sql /u01/app/oracle/product/12.2.0/db_1
#Unlock the ANONYMOUS account.
[oracle@XAG143 apex]$ sqlplus sys/[email protected]:1521/MYCDB as sysdba
DECLARE
l_passwd VARCHAR2(40);
BEGIN
l_passwd := DBMS_RANDOM.string('a',10) || DBMS_RANDOM.string('x',10) || '1#';
-- Remove CONTAINER=ALL for non-CDB environments.
EXECUTE IMMEDIATE 'ALTER USER anonymous IDENTIFIED BY ' || l_passwd || ' ACCOUNT UNLOCK CONTAINER=ALL';
END;
/
- Check the port setting for XML DB Protocol Server.
[oracle@XAG143 apex]$ sqlplus sys/[email protected]:1521/MYPDB1 as sysdba
SQL> SELECT DBMS_XDB.gethttpport FROM DUAL;
GETHTTPPORT
-----------
0
SQL> EXEC DBMS_XDB.sethttpport(8080);
#修改访问权限,允许其它机器访问本机的 APEX:
SQL> exec DBMS_XDB.SETLISTENERLOCALACCESS (FALSE);
#設置授權
declare
acl_path varchar2(500);
begin
select acl into acl_path from dba_network_acls t
where t.host='*' and t.lower_port is null
and t.upper_port is null;
if dbms_network_acl_admin.check_privilege(acl_path,'APEX_180200','connect') is null then
dbms_network_acl_admin.add_privilege(acl_path,'APEX_180200',true,'connect');
end if;
exception
--when no acl has been assigned to '*'.
when no_data_found then
dbms_network_acl_admin.create_acl('power_user.xml','acl connect','APEX_180200',true,'connect');
dbms_network_acl_admin.assign_acl('power_user.xml','*');
end;
/
commit;
- 漢化
#汉化
[oracle@DB01 zh-cn]$ pwd
/u01/app/oracle/product/12.2.0/db_1/apex/builder/zh-cn
[oracle@XAG143 zh-cn]$ sqlplus sys/[email protected]:1521/MYPDB1 as sysdba
SQL> Alter session set current_schema=APEX_180200;
SQL> @load_zh-cn.sql
- 更改參數
[oracle@DB01 apex]$ sql / as sysdba
SQL> alter system set shared_servers=5 scope=both;
SQL> alter system set job_queue_processes=20 scope=both;
10.如無法登陸則刪除如下用戶
SELECT username FROM dba_users WHERE (username LIKE 'FLOWS_%' OR username LIKE 'APEX_%') AND username NOT IN
(
SELECT 'FLOWS_FILES' FROM dual
UNION
SELECT 'APEX_PUBLIC_USER' FROM dual
UNION
SELECT schema FROM dba_registry WHERE comp_id = 'APEX'
);
DROP USER APEX_030200 CASCADE;
Finally, login and check everything is working…
Administration Services login page (used for managing the APEX instance):
http://10.0.2.1:8080/apex/apex_admin
NOTE: You’ll be prompted to change the ADMIN password the first time you logon.
Username: APEXADMIN
Password: Xag#123
Workspace login page: http://10.0.2.1:8080/apex
Workspace: APEXADMIN
Username: ADMIN
Password: *****
12 解決登陸是彈出window安全登陸窗口問題
首先使用sys 登录,切换到PDB
alter session set container=MYPDB1;
执行语句:
DECLARE
l_configxml XMLTYPE;
l_value VARCHAR2(5) := 'true'; --(true/false)
BEGIN
l_configxml := DBMS_XDB.cfg_get();
IF l_configxml.existsNode('/xdbconfig/sysconfig/protocolconfig/httpconfig/allow-repository-anonymous-access') = 0 THEN
-- Add missing element.
SELECT insertChildXML
(
l_configxml,
'/xdbconfig/sysconfig/protocolconfig/httpconfig',
'allow-repository-anonymous-access',
XMLType('' ||
l_value ||
' '),
'xmlns="http://xmlns.oracle.com/xdb/xdbconfig.xsd"'
)
INTO l_configxml
FROM dual;
DBMS_OUTPUT.put_line('Element inserted');
ELSE
-- Update existing element.
SELECT updateXML
(
DBMS_XDB.cfg_get(),
'/xdbconfig/sysconfig/protocolconfig/httpconfig/allow-repository-anonymous-access/text()',
l_value,
'xmlns=”http://xmlns.oracle.com/xdb/xdbconfig.xsd"'
)
INTO l_configxml
FROM dual;
DBMS_OUTPUT.put_line('Element updated.');
END IF;
DBMS_XDB.cfg_update(l_configxml);
DBMS_XDB.cfg_refresh;
END;
/
[oracle@DB01 apex]$ sql / as sysdba
SQL> ALTER USER XDB ACCOUNT UNLOCK;
SQL> ALTER USER ANONYMOUS IDENTIFIED BY anonymous;
SQL> ALTER USER XDB IDENTIFIED BY xdb;
SQL> ALTER USER ANONYMOUS ACCOUNT UNLOCK;
SQL> ALTER USER XDB ACCOUNT UNLOCK;
#以上方法还是不能解决XDB弹出窗口认证问题则如下处理
[oracle@XAG143 zh-cn]$ sqlplus sys/[email protected]:1521/MYPDB1 as sysdba
SQL> GRANT DBA to anonymous; --不推荐,此授权后权限过大(需要进一步分析)
[oracle@DB01 apex]$ sql sys/[email protected]:1521/MPTEST as sysdba
SQL> select COMP_ID, VERSION, STATUS from CDB_REGISTRY where COMP_ID='APEX' order by CON_ID;
COMP_ID VERSION STATUS
------------------------------ ------------------------------ --------------------------------------------
APEX 18.2.0.00.12 VALID