Unix

Connecting to a linux instance using putty and pem file


For the full post @ Linux Academy, use this link.
Courtesy : James and the Linux Academy !!

Advertisements

Error attaching to process: sun.jvm.hotspot.debugger.DebuggerException: Can’t attach to the process [ solved ]


I was in the process of getting the much awaited heap dump using jmap, from an ailing java process and booom !! This happens !!

Error attaching to process: sun.jvm.hotspot.debugger.DebuggerException: Can't attach to the process

Well, there are two things here that needs to be taken care off.

  1. The jmap process and the java process ( of whose, the heap dump is being taken ) should be running in the same user id.
  2. There is a linux ptrace bug which will prevent jmap from attaching to the java process. To resolve this, punch in the following command before you execute the jmap heapdump command.
echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope

Now go ahead and execute the heapdump command using jmap.

jmap -heap:format=b <process-id>

and voila !!…You are done !! ๐Ÿ™‚ ๐Ÿ™‚

 

Changing the default data directory in Mysql


Had to reconfigure the mysql data directory today. Found this stackoverflow link to be spot on.
stackoverflow-change mysql default data directory ( I really don’t want to be accused of plagiarism)
Reproducing the content here [Just in case the link disappears]

1. Stop MySQL using the following command:

sudo /etc/init.d/mysql stop

2. Copy the existing data directory (default located in /var/lib/mysql) using the following command:

sudo cp -R -p /var/lib/mysql /newpath

3. Edit the MySQL configuration file with the following command:

gedit /etc/mysql/my.cnf

4. Look for the entry for datadir, and change the path (which should be /var/lib/mysql) to the new data directory.

5. In the terminal, enter the command:

sudo gedit /etc/apparmor.d/usr.sbin.mysqld

6. Look for lines beginning with /var/lib/mysql. Change /var/lib/mysql in the lines with the new path. Save and close the file.

7. Restart the AppArmor profiles with the command:

sudo /etc/init.d/apparmor reload

8. Restart MySQL with the command:

sudo /etc/init.d/mysql restart

9. Now login to MySQL, and you can access the same databases you had before.

Cheers !!
The Nonsense Logger !!

Install Mysql in Ubuntu without Internet [Solved]


Today, i had to install mysql in an Ubuntu 12.04 64 bit precise instance. Ideally on an instance connected to the internet, issue the following command

sudo apt-get install mysql-server mysql-client

and you are ready to rock n roll !!

But that’s when your machine is directly connected to the internet. What do you do when you don’t have internet access on the machine?

Some scratching of the head and some more googling led me to this. You have to individualy download the required debian packages on a different machine, transfer them to your target machine and then install them using the dpkg command in the following order. Im sharing it here for self reference and for anyone else who would find this useful.

sudo dpkg -i libnet-daemon-perl_0.43-1_all.deb
sudo dpkg -i libplrpc-perl_0.2020-2_all.deb
sudo dpkg -i libdbi-perl_1.622-1_amd64.deb
sudo dpkg -i mysql-common_5.5.32-0ubuntu0.12.04.1_all.deb
sudo dpkg -i libmysqlclient18_5.5.32-0ubuntu0.12.04.1_amd64.deb
sudo dpkg -i libdbd-mysql-perl_4.021-1_amd64.deb
sudo dpkg -i mysql-client-core-5.5_5.5.32-0ubuntu0.12.04.1_amd64.deb
sudo dpkg -i libterm-readkey-perl_2.30-4build3_amd64.deb
sudo dpkg -i mysql-client-5.5_5.5.32-0ubuntu0.12.04.1_amd64.deb
sudo dpkg -i mysql-server-core-5.5_5.5.32-0ubuntu0.12.04.1_amd64.deb
sudo dpkg -i mysql-server-5.5_5.5.32-0ubuntu0.12.04.1_amd64.deb
sudo dpkg -i mysql-server_5.5.32-0ubuntu0.12.04.1_all.deb
sudo dpkg -i libhtml-template-perl_2.9-2_all.deb


Note : The packages mentioned above are meant specifically for the ubuntu 12.04 precise version. The required packages might vary from version to version. However the list above will give you a general sense of direction in case you land up in a situation like mine !!

Cheers !!
The Nonsense Blogger !!

Zip command in Ubuntu


 

Zipping a File

Format : zip <filename.zip> dir1 dir2…..

Example : zip abc.zip test1/ test2/

This creates a zip file abc.zip with the contents of ย folders test1 and test2

 

Unzipping a File

Format : unzip <filename.zip>

Example : unzip abc.zip

This unzips the contents of abc.zip to the current directory location

 

Unzipping a File to a specific folder

Format : unzip <filename.zip> -d dirname/

Example : unzip abc.zip -d unzip_dir/

This creates a folder unzip_dir and then unzips the contents of abc.zip to that folder.

 

Regards,

The NonsenseBlogger

Enabling SSL in JBoss Server


Difference between HTTP and HTTPS

Both HTTP and HTTPS are protocols used for client-server communication. The difference being that, in case of HTTPS, the communication between the client( usually a web browser ) and server ( usually a web server ) is done in an encrypted fromat. This is achieved by using SSL.

Find more about SSL here : SSL Guide for Openfire

Enabling SSL in JBoss App Server

To enable HTTPS or SSL connection in JBoss, one needs to create a keystore which will contain Self Signed Certificates that the JBoss server will use to communicate with the client. Use the following java command to create the keystore.

keytool -genkey -alias tomcat -keyalg RSA -keystore NAME_OF_KEYSTORE -validity NUMBER_OF_DAYS

Example : keytool -genkey -alias tomcat -keyalg RSA -keystore JBoss_KS_Arun -validity 60

This will create a keystore in the name JBoss_KS_Arun. Copy this to the jboss/server/default/conf/ directory in JBoss. Then modify the server.xml as follows

ย <Connector port=”8443″ protocol=”HTTP/1.1″ SSLEnabled=”true”
maxThreads=”150″ scheme=”https” secure=”true”
clientAuth=”false”
strategy=”ms”
address=”${jboss.bind.address}”
keystoreFile=”${jboss.server.home.dir}/conf/JBoss_KS_Arun”
keystorePass=”JBoss_KS_Arun”
truststoreFile=”${jboss.server.home.dir}/conf/JBoss_KS_Arun”
truststorePass=”JBoss_KS_Arun”
sslProtocol=”TLS”/>

Now try hitting the server @ https://localhost:8443. You should be able to see the JBoss welcome screen. ๐Ÿ™‚ ๐Ÿ™‚

The other option to Self Signed Certificates is to use certificates from Certification Authorities ( CA ) like verisign. To find the difference both, use this link

Cheers,

The Nonsense Logger

What is .bashrc


What is .bashrc ?

.bashrc contains the scripts that are executed when ‘BASH’ shell ( Bourne Again Shell ) is launched. ย It basically contains the settings that must be enabled for a bash shell when it is launched. The ‘.bashrc’ exist at two levels ie one at the root level ( global one ) and another one at the user level ( ie shell settings specific for that particular user )

Global bashrc location : /etc/

User Specifc location : /home/username/

Ideally all your environment variables like JAVA_HOME should be set inside your .bashrc.

eg :

#Setting Java Home and Path Variable
export JAVA_HOME=/home/mindtree/java/jdk1.6.0_22
export PATH=$JAVA_HOME/bin:$PATH
export ODE_HOME=/home/mindtree/apache-ode-jbi-2.0-beta2
export RAPIDAPPSERVER_HOME=/home/mindtree/RCSBuildXMLFiles

Once you change the contents of .bashrc. ย You need to execute the command

$source .bashrc

so that the changes take effect. If this doesn’t work, try starting a new terminal or a new tab within the existing terminal.

More on linux shell scripting @ ย http://www.arachnoid.com/linux/shell_programming.html

Cheers,

The Nonsense Blogger ๐Ÿ™‚ ๐Ÿ™‚