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