Friday 25 November 2016

ORA-27102: out of memory

While try to bring up the database getting below error

SQL> startup
ORA-27102: out of memory
SVR4 Error: 22: Invalid argument
DB version: 11.2.0.4
Server:Solaries 10

For further details in alert log below massage appear

WARNING: The system does not seem to be configured
optimally. Creating a segment of size 0x0000002340000000

Cause: Oracle is trying to create a 151Gb shared memory segment, but operating system responded with an invalid argument (EINVAL) error message. As the alert log suggested, “fix shm parameters in /etc/system” and showed “creating segment of size .
Once convert the Hex value(
0x0000002340000000)  into decimal it is 151 GB approx.



To know the current allocated memory is 

% prctl -n project.max-shm-memory -i project 3
NAME    PRIVILEGE       VALUE    FLAG   ACTION                       RECIPIENT
project.max-shm-memory
        privileged       125GB      -   deny                                 -
        system          16.0EB    max   deny                                  

Currently 125 GB is allocated to the database.To bring up the database or resolve the issue ,
we need to  increase it either equal to 151 GB or more.
We have decided to make it 200Gb to avoid same issue in future.
To change it temporary ,means changed will lost after server reboot.

# prctl -n project.max-shm-memory -r -v 200G -i project 3
NAME PRIVILEGE VALUE FLAG ACTION RECIPIENT
project.max-shm-memory
        privileged       200GB      -   deny                                 -
        system          16.0EB    max   deny     
this change is temporary.
To make the change permanently to the server for the database.
# projmod -s -K "project.max-shm-memory=(priv,200g,deny)" 'default' 
 NAME PRIVILEGE VALUE FLAG ACTION RECIPIENT
project.max-shm-memory
        privileged       200GB      -   deny                                 -
        system          16.0EB    max   deny     

Thursday 24 November 2016

Unlock APEX ADMIN user account without resetting password.

 Once the Apex admin user account is locked.You have only two option left.
1. Reset the admin user account  or
2. Unlock the ADMIN account

for step 2: To unlock the ADMIN account

! Query the id for the “INTERNAL” workspace:

SQL> SELECT workspace_id FROM apex_workspaces WHERE workspace = 'INTERNAL';
WORKSPACE_ID
    10
!! Find  the APEX schema’s name for your version:

SQL> select username from dba_users where username like 'APEX%' order by 1;
USERNAME

APEX
APEX_050200
APEX_PUBLIC_USER
 SQL>
!!! Switch to  your session to the APEX-schema:

SQL> alter session set current_schema = APEX_050200;                     
Session altered.
SQL>


!!!! Unlock your ADMIN account with the following code:
 SQL> begin
      wwv_flow_security.g_security_group_id := 10;
      wwv_flow_fnd_user_api.UNLOCK_ACCOUNT('ADMIN');
      commit;
    end;
    /
PL/SQL procedure successfully completed.
SQL>

                                                                                        

Thursday 10 November 2016

Upgrade APEX from 4.2 to 5.0

1.  Download the zip file  of APEX 5.0  from oracle support.

.2. Change your working directory to apex.Where you want to unzip the file.

3.Pre-Installation checks

check the current version of apex.
select comp_name, version from dba_registry;

COMP_NAME                                          VERSION
-------------------------------------------------- --------------------------
Apex                                              4.2.0.3.0

select account_status from dba_users where username = 'APEX_PUBLIC_USER';

ACCOUNT_STATUS
--------------------------------
OPEN

select default_tablespace, temporary_tablespace from dba_users where username = 'APEX_040200';


DEFAULT_TABLESPACE             TEMPORARY_TABLESPACE
------------------------------ ------------------------------
APEX                                                     TEMP


 4. Upgradation 

The script we need to run to do the installation or upgradation is  – apexins.sql . It is not required to uninstall the previous version while upgrading 

–  the script takes three parameters :
  • The default tabelspace of the APEX owner schema
  • The default tablespace of FLOWS_FILES schema
  • A temporary tablespace in the database
  • A virtual directory for APEX images.

We already know that the default tablespace for the APEX owner is APEX
We also know that the temporary tablespace is called TEMP
As for the FLOWS_FILES schema…

select default_tablespace from dba_users where username = 'FLOWS_FILES';
DEFAULT_TABLESPACE
------------------------------
SYSAUX

Wo to your working directory where you unzip the binary file and run the below command for upgradation.

@apexins.sql APEX SYSAUX TEMP /i/

Once Upgradation complete the logs are look like below

..done load verification images
timing for: Verification Images Load
Elapsed: 00:00:00.63
Set Credentials...
Creating Packaged Application Wizard Information...
Check Compatibility...
...Delete Packaged Applications and associated images
...Load Packaged Application Categories
...Load Packaged Applications and associated images
...done
Application Express Packaged and Sample Applications installation data

...Remove existing packaged application data


...Load packaged application archive

API Last Extended:20130101
Your Current Version:20130101
This import is compatible with version: 20130101
COMPATIBLE (You should be able to run this import without issues.)
--workspace/static/files
... elapsed: 40.3 sec
...done

...Expand packaged application archive

...done
timing for: Install Packaged and Sample Applications
Elapsed: 00:00:44.94

Session altered.


Package body altered.


Package body altered.

-- Enabling ws constraints. -------

PL/SQL procedure successfully completed.


Session altered.

...Adjust Application Express (APEX) owner and version

14 rows updated.


Commit complete.

timing for: Install Internal Applications
Elapsed: 00:10:22.51

Revoke succeeded.

JOB_QUEUE_PROCESSES: 4

PL/SQL procedure successfully completed.


Session altered.


Performing Application Express component validation - please wait...

Completing registration process. 07:59:19
Validating installation.  07:59:19
...Starting validation 07:59:19
...Database user "SYS", database schema "APEX_050000", user# "132" 07:59:19
...270 packages
...263 package bodies
...465 tables
...8 functions
...16 procedures
...4 sequences
...497 triggers
...1582 indexes
...255 views
...0 libraries
...14 types
...5 type bodies
...0 operators
...0 index types
...Begin key object existence check 07:59:52
...Completed key object existence check 07:59:52
...Setting DBMS Registry 07:59:52
...Setting DBMS Registry Complete 07:59:52
...Exiting validate 07:59:52

PL/SQL procedure successfully completed.

timing for: Validate Installation
Elapsed: 00:00:33.20

Session altered.

timing for: Complete Installation
Elapsed: 00:23:59.23

PL/SQL procedure successfully completed.




Thank you for installing Oracle Application Express 5.0.4.00.12

Oracle Application Express is installed in the APEX_050000 schema.

The structure of the link to the Application Express administration services is as follows:
http://host:port/pls/apex/apex_admin (Oracle HTTP Server with mod_plsql)
http://host:port/apex/apex_admin     (Oracle XML DB HTTP listener with the embedded PL/SQL gateway)
http://host:port/apex/apex_admin     (Oracle REST Data Services)

The structure of the link to the Application Express development interface is as follows:
http://host:port/pls/apex (Oracle HTTP Server with mod_plsql)
http://host:port/apex     (Oracle XML DB HTTP listener with the embedded PL/SQL gateway)
http://host:port/apex     (Oracle REST Data Services)


PL/SQL procedure successfully completed.


5. Upgrade Application Express password:
  •         SQL> @apxchpwd
    
            Enter password for Application Express ADMIN account.
                 Provide the password to application team

6. Configure APEX_PUBLIC_USER Account


ALTER USER APEX_PUBLIC_USER ACCOUNT UNLOCK;
ALTER USER APEX_PUBLIC_USER IDENTIFIED BY password

Incase application team facing any  connectivity issue :


A. verify the port number where the Oracle XML DB HTTP Server is running. 

SELECT DBMS_XDB.GETHTTPPORT FROM DUAL; 

EXEC DBMS_XDB.SETHTTPPORT(8080); ---if above return port 0

B.Enable Network Services

DECLARE
ACL_PATH VARCHAR2(4000);
BEGIN
-- Look for the ACL currently assigned to '*' and give APEX_040200
-- the "connect" privilege if APEX_040200 does not have the privilege yet.
SELECT ACL INTO ACL_PATH FROM DBA_NETWORK_ACLS
WHERE HOST = '*' AND LOWER_PORT IS NULL AND UPPER_PORT IS NULL;
IF DBMS_NETWORK_ACL_ADMIN.CHECK_PRIVILEGE(ACL_PATH, 'APEX_040200','connect') IS NULL THEN
DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE(ACL_PATH,'APEX_040200', TRUE, 'connect');
END IF;
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_NETWORK_ACL_ADMIN.CREATE_ACL('power_users.xml',
'ACL that lets power users to connect to everywhere',
'APEX_040200', TRUE, 'connect');
DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL('power_users.xml','*');
END;
/