To Get Forms Runtime Diagnostics also know as FRD logs

 ######Tracing And Logging For Forms In Oracle Applications [ID 438652.1]######

How to check Forms are Implemented in socket mode or servlet mode. 

==================================================

 1. R12.1 Forms can be implemented in servlet mode or socket mode. Check file $FORMS_WEB_CONFIG_FILE (or $INST_TOP/ora/10.1.2/forms/server/appsweb.cfg) to find which mode forms runs:


In Servlet mode:
serverURL=/forms/lservlet
connectMode=servlet    

In Socket mode:
serverURL=(should be blank)
connectMode=Socket

This can be also verified by Profile option "ICX: Forms Launcher" value https://hostname.domain:port/forms/frmservlet on site level.

How To Enable FRD logs?

1: Obtain FRD Trace Using Appsweb.cfg
2: Obtain FRD Trace Using Profile Options
3: Obtain FRD in an ADHOC way

1) To enable FRD on Site level:
In appsweb.cfg, set "record=collect" as shown below (under ENVIRONMENT SPECIFIC PARAMETERS section)

# Sub argument for other params
record=collect

also can specify the log name
log=site1.log 

2) To enable FRD on User level:
Change Profile option "ICX: Forms Launcher" on user level to https://hostname.domain:port/forms/frmservlet?record=collect

Then, launch forms after logging onto EBS (usually without any services downtime, but may need to bounce Apache or clear cache). Forms shall popup a note "Forms Runtime Diagnostics is enabled, Please note this can affect performance." before forms shows up.

By default, trace file collect_<pid> gets written in folder $FORMS_TRACE_DIR, where <pid> is the process identifier.  "grep" the pid to find which os process created it.

Optionally, in appsweb.cfgs, specify the log name
log=user1.log
(Note: Log file site1.log or user1.log will be saved in folder $FORMS_TRACE_DIR. This folder may need manually cleaning from time to time.)

3) Enabling FRD (in R12.1) by URL https://hostname.domain:port/forms/frmservlet?record=collect ( or https://hostname.domain:port/forms/frmservlet?record=collect+log=user1.log )
Enter EBS userID/password to access forms directly. But it may give error:
APP-FND-01542: This Applications Server is not authorized to access this database.

To get this working, modify current context file by changing “s_appserverid_authentication” value from SECURE to OFF. Then shutdown apps and run Autoconfig.

3. When QA uses Vugen 12 for scripting and uses HP Performance Center (PC) 12 to run the scripts to test EBS R12.1.3 site performance, I was asked to change Profile option "ICX: Forms Launcher" on user level from https://hostname.domain:port/forms/frmservlet to
https://hostname.domain:port/forms/frmservlet?play=&record=names

I did not know what that profile value really does. But after the change, performance testing worked by PC 12 for our QA.

NOTES:  For JWS, do NOT use Method 2 of Option 1 in Doc ID 438652.1 or follow Doc ID 373548.1 (How To Collect And Use Forms Trace (FRD) in Oracle Applications Release 12) to enable FRD by setting up profile option Forms Runtime Parameters to "record=forms tracegroup=0-97". It will give error "FRM-90926: Duplicate Parameter on Command Line" without launching forms.


OUTPUT
=======
When a form is run with FRD enabled, a combination of external user-application interactions and internal Forms processing events are written in chronological order to a log file. These events can be analyzed to determine user actions and corresponding system responses, which aid in problem diagnosis and issue resolution. Kindly refer below display for a brief extract from a frd log file.


Extracts from a frd log file :

File Name: /oracle1/PROD/inst/apps/PROD_vkaria/logs/ora/10.1.2/forms/collect_32188
Process ID: 22334
Client IP: 141.19.111.99
Forms 10.1 (Forms Runtime) Version 10.1.2.0.2 (Production)
PL/SQL Version 10.1.0.5.0 (Production)
Oracle Virtual Graphics System Version 10.1.2.0.0 (Production)
Oracle Multimedia Version 10.1.2.0.2 (Production)
Oracle Tools Integration Version 10.1.2.0.2 (Production)
Oracle Tools Common Area Version 10.1.2.0.2
Oracle CORE 10.1.0.4.0 Production


Opened file: /oracle1/PROD/apps/apps_st/appl/fnd/12.0.0/forms/US/FNDSCSGN.fmx

ON-LOGON Trigger Fired:
Form: FNDSCSGN

State Delta:
FNDSCSGN, 1, Trigger, Entry, 2016355936, ON-LOGON

FNDSCSGN, 2, Prog Unit, Entry, 2017421936, /FNDSCSGN-1/P53_04_JAN_200703_41_43

FNDSCSGN, 3, Prog Unit, Entry, 2018075936, /FNDSCSGN-1/DO_LOGON


Executing DEFAULT_VALUE Built-in:
In Argument 0 - Type: String Value: NULL
In Argument 1 - Type: String Value: GLOBAL.FNDSCSGN_UNAME

Executing GET_APPLICATION_PROPERTY Built-in:
In Argument 0 - Type: Number Value: 73
Out Argument 0 - Type: String Value: NULL

Note:http://appsdbastuff.blogspot.com/2010/04/forms-runtime-diagnostics-frd-tracing.html

Multiple-opatch-automation

########################SCRIPT TO APPLY MULTIPLE OPATCHES################################
P=/testappl/APRILCPU2020/DB/SR_Patches
export P 
for Patch in 21321429 20123899 28682351 25139545 30216977 21967332 25099339 23604553 31179008 30614876
do 
cd $P/$Patch 
$ORACLE_HOME/OPatch/opatch apply -silent -local 
done 

multiple-dir-rename

for DIR in   xxxx09   xxxx10   xxxx11   xxxx14   
do
cd /$DIR
mv -i PRODUTION DEV
done

INVALID-BACKUP-AUTOMATION

#################SCRIPT FOR AUTOMATIC INVALID TABLE BACKUP###########

#!/usr/bin/bash
##rm pcount.log
##rm qcount.log
t=`date +"%Y%m%d%H%M%S"`
p="invalids$t"
pcount="pcount.$t"
qcount="qcount.$t"
a=`grep -o '[0-9]\+' pcount.log|sed -n 1p`
b=`grep -o '[0-9]\+' qcount.log|sed -n 1p`
sqlplus -s "/ as sysdba"  << EOF
create table $p as select * from dba_objects where status like 'INVALID';
spool pcount.log
select count (*) from $p;
exit;
EOF
sqlplus -s "/ as sysdba" << EOF
spool qcount.log
select count(*) from dba_objects where status like 'INVALID';
exit;
EOF
if [ $a == $b ]
then
echo "#########****INVALID TABLE BACKUP HAS BEEN TAKEN SUCESSFULLY****#######"
echo       "INVALID-BACKUP-TABLENAME:           $p"
echo       "INVALID-BACKUP-TABLECOUNT:          $a"
echo       "ACUTAL-INVALID-TABLE-COUNT:         $b"
else
sqlplus -s "/ as sysdba"  << EOF
spool drp.txt
drop table $p;
spool off;
exit;
EOF
echo "There is an issue with taking automated backup so please check and take the invalid count manually"
fi

NODE MANAGER INSTALL/CONFIG IN WEBLOGIC


***********Uninstall / Reinstall NodeManager Service on WINDOWS***

This needs to be done if you installed Node Manager with the standard installer because by default Node Manager binds to localhost. So as more OS instances are added, it will be required to have Node Manager instances on the network communicate to each other. This can only happen if Node Manager binds to an network interface that is available remotely.

open cmd prompt
run D:\Oracle\wls11g\wlserver_10.3\server\bin\setWLSEnv.cmd
run D:\Oracle\wls11g\wlserver_10.3\server\bin\uninstallNodeMgrSvc.cmd
Make backup copy of installNodeMgrSvc.cmd
edit installNodeMgrSvc.cmd to bind to hostname for remote starts
set NODEMGR_HOST=jbayer-us
run D:\Oracle\wls11g\wlserver_10.3\server\bin\installNodeMgrSvc.cmd
start the service – mine is called “Oracle WebLogic NodeManager…” but on older versions it’s likely will start with “BEA …”
starting the NodeManager process should create the nodemanager.properties file we will edit next
CrashRecovery and StartupScriptEnabled (updated 01/10/2010)
We want to Enable NodeManager to restore servers to their last known state after a reboot.
Open nodemanager.properties from the directory D:\Oracle\wls11g\wlserver_10.3\common\nodemanager\
Change the CrashRecoveryEnabled property from false to true:
CrashRecoveryEnabled=true
Also, because the domain’s \bin\startWebLogic script already has classpath configured, which is especially helpful for use with SmartUpdate that manages WebLogic patches as those classpath’s are not trivial to understand, I strongly recommend setting StartupScriptEnabled=true StartScriptEnabled=true in nodemanager.properties (Thanks to Ray T for the typo fix 6/29/10)
stop/start node manager after making changes to nodemanager.properties
Set up the Machines
Go to the domain's AdminServer console
http://localhost:7001/console
If you need to start it, run \bin\startWebLogic.cmd
With the console navigate to -> Environment -> Machines
Create a new machine – I named mine after the hostname of the server - jbayer-us
If you have more than one OS instance, create one machine for each.
nm_machines

In console go to -> Environment -> Servers
Create a new server, example: managedServer1
Put in the listen address to the hostname you want to bind to, in my case jbayer-us
Change the port to 8001or another available port so as not to conflict with the 7001 port of the AdminServer
Assign managedServer1 it to the jbayer-us machine you just created - -> Enviornment -> Servers -> managedServer1
There should be a dropdown you can use to select the machine
Click the save button on this settings page (don't forget this step)
Now activate changes if required
We need to assign the machine for the AdminServer, this cannot be done while the AdminServer is running.

Stop AdminServer
Open the domain config, example - D:\Oracle\wls11g\user_projects\domains\my_domain\config\config.xml
Find the element used to assign the machine for managedServer1
jbayer-us
Copy that and paste that element right after the AdminServer element
If it is not already set, also specify the AdminServer listen address to be the hostname to bind to, by default it is blank which means bind to all network interfaces.
After these changes my config.xml snippet for the AdminServer looks like this:


AdminServer

jbayer-us

jbayer-us



Start the AdminServer again with the domain directory’s bin\startWebLogic.cmd
Check the console page -> Environment -> Servers to see that the servers are defined correctly as expected

Enroll the domain with Node Manager (updated 01/10/2010)
Navigate with a command prompt go to the domain directory
run bin\setDomainEnv.cmd
run java weblogic.WLST
connect to the AdminServer with your credentials:
connect('weblogic','welcome1','t3://jbayer-us:7001')
Make sure you use forward slashes instead of backslashes in Windows:
nmEnroll(domainDir='D:/Oracle/wls11g/user_projects/domains/my_domain',nmHome='D:/Oracle/wls11g/wlserver_10.3/common/nodemanager')
Now go back to the web console - http://localhost:7001, for each server in the environment, go to the server start tab and put in the appropriate values.
serverStartTabIf you are using StartScriptEnabled=true in nodemanager.properties, then the classpath and jvm arguments from the script will be used first and the values you specify on the Server Startup tab will get added to the end, so you only need to enter values that are unique to each server in the classpath and arguments section.
If you’re using Sun JDK instead of JRockit, then use –Xrs instead of –Xnohup refer to the official docs for more on this, but it has to do with handling OS signals properly.
7-2-10 update: Reader Ray T writes in with another tip:
“After some testing: starting, stopping servers, killing processes, rebooting etc after the configuration, I also found that I could not get the managed servers to shutdown cleanly - or at least the console would not recognize that they had. This had the added side effect of then not letting me start/restart a managed server via the console.

I found that also adding StopScriptEnabled=true solved that final problem.”



Click the image to enlarge – actual text values below:

Java Home

D:\Oracle\wls11g\jrockit_160_14_R27.6.5-32

Java Vendor

Oracle

BEA Home

D:\Oracle\wls11g

Root Directory

D:\Oracle\wls11g\user_projects\domains\my_domain

Classpath is empty as the script values are sufficient

Arguments

-Xnohup

Security Policy File

D:\Oracle\wls11g\wlserver_10.3\server\lib\weblogic.policy

User Name

weblogic

Password

welcome1

Confirm Password

welcome1

Save
Now do the same thing for each managed server.
Activate the changes if required

Node Manager Domain Username and Password
Set the Node Manager username/password for the domain in the console
Click in the console navigator
Select Security tab
Expand to the "Advanced" options about half-way down the page
Choose a Node Manager username/password and put it in the username/password/confirm boxes your credentials, these could be unique from your user used to start the AdminServer, but I chose to keep mine the same weblogic/welcome1.  If you change this user name and password, then you’ll need to specify both when using the command nmConnect().  Thanks Ray T for the catch - 6/29/10.

Decrease Log Verbosity For Standard OutnmCriticalLogSetting
In console, go to each server's Logging -> General page
Expand to the Advanced section half-way down the page
Change the standard out notice level to "Critical"
This log file that captures Standard Out does not roll over while a server is running, so it's really important to make sure this file doesn't get too large. Note that this is not the server log file, this is only standard out.



Have NodeManager Start and Stop the Servers
If it is running, shutdown the AdminServer
Start the AdminServer with NodeManager
Go to domain dir
run bin\setDomainEnv.cmd
run java weblogic.WLST
nmConnect(domainName='my_domain')  nmConnect(domainName=’my_domain’, username=’weblogic’, password=’welcome1’)  6/29/10 Updated thanks to Ray T who noticed that if you change the domain’s Node Manager user and password in the section above called “Node Manager Username and Password” that you’ll need to specify those values here otherwise the defaults of weblogic/welcome1 are used, which worked in my case, but not for others.
nmStart('AdminServer')
Go to console -> Environment -> Servers control tab and start the managed server from the console. It will send a command to Node Manager which actually performs the operation on the console's behalf.
Gotcha! – If you have never started the managed server ever before and you try to start it from Node Manager, you might get an error.  In the server log it mjght say something like: Booting as admin server, but servername, managedServer1, does not match the admin server name, AdminServer  To get around this, simply start the Managed Server for the first time using either the Admin Console Servers->Control tab or the startManagedWebLogic.cmd script.  Subsequent nmStart commands should not have this issue any longer.

Test Killing and Restarting
If the servers are started successfully by Node Manager, try and kill a process from task manager and see if it restarts.

Looking at the Node Manager directory in the domain for each Managed Server, you will be able to see the state - below is a screenshot of managedServer1's files. The PID and .state files should tell you what you need to know to see if the server recovered.  If it did not, the .out file in the server log directory should hopefully give you a clue why.

nmDir

If manual killing of the process restarts a Server then you are ready to test an operating system reboot. Reboot the machine without stopping the WebLogic Servers. Each server should be restored to the state that it was in when the OS was rebooted.

How to Enroll a Node Manager in weblogic?
========================================================================
Applies to:
Weblogic: 10.3.6 and later
========================================================================
nmEnroll is used to enroll a machine or a domain with the node manager.
Few of us may forget to configure NodeManager after installing Weblogic server. Follow below steps to enroll nodemanager manually in weblogic.
1. Create a Machine:
     • Login to weblogic console
     • Click on Lock & Edit button in change center.
     • Go to Environment -> Machines -> click New
     • Provide name and select machine OS
     • Click Next
     • Select type, provide host and port details for node manager and click Finish
     • Click Activate Changes.

2. Configure node manager username and password:
     • Login to weblogic console and take lock & edit.
     • Under domain Structure click on domain_name on left hand side.
     • Go to security tab and click on Advanced.
     • Configure/update NodeManager Username and password.
     • Click save and click Active Changes.

3. Enroll Node Manager:
     • Make sure admin server is up and running.
     • Login to host
     • Go to $ORACLE_HOME/oracle_common/common/bin and run ./wlst.sh
     • Use Connect command to connect to admin server
        connect('','','t3://:')
     • Run nmEnroll
        nmEnroll('', '')
        E.g.
        nmEnroll('/u01/Oracle/Middleware/user_projects/domains/base_domain',                '/u01/Oracle/Middleware/wlserver_10.3/common/nodemanager')
     • Once it is Successfully enrolled to machine with the domain directory check
        $WL_Home/common/nodemanager/nodemanager.domains file. It should have domain entry.
     • Set StartScriptEnabled=true and StopScriptEnabled=true in $WL_Home/common/nodemanager/nodemanager.properties file.
     • Restart the nodemanager and check the status in weblogic console if it is in active status or not.
     • Go to Environment -> Machines -> Click on Machine name
     • Go to Monitoring tab and verify Node Manager Status


Note 1 -

If you are getting below error during connect with node manager, then it means you haven't changed username,password for nodemanager from admin console ( above step 6 )

WLSTException: Error occured while performing nmConnect : Cannot connect to Node Manager. : Access to domain 'base_domain' for user 'weblogic' denied

Note 2 -

If you are getting below error during connect of node manager then it mean you haven't followed above defined steps OR haven't added your domain on nodemanager.domains


WLSTException: Error occured while performing nmConnect : Cannot connect to Node Manager. : Configuration error while reading domain directory

OPENVPN AS BASTON HOST IN AWS

ref:https://www.freecodecamp.org/news/how-you-can-use-openvpn-to-safely-access-private-aws-resources-f904cd24f890/


STEPS:
Create Linux server(ec2) as a private node
Create Openvpn server along with adding the linux server subnet id rannge in Security group
Once your openvpn server is ready then you can able to ssh from openvpn to your linux server




automation-healthcheck

Problem for automation

[user@server lk]$ CONCSUB apps/passwordofuser SYSADMIN 'System Administrator' SYSADMIN WAIT=N CONCURRENT FND FNDSCURS > req.txt
[user@server lk]$ cat req.txt
Submitted request 4632124 for CONCURRENT FND FNDSCURS

[user@server lk]$ awk '{print $3}' req.txt
4632124


SQL> SQL> Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[user@server lk]$ CONCSUB apps/passwordofuser SYSADMIN 'System Administrator' SYSADMIN WAIT=N CONCURRENT FND FNDSCURS > req.txt
[user@server lk]$ > req.txt
[user@server lk]$ cat req.txt
[user@server lk]$ CONCSUB apps/passwordofuser SYSADMIN 'System Administrator' SYSADMIN WAIT=N CONCURRENT FND FNDSCURS > req.txt
[user@server lk]$ cat req.txt
Submitted request 4632126 for CONCURRENT FND FNDSCURS

[user@server lk]$ sqlplus apps/passwordofuser << EOF
> spool healthcheck.txt
> set lines 300
> select a.user_concurrent_program_name , a.CONCURRENT_PROGRAM_ID , REQUEST_ID
> ,REQUEST_TYPE,PHASE_CODE  , STATUS_CODE , ACTUAL_START_DATE ,COMPLETION_TEXT
> from fnd_concurrent_programs_tl a, fnd_concurrent_requests b
> where a.concurrent_program_id=b.concurrent_program_id
> and program_application_id=0
> and REQUEST_ID=4632126;
> spool off;
> exit;
> EOF

SQL*Plus: Release 8.0.6.0.0 - Production on Wed Apr 1 07:41:10 2020

(c) Copyright 1999 Oracle Corporation.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> SQL> SQL>   2    3    4    5    6
USER_CONCURRENT_PROGRAM_NAME                                                                                                               CONCURRENT_PROGRAM_ID REQUEST_ID R P S ACTUAL_ST
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ --------------------- ---------- - - - ---------
COMPLETION_TEXT
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Active Users                                                                                                                               20641     4632126   C C 01-APR-20
Normal Running


***After few minits--we dont estimate the time***

SQL> SQL> SQL>   2    3    4    5    6
USER_CONCURRENT_PROGRAM_NAME                                                                                                               CONCURRENT_PROGRAM_ID REQUEST_ID R P S ACTUAL_ST
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ --------------------- ---------- - - - ---------
COMPLETION_TEXT
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Active Users                                                                                                                               20641     4632126   C C 01-APR-20
Normal completion


when it get the status like completion then we need to conculde that reqeust has been completed and application is running fine




########################SOLUTION IS #######healthcheck report for oracle apps

#!/bin/sh
username=$1;
password=$2;
> req.txt;
> healthcheck.txt;
sd=`echo $TWO_TASK`
CONCSUB $1/$2 SYSADMIN 'System Administrator' SYSADMIN WAIT=N CONCURRENT FND FNDSCURS > req.txt
requid=`awk '{print $3}' req.txt`
echo $requid;
sqlplus $1/$2 << EOF
spool healthcheck.txt
set lines 300
select a.user_concurrent_program_name , a.CONCURRENT_PROGRAM_ID , REQUEST_ID
,REQUEST_TYPE,PHASE_CODE  , STATUS_CODE , ACTUAL_START_DATE ,COMPLETION_TEXT
from fnd_concurrent_programs_tl a, fnd_concurrent_requests b
where a.concurrent_program_id=b.concurrent_program_id
and program_application_id=0
and REQUEST_ID=$requid;
spool off;
exit;
EOF
####REQSTATUS####
a=`cat healthcheck.txt|grep Normal|wc -l`
while [ $a -le 1 ]
do
> healthcheck.txt
echo "$requid is running"
sleep 2
sqlplus $1/$2 << EOF
spool healthcheck.txt
set lines 300
select a.user_concurrent_program_name , a.CONCURRENT_PROGRAM_ID , REQUEST_ID
,REQUEST_TYPE,PHASE_CODE  , STATUS_CODE , ACTUAL_START_DATE ,COMPLETION_TEXT
from fnd_concurrent_programs_tl a, fnd_concurrent_requests b
where a.concurrent_program_id=b.concurrent_program_id
and program_application_id=0
and REQUEST_ID=$requid;
spool off;
exit;
EOF
a=`cat healthcheck.txt|grep Normal|wc -l`
done
rm -rf healthcheck.txt
>outfile.txt
echo REQUESTID=$requid > outfile.txt
echo PROGRAMNAME="Active users" >>outfile.txt
echo STATUS="COMPLETED" >> outfile.txt
echo PHASE="NORMAL" >> outfile.txt
###DBSTATUS#####
###spool DB.txt
sqlplus $1/$2 << EOF
spool DB.txt
conn $1/$2
select * from global_name;
spool off;
exit;
EOF
b=`cat DB.txt|grep Connected|wc -l`
if [$b -ge 1 ]
then
rm -rf DB.txt
echo DATABASENAME=$sd >> outfile.txt
echo DBSTATUS="UP AND RUNNING" >> outfile.txt
fi
########APACHE STATUS#############
as=`pwd`
rm -rf apache.txt
cd $COMMON_TOP/admin/scripts/$TWO_TASK*
rm -rf apache.txt
sh adapcctl.sh status > apache.txt
chmod -R 777 apache.txt
cp -r apache.txt $as
cd $as
p=`cat apache.txt|grep not|wc -l`
if [$p -ge 1 ]
then
echo APACHESTATUS="APACHE IS NOT RUNNING"  >> outfile.txt
else
echo APACHESTATUS="APACHE IS UP AND  RUNNING" >> outfile.txt
fi






GIT/tree installation by chef cookbook

Install git and tree by using chef cook book

Note:yum/apt-get are resources in chef


first need to deploy server or use the chef server online create account(only for less than 5 nodes)

download chef repo after adding organization details






Then go to chef-repo and create cook book using the below commands(CMD PROMPT)

C:\Users\admin>cd C:\Users\admin\Desktop\chef-repo\cookbooks

C:\Users\admin\Desktop\chef-repo\cookbooks>chef generate cookbook linuxyum -b
C:/opscode/chefdk/embedded/lib/ruby/gems/2.6.0/gems/ffi-1.12.1-x64-mingw32/lib/ffi/struct.rb:207:in `layout': [DEPRECATION] Struct layout is already d
efined for class Windows::ServiceStructs::SERVICE_STATUS_PROCESS. Redefinition as in C:/opscode/chefdk/embedded/lib/ruby/gems/2.6.0/gems/win32-service
-2.1.4/lib/win32/windows/structs.rb:72:in `' will be disallowed in ffi-2.0. (StructuredWarnings::StandardWarning)
Generating cookbook linuxyum
- Ensuring correct cookbook content

Your cookbook is ready. Type `cd linuxyum` to enter it.

There are several commands you can run to get started locally developing and testing your cookbook.
Type `delivery local --help` to see a full list of local testing commands.

Why not start by writing an InSpec test? Tests for the default recipe are stored at:

test/integration/default/default_test.rb

If you'd prefer to dive right in, the default recipe can be found at:

recipes/default.rb






then save this file and upload to chef server by using the berks

C:\Users\admin\Desktop\chef-repo\cookbooks>berks install
No Berksfile or Berksfile.lock found at 'C:/Users/admin/Desktop/chef-repo/cookbooks'!

C:\Users\admin\Desktop\chef-repo\cookbooks>ls
TESTINGFIRSTPROJECT  chefignore  linuxyum  starter

C:\Users\admin\Desktop\chef-repo\cookbooks>cd li*

C:\Users\admin\Desktop\chef-repo\cookbooks\linuxyum>berks install
Resolving cookbook dependencies...
Fetching 'linuxyum' from source at .
Fetching cookbook index from https://supermarket.chef.io...
Using linuxyum (0.1.0) from source at .

C:\Users\admin\Desktop\chef-repo\cookbooks\linuxyum>berks upload
Uploaded linuxyum (0.1.0) to: 'https://api.chef.io/organizations/genpacts'

C:\Users\admin\Desktop\chef-repo\cookbooks\linuxyum>



Check  the cook book is uploaded in chef server then create runlist for the node(linux node)


After that we have to wait for convergence(default is 30mts),i dont want to wait and wanted to run the runlist manually

For that login to linux server and fire the below command

[ec2-user@ip-172-31-35-150 ~]$ sudo chef-client
Starting Chef Infra Client, version 15.8.23
resolving cookbooks for run list: ["linuxyum"]
Synchronizing Cookbooks:
  - linuxyum (0.1.0)
Installing Cookbook Gems:
Compiling Cookbooks...
Converging 2 resources
Recipe: linuxyum::default
  * yum_package[git] action install
    - install version 0:2.23.1-1.amzn2.0.1.x86_64 of package git
  * yum_package[tree] action install
    - install version 0:1.6.0-10.amzn2.0.1.x86_64 of package tree

Running handlers:
Running handlers complete
Chef Infra Client finished, 2/2 resources updated in 17 seconds
[ec2-user@ip-172-31-35-150 ~]$







REDIS WITH PHP APPLICATION

Story

A website/application has own challenges even it is successed, when it touches high number of users.
similarly we faced one issue that an application is reciving huge users at few times but not all times.
obviously we planned  application much more reliable and consistent. If the term scalability crossed your mind, you've got the right idea.

scalability is the ability of a system to handle an increased amount of traffic or processing and accommodate growth while maintaining a desirable user experience.
There are basically two ways of scaling a system: vertically, also known as scaling up,(increasing system configuration with memory and hard disk i can say)
and horizontally, also known as scaling out.(just deploying another server to share the exisitng load)

vertically scaling has no issue but it has it own challenges like only mem or infra will be changed its not suitable for all scenarios.

we have problem here when we do harizonal scaling

When user A makes a request to mydomain.com, the load balancer will forward requests to server1. User B, on the other hand, gets forwarded another node from the cluster, server2.

What happens when user A makes changes to the application, like uploading files or updating content in the database? How do you maintain consistency across all nodes in the cluster? Further, PHP saves session information in disk by default. If user A logs in, how can we keep that user's session in subsequent requests, considering that the load balancer could send them to another server in the cluster?

Need to maintain user session in common storage devise then only it can have more accessability


****************REDIS IS SOLUTION FOR THIS********

Redis.
Redis is an in-memory data structure store, used as a database, cache and message broker. It stores data in key-value which gives Redis more flexibility and performance.

Prerequisites
Before we start this tutorial you need to have complete access to your server we need to install Redis server and also add some required PHP extension.

Installing and configure Redis
Step 1. Login to your server via terminal or putty if you are using the window.



Step 2. Once login successfully runs bellow commands.

sudo apt update
sudo apt install redis-server
Step 3. Check if Redis is installed successfully using below command

sudo systemctl status redis
Configure Redis sever with PHP
Step 4. Now we can check Redis server is functioning correctly, we can use redis-cli, Redis CLI is a command-line tool for Redis.

redis-cli
Redis cache with PHP



Step 5. Now if you want to restart Redis server run this command

sudo systemctl restart redis
Or, if you want to clear Redis cache you can run this command

redis-cli flushall
Configure Redis for PHP extension
To use Redis with your PHP application we need an extension that connects PHP with Redis to do that we need to run below command.

sudo pecl install redis
sudo apt-get install php-redis
After this, we need to restart our PHP using below command

sudo service php7.0-fpm restart
Now once your PHP restarts you are ready to use the Redis server.


***first method to add cache as redis***

ubuntu@ip-172-31-37-25:/etc/php/7.2/cli$ pwd
/etc/php/7.2/cli
ubuntu@ip-172-31-37-25:/etc/php/7.2/cli$ grep  session.save_handler php.ini
session.save_handler = files
ubuntu@ip-172-31-37-25:/etc/php/7.2/cli$ ###MAKE THIS ENTRY AS redis###
ubuntu@ip-172-31-37-25:/etc/php/7.2/cli$ session.save_handler = redis
session.save_handler: command not found
ubuntu@ip-172-31-37-25:/etc/php/7.2/cli$ grep session.save_path php.ini
;     session.save_path = "N;/path"
;     session.save_path = "N;MODE;/path"
;session.save_path = "/var/lib/php/sessions"
;       (see session.save_path above), then garbage collection does *not*
ubuntu@ip-172-31-37-25:/etc/php/7.2/cli$ hostname
ip-172-31-37-25




****second method to add cache as REDIS***
Add Redis as Cache in LAVAPHP 3 Application
If you want to use Redis as a cache for your LAVAPHP 3 Application you update your cache setting in config/app.php and update your cache setting with this

'Cache' => [
        'default' => [
            'className' => 'Redis',
            'path' => CACHE,
            'password' => false,
            'server' => '127.0.0.1',
            'port' => 6379,
        ],
        '_cake_core_' => [
            'className' => 'Redis',
            'prefix' => 'cake_redis_core_',
            'path' => CACHE . 'persistent/',
            'serialize' => true,
            'duration' => '+1 years',
            'server' => '127.0.0.1',
            'port' => 6379,
            'password' => false,
        ],
        '_cake_model_' => [
            'className' => 'Redis',
            'prefix' => 'cake_redis_model_',
            'path' => CACHE . 'models/',
            'serialize' => true,
            'duration' => '+1 years',
            'server' => '127.0.0.1',
            'port' => 6379,
            'password' => false,
        ],
    ],






REDIS CLUSTER - AWS

https://aws.amazon.com/getting-started/tutorials/setting-up-a-redis-cluster-with-amazon-elasticache/

After creation of REDIS cluster from elastic cache using the above link

Checklist screen shots for take check points and validated cpu utilization on master and slave nodes of Redis cluster.












TESTING REDIS ENDPONTS WITH MASTER AND SLAVE

[ec2-user@ip-172-31-34-239 redis-stable]$ ./src/redis-cli -c -h elc-tutorial.0p8iyu.clustercfg.aps1.cache.amazonaws.com:6379
Could not connect to Redis at elc-tutorial.0p8iyu.clustercfg.aps1.cache.amazonaws.com:6379:6379: Name or service not known
not connected> exit
[ec2-user@ip-172-31-34-239 redis-stable]$ ./src/redis-cli -c -h elc-tutorial.0p8iyu.clustercfg.aps1.cache.amazonaws.com -p 6379
elc-tutorial.0p8iyu.clustercfg.aps1.cache.amazonaws.com:6379> ping
PONG
elc-tutorial.0p8iyu.clustercfg.aps1.cache.amazonaws.com:6379> kufle
(error) ERR unknown command `kufle`, with args beginning with:
elc-tutorial.0p8iyu.clustercfg.aps1.cache.amazonaws.com:6379> ROLE
1) "master"
2) (integer) 114957
3) 1) 1) "10.9.2.61"
      2) "6379"
      3) "114957"
   2) 1) "10.9.2.46"
      2) "6379"
      3) "114957"
elc-tutorial.0p8iyu.clustercfg.aps1.cache.amazonaws.com:6379> exit
[ec2-user@ip-172-31-34-239 redis-stable]$ ./src/redis-cli -c -h elc-tutorial-0001-001.0p8iyu.0001.aps1.cache.amazonaws.com -p 6379
elc-tutorial-0001-001.0p8iyu.0001.aps1.cache.amazonaws.com:6379> ping
PONG
elc-tutorial-0001-001.0p8iyu.0001.aps1.cache.amazonaws.com:6379> ROLE
1) "master"
2) (integer) 124576
3) 1) 1) "10.9.2.51"
      2) "6379"
      3) "124576"
   2) 1) "10.9.2.202"
      2) "6379"
      3) "124576"
elc-tutorial-0001-001.0p8iyu.0001.aps1.cache.amazonaws.com:6379> exit
[ec2-user@ip-172-31-34-239 redis-stable]$ ./src/redis-cli -c -h elc-tutorial-0001-002.0p8iyu.0001.aps1.cache.amazonaws.com  -p 6379
elc-tutorial-0001-002.0p8iyu.0001.aps1.cache.amazonaws.com:6379> ping
PONG
elc-tutorial-0001-002.0p8iyu.0001.aps1.cache.amazonaws.com:6379> role
1) "slave"
2) "10.9.2.191"
3) (integer) 6379
4) "connected"
5) (integer) 128158
elc-tutorial-0001-002.0p8iyu.0001.aps1.cache.amazonaws.com:6379> exit
[ec2-user@ip-172-31-34-239 redis-stable]$ elc-tutorial-0001-003.0p8iyu.0001.aps1.cache.amazonaws.com
-bash: elc-tutorial-0001-003.0p8iyu.0001.aps1.cache.amazonaws.com: command not found
[ec2-user@ip-172-31-34-239 redis-stable]$ ./src/redis-cli -c -h elc-tutorial-0001-003.0p8iyu.0001.aps1.cache.amazonaws.com  -p 6379
elc-tutorial-0001-003.0p8iyu.0001.aps1.cache.amazonaws.com:6379>
elc-tutorial-0001-003.0p8iyu.0001.aps1.cache.amazonaws.com:6379> ping
PONG
elc-tutorial-0001-003.0p8iyu.0001.aps1.cache.amazonaws.com:6379> role
1) "slave"
2) "10.9.2.191"
3) (integer) 6379
4) "connected"
5) (integer) 130931
elc-tutorial-0001-003.0p8iyu.0001.aps1.cache.amazonaws.com:6379>

Boto3 script for S3

After installing python and awscli then you need to install boto3 as well(using pip install boto3)

>>> #######SIMPLE PROGRAM TO CHECK S3 BUCKETS LIST#############
...
>>>
>>> import boto3
>>> import botocore
>>> s3=boto3.client('s3')
>>> response = s3.list_buckets()
>>> print(response)
{'ResponseMetadata': {'RequestId': 'ECB2CB36318CA7FE', 'HostId': 's6XyLpmSTIAfBFLIaxW4CbbtPSHFa4XLxeviPeYpzV+htEUPiiv+K0jGGEuciWKKxkiJEceJUgY=', 'HTTP
StatusCode': 200, 'HTTPHeaders': {'x-amz-id-2': 's6XyLpmSTIAfBFLIaxW4CbbtPSHFa4XLxeviPeYpzV+htEUPiiv+K0jGGEuciWKKxkiJEceJUgY=', 'x-amz-request-id': 'E
CB2CB36318CA7FE', 'date': 'Tue, 10 Mar 2020 19:21:30 GMT', 'content-type': 'application/xml', 'transfer-encoding': 'chunked', 'server': 'AmazonS3'}, '
RetryAttempts': 0}, 'Buckets': [{'Name': 'dfsddf', 'CreationDate': datetime.datetime(2020, 3, 10, 19, 7, 19, tzinfo=tzutc())}], 'Owner': {'ID': '91472
c2bf0b0b64b4e245a8fc89bfb6f042e150c9c64791eb28a53bfcc88ff91'}}



####SIMPLE PROGRAM TO CREATE S3 BUCKET###

s3.create_bucket(Bucket='lavakumars321uysdsdsd2a1',
                          CreateBucketConfiguration={
                              'LocationConstraint': 'ap-south-1'})

###AFTER ADDING RESPOSE WHEN WE CREATE S3####
>>>response = s3.list_buckets()
>>> s3.create_bucket(Bucket='lavakumars321uy2a1',
...                           CreateBucketConfiguration={
...                               'LocationConstraint': 'ap-south-1'})
{'ResponseMetadata': {'RequestId': 'EC3AC2A414ED721E', 'HostId': 'EDYRVnXDSnxlvUq1s4u+5s3+G7z5LUWqJzIM9cjjf4nFqZ3uuCA4H5jRW4km59aM09D1uW5y4BY=', 'HTTP
StatusCode': 200, 'HTTPHeaders': {'x-amz-id-2': 'EDYRVnXDSnxlvUq1s4u+5s3+G7z5LUWqJzIM9cjjf4nFqZ3uuCA4H5jRW4km59aM09D1uW5y4BY=', 'x-amz-request-id': 'E
C3AC2A414ED721E', 'date': 'Tue, 10 Mar 2020 19:39:11 GMT', 'location': 'http://lavakumars321uy2a1.s3.amazonaws.com/', 'content-length': '0', 'server':
 'AmazonS3'}, 'RetryAttempts': 0}, 'Location': 'http://lavakumars321uy2a1.s3.amazonaws.com/'}
>>>


####USING FUNCTION-->GIVING BUCKETNAME EXPLICITLY####
>>>import boto3
>>>s3=boto3.client('s3')
>>> def create_bucket(bucket_name):
...     return s3.create_bucket(Bucket=BUCKET_NAMES,
...                           CreateBucketConfiguration={
...                               'LocationConstraint': 'ap-south-1'})
...
>>> BUCKET_NAMES='kismathkiladi12k'
>>> create_bucket(BUCKET_NAMES)
{'ResponseMetadata': {'RequestId': 'FD1570B5569FDCA8', 'HostId': 'TaTv3ihPmLGaPwgrrpMdd1QkphBwoJ9jpeoOHe817CEbBrOCkV/0zBiapFZsQ6KHcFjLs8hlmKo=', 'HTTP
StatusCode': 200, 'HTTPHeaders': {'x-amz-id-2': 'TaTv3ihPmLGaPwgrrpMdd1QkphBwoJ9jpeoOHe817CEbBrOCkV/0zBiapFZsQ6KHcFjLs8hlmKo=', 'x-amz-request-id': 'F
D1570B5569FDCA8', 'date': 'Tue, 10 Mar 2020 20:46:54 GMT', 'location': 'http://kismathkiladi12k.s3.amazonaws.com/', 'content-length': '0', 'server': '
AmazonS3'}, 'RetryAttempts': 0}, 'Location': 'http://kismathkiladi12k.s3.amazonaws.com/'}
>>>

for output

>>> print(create_bucket)

x