martedì 28 febbraio 2017

Codemotion Roma 2017 - 24/25 Marzo - Presente !!!

Anche per questa edizione sarò presente insieme al mitico Gabba, venite a trovarci allo stand di Oracle e venite ad ascoltarci il 25 marzo alle 12:30. Vi aspettiamo.   :)


You and your containers: strumenti di automazione in Cloud


12:30/13:10


L'intervento si propone di illustrare l'utilizzo di strumenti di automazione per ambienti basati su Container adatti ad un approccio DevOps, dallo sviluppo alla produzione. Saranno forniti dettagli ed esempi pratici su Container in Cloud per visualizzare, configurare ed orchestrare i propri stack tecnologici su di una infrastruttura Docker erogata come servizio.

Language: Italian
Level: Intermediate


venerdì 28 ottobre 2016

Codemotion Milano 2016: Parlerò di "DevOps in Cloud, dai Container all’approccio Codeless"




Io e il mitico Gabriele Provinciali saremo presenti al Codemotion Milano 2016, il 26 Novembre alle 12.30

DevOps in Cloud, dai Container all’approccio Codeless. [12:30/13:10]
Un approccio moderno allo sviluppo software dovrebbe sfruttare linguaggi ed ambienti appartenenti a diverse tipologie di innovazione: DevOps per automatizzare continuous integration e continuous delivery, il Cloud per gestire il ciclo di vita del software in qualsiasi momento, i Software Containers per raggiungere livelli di scalabilità adeguati alle dimensioni dell’audience e un approccio Codeless per confezionare applicazioni e cruscotti ad uso dell’utenza business. Il talk sarà articolato intorno a queste quattro aree mostrando principalmente esempi pratici.


lunedì 24 ottobre 2016

WebLogic Cluster & Load Balancer: Example with WebLogic Plug-In on Apache HTTP Server


I have used on Windows 10 x64 :
I assume that you have already Installed and Configured a Cluster (Traditional or Dynamic) on WLS.

In my examples I have created a Dynamic Cluster with 2 Managed Server (Maximum of 8) and the 2 Active Managed Server are:
FabryManaged-1: fmarini-it.it.oracle.com:7101
FabryManaged-2: fmarini-it.it.oracle.com:7102

It is recommended to enable the WLS settings "WebLogic Plugin Enabled":
http://www.ateam-oracle.com/wls-plugin-enabled/

Install now Apache Http Server:
it is very simple, on windows you must only unzip the file.

Now unzip the content of the file WLSPlugin12.2.1.1.0-Apache2.2-Apache2.4-Win64-12.2.1.1.0.zip inside a folder.

I have installed Apache in  d:\Apache24 and I have unzipped the plugin in the folder d:\Apache24\WLS-PLUGIN\


This is the content extracted from WLSPlugin12.2.1.1.0-Apache2.2-Apache2.4-Win64-12.2.1.1.0.zip:


I have created a startApache.cmd file where I have added d:\Apache24\WLS-PLUGIN\lib\ to the PATH envinroment variable:



Now we must modify the httpd.conf that is in the folder: d:\Apache24\conf:
- We must add the WebLogic plugin
- We must add the information of the WebLogic Cluster:

LoadModule weblogic_module d:\Apache24\WLS-PLUGIN\lib\mod_wl_24.so  
 <IfModule weblogic_module>  
   <Location />  
    SetHandler    weblogic-handler  
    WebLogicCluster fmarini-it.it.oracle.com:7101,fmarini-it.it.oracle.com:7102  
   </Location>  
 </IfModule>  


Now start everything, WebLogic Admin, your Cluster and Apache, deploy something on the cluster and test it, in my example I have deployed MyApp.war on a Dynamic cluster that is composed by 2 managed server (and 8 as max), and I can test MyApp pointing directly to each one of the Managed Server:

http://fmarini-it.it.oracle.com:7101/MyApp
http://fmarini-it.it.oracle.com:7102/MyApp

To test if the Apache & the Weblogic PlugIn are correctly configured, you can try to call your deployed App pointing directly on Apache: (In my test I have started everything on a single machine):

http://localhost/MyApp

You must remember that in httpd.conf file you have only defined 2 Managed Server that at he moment are part of the Dynamic Cluster.

Those 2 Managed are defined "Cluster Master" and they are responsible to create/maintain & update the Dynamic Server List that WebLogic send to the WebLogic PlugIn:

DynamicServerList (default ON)
WebLogicCluster is only a starting point for the dynamic server list that the server and plug-in maintain
This server list is dynamically updated for every request
If set to OFF:
The plug-in only uses the static list specified with the WebLogicCluster parameter
If one or more servers in the static list fails, the plug-in could waste time trying to connect to a dead server, resulting in decreased performance.
If you add a new server to the cluster, the plug-in cannot proxy requests to the new server unless you redefine this parameter. WebLogic Server automatically adds new servers to the dynamic server list when they become part of the cluster.

Important Points:
  • WLS sends the dynamic server list as a part of a response to the proxy (example Apache) NOT to the client
  • Only the cluster master would send the list after collecting the details which servers are up and read to servers client request, NOT each servers sends the list.
  • If you Shutdown or Create and Start new Managed Server (also not defined in WebLogicCluster parameter of the httpd.conf file) the oldest Active Managed Server is always the Cluster Master
Try to put DebugConfigInfo  On (Disable It on Production Environment) inside the httpd.conf file, like this:

<IfModule weblogic_module>  
   <Location />  
    SetHandler    weblogic-handler  
    WebLogicCluster fmarini-it.it.oracle.com:7101,fmarini-it.it.oracle.com:7102  
    DebugConfigInfo On  
   </Location>  
 </IfModule>  

Now try to call your Application adding in the URL this parameter:
?__WebLogicBridgeConfig

In my case, if I call:
http://localhost/MyApp?__WebLogicBridgeConfig

I receive this output in the Browser:

WebLogic Server Plugin version 12.2.1.1.0, <WLSPLUGINS_12.2.1.1.0_WINDOWS.X64_160606.1942>
Query String: '?__WebLogicBridgeConfig'
WebLogic Cluster List:
  1. Host: '192.168.56.1' Port: 7101 SecurePort: 0 *Primary*
WLRetryAfterDroppedConnection: 'ALL'
WLRetryOnTimeout: 'NONE'
    General Server List:
    1. Host: '192.168.56.1' Port: 7101 SecurePort: 0 Status: OK
    2. Host: '192.168.56.1' Port: 7102 SecurePort: 0 Status: OK
    ConnectRetrySecs: '2'
    ConnectTimeoutSecs: '10'
    WLCookieName: JSESSIONID
    DebugConfigInfo: 'ON'
    DefaultFileName: ''
    DisableCookie2Server: OFF
    DynamicServerList: 'ON'
    ErrorPage: ''
    FileCaching: ON
    Idempotent: ON
    KeepAliveEnabled: ON
    KeepAliveSecs: 20
    MaxPostSize: 0
    MaxSkipTime: '10'
    PathPrepend: ''
    PathTrim: ''
    QueryFromRequest: OFF
    WLForwardUriUnparsed: OFF
    WLAllowDoubleEscapedURI: OFF
    SecureProxy: 'OFF'
    StatPath: 'false'
    WLDNSRefreshInterval: '0'
    WLIOTimeoutSecs(old name is HungServerRecoverSecs): '300'
    WLSocketTimeoutSecs: '2'
    WLProxySSL: OFF
    WLProxyPassThrough: OFF
    WLProxySSLPassThrough: OFF
    WLServerInitiatedFailover: ON
    WLMaxWebSocketClients: 32

    Runtime statistics:


    • requests: 7
    • successful requests: 6
    • Exception objects created: 7
    • Exception Objects deleted: 14
    • URL Objects created: 5
    • URL Objects deleted: 4
    • connections recycled: 0
    • UNKNOWN_ERROR_CODE exceptions: 0
    • CONNECTION_REFUSED exceptions: 7
    • CONNECTION_TIMEOUT exceptions: 0
    • READ_ERROR_FROM_CLIENT exceptions: 0
    • READ_ERROR_FROM_SERVER exceptions: 0
    • READ_ERROR_FROM_FILE exceptions: 0
    • WRITE_ERROR_TO_CLIENT exceptions: 0
    • WRITE_ERROR_TO_SERVER exceptions: 0
    • WRITE_ERROR_TO_FILE exceptions: 0
    • READ_TIMEOUT exceptions: 0
    • WRITE_TIMEOUT exceptions: 0
    • UNKNOWN_HOST exceptions: 0
    • NO_RESOURCES exceptions: 0
    • PROTOCOL_ERROR exceptions: 0
    • CONFIG_ERROR exceptions: 0
    • FAILOVER_REQUIRED exceptions: 0
    • POST_TIMEOUT exceptions: 0
    • REQUEST_ENTITY_TOO_LARGE exceptions: 0
    • HALF_OPEN_SOCKET_RETRY exceptions: 0
    • BAD_REQUEST_FROM_CLIENT exceptions: 0
    • UNKNOWN_ERROR_CODE exceptions: 0
    ---------------------------------------------------------------------------------------------------------------------

    If you are using Apache 2.4 on Windows NT follow this suggestion:

    venerdì 21 ottobre 2016

    How to create a WebLogic Cluster on two different Machines

    Suppose that you have two different Hardware (or Virtual) Machines:

    Machine_A and Machine_B

    To create a WebLogic Horizontal Cluster on these Machines you have to do:

    --- [01] ---
    Verify that there are no limitation on the LAN between the 2 Machines, you must be able to ping Machine_B from Machine_A and Machine_A from Machine_B.

    Verify also that there in not an active firewall.

    For example on Linux:

    service firewalld stop 
    (stop the firewall if it is active)

     systemctl disable firewalld  
    (to permanently disable the firewall)

    Verify that DATE & TIME are the same on both Machines
    Verify that on Machine_A and Machine_B it is installed the same version of JDK
    Verify that you are using the same version of OS with the same patches level on both Machines

    --- [02] ---
    Install the same version of WLS software on both Machines, it is suggested to install WLS under the same PATH on the 2 Machines:

    For examples I have installed WLS in :

    Machine_A:
    c:\FABRIZIO\demo_wls  

    Machine_B:
    c:\FABRIZIO\demo_wls  

    --- [03] ---
    Create a Domain with Admin Server on Machine_A.
    (In my example I have created a "base_domain" with an AdminServer on port 7001)

    To do this you can execute the command:
    c:\FABRIZIO\demo_wls\oracle_common\common\bin\config.cmd  

    --- [04] ---
    Start the Admin Server:
    c:\FABRIZIO\demo_wls\user_projects\domains\base_domain\startWebLogic.cmd 

    Open the WLS Console:
     http://IP_Machine_A:7001/console

    Create a Cluster with 2 Managed Server (ManagedServer_on_A , ManagedServer_on_B)
    (If you prefer you can create the cluster during the creation of the domain)

    --- [05] ---
    Stop the AdminServer and verify that there are no Active Servers and no JVM running in your Domain.

    Now we must create a compressed copy of the Domain ("base_domain") that you have created on Machine_A, transfer and uncompress  it on Machine_B.

    To do this you must:

    Execute the PACK command on Machine_A with the following parameters:
    c:\FABRIZIO\demo_wls\oracle_common\common\bin\pack.cmd  
     -managed=true  
     -domain=c:\FABRIZIO\demo_wls\user_projects\domains\base_domain  
     -template=c:\FABRIZIO\demo_wls\user_projects\domains\basedomain_managed.jar  
     -template_name="MyBaseDomain"  

    The complete command is:
    pack -managed=true -domain=c:\FABRIZIO\demo_wls\user_projects\domains\base_domain -template=c:\FABRIZIO\demo_wls\user_projects\domains\basedomain_managed.jar -template_name="MyBaseDomain" 

    The result of this command is the creation of the file:
    basedomain_managed.jar
    under the directory on Machine_A:
    c:\FABRIZIO\demo_wls\user_projects\domains

    Now transfer the file basedomain_managed.jar on Machine_B under the directory:
    c:\FABRIZIO\demo_wls\user_projects\domains
    (you need to create the directories "user_projects" and "domains")

    Execute the UNPACK command on Machine_B with the following parameters:
    c:\FABRIZIO\demo_wls\oracle_common\common\bin\unpack.cmd  
     -domain=c:\FABRIZIO\demo_wls\user_projects\domains\base_domain  
     -template=c:\FABRIZIO\demo_wls\user_projects\domains\basedomain_managed.jar  

    The complete command is:
    unpack -domain=c:\FABRIZIO\demo_wls\user_projects\domains\base_domain -template=c:\FABRIZIO\demo_wls\user_projects\domains\basedomain_managed.jar  

    The result of this command is the creation, on Machine_B, of a new Domain (in my case "base_domain") under the directory
    c:\FABRIZIO\demo_wls\user_projects\domains

    --- [06] ---
    Start AdminServer on Machine_A:
    c:\FABRIZIO\demo_wls\user_projects\domains\base_domain\startWebLogic.cmd  

    Wait until AdminServer is Running.

    Now we must start the 2 Managed Servers of the Cluster with the command:
    startManagedWebLogic.cmd SERVER_NAME {ADMIN_URL}  


    Start ManagedServer_on_A on Machine_A, to do this execute the command:
    c:\FABRIZIO\demo_wls\user_projects\domains\base_domain\bin\startManagedWebLogic.cmd ManagedServer_on_A http://IP_Machine_A:7001

    Start ManagedServer_on_B on Machine_B, to do this execute the command:
    c:\FABRIZIO\demo_wls\user_projects\domains\base_domain\bin\startManagedWebLogic.cmd ManagedServer_on_B http://IP_Machine_A:7001  

    --- [07] ---
    This is a procedure valid for all the versions of WLS, but starting from WLS 12.1.2, you do not need to execute the nmEnroll() command on WLST  to enroll the node manager:

    https://blogs.oracle.com/WebLogicServer/entry/new_node_manager_configuration_model
    • When you use the “pack” command with the “-managed=true” option, the configuration framework includes changes to the nodemanager.properties file in the template file.
    • When you use the “unpack” command on the remote host where you want to run your Managed Servers, the configuration framework sets up the domain, regenerates the nodemanager.properties file, generates a nodemanager.domains file (no need to run nmEnroll!), generates a DemoIdentity.jks keystore, and generates a startNodeManager script.

    venerdì 13 maggio 2016

    Oracle Rest Data Service & Oracle Cloud (Second Part): How to INSERT (POST) data with REST

    In the [FIRST] part you have learned how to create a REST Data Service in Oracle Database (in Cloud)

    We have create a SELECT (GET), now we will see how to create an INSERT (POST).

    You can use the "auto rest" (more info here) but with this you can do only simple insert, with primary key and only a "select * ..." if you would like to specialized your INSERT (or UPDATE or DELETE) you must do what I will explain in this post.

    We will create a Data Service that will insert a row in the "emp" table of the HR user:


    This is the configuration:
    Insert in the Source field your preferred insert:

    begin  
        insert into emp (empno,ename,job,hiredate,sal,deptno) values   
        (:empno,:ename,:job,:hiredate,:sal,:deptno);  
     end; 

    This is an example, you can write every kind of complex insert.


     Now you can test it, I suggest to use something like "Postman":

    use your url in the POST field:
    https://yourIP/ords/pdb1/mariniws/hr/emp/

    Set in the Headers tab:
    Content-Type: application/json



    Select the Body tab and put here the data to send:

     {  
      "empno":1234,  
      "ename":"Marini",  
      "job":"PRESIDENT",  
      "hiredate":"2003-02-01T08:00:00Z",  
      "sal":5000,  
      "deptno":10  
     }  

    Click the "Send" button:
    If all It is ok, you will receive a Status 200 OK


    If you refresh SQL Developer you can find the new row:




    giovedì 12 maggio 2016

    Oracle Rest Data Service & Oracle Cloud (First Part): how to expose your data with REST in a very simple and fast way

    In this post I'll present ORDS (Oracle Rest Data Services) we will work on Oracle Cloud, but if you are interested in It you can download ORDS and install It on premise, you can find HERE all the informations.

    In Oracle Database Cloud Service, ORDS is already installed and running and it is very simple to create a Rest Data Service using as starting point a table tha already exist in the Database.

    In this example I'll use the EMPLOYEE table under the HR user:

    (some images captured from my SQL Developer connected to my Oracle Database Cloud Service )



    I'll cretae a REST service that is able to receive in the URL the employee_id, execute the query "select * from employees where employee_id = : employee_id" and that return a JSON object.

    To be able to create the Rest Data Service we will use the APEX (Application Express) console from the Oracle Database Cloud Service, this console respond in HTTPS so we need to open that protocol and port from the Oracle Cloud Compute Node:

    Connect to your Oracle Database Cloud Service and select Oracle Compute Cloud Service:


    Select Network and enable https for the DB service:


    Now return in your Oracle DBCS and open the APEX console:


    The first time you need to use the following information to connect as Administartor:
    INTERNAL
    ADMIN
    your ADMIN password (the one that you use also in SQL Developer to connect)


    As ADMIN you can create now a workspace where you can create all the Rest Data Services that you need, so click on "Create Workspace":


    Choose a name for your workspace (this will appear in the Rest URL).
    Click the Next Button:


    I'll use an existing schema and table , so I have selected YES on the field "Re-use existing schema?", then click on the field "Schema Name" to choose which table expose via REST:


    a popup will appear with the existing tables names, choose your one:


    Click the Next button:


    Choose an Admin username & password.
    Click on the Next button:


    Review all the inserted data then click on the "Create Workspace" button:


    Your workspace is created, click on "Done" button:


    Logout from the console:


    Now you can login in your new workspace with your new credentials:


    Use the name of your new workspace, the new ADMIN and PASSWORD:


    After the first login in the new workspace you must change the password:


    Choose a new password then click on "Apply Changes":


    Now select "SQL Workshop", here we can create REST Data Services:


    Select "RESTful Services":


    Click on the "Create" button:


    Choose a Name for your REST Data Service, this will appear in the console, Choose an URI Prefix, this will appear in the REST URL:

    Name: hr
    URI Prefix: hr/

    Choose an URI Template, this will appear in the REST URL, if you whant to pass parameter use {}

    URI Template: employees/{employee_id}

    Example, the REST URL:
    https://myIP/ords/pdb1/mariniws/hr/employees/101
    will return a JSON with the resul of the query:
    "select * from employees where employee_id = : employee_id

    Scroll down the page:


    Select:
    GET as Method
    Source Type=Query
    Format=JSON

    Insert you Query in the Source field:
    select * from employees where employee_id = : employee_id

    Click on Create Module:


    You have created your REST Data Service.
    To test It click on the GET link on the left panel:


    Scroll down the page and click on the "Set Bind Variables" button:


    Put 101 in the EMPLOYEE_ID field and then click on the Test button:


    You will receive a popup with the JSON response:

    I have installed the "JSONView" plugin for Chrome to have a readable answer:


    This is the JSONView plugin.


    As soon as possible I'll write some example of code on how to call those kind of Rest data Services from Java and Node.js.