Posts

Showing posts from 2018

PowerShell Help

Enabling PSRemoting :- Enable-PSRemoting -SkipNetworkProfileCheck get-netconnectionprofile Set-NetConnectionProfile -InterfaceAlias Wi-Fi -NetworkCategory Private WinRM quickconfig Method 2: Successful 1. Enable-PSRemoting -Force 2. Set-Item wsman:\localhost\client\trustedhosts * 3.  Restart-Service WinRM 4. Test-WsMan COMPUTER (servername) 5. Enter-PSSession -ComputerName servername -Credential kkolguri 6. once you connect to the remote session - type sqlps and start working on the powershell Enter-PSSession -ComputerName zeun76sqpstg01 -Credential kkolguri Setting up Mirror Using PowerShell: #Check to make sure database is in full recovery mode #Creates a new backup of data file and log on primary, then secondary restores from that location $dbnames = Invoke-Sqlcmd -Query "select name   from sys.databases where database_id  in (9,10,12)" | Select-Object -ExpandProperty name #| Out-File F:\dbnames.txt $dbnames= ...

SQL SEVER ON LINUX

Admin@123 Follow the  installation guide from Microsoft: Downloading Repo [root@dfwlncmssql-01 ~]# curl -o /etc/yum.repos.d/mssql-server.repo https://pack                                                                                                                     ages.microsoft.com/config/rhel/7/mssql-server-2017.repo   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current                                  Dload  Upload   Total   Spent    Left  Speed   0  ...

Netezza Commands

Table Size  select tablename, used_bytes/pow(1024,4) as used_TB   from _v_table_storage_stat  where tablename  in (  select tablename from _v_table where tablename not like  '_VT_%' and tablename not like '_T_%'); Objects owned by a user: select o.objname, d.database, oc.classname, u.usename from _t_object o, _t_user u, _t_object_classes oc, _v_database d where u.usename='username' and u.usesysid=o.objowner and o.objclass=oc.objclass and o.objdb=d.objid; Tip: Use NZ_HELP to get   syntax of all commands Like -    nz_help | grep grant [nz@dfw86inzb-04 ~]$ nz_help | grep grant nz_db_group_access_listing           To show what groups have been granted access to what databases. nz_db_user_access_listing            To show what users have been granted access to what databases. nz_ddl_grant_group    ...

Sample Python Script

from pymongo import MongoClient client = MongoClient('localhost:27018') collection = client.ucc_ppt.storage with open('/home/kolguk01/cfit_ucc_account_new.txt') as f:     for word in f.readlines():         collection.delete_many({'account': word.rstrip()}) How to execute it .. Python name.py

MongoDB Version Upgrade 3.4 to 3.6

Upgrade of Mongo 3.4 to 3.6 Please follow below steps to upgrade from Mongo 3.4 to 3.6 Pre-requisites: 1.        Make sure your Mongo version running on Mongo 3.4 2.        Connect to Mongo Shell and run the below command on the Primary Node a.        db.adminCommand( { setFeatureCompatibilityVersion: "3.4" } ) POC:PRIMARY> db.adminCommand( { setFeatureCompatibilityVersion: "3.4" } ) { "ok" : 1 } POC:PRIMARY> 3.        Make sure you have the Mongo 3.6 binaries ready Upgrade Procedure: 1.        Stop the Mongod service on one of the secondary node Sudo /etc/init.d/monogd stop 2.        Un-tar the Mongo.3.6.tz file to a location [root@dfwlncmgdb-06 kolguk01]# tar -xvf mongodb-linux-x86_64-rhel62-3.6.3.tgz 3.          Replace the...

Linux Commands

cp -R SRCFOLDER DESTFOLDER/   --copy folder Cp file destination   -- copy a file #Remove lines with containing specific text sed -i '/pattern to match/d' ./infile #renaming the file Mv oldfilename newfilename # send email echo 'Body of mail .' | mailx -s 'subject of mail ' -a   /pathtotheattachment    mailid du -hs *|sort -h   --> size in sorting order tar -zcvf consumer.gz    /home/kolguk01/consumer   -- Gunzip folder Rm -rf    --- remove folder Check IP address of Linux server /sbin/ifconfig Remove files   older than 14 days /usr/bin/find   /home/kolguk01/rpcache/mongo*.txt   -mtime   +14   -type f -exec rm {} \; Replace a string :%s/pattern/replace/ /g for all at once Convert Windows text file to Unix file --we do it by removing the character "\r" Od -c filename | head -- to check if it has windows characters ...

MongoDB Commands

Export collection without ID field: mongo --host dfwlnpmgdb-03:27018 cpq_prod --quiet --eval "db.PricingTable.find({}, {_id: 0}).forEach(printjson)" > /home/kolguk01/export/out.json Create/DROP Index: Note: Always use background set to true while creating the indexes db.css.dropIndex("ts_365_days") db.css.dropIndex("url_1_src_1") db.css.dropIndex("_id_") db.css.createIndex( { "ts" : 1}, {"name" : "ts_365_days", "expireAfterSeconds" : 31536000,background : true}) db.css.createIndex( { "url" : 1, "src" : 1}, {"name" : "url_1_src_1", "unique" :true,background : true}) db.css.createIndex( { "_id" : 1}, {"name" : "_id_" ,background : true}) Select documents without the _id field db . collection . find ({}, { _id : 0 }) How to configure Replica set in MongoDB Step 1 : In th...