Monday, 27 November 2017

How to run maven build through command prompt?


Change directory and move into the folder where the pom.xml file exists. Then run the following two commands to build the maven.

Clean Compile:

mvn clean compile -Dmaven.test.skip=true

Run:

mvn install -Dmaven.test.skip=true

-Dmaven.test.skip=true  will skip the test folder and files.

Wednesday, 22 November 2017

How to create admin and db based user in mongodb?


Admin User:

db.createUser(
    {
      user: "admin",
      pwd: "password123",
      roles: ["userAdminAnyDatabase","userAdmin","readWrite","dbAdmin","clusterAdmin","readWriteAnyDatabase","dbAdminAnyDatabase"]
    }
)

DB based User:

User who can access only a specific database.

db.createUser(
   {
     user: "myuser",
     pwd: "password123",
     roles: [ { role: "readWrite", db: "databasename" } ]
   }
);

Monday, 20 November 2017

How to get total number of active connections in linux?


Solution

netstat -n | grep [:portnumber] | grep ESTABLISHED | wc -l

Example

netstat -n | grep :8080 | grep ESTABLISHED | wc -l

Explanation 

netstat
(network statistics) command displays network connections (both incoming and outgoing), routing tables, and a number of network interface (network interface controller or software-defined network interface) and network protocol statistics.

-n: Show numerical addresses instead of trying to determine symbolic host, port or user names

grep (global regular expression print) command processes text line by line and prints any lines which match a specified pattern.

wc (word count) command prints a count of newlines, words, and bytes for each input file. 

-l: print the newline counts.

The total number of locks exceeds the lock table size

 SHOW VARIABLES LIKE 'innodb_buffer_pool_size'; SET GLOBAL innodb_buffer_pool_size = 2147483648;  -- 2GB Note: The value is in byte...