Search This Blog

Wednesday, 30 November 2016

“Login Failure: the target account name is incorrect” on a Windows file share

The solution was to Uninstall the 'Client for Microsoft Networks' from the network adapter, reboot, reinstall and reboot.

Problem will be fixed.

Shink log file in sql server 2008 r2

USE alphago;
GO  -- Truncate the log by changing the database recovery model to SIMPLE.  ALTER DATABASE AdventureWorks2008R2  
SET
RECOVERY SIMPLE; GO -- Shrink the truncated log file to 1 MB.
DBCC
SHRINKFILE (
alphago_Log, 1); GO -- Reset the database recovery model. ALTER DATABASE alphago SET RECOVERY FULL; GO

Tuesday, 29 November 2016

Oracle database ​size in MB/GB query​ with creation date.

Query to find SID used & free space in it.

col "Database Size" format a20
col "Free space" format a20
col "Used space" format a20
select round(sum(used.bytes) / 1024 / 1024 / 1024,2 ) || ' GB' "Database Size"
, round(sum(used.bytes) / 1024 / 1024 / 1024 ) -
round(free.p / 1024 / 1024 / 1024,2) || ' GB' "Used space"
, round(free.p / 1024 / 1024 / 1024,2) || ' GB' "Free space"
from (select bytes
from v$datafile
union all
select bytes
from v$tempfile
union all
select bytes
from v$log) used
, (select sum(bytes) as p
from dba_free_space) free
group by free.p

Query to find database size in MB/GB with creation date.

select
  a.owner,b.created, ROUND(sum(bytes)/1024/1024,2) as size_in_MB, ROUND(sum(bytes)/1024/1024/1024,2) as size_in_GB
  from
  dba_segments  a inner join dba_users  b
  on a.owner=b.username
group by
 a.owner,b.created;





MYSQL database ​size in MB/GB query​ with creation date.

SELECT table_schema "Database Name", create_time, ROUND(SUM(data_length+index_length)/1024/1024, 0)
"Database Size (MB)",ROUND(SUM(data_length+index_length)/1024/1024/1024)
"Database Size (GB)"  FROM information_schema.TABLES GROUP BY table_schema;

MSQL database ​size in MB/GB query​ with creation date.

SELECT d.NAME, create_date,
    ROUND(SUM(mf.size) * 8 / 1024, 0) Size_MBs
    ,(SUM(mf.size) * 8 / 1024) / 1024 AS Size_GBs
FROM sys.master_files mf
INNER JOIN sys.databases d ON d.database_id = mf.database_id
WHERE d.database_id > 4 -- Skip system databases
GROUP BY d.NAME,create_date
ORDER BY d.NAME

kill/remove a process running on particular port in Linux

​Use the command
option 1:

 
netstat -tulpn | grep 1100

It will show the list of processes with port number and process id

tcp        0      0 0.0.0.0:1100                0.0.0.0:*                   LISTEN      22746/Rserve.dbg

the number before  /Rserve.dbg is a process id. Now use kill command to kill the process

kill -9 22746

-9 implies the process will be killed forcefully.

option 2:
lsof -i:1100;kill -9 22746

oneshot: kill -9 $(lsof -t -i:1100)


option 3:


# fuser 1100/tcp
#
fuser -k 1100/tcp (kill)


Wednesday, 23 November 2016

How to check mysql dsn entry in Linux box

isql -v mydsn myusername mypassword

​[root@linuxmysql opt]# isql -v analyt_52 reuser resuer
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+
SQL>    

Friday, 18 November 2016

Creating a New DB2 Database Using a SQL Script

To create a new DB2 database using a SQL script

  1. Create a user for the new database. For example, to create a user named csuser on Linux:
    useradd -d /home/csuser -m -p welcome1 csuser  
  2. Log in with DB2 instance owner credentials. For example, db2inst1.
  3. Create a file with the following DB2 commands. (For example, create db.sql and modify the database name, path, and user variables to match your installation):
    CREATE DATABASE <DBNAME> AUTOMATIC STORAGE YES ON '<DB2_HOME>/Databases/<DBNAME>'   DBPATH ON '<DB2_HOME>/Databases/<DBNAME>'   USING CODESET UTF-8 TERRITORY US COLLATE USING SYSTEM PAGESIZE 32768;  CONNECT TO <DBNAME>;  GRANT DBADM,CREATETAB,BINDADD,CONNECT,CREATE_NOT_FENCED_ROUTINE,IMPLICIT_SCHEMA,LOAD,CREATE_EXTERNAL_ROUTINE,QUIESCE_CONNECT,SECADM ON DATABASE TO USER <DBUSER>;  UPDATE DATABASE CONFIGURATION USING APPLHEAPSZ 1024 DEFERRED;  UPDATE DATABASE CONFIGURATION USING LOCKTIMEOUT 30 DEFERRED;  UPDATE DATABASE CONFIGURATION USING APP_CTL_HEAP_SZ 1024 DEFERRED;  UPDATE DATABASE CONFIGURATION USING LOGFILSIZ 32768 DEFERRED;  UPDATE DATABASE CONFIGURATION USING LOGSECOND 8 IMMEDIATE ;  CONNECT RESET;  
  4. Create the directory for your database.
    mkdir -p <DB2_HOME>/Databases/<DBNAME>  
  5. Execute the sql script. For example:
    db2 -tvsf createdb.sql  

Useful DB2 Commands

CommandDescription
db2cmdOpen DB2 Command line Tool
db2ccOpen DB2 Control Centre
db2startStart Database Normaly
db2stopStop Database Normaly
db2stop forceStop Database forcely
db2 force application allClose all applications that uses DB2 Database.
db2levelDisplay DB2 version and fix pack level
db6levelDisplay DB2 Client Version
db2 terminateClose the database connection
db2_kill -allKill a hanged instance
db2licm -lView license information
db2 connect to <db2sid>Establish connection to an instance
db2 list tablespaces show detailDisplays table space information
db2 get dbm cfgDisplay configuration parameter of database manager.
db2 get db cfg for <db2 sid>Display configuration parameter of an instance
db2 update dbm cfg using <parameter_name> <new value>Change value of a database manager configuration parameter.
db2 update db cfg for <db2 sid> using <parameter_name> <new value>Change value of a instance configuration parameter.
db2 drop database <target db2sid>Delete and instance
db2 activate db <dbsid>Activate Database
db2 deactivate <dbsid>Deactivate an active database
db2 rollforward db <SID> to end of logsApply all pending logs
db2 rollforward db <db2sid> query statusDisplay rollforward status
db2 backup database <sid> to "disk:\location"Take an offline backup to specified location
db2 list utilities show detailDisplay Database backup status
db2 restore db <sid> from "disk:\path" replace history fileRestore database from a backup image

DB2 license installation steps

To apply any of the DB2 Enterprise Server Edition, DB2 Advanced Enterprise Server Edition, DB2 Workgroup Server Edition, or DB2 Advanced Workgroup Server Edition licenses:

  1. Install the DB2 Version 10.5 – Workgroup, Enterprise, and Advanced Editions common image using the DB2 Setup wizard.
  2. Run the db2licm -a command, to apply the relevant licenses for either the DB2 Enterprise Server Edition, DB2 Advanced Enterprise Server Edition, DB2 Workgroup Server Edition, or DB2 Advanced Workgroup Server Edition.

    Windows

    db2install_path\bin\db2licm -a filename

    where db2install_path is the DB2 installation path, filename is the full path name and file name for the license certificate file that corresponds to the DB2 product edition you have purchased.

    Linux or UNIX

      INSTHOME/sqllib/adm/db2licm -a filename

    where INSTHOME represents the home directory of the instance owner and filename is the full path name and file name for the license certificate file that corresponds to the DB2 product edition you have purchased. The db2licm command can also be found in the path where the DB2 database product is installed. For example, /opt/IBM/db2/V10.5/adm on Linux or UNIX operating system, if you use the default installation directory.

  3. Start of changeIf you have purchased a DB2 add-on offering, run the db2licm -a command to activate the relevant functionalities for the DB2 offering. For example: if you purchased the IBM® DB2 BLU Acceleration In-Memory Offering:

    Windows

    db2install_path\bin\db2licm -a <license_path>/db2baf.lic

    where db2install_path is the DB2 installation path, <license_path> is the full path name for the license file, and db2baf.lic is the license certificate file of IBM DB2 BLU Acceleration In-Memory Offering.

    Linux or UNIX

      INSTHOME/sqllib/adm/db2licm -a <license_path>/db2baf.lic

    where INSTHOME represents the home directory of the instance owner and <license_path> is the full path name for the license file, and db2baf.lic is the license certificate file of IBM DB2 BLU Acceleration In-Memory Offering.End of change

  4. To verify the DB2 product license information, run the db2licm -l command.

that key can’t be used to activate this edition of windows

Method 1:

This may work for other later Operating Systems but it has been tested on 2012 R2.

I installed 2012 R2 on a brand new server as a trial and then later the license arrived, while trying to install the license, it was failed with error saying "that key is not valid for this version of Windows".

Firstly, check to make sure of what version you are using by running the following command

dism /online /get-currentedition

and check the possible target edition

dism /online /get-targeteditions

and if yours is supported then all you need is the new key and run the following command, be sure you are connected to the internet.

dism /online /set-edition:EDITION /product xxxxx-xxxxx-xxxxx-xxxxx-xxxxx /accepteula

if you don't put /accepteula it will not work.


SCREEN SHOTS:

Windows 2012 R2 - 2 days remaining

If you try and enter the new product key from the System Control Panel you'll receive an activation error like below.

Windows 2012 R2 activation failed

Open an Administrative Command Prompt. Then run the command:

slmgr.vbs /dlv

Administrative Command Prompt - slmgr -dlv

Slmgr.vbs /dlv is used for volume licensing, and this step is to gather information only. The /dlv switch displays detailed license information. As you can see below we are currently running the ServerStandardEval edition.

If you wanted to continue using the trial for another 180 days, your could use the /rearm switch.

Results of slmgr -dlv

From the Administrative Command Prompt, run the command:

dism /online /get-currentedition

This will confirm the information we obtained from slmgr.vbs /dlv, as you can see the current version is ServerStandardEval.

Administrative Command Prompt - dism online get-currentedition

Next, run the command:

dism /online /get-targeteditions

This will show you which versions the current evaluation license can be upgraded to, in our case it can be upgraded to ServerStandard or ServerDatacenter.

Administrative Command Prompt - dism get-targeteditions

Next run the command:

dism /online /set-edition:ServerStandard /ProductKey:xxxxx-xxxxx-xxxxx-xxxxx-xxxxx /AcceptEula

This command selects the version of Windows 2012 R2 you want to upgrade to, specifies the product key and Accepts the Eula.

Administrative Command Prompt - 9. dism online set-edition productkey accepteula

Once the process has completed it will prompt you to restart your computer.

Administrative Command Prompt - dism online set-edition productkey accepteula - completed

The process will reboot the server twice.

Reboot adding features

Cleaning up installation

Once completed and logged in you can see in the bottom right hand corner that the server is no longer running and evaluation version. Also on my test server I received an Shutdown Event Tracker.

Windows Server 2012 R2 Standard unexpected shutdown message


Wednesday, 16 November 2016

SQL Developer is returning only the date,not the time

​Go to Tools> Preferences > Database > NLS and set the Date Format as MM/DD/YYYY HH24:MI:SS​

Monday, 14 November 2016

"Unable to connect to RDP server" message using Remmina in Ubuntu 12.04

​Any change made in certificate will not be auto update in Linux rdp session.​

Certificate will be updated to known_host for the first time of the session.

1) Go to the users home directory and .freerdp directory.
​root@luciu06:/home/likewise-open/TECHSOL/go/.freerdp# cat known_hosts 192.168.168.104 20:be:c9:56:2d:80:84:96:dc:00:7e:5b:49:88:57:5e:d6:a9:16

2) Remove the known_hosts certificate value,
root@luciu06:/home/likewise-open/TECHSOL/go/.freerdp# cat > known_hosts (Ctrl+D)



WiFi/LAN Network icon disappeared in Windows tasks bar.

  1. Click Start
  2. Type: regedt32
  3. Press enter
  4. Using the left pane, navigate to:
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network
  5. Once in the above folder, right-click on Config and choose Delete
  6. Close Registry Editor
  7. Reboot.

Tuesday, 8 November 2016

Linux Oracle Database Installation : Display Problem

​Display, it's very common problem when i installed Oracle Database on Linux, not only database, but also oracle weblogic too.

Here, some steps to solve the display problem
1. open terminal as root
2. DISPLAY=:0.0
3. export DISPLAY
4. xhost +
5. su - oracle
6. DISPLAY=:0.0
7. export DISPLAY
8. execute ./runInstalle​r

if ./runInstaller still can't be executed, reboot server, and xhost + again

Sunday, 6 November 2016

how to Extend windows server evaluation grace period

​After Window Server evaluation period has expired , you will found out unexpected behavior for your machine like unexpected Shutdown / Restart every one hour approximately !

Windows License is expired Build 9600

In this case, you only have two options:

  • Purchasing a new Windows Key, activate windows through "Go to PC  Settings".
  • Extend Window Server evaluation period has expired .

Note :  The windows will notify you with the following message.

Your Windows license will expire soon.

Before 12 days of Windows Server 2012 license Expiration to activate Windows.

In this hint, I will elaborate How to Extend Windows Server Evaluation Period by following the bit mentioned steps below:

Steps:

  • Open Command Prompt as Administrator.

  • Reset the licensing status of machine by typing the following command
    • "slmgr.vbs /rearm".

  • Restart the server.
  • The Windows Evaluation Period should now be extended to additional 180 days.
  • After Server restart , wait a moment and you will find the license has been extended successfully.

Extend Windows Server 2012 Evaluation Period

Regarding Windows Server 2008

  • Follow the above-mentioned steps with the following changes.
    • The command will be slmgr.vbs -rearm instead of slmgr.vbs /rearm.
    • The command will extend windows evaluation period to additional 60 days,  that can be used again for three times.​