recipes


person holding black pen and book near pink ceramic mug

Photo by rawpixel.com on Pexels.com
BEGIN  
FOR loop_counter IN 1..1000000 LOOP 
INSERT INTO "EVENTS" (EVENTID, "SOURCE", TYPE, EVENT_DATE, DESCRIPTION) 
VALUES (loop_counter, loop_counter, 'warning', 
        TO_DATE(TRUNC(DBMS_RANDOM.VALUE(TO_CHAR(DATE '2000-01-01','J') ,TO_CHAR(DATE '9999-12-31','J'))),'J')
        ,dbms_random.value(1,100)
       ); 
END LOOP; 
COMMIT; 
END;

ORDS MATTERS

curl --location --request GET 'https://m...q.apigateway.eu-frankfurt-1.oci.customer-oci.com/inv...e/v1/workorder?codActuacion=20...3&offset=0&limit=10' --header 'Authorization: Basic SU...w' | jq .items[0].workorder
	select  w.json.common
 		from inv_wo_json w
 		where  w.json.common.cod_actuacion = :codActuacion 
		offset :fetch_offset rows fetch next :fetch_size rows only
begin
    
INSERT INTO inv_wo_json (
    id_json,
    created,
    created_by,
    updated,
    updated_by,
    json
) VALUES (
    NVCTS.INV_S_WO_JSON_ID.NEXTVAL,
    current_timestamp,
    'ZNTSMW',
    null,
    null,
    :body_text
);
    htp.print('{code : 0, msg : "" }');
    --htp.print(:content_type || :current_user || :forward_location || :fetch_offset || :fetch_size || :page_offset || :page_size || :row_offset || :row_count || :status_code);
exception
    when others then
       htp.print('{ code : 999 , msg : "' || SQLERRM || '"}');
end;

cloud apps urls

/analytics
/biacm
/xmlpserver
/integration/worklistapp
/cs

scale aut. db

oci db autonomous-database update --autonomous-database-id xxx --cpu-core-count yyy

oci os

oci os object put –bucket-name solvencialogs –file prueba

umount device busy

mount -o remount /logs

umount /logs

OCI LOGGING

systemctl status unified-monitoring-agent

systemctl restart unified-monitoring-agent

/var/log/unified-monitoring-agent/unified-monitoring-agent.log 

/etc/unified-monitoring-agent/conf.d/fluentd_config/fluentd.conf


OCI INSTANCE METADATA SERVICE

curl -H "Authorization: Bearer Oracle" -L http://169.254.169.254/opc/v2/instance/

BLOCK VOLUME GROUP BACKUPS

oci bv volume-group-backup create --volume-group-id ocid1.volumegroup.oc1.eu-frankfurt-1.abtheljspqi6gqfonkvhulauwj6nzoafz7wln27sbzus47wuuqo6ukttj4bq --type INCREMENTAL --display-name BACKUP-DISCOS-PROD-AD1

oci bv volume-group-backup create --volume-group-id ocid1.volumegroup.oc1.eu-frankfurt-1.abtheljr4u6qc6qiptvt3oi37axw2q75rq2sfxe3zadvtqywhey5gvnhjg6q --type INCREMENTAL --display-name BACKUP-DISCOS-PROD-AD2

GET SSL CERT

openssl s_client -showcerts -connect x.y.z.t:443 /dev/null|openssl x509 -outform PEM >mycertfile.pem

--
openssl x509 -in tls.crt -out tls.pem

DB LOCKS

select c.owner, c.object_name, c.object_type, b.sid, b.serial#, b.status, b.osuser, b.machinefromgv$locked_object a , gv$session b, dba_objects cwhereb.sid = a.session_id and a.object_id = c.object_id;

OCI SESSION

oci session authenticate --region eu-frankfurt-1

oci ce cluster get --cluster-id <clusterocid> --profile <profilename> --auth security_token

oci compute instance action --action START --instance-id ocid1.instance.oc1.eu-frankfurt-1.abtheljryhjheloazfywoxq52fbnykje2obue6nb4oeense5477cvtuyeswa --profile melia --auth security_token --wait-for-state RUNNING --max-wait-seconds 120

LOYALTY CLOUD REST

Transactions

https://adc3-zdic-fa-ext.oracledemos.com/crmRestApi/resources/11.13.18.05/loyaltyTransactions?offset=175&limit=100&fields=LoyTransactionId&onlyData=true&q=LoyTransactionId>'100000368315559'

Promotions

https://adc3-zdic-fa-ext.oracledemos.com//crmRestApi/resources/11.13.18.05/loyPromotions?expand=all&limit=1&onlyData=true&q=Name=test

Attributes of a promotion

https://adc3-zdic-fa-ext.oracledemos.com//crmRestApi/resources/11.13.18.05/loyPromotions/300000183643184/child/PromotionAttributes

Programs

https://adc3-zdic-fa-ext.oracledemos.com//crmRestApi/resources/11.13.18.05/loyPrograms

Promotions asigned to a transaction

https://adc3-zdic-fa-ext.oracledemos.com/crmRestApi/resources/11.13.18.05/loyTransactions/300000183643193/child/Promotions

Service requests of a member

https://adc3-zdic-fa-ext.oracledemos.com/crmRestApi/resources/11.13.18.05/serviceRequests?q=LoyMemberName="Aaron Becker"

https://adc3-zdic-fa-ext.oracledemos.com/crmRestApi/resources/11.13.18.05/serviceRequests?q=LoyMemberName="ad pepelu"&onlyData=true

SOACS START/STOP WITH PSMCLI

echo '{"allServiceHosts":"true"}' > BRACSOAPRE.json

psm soa stop --service-name BRACSOAPRE2 -c BRACSOAPRE.json
J1

Tunnel to OCI DB system via jump box

ssh -i privatekeyfile -N -L localhost:1521:dbnodeprivateip:1521 opc@jumpboxpublicip

OCI object storage

https://swiftobjectstorage.<region>.oraclecloud.com/v1/<tenantname>/<containername>

Auth token

username/<generate an authtoken in dashboard or with CLI>

oci iam auth-token create --description test --user-id ocid1.user.oc1..aaaaaaaahtqjy2k7qigfpe7u5fb74xttzangq54y36amgazhszd4uzknttva

docker

docker login container-registry.oracle.com

grafana

brew services stop grafana

jdbc to oracle

CDB SID

jdbc:oracle:thin:@130.61.67.9:1521:ORCLCDB

PDB servicename

jdbc:oracle:thin:@//130.61.67.9:1521/orclpdb1.localdomain

docker cleaner

docker container stop $(docker ps -a -q) && docker rm $(docker ps -a -q) && docker rmi -f $(docker images -q)
docker system prune

oci command list instances

oci compute instance list --compartment-id ocid1.compartment.oc1..aaaaaaaaefsgvdfcqutt4p5qhjcyuefz5tbpwj5kdp25gi2uvzwd663go63q --output table --query "data [*].{Region:\"region\", Shape:shape}"'

dowload otn soft with wget

wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-x64.tar.gz

key pairs

openssl genrsa -out mykey.pem (generate key)
ssh-keygen -f private.pem -y > private.pub
puttygen whatever.ppk -O private-openssh -o whatever.pem (ppk to pem)
puttygen keyfile -O private -o keyfile.ppk (pen to ppk)
ssh-keygen -l -E md5 -f file.pub (print fingerprint)
openssl rsa -in privatepem -pubout (print public pem from private pem)

scale autonomous databse

oci db autonomous-database update  --autonomous-database-id ocid1.autonomousdatabase.oc1.eu-frankfurt-1.abtheljrsl2t7czntim5sx2sc4rzznu7cqxji7y52f7zl4qbsff5g3u3ic7q --wait-for-state AVAILABLE --cpu-core-count 1

tcpdump capture

tcpdump -i any -w capture_file -G 60 

k8s dashboard

http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/.

create db system from backup

oci db system launch-from-backup --availability-domain IesV:EU-FRANKFURT-1-AD-2 --compartment-id ocid1.compartment.oc1..aaaaaaaabi3huagfrq3lfmqvwkjoz625otxgrzbqte3et73kro5yqps32aoa --hostname restaurada --shape VM.Standard1.1 --subnet-id ocid1.subnet.oc1.eu-frankfurt-1.aaaaaaaabba5bdnhyip7ow24tg3dhq5u3ig6kxdtjrv4khzpzajlqvwjbxtq --database-edition ENTERPRISE_EDITION --admin-password ABcd##1234 --backup-id ocid1.dbbackup.oc1.eu-frankfurt-1.abtheljrx4oc4zvh4iidpiygikcji5ys2w6cynud4iv56su6x4rsznkoux5a --backup-tde-password ABcd##1234 --ssh-authorized-keys-file publicKey --cpu-core-count 1 --node-count 1 --initial-data-storage-size-in-gb 256

linux7 fw

sudo firewall-cmd --zone=public --permanent --add-port=1521/tcp
sudo firewall-cmd --reload

iptables nat

sudo iptables -t nat -vnL

oci cli

oci compute instance list --compartment-id ocid1.compartment.oc1..aaaaaaaabi3huagfrq3lfmqvwkjoz625otxgrzbqte3et73kro5yqps32aoa

oci compute instance get --instance-id ocid1.instance.oc1.eu-frankfurt-1.abtheljrc4k32kfkx3eyevi6rmmrnrncqt6qul2w5s4zodfdb6tdklnby2xq

oci compute instance action --action stop  --instance-id ocid1.instance.oc1.eu-frankfurt-1.abtheljrc4k32kfkx3eyevi6rmmrnrncqt6qul2w5s4zodfdb6tdklnby2xq

psm cli

psm jcs delete-service -s pruebaj -d SYS -a Welcome#1 -of json

my ip from linux cmd

curl ifconfig.me
curl icanhazip.com
curl ipecho.net/plain
curl ifconfig.co

get certificates

openssl s_client -connect smtp.gmail.com:465 -showcerts

encrypt

openssl enc -base64 -e -des3 -in prueba.txt -out prueba.enc
openssl enc -base64 -des3 -d -in prueba.enc -out prueba.des.txt
keytool -printcert -file <file>
openssl req -nodes -x509 -newkey rsa:2048 -days 3650 -keyout jmuCA.key -out jmuCA.crt
openssl genrsa -out web.key 2048
openssl req -new -key web.key -out web.csr
openssl x509 -CA jmuCA.crt -CAkey jmuCA.key -req -in web.csr -days 3650 -CAcreateserial -sha1 -out web.crt
openssl pkcs12 -export -name web -in web.crt -inkey web.key -out web.p12
( keytool -list -keystore web.p12 -v )
keytool -importcert -alias web -file web.p12 -keystore web.jks -storetype pkcs12 (error)
svc.importKeyStore(appStripe='OTD', name='opc-config', password='welcome1',aliases='web', keypasswords='welcome1', type='JKS', permission=true, filepath='/u01/app/oracle/tools/home/oracle/web.p12')

allocate bigfile

fallocate -l 1G test.img

crawl a web

wget --no-clobber --convert-links --random-wait -r -p --level 10 -E -e robots=off -U mozilla http://www.intratext.com
/etc/rc.local

su – <user> <command>

ssh-keygen -t rsa

jdbc:oracle:thin:@<ip>:<port>:<service> [sys as sysdba ]

change ssh port

apache certificate

export http_proxy=http://<USERNAME>:<PASSOWRD>@<proxy-server>:<port>

INTERRUPTS

watch -n5 “cat /proc/interrupts”

xen

xl sched-credit
xl sched-credit -d 0 -w 512
xl vcpu-list
xl vcpu-pin Domain-name1 0 0
xl vcpu-pin Domain-name1 1 1
xl vcpu-pin Domain-name2 all 2-6
xl vcpu-pin 1 all - 16-18
xm sched-credit -d <domain>
xm sched-credit -d <domain> -w <weight>
xm sched-credit -d <domain> -c <cap>

tunning xen

https://wiki.xen.org/wiki/Tuning_Xen_for_Performance
http://www.oracle.com/technetwork/server-storage/vm/ovm-performance-2995164.pdf

numa

xl info -n

http://mokumsolutions.com/oracle-vm-numa-best-practices

https://blogs.oracle.com/wim/entry/understanding_memory_allocation_in_oracle

ovm tunning

Click to access ovm-performance-2995164.pdf

https://blogs.oracle.com/jsavit/entry/oracle_vm_performance_and_tuning

REPOS OVM (para instalar “cosas”)

poner en /etc/yum.repos.d los repos de ol6

STRESS

[

mkdir /stress_test

cd /stress_test

wget http://people.seas.harvard.edu/~apw/stress/stress-1.0.4.tar.gz

tar –zxvf stress-1.0.4.tar.gz

cd stress-1.0.4

yum install gcc

./configure

make all

src/stress –cpu 1

]

PARSEC

http://parsec.cs.princeton.edu/parsec3-doc.htm

TOP CPU CONSUMER THREAD

get pid: top -H -p <pid>
grab threadid from top processes
convert threadid to hex: hexthid=printf "%x \n" <threadid>
jcmd <pid> Thread.print | grep <hexthid>

GET PID

pgrep  -u   | cut -f 1 -d ” “

 iptables –table nat –list

vncserver  :1 -geometry 1360×768

BBDD

ALTER PLUGGABLE DATABASE ALL OPEN READ WRITE;
ALTER SESSION SET container = xxxx;
select instance_name from gv$instance;
select name from gv$services;
select * from gv$pdbs;
yum install oracle-rdbms-server-12cR1-preinstall
ALTER SESSION SET container = xxxx
select /* +  parallel (t, 256)*/ sum (a.n) from mytest.t a, t b where a.n in (select max( n * 3.141592 / 3.141592)from t);
CREATE BIGFILE TABLESPACE T
 DATAFILE
 'T01' SIZE 107374182400 REUSE AUTOEXTEND ON NEXT 100 MAXSIZE 1099511627776
 NOLOGGING
 DEFAULT ROW STORE COMPRESS ADVANCED INMEMORY MEMCOMPRESS FOR CAPACITY HIGH DISTRIBUTE AUTO DUPLICATE ALL PRIORITY CRITICAL
 SEGMENT SPACE MANAGEMENT AUTO
 EXTENT MANAGEMENT LOCAL;alter system set sga_target=1000m scope=both;

SQL> alter system set sga_target=1000m scope=both;

SQL> alter system set sga_max_size=3000m scope=spfile;

LINUX

find / -type f -size +5000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'

ldd

touch --d="2015-12-07 09:00:00"  *

du -a / | sort -n -r | head -n 20
nettui
yum install keepalived
systemctl set-default multi-user.target | graphical.target
printf "username=weblogic\npassword=tolay" >boot.properties

http://public-yum.oracle.com/

ip addr add 192.168.1.50/24 dev eth2
ip link set eth2 up
ip addr del 192.168.1.50/24 eth2
ip link set eth2 down
ip route add 10.10.20.0/24 via 192.168.50.100 dev eth0
ip route del 10.10.20.0/24

Increase filesystem in a Vol

su -
df -h /tmp
vgdisplay VolGroup
lvextend -L +1024m /dev/mapper/VolGroup-LogVol02
resize2fs /dev/mapper/VolGroup-LogVol02
df -h /tmp

IPSEC

ipsec auto –add xxx ipsec auto –up xxx tail -f /var/log/secure

WINDOWS

handle https://technet.microsoft.com/en-us/sysinternals/handle

SOLARIS

find -exec grep {}\

pkg install --accept solaris-desktop
vncserver [- list | -kill 😡 ]
svcadm disable
svcs
prsstat
ibswitches
dladm [show-eoib, show-ib, show-phys, show-vnic]
ipadm [show-if, show-addr]
showvnics
showvlan
netadm enable -p ncp defaultfixed
netadm enable -p ncp Automatic
dladm create-vnic -l net0 vnic0
ipadm create-addr -T dhcp net0
pkgadd -d >xxx.pkg
pkg set-publisher -k pkg.oracle.com.key.pem -c pkg.oracle.com.certificate.pem -G "*" -g https://pkg.oracle.com/solarisstudio/release solarisstudio
swap -l
zfs set volsize=2g rpool/swap
prctl -n project.max-shm-memory -v 6gb -r -i project default
netadm enable -p ncp Automatic
zoneadm list -vi
zoneadm -z xxx shutdown
pkg set-publisher -k pkg.oracle.com.key.pem -c pkg.oracle.com.certificate.pem -G "*" -g https://pkg.oracle.com/solarisstudio/release solarisstudio
ipadm create-ip otdvip0
ipadm create-addr -T static -a 192.168.1.9/24 otdvip0
mkdir -p /u01/OTD
mkdir -p /u01/OTDInstances
mount -o vers=3 192.168.1.17:/export/soft /u01/OTD
mount -o vers=3 192.168.1.17:/export/config /u01/OTDInstances/
pkg install vrrp

VIRTUALBOX

Modo promiscuo + nohup snoop -d iface &

APACHE

ProxyPass / http://otd-vip.ti.uam.es:6001/
ProxyPassReverse / http://otd-vip.ti.uam.es:6001/

OVM

service ovmm resstart
service ovmcli restart

https://ovmmserver:7002/0vm/console (admin/xxxx)

ZFS

https://zfsserver:215 (root/xxxx)

WLST

from java.text import SimpleDateFormat

connect('weblogic','xxxxx','t3://server:port')
serverRuntime()
cd('PartitionRuntimes/testpart_p0/ApplicationRuntimes/WebApplication2/WorkManagerRuntimes/default')
for i in range(10000):
 print get('PendingRequests')
 import time
 time.sleep(3)
disconnect()
p=getPath('com.bea:ServerRuntime=testpart_server_1,Name=default,ApplicationRuntime=WebApplication2,Type=WorkManagerRuntime,PartitionRuntime=testpart_p0')
print p

JMAP

jmap -dump:[live],format=b,file=/dir/fichero (ulimit -f unlimited) jps (lists pids) jstack
./jcmd 23092 JFR.start duration=300s filename=/home/oracle/myrecording1.jfr
./jmap -dump:live,format=b,file=/home/oracle/md1 23092
./jmap -histo:live 23092 > /home/oracle/histo-live
gdb --pid=23092
(gdb) gcore
Saved corefile core.23092
(gdb) detach
Detaching from program: /oracle/jdk1.7.0_76/bin/java, process 23092
(gdb) quit
./jmap -heap:format=b ./java core.23092 > /home/oracle/heap.hprof 2>&1
JMC:
-Dcom.sun.management.jmxremote.port=7091
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-XX:+UnlockCommercialFeatures
-XX:+FlightRecorder
./jcmd JFR.start duration=60s filename=myrecording.jfr

SUSE enterprise

sudo -s -u ec2-user /usr/java/jdk1.8.0_101/bin/jcmd 19536 JFR.start duration=60s filename=myrecording.jfr

JFR help

https://docs.oracle.com/javacomponents/jmc-5-3/jfr-runtime-guide/comline.htm#BABHCDCE

JROCKIT

./jrcmd   hprofdump filename=
./jrcmd pid start_flightrecording duration=60s filename=myrecording.jfr settings=full
Template NameDescription
codeAdditional settings for enabling more verbose compiler logging.
defaultDefault settings tuned for a very low performance overhead and recommended for always-on production use.
freememAdditional settings for debugging out-of-memory and fragmentation problems.
fullEnables collection of all available events for all subsystems. Warning: This has a very high performance overhead.
ioAdditional settings for enabling more verbose Java I/O logging.
leakAdditional settings for debugging memory leaks.
locksAdditional settings for enabling more verbose synchronization logging.
memoryAdditional settings for enabling more verbose GC/memory management logging.
offDisables all events for all subsystems.
profileRecommended settings for creating a profiling recording. They provide a good balance between the amount of information available and the performance overhead introduced.
sampleAdditional settings for enabling hotspot sampling of code.
semirefsAdditional settings for debugging problems with java.lang.ref.Reference objects and its subclasses.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.