2014. november 14., péntek

ActiveMQ on Ubuntu 14.04 x64 VPS - Solve OutOfMemoryError, Could not reserve enough space for object heap

You need some tweaks to run ActiveMQ in a resource-constrained VPS environment, I've tried this on a VPS that had 2GB RAM.

0. Download ActiveMQ, extract to /opt/activemq and run:

./activemq setup



1. Tweak JAVA minimum heap memory and max heap size - run and also put this line to ~/.bashrc :

export JAVA_OPTS="-Xms128m -Xmx512m"


Verify settings:

echo $JAVA_OPTS
-Xms128m -Xmx512m

echo $_JAVA_OPTIONS

(empty)



2. Limit resource usage (memoryUsage -> 32MB):
nano conf/activemq.xml

          <systemUsage>
            <systemUsage>
                <memoryUsage>
                    <memoryUsage limit="32 mb"/>
                </memoryUsage>
                <storeUsage>
                    <storeUsage limit="10 gb"/>
                </storeUsage>
                <tempUsage>
                    <tempUsage limit="10 gb"/>
                </tempUsage>
            </systemUsage>
        </systemUsage>



3. Comment out a few transport Connectors


        <transportConnectors>
            <!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
            <transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>

      <!--      <transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
            <transportConnector name="stomp" uri="stomp://0.0.0.0:61613?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
            <transportConnector name="mqtt" uri="mqtt://0.0.0.0:1883?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
            <transportConnector name="ws" uri="ws://0.0.0.0:61614?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
      
-->
  </transportConnectors>




4. Set ACTIVEMQ_OPTS_MEMORY and ACTIVEMQ_OPTS

nano /etc/default/activemq

# Set jvm memory configuration
if [ -z "$ACTIVEMQ_OPTS_MEMORY" ] ; then
ACTIVEMQ_OPTS_MEMORY="-Xms128M -Xmx512M"
fi

# Uncomment to enable audit logging
#ACTIVEMQ_OPTS="$ACTIVEMQ_OPTS -Dorg.apache.activemq.audit=true"
ACTIVEMQ_OPTS="$ACTIVEMQ_OPTS -Dorg.apache.activemq.UseDedicatedTaskRunner=false"



5. Setting up proper passwords:

/opt/activemq/conf# nano jetty-realm.properties

# username: password [,rolename ...]



Error messages on a VPS with 2GB RAM before tweaks:

INFO: Loading '/etc/default/activemq'
INFO: Using java '/usr/bin/java'
Error occurred during initialization of VM
Could not reserve enough space for object heap
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.


opt/activemq/bin/activemq console
INFO: Loading '/etc/default/activemq'
INFO: Using java '/usr/bin/java'
INFO: Starting in foreground, this is just for debugging purposes (stop process by pressing CTRL+C)
Error occurred during initialization of VM
java.lang.OutOfMemoryError: unable to create new native thread
at java.lang.Thread.start0(Native Method)
at java.lang.Thread.start(Thread.java:714)
at java.lang.ref.Finalizer.<clinit>(Finalizer.java:226)

./activemq: 453: ./activemq: Cannot fork

ERROR: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.activemq.xbean.XBeanBrokerService#0' defined in class path resource [activemq.xml]: Invocation of init method failed; nested exception is java.lang.OutOfMemoryError: unable to create new native thread
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.activemq.xbean.XBeanBrokerService#0' defined in class path resource [activemq.xml]: Invocation of init method failed; nested exception is java.lang.OutOfMemoryError: unable to create new native thread


Environment details:

ulimit -a
core file size          (blocks, -c) unlimited
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 127259
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 10240
cpu time               (seconds, -t) unlimited
max user processes              (-u) 127259
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

See also:

http://activemq.apache.org/javalangoutofmemory.html

2014. november 12., szerda

Kiegészítő LaTeX csomagok használata a Gummi, illetve TeX Live szerkesztőkben (Ubuntu 14.04)

Gummi TeX szerkesztő telepítése:

sudo apt-get install gummi 

Futassuk az alábbi két parancsot a Terminálból:

cd ~/.config/gummi
ln -s /usr/share/texmf-texlive

EN: Use additional LaTeX / TeX packages for Gummi or TeX Live on Ubuntu
  1. Figure out where you installed the extra packages, from TeX Live or whatever else.  (For me, they live at /usr/share/texmf-texlive/.)
  2. Create a symbolic link within the Gummi configuration folder to the TeXLive files:
    • cd ~/.config/gummi
      ln -s /usr/share/texmf-texlive
    Experimentation suggests that pointing Gummi at the top-level directory is sufficient for access to all of the subfolders.  If it fits the structure of your machine better, you could also copy or move the files — but I’d stick with a symbolic link unless you have a good plan in mind.
http://www.pamelatoman.net/blog/2013/11/using-additional-packages-with-gummi/

2014. november 3., hétfő

GRUB és indítóképernyő testreszabás

EN: Customize GRUB wallpaper and boot splash logo - Ubuntu 14.04

GRUB háttérkép beállítása:

Válasszunk ki egy nem-indexelt, RGB típusú PNG képet 640x480-as felbontásban (wallpaper.png)

sudo cp wallpaper.png /boot/grub/
sudo update-grub

Indítóképernyő:

Töltsd le és csomagold ki a ZIP fájlt:
http://data.hu/get/8188574/ubuntu-boot-myimage.zip

sudo cp -r ubuntu-boot-myimage '/lib/plymouth/themes'
sudo mv '/lib/plymouth/themes/default.plymouth' '/lib/plymouth/themes/default.plymouth.backup'
sudo ln -s '/lib/plymouth/themes/ubuntu-boot-myimage/ubuntu-faded-screen.plymouth' '/lib/plymouth/themes/default.plymouth'
sudo update-initramfs -u

2014. november 2., vasárnap

Bejelentkezési probléma sudo startx futtatása után

EN: After running sudo startx, system does not log in on Ubuntu Linux.

Problem: user root became owner of ~/.Xauthority file

Solution:
Press CTRL+ALT+F1, log in and run:
sudo chown USERNAME .Xauthority
sudo chgrp USERNAME .Xauthority

Where USERNAME is your user (login) name.

PDF dokumentumokból szöveg készítése (OCR) Linuxon

EN: How to OCR any PDF file on Ubuntu Linux with pdftoppm, convert and tesseract

#!/bin/sh
mkdir tmp 2>/dev/null
cp $@ tmp
cd tmp
clear
echo
echo "Processing $@..."
pdftoppm *.pdf -f 1 -l 100 -r 600 ocrbook 2>error.txt

for i in *.ppm; do
echo "CONVERT: $i"
convert "$i" "`basename "$i" .ppm`.tif"; done

for i in *.tif; do
echo "OCR: $i"
# -l hun  -->> OCR for HUNGARIAN LANGUAGE
tesseract 1>/dev/null 2>error.txt "$i" "`basename "$i" .tif`" -l hun; done
for i in *.txt; do cat $i >> pdf-ocr-output.txt; echo "\n[$1]\n" >> pdf-ocr-output.txt; done
mv pdf-ocr-output.txt ..

# Cleanup
mkdir text 2>/dev/null
mv *.txt text 2>/dev/null
rm * 2>/dev/null
cd ..
#rmdir tmp


Original source (script was modified):
http://ubuntuforums.org/showthread.php?t=880471

2014. október 18., szombat

Linux folyamatok elemzése, hibakeresés

EN: Linux process information, debugging

dstat -cdmnspg --top-bio --top-io --top-cpu


dstat output on Linux

2014. október 16., csütörtök

Oneplus One USB transfer in Ubuntu 14.04 x64

USB adatátvitel OnePlus One telefonra Ubuntu 14.04 Linux rendszeren:

gksu gedit /lib/udev/rules.d/69-libmtp.rules

Adding the following entries did the trick:

ATTR{idVendor}=="05c6", ATTR{idProduct}=="6764", SYMLINK+="libmtp-%k", MODE="660", GROUP="audio", ENV{ID_MTP_DEVICE}="1", ENV{ID_MEDIA_PLAYER}="1", TAG+="uaccess"

ATTR{idVendor}=="05c6", ATTR{idProduct}=="6765", SYMLINK+="libmtp-%k", MODE="660", GROUP="audio", ENV{ID_MTP_DEVICE}="1", ENV{ID_MEDIA_PLAYER}="1", TAG+="uaccess"

Restart udev:
sudo service udev restart

Reconnect the device and it should work. Make sure that MTP transfer mode is selected on your phone.

http://askubuntu.com/questions/505932/ubuntu-14-04-mtp-error

2014. október 11., szombat

MySQL 5.5 telepítése Ubuntu 14.04 rendszerre

Install MySQL 5.5 on Ubuntu 14.04

sudo apt-get install libdbd-mysql-perl libmysqlclient18 mysql-client-5.5 mysql-client-core-5.5 mysql-common mysql-server mysql-server-5.5 mysql-server-core-5.5 php5-mysql phpmyadmin

2014. július 31., csütörtök

Samsung telefon tárhely nem csatolható Ubuntu 12.04 alatt

EN: Unable to mount SAMSUNG_Android in UBUNTU 12.04


Hiba: Error initializing camera: -60: Could not lock the device

Futassuk Terminálból:
sudo add-apt-repository ppa:langdalepl/gvfs-mtp
sudo apt-get update
sudo apt-get install gvfs

És indítsuk újra a számítógépet.

http://stackoverflow.com/questions/15055304/unable-to-mount-samsung-android-in-ubuntu

2014. július 20., vasárnap

Ubuntu 14.04 LTS software installer and config shell script

#!/bin/sh

echo "Install common GNU/Linux applications to Ubuntu"
cd
cd Letöltések
cd Downloads

#+SYSTEM
sudo apt-get install -y gmountiso p7zip rar lame xfburn
sudo apt-get install -y krusader kdiff3 krename
sudo apt-get install -y gnome-system-tools bleachbit gparted

# HDD
sudo apt-get install -y preload shred srm

# HU
sudo apt-get install -y language-pack-hu language-pack-gnome-hu language-pack-hu-base language-pack-gnome-hu-base

#+OFFICE
sudo apt-get install -y libreoffice-presentation-minimizer libreoffice-l10n-hu aspell-hu hunspell-hu aspell-en hunspell-en-us

#+MEDIA
sudo apt-get install -y vlc phatch nautilus-image-converter audacity picard puddletag gimp

# Skype telepítése
#Ubuntu - enable "partner" repository
#sudo sed -i "/^# deb .*partner/ s/^# //" /etc/apt/sources.list
#sudo apt-get update
#sudo apt-get install -y skype

#  Skype honlap - Website:
#http://www.skype.com/hu/download-skype/skype-for-linux/downloading/?type=ubuntu64
wget get.skype.com/go/getskype-linux-beta-ubuntu-64 -O skype.deb
sudo apt-get install -y gdebi
sudo gdebi --n skype.deb

# Skype magyar nyelvi fájl telepítése
wget http://urbalazs.hu/blog/uploads/skype_hu_4.3.0.37.tar.gz
sudo tar -C /usr/share/skype/lang -xzf skype_hu_4.3.0.37.tar.gz

# Audex Hang CD átalakító program  - Audex CD ripper application:
sudo apt-get install -y audex

# Nem szükséges programok eltávolítása -  Remove unneeded apps - OPTIONAL
sudo apt-get purge -y brasero

# Install Chromium + default incognito mode
sudo apt-get install -y chromium-browser
sudo perl -pi -e 's?Exec=chromium-browser?Exec=chromium-browser --incognito?g' /usr/share/applications/chromium-browser.desktop

# Védett mód - protected mode
# http://sourceforge.net/projects/firejail/files/firejail/
sudo perl -pi -e 's?Exec=chromium-browser?Exec=firejail chromium-browser --incognito?g' /usr/share/applications/chromium-browser.desktop

#+Google Chrome
sudo deb http://dl.google.com/linux/deb/ stable non-free main
sudo wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -

# Run Windows applications - Office 2003/2007/2010, Total Commander, Photoshop, games, etc...
# See AppDB: https://appdb.winehq.org/
yes | sudo add-apt-repository ppa:ubuntu-wine/ppa

# Ubuntu Tweak telepítése
yes | sudo add-apt-repository ppa:tualatrix/ppa

# INSTALL FROM EXTRA REPOSITORIES
sudo apt-get update
sudo apt-get install -y google-chrome-stable
sudo apt-get install -y ubuntu-tweak
sudo apt-get install -y playonlinux winetricks wine1.7

# Apport letiltása - megszűnnek a bosszantó rendszerösszeomlás-jelentések
# Disable apport - remove annoying system crash messages
sudo perl -pi -e 's/enabled=1/enabled=0/g' /etc/default/apport

# Swap only after 90% RAM is full
echo "vm.swappiness = 10" | sudo tee -a /etc/sysctl.conf

# END OF AUTOMATED PART
exit 0

# Wifi hotspot: Ethernet kapcsolat + Wifin internet megosztás:
# sudo perl -pi -e 's?mode=infrastructure?mode=ap' /etc/NetworkManager/system-connections/wifi-hotspot
# [ipv4]
# method=shared


# Szoftver tárolók könnyű hozzáadása
# Add repositories easily:
sudo apt-get install -y python-software-properties

# Krita képszerkesztő és digitális festőprogram - Krita image editor and digital painter
yes | sudo add-apt-repository ppa:kubuntu-ppa/backports 
sudo apt-get update
sudo apt-get install -y krita

# e.g. install MUMBLE VoIP client:
yes | sudo add-apt-repository ppa:mumble/release
sudo apt-get update
sudo apt-get install -y mumble

# SWF fájlok megnyitása böngészőben - Play SWF files in browser
sudo perl -pi -e 's?<mime-type type="application/vnd.adobe.flash.movie">?<mime-type type="application/x-shockwave-flash">?g' /usr/share/mime/packages/freedesktop.org.xml
sudo update-mime-database /usr/share/mime

# Installing MATE in Ubuntu 14.04 LTS
yes | sudo apt-add-repository ppa:ubuntu-mate-dev/ppa
yes | sudo apt-add-repository ppa:ubuntu-mate-dev/trusty-mate
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install --no-install-recommends ubuntu-mate-core ubuntu-mate-desktop

# TEAMVIEWER - Távsegítség program telepítése - REMOTE HELP
wget http://download.teamviewer.com/download/teamviewer_i386.deb
sudo apt-get install -y gdebi
sudo gdebi --n teamviewer_i386.deb


Install latest Xfburn CD/DVD writer on Linux from source - Ubuntu 12.04

How to install Xfburn CD/DVD writer - Tested on Ubuntu 12.04 LTS x64
Xfburn linuxos CD/DVD író alkalmazás telepítése forrásból
Download source:
http://goodies.xfce.org/projects/applications/xfburn
Unpack.
Install dependencies - run these commands from the Terminal:

sudo apt-get install intltool libburn* libisofs* libgtk2.0-dev  libxfce4ui-1-* exo-utils* libexo-1-*

Usual installation:
cd into_unpacked_xfburn_src_directory
./configure
sudo make
sudo make install



2014. május 7., szerda

Install Photoshop CS6 on Ubuntu 14.04 x64

Install Photoshop CS6 on Ubuntu 14.04 x64

- Open the Terminal and type:

sudo add-apt-repository ppa:ubuntu-wine/ppa
sudo apt-get update
sudo apt-get install wine1.7 winetricks

winetricks atmlib gdiplus msxml3 vcrun2005 vcrun2005sp1 vcrun2008 fontsmooth-rgb gecko
- Start the installer:

cd [PS-Install-Directory]
wine setup.exe

- If installer fails, try the 32-bit wineprefix:

mv ~/.wine
~/.wine
_backup

WINEARCH=win32 WINEPREFIX=~/.wine winecfg

winetricks atmlib gdiplus msxml3 vcrun2005 vcrun2005sp1 vcrun2008 fontsmooth-rgb gecko 


cd [PS-Install-Directory]
wine setup.exe 

2014. március 15., szombat

Fájlok biztonságos törlése Linuxon a shred+srm paranccsal - Secure delete/wipe files on Linux with the shred+srm command

sudo apt-get install secure-delete

export PATH=$PATH:~/scripts

Create script in ~/scripts

#!/bin/bash

if [ $1 ]
then
    echo "Target folder given: $1"
    FOLDER="$1"
    cd $1 2>/dev/null
    if [[ $? -eq 1 ]]
    then
        echo "Target folder does not exist, exiting!"
        exit 1
    fi
else
    echo "Targeting current directory."
    FOLDER=`pwd`
fi

echo
echo $FOLDER
read -p "CAUTION! Are you sure to shred this entire folder? (y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
    echo
    ls
    echo
    echo "ALL FILES HERE and also in SUBDIRECTORIES WILL BE ERASED!"
    echo $FOLDER
    echo "--------------------------------------"
    read -p "!!! - CONFIRM AGAIN (capital Y/N) " -n 1 -r
    echo
    if [[ $REPLY =~ ^[Y]$ ]]
    then
        if [[ -e $1 ]]
        then
             find "$1" -type f -execdir shred -uvzn 3 '{}' \;
             srm -sR "$1"
        else
             find . -type f -execdir shred -uvzn 3 '{}' \;
             srm -sR .
        fi
    else
        echo "Exiting, no action."
        exit 1
    fi
fi