Category Archives: DevOps

Generating SSL certificate

ssl
To apply SSL connection in your server you have to use SSL certificate.
Here are the steps to create Self-Signed SSL certificate:

1. Install openssl.

yum install -y openssl

2. Create shell script add_ssl.sh:

#!/bin/bash
set -e

prefix=$1

# Generate private key
openssl genrsa -out $prefix.key 2048

# Generate CSR
echo -e "[LOCALE]\n[COUNTRY]\n[CITY]\n[COMPANY]\nSSL\n$prefix\n[EMAIL]\n\n\n\n" \
	| (openssl req -new -key $prefix.key -out $prefix.csr)

# Generate Self Signed Key
openssl x509 -req -days 365 -in $prefix.csr -signkey $prefix.key -out $prefix.crt

# Copy the files to the correct locations
mv $prefix.crt /etc/ssl
mv $prefix.key /etc/ssl
mv $prefix.csr /etc/ssl

Replace [LOCALE], [COUNTRY], [CITY], [COMPANY], [EMAIL] with your values.

3. Run script example:

./add_ssl.sh gik.firetrot.com

Why Docker?

docker
Docker is the most simple and clear method to isolate your services. DevOps can in significantly convenient way deploy and control their services in server environment.
Docker is nothing new but wrapper over LXC. There are two concepts when you start working with docker:

  • Docker image is what you build
  • Docker container is what you run

Docker uses layer system very similar to Version Control System. After restart container all data will be lost if not commited!
So, to run a docker container you have to create a docker image. There are two methods to create docker image. The first, you can get base docker image of your favorite linux OS, run and login to it and manually install whatever. After that commit image to save changes. It is old and hardcore way. I prefer the second one, create docker image from so called “Dockerfile” – describes all to compose image.

Example usage:

  1. Create folder “base”.
  2. Create “Dockerfile” in it with the following contents:
    FROM centos:7
    MAINTAINER "FireTrot Studio" <admin@firetrot.com>
    
    # ENV
    ENV container=docker
    
    # IMPORT
    RUN rpm --import http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7
    
    # INSTALL
    RUN yum -y install net-tools
    
    # RUN
    CMD ["ping", "localhost"]
    
  3. Build docker image with command:
    docker build -t base .
    
  4. Run docker container with command:
    docker run -it --name=base docker_base
    

And then you’ll see the output of container work.

VirtualBox ‘/etc/init.d/vboxdrv setup’ issue after kernel update

vboxkernel
It’s too disturbed to run ‘/etc/init.d/vboxdrv setup’ command after kernel update each time. But how can it be fixed?
Fortunately, way is:

sudo apt-get install linux-headers-`uname -r`
sudo dpkg-reconfigure virtualbox-dkms  
sudo modprobe vboxdrv

So, DKMS package keeps track of Linux kernel changes and recompiles the vboxdrv kernel module if necessary.
Thanx to http://askubuntu.com/a/220778 a lot!

Restart, shutsdown, logoff Windows from command line

cmdprompt
It’s often need to restart, shutsdown, logoff Windows from command line. For example, if you connect to OS via remote desktop protocol you can’t restart/shutdown it from UI.
In such case you can use next:

shutdown -r
restarts os

shutdown -s
shutdown os

shutdown -l
logoff os

shutdown -t xx
where xx is number of seconds to wait till shutdown/restart/logoff

shutdown -i
gives you a dialog box to fill in what function you want to use

shutdown -a
aborts the previous shutdown command....very handy!

Additional options:

-f
force the selected action

Thanx to http://stackoverflow.com/a/162305

JBoss remote debug

jboss_logo
To connect to JBoss application server remotely you should perform next action:

open run.conf.bat (for windows) or run.conf (for linux) file in JBoss bin folder
and add the following java argument:

JAVA_OPTS="$JAVA_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"

If you miss -Xdebug parameter you can enter to debug mode but after timeout (a few minutes) you’ll be disconnected and JBoss restart occurred!
Read more at http://stackoverflow.com/questions/18182666/eclipse-remote-debugging-with-jboss.

Thanx to http://stackoverflow.com/a/18211332

Firefox plugins what i use

ff
Here is a list of plugins for Firefox browser which i use everyday.

1. ColorfulTabs - colors every tab in a different color and makes them easy to distinguish while beautifying the overall appeal of the interface.
ColorfulTabs
https://www.binaryturf.com/free-software/colorfultabs-for-firefox

2. Tab Mix Plus – duplicating tabs, controlling tab focus, tab clicking options, undo closed tabs and windows, plus much more.
tabmixplus
http://tmp.garyr.net/

3. Tab Utilities – utilities for tabbed browsing.
TabUtilities
https://addons.mozilla.org/en-US/firefox/addon/tab-utilities/

4. Firebug - edit, debug, and monitor CSS, HTML, and JavaScript live in any web page.
Firebug
www.getfirebug.com

5. Ghostery - see who’s tracking your web browsing and block them.
Ghostery
https://www.ghostery.com/en/

6. gTranslate - translates the selected text via Google Translate.
gTranslate
https://addons.mozilla.org/en-US/firefox/addon/gtranslate/

7. Flash and Video Download – download flash games and videos with a single click.
FlashandVideoDownload
http://www.fnvfox.com/

Have fun with FF!

How to kill session in Oracle DB

oracle
To kill session in oracle we need:

Step 1: Find SID and SERIAL#:

SELECT SID, SERIAL# FROM v$session WHERE username = 'TEST';

Step 2: Try to disconnect session:

ALTER SYSTEM DISCONNECT SESSION 'sid,serial#' POST_TRANSACTION;

Or:

ALTER SYSTEM DISCONNECT SESSION 'sid,serial#' IMMEDIATE;

If doesn’t help, use next step.

Step 3: Run kill session command:

ALTER SYSTEM KILL SESSION 'sid,serial#' IMMEDIATE;

If doesn’t help, use next step.

Step 4: Kill system process. Firstly find SPID:

SELECT P.SPID, S.SID, S.SERIAL# FROM V$PROCESS P, V$SESSION S WHERE P.ADDR = S.PADDR AND S.SID = XXX;

And then for windows:

orakill ORACLE_SID spid

Or for linux:

kill spid

For more info, read here:
http://oracle-base.com/articles/misc/killing-oracle-sessions.php
http://www.ora00600.com/wordpress/articles/kill-oracle-session/