Skip to main content

Posts

Suspend & Resume Always on AG Group Sync

  Suspend Sync Go to Primary Node Execute below dynamic query: select 'ALTER DATABASE ['+DB_name(database_id)+'] SET HADR SUSPEND;' from master.sys.dm_hadr_database_replica_states where is_local = 1 For example, it will show the below result. Copy the below line and execute. ALTER DATABASE [AAA] SET HADR SUSPEND; ALTER DATABASE [BBB] SET HADR SUSPEND;   Resume Sync Go to Primary Node Execute below dynamic query: select 'ALTER DATABASE ['+DB_name(database_id)+'] SET HADR RESUME;' from master.sys.dm_hadr_database_replica_states where is_local = 1 For example, it will show the below result. Copy the below lines and execute. ALTER DATABASE [AAA] SET HADR RESUME; ALTER DATABASE [BBB] SET HADR RESUME;

Generate Creation Table Script using SQL Query

SQL Query select 'create table ' || table_name || ' (' || column_name || ' ' ||  DATA_TYPE || '(' ||  case data_type  when 'NUMBER' then data_precision when 'VARCHAR2' then CHAR_LENGTH when 'CHAR' then CHAR_LENGTH end  || '),' txt,table_name,column_id,data_type from user_tab_columns where table_name in (  'EMPLOYEE', 'EMPLOYEE_POSITION'  ) and column_id=1 union select column_name || ' ' ||  DATA_TYPE || '(' ||  case data_type  when 'NUMBER' then data_precision when 'VARCHAR2' then CHAR_LENGTH when 'CHAR' then CHAR_LENGTH end || '),' txt,table_name,column_id,data_type from user_tab_columns out1 where table_name in (  'EMPLOYEE', 'EMPLOYEE_POSITION' ) and column_id>1 and column_id<( select max(column_id) from user_tab_columns where table_name=out1.table_name ) union select column_name || ' ' ||  DATA_TYPE || '(' ||  case dat...

How to check progress of dbcc shrinkfile

  Query to check progress of dbcc shrinkfile select s.session_id,command,t.text,percent_complete,s.start_time from sys.dm_exec_requests s  CROSS APPLY sys.dm_exec_sql_text(s.sql_handle) t where command like '%Dbcc%'

Oracle Wait Events

Below query to check the wait events in the database col EVENT for a50 set head on feed on set lines 134 pages 2000 select event,count(*) from  gv$session where event not like 'Streams%' and wait_class <> 'Idle' group by event order by 2;

Unix Bash Script

Bash Script that will recursively find all files under a directory and also under sub-directories. It will print all the files and also show the count for the words inside the files. count_words.sh for i in `find $1 -name "*" -type f` do wc -w $i done count_words.sh <directory_name>

Load records from csv file in S3 file to RDS MySQL database using AWS Data Pipeline

 In this post we will see how to create a data pipeline in AWS which picks data from S3 csv file and inserts records in RDS MySQL table.  I am using below csv file which contains a list of passengers. CSV Data stored in the file Passenger.csv Upload Passenger.csv file to S3 bucket using AWS ClI In below screenshot I am connecting the RDS MySQL instance I have created in AWS and the definition of the table that I have created in the database testdb. Once we have uploaded the csv file we will create the data pipeline. There are 2 ways to create the pipeline.  Using "Import Definition" option under AWS console.                    We can use import definition option while creating the new pipeline. This would need a json file which contains the definition of the pipeline in the json format. You can use my Github link below to download the JSON definition: JSON Definition to create the Data Pipeline Using "Edit Architect" ...

Install Gitlab-runner and execute your first pipeline

In this article we will see how to install gitlab-runner on Redhat Linux 6 What is Gitlab Runner? Below is the definition of Gitlab-runner as provided in Gitlab documentation: " GitLab Runner is the open source project that is used to run your jobs and send the results back to GitLab. It is used in conjunction with Gitlab CI/CD , the open-source continuous integration service included with GitLab that coordinates the jobs" As you can see in below screenshot that there are currently no runners registered with your Gitlab. In order to see all registered runners: Goto your Gitlab console -> Your Project -> Settings -> CI / CD Expand the Runners section and you will see a screen similar to below. Any registered runners will be visible in this section. You can't see any runners, as currently there are no runners registered. Now let us see the steps to install Gitlab runner, register it with Gitlab and run your first pipeline: Install Runner: - Run the wget command to...