28 Aralık 2017 Perşembe

Weblogic SSL Konfigürasyonu

İşlemlerde örnek olarak /app/ssl dizini kullanılmıştır

keytool -genkey -keyalg RSA -alias medrec -keystore identity.jks -validity 360 -keysize 2048

keytool -export -alias medrec -file medrec.crt -keystore identity.jks

keytool -import -trustcacerts -alias medrec -file medrec.crt -keystore trust.jks

Weblogic console üzerinden ilgili server için SSL portu açılır

İlgili serverda Keystore sekmesinde aşağıdaki ayarlar yapılır

Keystores : Custom Identity and Custom Trust
Custom Identity Keystore : /app/sslidentity.jks
Custom Identity Keystore Type : JKS
Custom Identity Keystore Passphrase : changeit (identity.jks için hangi şifre belirlenmişse)
Confirm Custom Identity Keystore Passphrase : changeit

Custom Trust Keystore : /app/ssl/trust.jks
Custom Trust Keystore Type : JKS
Custom Trust Keystore Passphrase : changeit (trust.jks için hangi şifre belirlenmişse)
Confirm Custom Trust Keystore Passphrase : changeit

SSL tanımı yapılır. (SSL sekmesi)
Confirm Custom Trust Keystore Passphrase : medrec
Private Key Passphrase : changeit
Confirm Private Key Passphrase : changeit
Hostname Verification : none seçilir

20 Aralık 2017 Çarşamba

Linux terminalde username@hostname:working directory görüntülenmesi

Login olunan sunucuda user@hostname:working_directory şeklinde komut satırını görmek için aşağıdaki tanımın .bashrc yada .bash_profile dosyasına eklenmesi yeterli olacaktır

export PS1='\u@\h:\w\$ '

appadmin@alpullu:/$

14 Kasım 2017 Salı

Windows 10 iso versiyon bilgisi

C:\WINDOWS\system32>dism /Get-WimInfo /WimFile:E:\x64\sources\install.esd /index:1

Deployment Image Servicing and Management tool
Version: 10.0.15063.0

Details for image : E:\x64\sources\install.esd

Index : 1
Name : Windows 10 S
Description : Windows 10 S
Size : 15.568.710.987 bytes
WIM Bootable : No
Architecture : x64
Hal : <undefined>
Version : 10.0.16299
ServicePack Build : 15
ServicePack Level : 0
Edition : Cloud
Installation : Client
ProductType : WinNT
ProductSuite : Terminal Server
System Root : WINDOWS
Directories : 21270
Files : 102845
Created : 30.09.2017 - 16:24:52
Modified : 15.11.2017 - 10:09:06
Languages :
        tr-TR (Default)

The operation completed successfully.

13 Kasım 2017 Pazartesi

SQL Server index fragmentation

SELECT OBJECT_NAME(ind.OBJECT_IDAS TableNameind.name AS IndexNameindexstats.index_type_desc AS IndexTypeindexstats.avg_fragmentation_in_percent 
FROM sys.dm_db_index_physical_stats(DB_ID(), NULLNULLNULLNULLindexstats 
INNER JOIN sys.indexes ind  
ON ind.object_id = indexstats.object_id 
AND ind.index_id = indexstats.index_id 
WHERE indexstats.avg_fragmentation_in_percent > 30 
ORDER BY indexstats.avg_fragmentation_in_percent DESC

23 Ekim 2017 Pazartesi

Decrypt Weblogic Server Admin Password

1. Create a script decrypt_password.py in $DOMAIN_HOME/security directory and paste the following code into it:
from weblogic.security.internal import *
from weblogic.security.internal.encryption import *
encryptionService = SerializedSystemIni.getEncryptionService(".")
clearOrEncryptService = ClearOrEncryptedService(encryptionService)

# Take encrypt password from user
pwd = raw_input("Paste encrypted password ({AES}fk9EK...): ")

# Delete unnecessary escape characters
preppwd = pwd.replace("\\", "")

# Display password
print "Decrypted string is: " + clearOrEncryptService.decrypt(preppwd)
2. Set domain environment variables
source $DOMAIN_HOME/bin/setDomainEnv.sh
3. Get encrypted password, in this example from boot.properties file of AdminServer
#Username:
grep username $DOMAIN_HOME/servers/AdminServer/security/boot.properties | sed -e "s/^username=\(.*\)/\1/"

#Password:
grep password $DOMAIN_HOME/servers/AdminServer/security/boot.properties | sed -e "s/^password=\(.*\)/\1/"
4. Navigate to $DOMAIN_HOME/security directory and run the following command to start decryption:
cd $DOMAIN_HOME/security

java weblogic.WLST decrypt_password.py


Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

Please enter encrypted password (Eg. {AES}fk9EK...): {AES}jkIkkdh693dsyLt+DrKUfNcXryuHKLJD76*SXnPqnl5oo\=
Decrypted string is: welcome01
Decrypted value will be displayed on the screen

30 Eylül 2017 Cumartesi

SQL Server max degree of parallelism

USE AdventureWorks2012 ; GO EXEC sp_configure 'show advanced options', 1; GO RECONFIGURE WITH OVERRIDE; GO EXEC sp_configure 'max degree of parallelism', 8; GO RECONFIGURE WITH OVERRIDE; GO

26 Eylül 2017 Salı

Oracle Tablo Boyutları

SELECT A.OWNER,
A.TABLE_NAME,
NUM_ROWS,
TRUNC (b.size_G, 2) AS SIZE_G
FROM DBA_TABLES A,
(  SELECT owner, table_name, ROUND (SUM (bytes) / 1024 / 1024 / 1024) SIZE_G
  FROM (SELECT segment_name table_name, owner, bytes
  FROM dba_segments
WHERE segment_type IN ('TABLE',
'TABLE PARTITION',
'TABLE SUBPARTITION')
UNION ALL
SELECT i.table_name, i.owner, s.bytes
  FROM dba_indexes i, dba_segments s
WHERE     s.segment_name = i.index_name
   AND s.owner = i.owner
   AND s.segment_type IN ('INDEX',
  'INDEX PARTITION',
  'INDEX SUBPARTITION')
UNION ALL
SELECT l.table_name, l.owner, s.bytes
  FROM dba_lobs l, dba_segments s
WHERE     s.segment_name = l.segment_name
   AND s.owner = l.owner
   AND s.segment_type IN ('LOBSEGMENT',
  'LOB PARTITION',
  'LOB SUBPARTITION')
UNION ALL
SELECT l.table_name, l.owner, s.bytes
  FROM dba_lobs l, dba_segments s
WHERE     s.segment_name = l.index_name
   AND s.owner = l.owner
   AND s.segment_type = 'LOBINDEX')
  GROUP BY table_name, owner
  ORDER BY SUM (bytes) DESC) b
WHERE     A.TABLE_NAME IN ('AUDIT_COUNTER',
'AUDIT_DETAILS',
'AUDIT_TRAIL',
'CI_INDEXES',
'CUBE_INSTANCE',
'CUBE_SCOPE',
'DLV_MESSAGE',
'DLV_SUBSCRIPTION',
'DOCUMENT_CI_REF',
'DOCUMENT_DLV_MSG_REF',
'HEADERS_PROPERTIES',
'WI_FAULT',
'WORK_ITEM',
'XML_DOCUMENT',
'COMPONENT_INSTANCE',
'COMPOSITE_INSTANCE',
'COMPOSITE_INSTANCE_ASSOC',
'COMPOSITE_INSTANCE_FAULT',
'COMPOSITE_SENSOR_VALUE',
'INSTANCE_PAYLOAD',
'REFERENCE_INSTANCE',
'REJECTED_MESSAGE',
'REJECTED_MSG_NATIVE_PAYLOAD',
'MEDIATOR_AUDIT_DOCUMENT',
'MEDIATOR_CASE_DETAIL',
'MEDIATOR_CASE_INSTANCE',
'MEDIATOR_DEFERRED_MESSAGE',
'MEDIATOR_INSTANCE',
'MEDIATOR_PAYLOAD')
AND A.OWNER = 'TTOTEST_SOAINFRA'
AND a.table_name = b.TABLE_name
AND A.OWNER=B.OWNER
ORDER BY TABLE_NAME

17 Eylül 2017 Pazar

SQL Server Rebuild All Index

DECLARE @Database VARCHAR(255) 
DECLARE @Table VARCHAR(255) 
DECLARE @cmd NVARCHAR(500) 
DECLARE @fillfactor INT

SET @fillfactor = 90

DECLARE DatabaseCursor CURSOR FOR 
SELECT name FROM master.dbo.sysdatabases 
WHERE name IN ('RTM', 'RTM2') 
ORDER BY 1 

OPEN DatabaseCursor 

FETCH NEXT FROM DatabaseCursor INTO @Database 
WHILE @@FETCH_STATUS = 0 
BEGIN 

   SET @cmd = 'DECLARE TableCursor CURSOR FOR SELECT ''['' + table_catalog + ''].['' + table_schema + ''].['' +
  table_name + '']'' as tableName FROM [' + @Database + '].INFORMATION_SCHEMA.TABLES
  WHERE table_type = ''BASE TABLE''' 

   -- create table cursor 
   EXEC (@cmd) 
   OPEN TableCursor 

   FETCH NEXT FROM TableCursor INTO @Table 
   WHILE @@FETCH_STATUS = 0 
   BEGIN 

       IF (@@MICROSOFTVERSION / POWER(2, 24) >= 9)
       BEGIN
           -- SQL 2005 or higher command
           SET @cmd = 'ALTER INDEX ALL ON ' + @Table + ' REBUILD WITH (FILLFACTOR = ' + CONVERT(VARCHAR(3),@fillfactor) + ')'
           EXEC (@cmd)
       END
       ELSE
       BEGIN
          -- SQL 2000 command
          DBCC DBREINDEX(@Table,' ',@fillfactor) 
       END

       FETCH NEXT FROM TableCursor INTO @Table 
   END 

   CLOSE TableCursor 
   DEALLOCATE TableCursor 

   FETCH NEXT FROM DatabaseCursor INTO @Database 
END 
CLOSE DatabaseCursor 
DEALLOCATE DatabaseCursor

SQL Server Index Fragmantation List

SELECT OBJECT_NAME(ind.OBJECT_ID) AS TableName,
ind.name AS IndexName, indexstats.index_type_desc AS IndexType,
indexstats.avg_fragmentation_in_percent
FROM sys.dm_db_index_physical_stats(DB_ID(), NULL, NULL, NULL, NULL) indexstats
INNER JOIN sys.indexes ind 
ON ind.object_id = indexstats.object_id
AND ind.index_id = indexstats.index_id
WHERE indexstats.avg_fragmentation_in_percent > 30
ORDER BY indexstats.avg_fragmentation_in_percent DESC

20 Ağustos 2017 Pazar

SQL Server SET OFFLINE-ONLINE

ALTER DATABASE [DBNAME] SET OFFLINE WITH
ROLLBACK IMMEDIATE

ALTER DATABASE [DBNAME] SET ONLINE

1 Mart 2017 Çarşamba

ASP.NET MVC File Upload

CSHTML

<input type="file" id="FileUpload1" />
<input type="button" id="btnUpload" value="Upload Files" />

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>

$(document).ready(function(){
    $('#btnUpload').click(function () {

        // Checking whether FormData is available in browser
        if (window.FormData !== undefined) {

            var fileUpload = $("#FileUpload1").get(0);
            var files = fileUpload.files;

            // Create FormData object
            var fileData = new FormData();

            // Looping over all files and add it to FormData object
            for (var i = 0; i < files.length; i++) {
                fileData.append(files[i].name, files[i]);
            }

            // Adding one more key to FormData object
            fileData.append('username', 'Manas');

            $.ajax({
                url: '/Home/UploadFiles',
                type: "POST",
                contentType: false, // Not to set any content header
                processData: false, // Not to process data
                data: fileData,
                success: function (result) {
                    alert(result);
                },
                error: function (err) {
                    alert(err.statusText);
                }
            });
        } else {
            alert("FormData is not supported.");
        }
    });
});
</script>

CONTROLLER

[HttpPost]
        public ActionResult UploadFiles()
        {
            // Checking no of files injected in Request object  
            if (Request.Files.Count > 0)
            {
                try
                {
                    //  Get all files from Request object  
                    HttpFileCollectionBase files = Request.Files;
                    for (int i = 0; i < files.Count; i++)
                    {
                        //string path = AppDomain.CurrentDomain.BaseDirectory + "Uploads/";  
                        //string filename = Path.GetFileName(Request.Files[i].FileName);  

                        HttpPostedFileBase file = files[i];     
                        
                        string fname;

                        // Checking for Internet Explorer  
                        if (Request.Browser.Browser.ToUpper() == "IE" || Request.Browser.Browser.ToUpper() == "INTERNETEXPLORER")
                        {
                            string[] testfiles = file.FileName.Split(new char[] { '\\' });
                            fname = testfiles[testfiles.Length - 1];
                        }
                        else
                        {
                            fname = file.FileName;
                        }

                        // Get the complete folder path and store the file inside it.  
                        fname = Path.Combine(Server.MapPath("~/Uploads/"), fname);
                        file.SaveAs(fname);
                    }
                    // Returns message that successfully uploaded  
                    return Json("File Uploaded Successfully!");
                }
                catch (Exception ex)
                {
                    return Json("Error occurred. Error details: " + ex.Message);
                }
            }
            else
            {
                return Json("No files selected.");
            }

        }

3 Ocak 2017 Salı