Monday, August 31, 2020

How to Convert Documents to PDF Format on the Ubuntu Command Line

 

Convert a single file to PDF format

Use the following command syntax in order to convert a single file located in your current directory:

$ lowriter --convert-to pdf filename.doc

For .docx files,

$ lowriter --convert-to filename.docx

Here is how I converted a .docx file to pdf. located in my Downloads folder.

Convert a single docx file to PDF on Linux

As you can see above, when I listed the contents of my current folder through the ls command, I could see the newly converted pdf file listed as well.

Saturday, August 22, 2020

Not able to access redshift Cluster in SQL Work Bench ? Solution is here.

 Go to AWS Redshift Dashboard.


Now Check for properties of the Cluster.



Now find the Network and Security tab 



Make sure that you have enabled 


Publicly accessible   Edit
Allow instances and devices outside the VPC connect to your database through the cluster endpoint

Yes

Thursday, August 20, 2020

Kafka Standalone testing producer and consumer -- Consumer is not receiving data even though we write something ?

 When you are testing kafka producer and consumer with standalone ..


If Consumer is not receiving data even though you write some data means that you did not pressed enter key ...

Until you enter enter key , consumer will not receive the data .

ERROR: Couldn't connect to Docker daemon at http+docker://localunixsocket - is it running?

 Problem: 




Solution:  run the docker-compose with sudo


Install Docker on Ubuntu Using Default Repositories

 Step 1: Update Software Repositories

It’s a good idea to update the local database of software to make sure you’ve got access to the latest revisions.

Open a terminal window and type:

sudo apt-get update

Allow the operation to complete.

Step 2: Uninstall Old Versions of Docker

Next, it’s recommended to uninstall any old Docker software before proceeding.

Use the command:

sudo apt-get remove docker docker-engine docker.io

Step 3: Install Docker on Ubuntu 18.04

To install Docker on Ubuntu, in the terminal window enter the command:

sudo apt install docker.io

Step 4: Start and Automate Docker

The Docker service needs to be setup to run at startup. To do so, type in each command followed by enter:

sudo systemctl start docker
sudo systemctl enable docker

enable docker command, in terminal

Step 5 (Optional): Check Docker Version

To verify the installed Docker version number, enter:

docker --version

checking version of docker installed in terminal

Tuesday, August 18, 2020

ERROR: org.apache.hadoop.hbase.PleaseHoldException: Master is initializing

 Solution for the above problem:


Change the zookeper default port : 2181 to 2282 

<property>

<name>hbase.zookeeper.property.clientPort</name>

<value>2282</value>

</property>

when we have to create the following path with zookeeper folder, it contains some data when we run start-hbase.sh  .. if nothing is created in this folder then  we will get the above error.

Actually I have pointed the zookeeper folder to HDFS .. But it is not working so that I have create the zookeeper folder in the following path... Note: we have to give write person to the start-hbase.sh running user .. 


<property>

<name>hbase.zookeeper.property.dataDir</name>

<value>/usr/local/softwares/hbase-2.2.5/zookeeper</value>

</property>


Sunday, August 16, 2020

How to Back Up and Restore a MySQL Database

 Back up From the Command Line (using mysqldump)

If you have shell or telnet access to your web server, you can backup your MySQL data by using the mysqldump command. This command connects to the MySQL server and creates an SQL dump file. The dump file contains the SQL statements necessary to re-create the database. Here is the proper syntax:

$ mysqldump --opt -u [uname] -p[pass] [dbname] > [backupfile.sql]
  • [uname] Your database username
  • [pass] The password for your database (note there is no space between -p and the password)
  • [dbname] The name of your database
  • [backupfile.sql] The filename for your database backup
  • [--opt] The mysqldump option

For example, to backup a database named 'Tutorials' with the username 'root' and with no password to a file tut_backup.sql, you should accomplish this command:

$ mysqldump -u root -p Tutorials > tut_backup.sql

This command will backup the 'Tutorials' database into a file called tut_backup.sql which will contain all the SQL statements needed to re-create the database.

With mysqldump command you can specify certain tables of your database you want to backup. For example, to back up only php_tutorials and asp_tutorials tables from the 'Tutorials' database accomplish the command below. Each table name has to be separated by space.

$ mysqldump -u root -p Tutorials php_tutorials asp_tutorials > tut_backup.sql

Sometimes it is necessary to back up more that one database at once. In this case you can use the --database option followed by the list of databases you would like to backup. Each database name has to be separated by space.

$ mysqldump -u root -p --databases Tutorials Articles Comments > content_backup.sql

If you want to back up all the databases in the server at one time you should use the --all-databases option. It tells MySQL to dump all the databases it has in storage.

$ mysqldump -u root -p --all-databases > alldb_backup.sql

The mysqldump command has also some other useful options:

--add-drop-table: Tells MySQL to add a DROP TABLE statement before each CREATE TABLE in the dump.

--no-data: Dumps only the database structure, not the contents.

--add-locks: Adds the LOCK TABLES and UNLOCK TABLES statements you can see in the dump file.

The mysqldump command has advantages and disadvantages. The advantages of using mysqldump are that it is simple to use and it takes care of table locking issues for you. The disadvantage is that the command locks tables. If the size of your tables is very big mysqldump can lock out users for a long period of time.

Back up your MySQL Database with Compress

If your mysql database is very big, you might want to compress the output of mysqldump. Just use the mysql backup command below and pipe the output to gzip, then you will get the output as gzip file.

$ mysqldump -u [uname] -p[pass] [dbname] | gzip -9 > [backupfile.sql.gz]

If you want to extract the .gz file, use the command below:

$ gunzip [backupfile.sql.gz]

Restoring your MySQL Database

Above we backup the Tutorials database into tut_backup.sql file. To re-create the Tutorials database you should follow two steps:

  • Create an appropriately named database on the target machine
  • Load the file using the mysql command:
$ mysql -u [uname] -p[pass] [db_to_restore] < [backupfile.sql]

Have a look how you can restore your tut_backup.sql file to the Tutorials database.

$ mysql -u root -p Tutorials < tut_backup.sql

To restore compressed backup files you can do the following:

gunzip < [backupfile.sql.gz] | mysql -u [uname] -p[pass] [dbname]

If you need to restore a database that already exists, you'll need to use mysqlimport command. The syntax for mysqlimport is as follows:

mysqlimport -u [uname] -p[pass] [dbname] [backupfile.sql]

Wednesday, August 5, 2020

he root scratch dir: /tmp/hive on hdfs should be writable current permissions are: rw-rw-rw s

Solution: /tmp/hive is temporary directory. Only temporary files are kept in this location. No problem even if we delete this directory, will be created when required with proper permissions.

Step 1) In hdfs, Remove the /tmp/hive directory ==> "hdfs dfs -rm -r /tmp/hive"

2) At OS level too, delete the dir /tmp/hive ==> rm -rf /tmp/hive

After this, started the spark-shell and it worked fine..

Monday, August 3, 2020

Create Jar file with Maven

Step 1: 
          Create a maven Project (any IDE or command line Maven)
Step 2: 
          Add the following to pom.xml file 

     
 <build>
        <sourceDirectory>src/main/scala</sourceDirectory>
        <testSourceDirectory>src/test/scala</testSourceDirectory>
        <plugins>
            <plugin>
                <groupId>org.scala-tools</groupId>
                <artifactId>maven-scala-plugin</artifactId>
                <version>2.15.2</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                        <configuration>
                            <args>
                                <arg>-dependencyfile</arg>
                                <arg>${project.build.directory}/.scala_dependencies</arg>
                            </args>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                    <showDeprecation>true</showDeprecation>
                    <showWarnings>true</showWarnings>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-eclipse-plugin</artifactId>
                <version>2.8</version>
            </plugin>
        </plugins>
    </build>

Step 3: 
          Clean the project with  : mvn clean
Step 4: 
        Create jar file with : mvn package
         The above command will create a jar file in target folder.

Now we have jar file which we can use in any application.

Create tuple in spark

scala> val rdd = sc.parallelize(for {
     |     x <- 1 to 3
     |     y <- 1 to 2
     | } yield (x, y), 8)

rdd: org.apache.spark.rdd.RDD[(Int, Int)] = ParallelCollectionRDD[13] at parallelize at <console>:24

scala> rdd.collect

res8: Array[(Int, Int)] = Array((1,1), (1,2), (2,1), (2,2), (3,1), (3,2))



Saturday, August 1, 2020

OBS Studio Audio Settings

In this discussion, I am going to explain how to set up Audio devices to OBS Studio.

Step 1:  

Open OBS Studio(Take New Profile)


On the Sources Section
   Click on the + Button then add Window Capture (xcomposite) and select any Window which we ant to record (say Browser.)

Now Click on the Settings  



and select Audio and then disable all the Devices section.

   Click on the + Button 




then add Audio Input Capture(PulseAudio)


Now add the filters by selecting the Audio mixer setting and then filters.

Make sure that we have to keep the System Volume to half.

With above setting Voice works properly

Recent Post

Databricks Delta table merge Example

here's some sample code that demonstrates a merge operation on a Delta table using PySpark:   from pyspark.sql import SparkSession # cre...