1 | ssh-keygen -y -e -f myprivate.key |
CharliePiks
Donnerstag, 16. Juni 2016
How to verify private and public keypair?
Reads the private key an prints the corresponding public key which can be directly compared to your available public keys
Donnerstag, 2. Juni 2016
Oracle Database Daily Backup and delete older then 5 days
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | #!/bin/sh #exec >/tmp/export.log #exec 2>&1 # Set Environment . ~oracle/oracle_env_arculhbt DIR=/oradata/arculhbt/dpdump/daily_backup DD=DATAPUMPDIR sqlplus / as sysdba <<EOF set echo on create or replace directory $DD as '$DIR'; exit EOF DUMP=arculhbt_$(date +%Y-%m-%d)_full.dmp LOG=arculhbt_$(date +%Y-%m-%d)_full_exp.log if [ -f $DIR/$DUMP ];then echo Dump already exist! => "Abort!" exit 1 # rm $DIR/$DUMP fi if [ -f $DIR/$LOG ];then rm $DIR/$LOG fi P=`dd if=/dev/urandom bs=512 count=1 2>/dev/null | tr -dc "a-zA-Z0-9-_\.\+\$\?" | fold -w 15 | head -1` echo "alter user system identified by \"$P\";" | sqlplus -S "/ as sysdba" expdp system/"$P" full=yes DIRECTORY=$DD DUMPFILE=$DUMP logfile=$LOG METRICS=YES # STATUS=120 sqlplus / as sysdba <<EOF set echo on drop directory $DD; exit EOF echo echo "-----[ DONE ]-----" echo "Create Zip-File and delete dump-file" zip -rm /oradata/arculhbt/dpdump/daily_backup/arculhbt_$(date +%Y-%m-%d)_full.zip /oradata/arculhbt/dpdump/daily_backup/arculhbt_$(date +%Y-%m-%d)_full.dmp /oradata/arculhbt/dpdump/daily_backup/arculhbt_$(date +%Y-%m-%d)_full_exp.log echo "Delete Backups older then 5 days" find /oradata/arculhbt/dpdump/daily_backup -iname "*.zip" -mtime +5 -delete |
Sending Mail from Command Line
Method 1 - Perl Script with attachment
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | #!/usr/bin/perl use MIME::Lite; $to = 'test_1@mail.de;test_2@mail.de'; $from = 'test_3@mail.de'; $subject = 'Test_Mail'; $message = 'Hello this is a test mail best regards me '; $msg = MIME::Lite->new( From => $from, To => $to, Cc => $cc, Subject => $subject, Type => 'multipart/mixed' ); # Add your text message. $msg->attach(Type => 'text', Data => $message ); # Specify your file as attachement. $msg->attach(Type => " application/msexcel ", Path => '/home/test_user/excel_filename.xls', Filename => 'excel_filename.xls', Disposition => 'attachment' ); $msg->send; print "Email Sent Successfully\n"; |
Method 2 - From Command Line
echo Hello, whats up | mail -s "Request" "test@mail.de"
Method 2a - From Command Line with attachment
mail -s "Test" test@mail.de < /var/log/messages
Method 3 - From Command Line with attachment
1 | echo "Test: OK" | mutt -a "error.txt" "calc.txt" -s "Subject: OK!" -- test.me@mail.de |
Transfer file from Windows to Linux
Required Software
- PSCP
- PuttyGen
Generate Key
1. Start puttygen.exe on Windows2. Change → "Number of bits in a generated key" to what you need, example 4096 or 2048
3. Click "Generate"
4. Change → "Key Comment"
5. Chose → "Key passpharse" and "Confirm passpharse"
6. Select and copy all of the text in the box labeled “Public key for pasting into OpenSSH authorized_keys file”.
7. Paste the public key from the Clipboard into the the authorized_keys file of the, which is located in the .ssh directory in your home directory on the remote host( If no such file is there we will have to manually create it).
8. Save the private key.
9. Use this code to transfer automatically
echo y | pscp.exe -i privatekey.ppk -pw myPassword E:\Zinsmatrix\Zinsmatrix\*.csv* oracle@10.10.10.10:/home/oracle/Zins
Check Tablespace size from Oracle Database
select df.tablespace_name "Tablespace", totalusedspace "Used MB",(df.totalspace - tu.totalusedspace) "Free MB", df.totalspace "Total MB", round(100 * ( (df.totalspace - tu.totalusedspace)/ df.totalspace)) "Pct. Free" from (select tablespace_name, round(sum(bytes) / 1048576) TotalSpace from dba_data_files group by tablespace_name) df, (select round(sum(bytes)/(1024*1024)) totalusedspace, tablespace_name from dba_segments group by tablespace_name) tu where df.tablespace_name = tu.tablespace_name ;
Change Archive Mode in Oracle Database
1. Check status of archivelog
2. Shutdown Database
3. Startup Database in Mount-Mode
4. Alter Database
or
5. Open Database
6. Check if the archivlog is correct
select log_mode from v$database;
2. Shutdown Database
shutdown immediate;
3. Startup Database in Mount-Mode
startup mount;
4. Alter Database
alter database noarchivelog;
alter database archivelog;
5. Open Database
alter database open;
6. Check if the archivlog is correct
select log_mode from v$database;
Disconnect User from Oracle Database
1. Select all user:
2. Select specific user:
3. Disconnect user by SID and Serial#:
select username from v$session where username is not null;
2. Select specific user:
select sid,serial#,program from v$session where username = 'yourusername';
3. Disconnect user by SID and Serial#:
alter system disconnect session 'SID','Serial' immediate;
Abonnieren
Kommentare (Atom)