Monday, March 2, 2015

Install Redmine 3.0 on Ububtu 14.10 with PostgreSQL

# install system packages:

sudo apt-get install ruby ruby-dev
sudo apt-get install postgresql libpq-dev
sudo apt-get install libmagickwand-dev imagemagick libmagickcore-dev


# PostgreSQL database:

createuser redmine

createdb -O redmine -E UTF8 redmine

psql -d redmine -c "ALTER DATABASE redmine SET datestyle=\"ISO,MDY\";"


# if restore beckup:

pg_restore -d redmine -Fc -v redmine.backup

vacuumdb --all --analyze


# Ruby:
tar xvf redmine-3.0.0.tar.gz

cd redmine-3.0.0/

sudo gem install bundler

cp config/database.yml.example config/database.yml


# in config/database.yml:

# PostgreSQL configuration example
production:
  adapter: postgresql
  database: redmine_default
  host: localhost
  username: redmine
  encoding: utf8
  password: "postgres"




bundle install --without development test mysqlclientlib

rake generate_secret_token

# if new database:
# rake RAILS_ENV=production db:create
RAILS_ENV=production rake db:migrate
rake RAILS_ENV=production redmine:load_default_data

# if restore
bundle exec rake db:migrate RAILS_ENV=production
bundle exec rake redmine:plugins:migrate RAILS_ENV=production
bundle exec rake tmp:cache:clear tmp:sessions:clear RAILS_ENV=production



# Puma web server (optional)
#sudo gem install puma



#Start bash script redmine.sh :

#!/bin/bash

cd /opt/redmine-3.0.0
export RAILS_ENV=production
nohup ruby bin/rails server webrick -e production &

Thursday, July 11, 2013

Install Redmine 2.3 on Ubuntu 13.04 with PostgreSQL

Download sources - http://www.redmine.org/


# Install commands, Ubuntu - specific, not from official instruction:

sudo apt-get install ruby ruby-dev
sudo apt-get install postgresql libpq-dev
sudo apt-get install imagemagic libmagickwand-dev ruby-rmagick






# Install commands, universal:

sudo gem install bundler
 

cd redmine-2.3
sudo bundle install --without development test mysql
sudo gem install pg


cp config/database.yml.example config/database.yml



Edit  config/database.yml:

production:
  adapter: postgresql
  database: redmine
  host: localhost
  username: postgres
  password: "postgres"










rake generate_secret_token

createdb -E UTF8 redmine



# Restore Redmine from backup:

pg_restore -d redmine -Fc -O redmine.backup

rake db:migrate RAILS_ENV=production
rake tmp:cache:clear
rake tmp:sessions:clear



# Startup script redmine.sh:

#!/bin/bash

cd /opt/redmine-2.3
export RAILS_ENV=production
nohup ruby script/rails server webrick -e production &

Tuesday, November 27, 2012

Java VM GC optimization

First, you can try the latest G1 Garbage collection in JDK 7u4 and later:
-XX:+UseG1GC  (JDK 1.7u4) -
G1 GC give more predictable pauses and latency with large heaps.


Print GC statistics

 

In order to be informed of any latencies caused by gc, you need to turn on gc logging. This is the magic combination of switches that works well:
-Xloggc:/some/relative/or/absolute/path/gc.log
-XX:+PrintGCDetails
-XX:+PrintGCTimeStamps
-XX:+PrintGCDateStamps
-XX:+PrintTenuringDistribution

Other rich variant:

-verbose:gc
-XX:+PrintGCDetails
-XX:+PrintGCTimeStamps
-XX:+PrintGCDateStamps
-XX:+PrintTenuringDistribution
-XX:+PrintPromotionFailure
-XX:+PrintClassHistogramBeforeFullGC
-XX:+PrintClassHistogramAfterFullGC
-XX:+PrintGCApplicationConcurrentTime
-XX:+PrintGCApplicationStoppedTime
-Xloggc:memory/gc.log
-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=memory/heap.dump
-XX:+UnlockDiagnosticVMOptions
-XX:+PrintAssembly
-XX:+CheckJNICalls


Good latency pattern

 

Here is the list of the recommended JVM settings for low latency & high throughput (JDK 1.6):
-server
-Xms2048m
-Xmx2048m
-XX:+UseConcMarkSweepGC
-XX:+UseParNewGC
-XX:+AggressiveOpts
-XX:+CMSParallelRemarkEnabled
-XX:+CMSScavengeBeforeRemark
-XX:+UseCMSInitiatingOccupancyOnly
-XX:CMSInitiatingOccupancyFraction=65
-XX:CMSWaitDuration=300000
-XX:GCTimeRatio=19
-XX:+DisableExplicitGC
-XX:NewSize=128m
-XX:MaxNewSize=128m
-XX:PermSize=64m
-XX:MaxPermSize=64m
-XX:SurvivorRatio=88
-XX:TargetSurvivorRatio=88
-XX:MaxTenuringThreshold=15
-XX:MaxGCMinorPauseMillis=1
-XX:MaxGCPauseMillis=5
-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=./gc_heap_dump/
-XX:+PrintGCDateStamps
-XX:+PrintGCDetails
-XX:+PrintTenuringDistribution
-Xloggc:./gc_log.log


Aggressive memory and execution settings

 

-server
-XX:+AggressiveHeap
-XX:+UseCompressedOops
-XX:+CompactFields
-XX:+CMSClassUnloadingEnabled
-XX:+UseSharedSpaces
-XX:-UseLoopPredicate


Linux system tuning

 


Max number of opened files
/etc/security/limits.conf
your_username       soft    nofile  32768
your_username       hard    nofile  65536

Thursday, August 11, 2011

Install Bonita BPMS 5.4.2 with JBoss 6

(also tested with Bonita 5.5)

Bonita API tutorials
http://www.bonitasoft.org/blog/tutorial/building-your-applications-with-bonita-runtime-part-1/
http://www.bonitasoft.org/blog/tutorial/building-your-applications-with-bonita-runtime-part-2/
http://www.bonitasoft.org/blog/tutorial/building-your-applications-with-bonita-runtime-%E2%80%93-part-3/

Bonita installation tutorials
http://www.bonitasoft.org/wiki/doku.php
http://www.bonitasoft.org/wiki/doku.php?id=install_bos5.3_in_jboss

==============================

Installation:
- download Bonita 5.4.2 + JBoss 5.1 bundle

- copy bonita-app.war bonita.ear bonita.war to JBOSS_HOME/server/default/deploy/

- rename bonita.war to bonita-web.war
new administration path - http://127.0.0.1:8080/bonita-web/
(otherwise JBoss 6 generate exception because two appication with similar name.)

copy folders bonita/client bonita/server/ from bundle to JBOSS_HOME/


add Bonita configuration lines to  JBOSS_HOME/bin/run.conf

#Sets Bonita configuration variables
BONITA_OPTS="-DBONITA_HOME=../bonita -Dorg.ow2.bonita.api-type=EJB3 "
MEMORY_OPTS="-Xshare:auto -Xms512m -Xmx1024m -XX:MaxPermSize=256m -XX:+HeapDumpOnOutOfMemoryError"
LOG_OPTS="-Djava.util.logging.config.file=../external/logging/logging.properties"
JAVA_OPTS="$JAVA_OPTS $BONITA_OPTS $MEMORY_OPTS $LOG_OPTS"
export JAVA_OPTS

- if your start directory is not $JBOSS_HOME/bin then you must add absolute path to BONITA_HOME, for example -DBONITA_HOME=/opt/jboss-6.0.0.Final/bonita


- add security configuration to JBoss:
Add to $asDomain\conf\login-config.xml inside <policy> tags:

<!-- Config for Bonita -->
<application-policy name="BonitaAuth">
          <authentication>
            <login-module code="org.ow2.bonita.identity.auth.BonitaIdentityLoginModule" flag="required"/>
          </authentication>
</application-policy>
<application-policy name="BonitaStore">
          <authentication>
            <login-module code="org.ow2.bonita.identity.auth.BonitaRemoteLoginModule" flag="required"/>
            <login-module code="org.jboss.security.ClientLoginModule" flag="required">
             <module-option name="password-stacking">useFirstPass</module-option>
           </login-module>
          </authentication>
</application-policy>
<!-- End config for bonita -->


==============================

Libraries:

- add

bonita-client-5.4.2.jar
jaxrs-api-1.2.1.GA.jar

to $JBOSS_HOME/client


- replace slf4j-api with version 1.6.1 (latest)

- replace hibernate-search with version 3.4.Final (latest) and move to /common/lib/

- replace lucene-core with version 3.1 (latest) and move to /common/lib/
- replace lucene-analyzers with version 3.1 (latest) and move to /common/lib/


bonita.war
- remove asm.jar
commons-codecs
commons-io
commons-logging
slfj
xstream


remove all hibernate & lucene libraries from bonita.ear WEB-INF/lib
(I removed all libraries from bonita.ear WEB-INF/lib)

==============================

Source code changes:

- make 2 changes in org.ow2.bonita.search.SearchUtil java class:

1 - recompile SearchUtil with hibernate-search-3.4.jar in dependencies
2 - remive (comment) all hibernate search hanlers regishtations

You can find SearchUtil.java here:
http://svn.bonitasoft.org/bonita-runtime/tags/bonita-runtime-5.4/bonita-server/src/main/java/org/ow2/bonita/search/SearchUtil.java
and SearchUtil.class in bonita.ear:bonita-ejbjar.jar

rebuild with hibernate-search-3.4.jar in dependencies and pack back to bonita.ear:bonita-ejbjar.jar

==============================

Switch from H2 to PostgreSQL database (optional):

- create PostgreSQL Bonita databases:

createdb -h localhost -U postgres -E UTF8 bonita_journal
createdb -h localhost -U postgres -E UTF8 bonita_history

(Bonita will self-create tables)

- copy postgresql JDBC driver jar file to JBOSS_HOME/server/default/lib/

- remove $JBOSS_HOME/server/default/deploy/h2-ds.xml
- create Bonita database configuration file $JBOSS_HOME/server/default/deploy/postgres-ds.xml

with text:
<?xml version="1.0" encoding="UTF-8"?>

<datasources>
  <no-tx-datasource>
    <jndi-name>bonita/default/journal</jndi-name>
    <connection-url>jdbc:postgresql://localhost/bonita_journal</connection-url>
    <driver-class>org.postgresql.Driver</driver-class>
    <user-name>postgres</user-name>
    <password></password>
    <idle-timeout-minutes>0</idle-timeout-minutes>
  </no-tx-datasource>

  <no-tx-datasource>
    <jndi-name>bonita/default/history</jndi-name>
    <connection-url>jdbc:postgresql://localhost/bonita_history</connection-url>
    <driver-class>org.postgresql.Driver</driver-class>
    <user-name>postgres</user-name>
    <password></password>
    <idle-timeout-minutes>0</idle-timeout-minutes>
  </no-tx-datasource>

</datasources>

Edit these files (comment H2 parts and uncomment PostgreSQL parts)
jboss-6.0.0.Final/bonita/server/default/conf/bonita-history.properties
jboss-6.0.0.Final/bonita/server/default/conf/bonita-journal.properties
(there is bug - PostgreSQL port 5432 written as 5433 - you must replace to 5432)

....

Profit!

Thursday, July 7, 2011

Mercurial Version Control CheatSheet

Tutorial: http://hgbook.red-bean.com/read/

create a new repository in the given directory:
hg init

Making a local copy of a repository:
hg clone http://hg.serpentine.com/tutorial/hello

A tour through history:
hg log

Viewing specific revisions:
hg log -r 3
hg log -r 0272e0d5a517
hg log -r 4:2 (from 2 to 4 revision)

display the latest changeset (HEAD revision):
hg tip

tell what Mercurial knows about the files in the repository:
hg status

review changes:
hg diff

create a new changeset:
hg commit

use the hg pull command to bring changes from remote repository to local (hg pull does not (by default) touch the working directory files):
hg pull [remote repository]

command to tell us what changes the hg pull command would pull into the repository, without actually pulling the changes in:
hg incoming [remote repository]

update working files to latest repository revision:
hg update tip

The hg outgoing command tells us what changes would be pushed into another repository
(it simply lists any changes in the current repository that aren’t in the another repository):
hg outgoing [remote repository]

And the hg push command does the actual push into another repository:
hg push [remote repository]

Make patch from single revision:
hg export 3 > ../changes.diff
or
hg export tip > patch.diff

Apply patch (single revision):
hg import ../changes.diff

Create branch:
hg clone -r mybranchname

List activerepository branches:
hg branches -a

List actual repository branch head revisions:
hg heads

Merge heads:
hg merge
hg commit -m "merge"

Tag version:
hg tag Version-1.0

Init new project:
hg init myproject

Import Subversion repository
(Mercurial will automatically detect the trunk, tags and branches layout that Subversion projects usually use):
hg convert http://python-nose.googlecode.com/svn

To start tracking working files:
hg add

Undo changes that you have made to your working directory:
hg revert

Undo revision:
hg rollback

Undo entire changeset:
hg backout --merge

Finding the source (revision) of a bug:
hg bisect

Repository backup (The -U option doesn't check out a working directory after the clone completes):
hg clone -U myrepo myrepo.bak

Sign code (GPG extension):
hg sign [REVISION]

Check signature:
hg sigcheck REVISION

List signed revisions:
hg sigs

Friday, May 27, 2011

OpenERP 6.0 installation instruction (Debian 5)

Please read my previous post http://enterprise-soft.blogspot.com/2011/05/openerp-60-installation-instruction.html

Here are only Debian 5 specific differences


# install system dependencies
apt-get install python
apt-get install python-lxml
apt-get install python-mako
apt-get install python-egenix-mxdatetime
apt-get install python-dateutil
apt-get install python-psycopg2
apt-get install python-pychart
apt-get install python-pydot
apt-get install python-tz
apt-get install python-reportlab
apt-get install python-yaml
apt-get install python-vobject
apt-get install python-setuptools
apt-get install python-matplotlib # for client
apt-get install python-hippocanvas # for client

# configuration file for Debian - /usr/share/doc/openerp-server-6.0.2/openerp-server.conf

adduser openerp
su openerp
cd

#run for testing:
python /usr/lib/python2.5/site-packages/openerp-server/openerp-server.py

# run standalone server:
nohup python /usr/lib/python2.5/site-packages/openerp-server/openerp-server.py &

Postinstall steps

1. OpenERP client - change superadministrator password
2. OpenERP client - create database for your company

OpenERP 6.0 installation instruction (Ubuntu)

# download openerp-server and openerp-client sources from official site http://www.openerp.com/

# create database user
sudo su postgres
createuser openerp
psql template1 -c "alter role openerp with password 'postgres'";
exit

# install system dependencies
sudo apt-get install python-lxml
sudo apt-get install python-mako
sudo apt-get install python-egenix-mxdatetime
sudo apt-get install python-dateutil
sudo apt-get install python-psycopg2
sudo apt-get install python-pychart
sudo apt-get install python-pydot
sudo apt-get install python-tz
sudo apt-get install python-reportlab
sudo apt-get install python-yaml
sudo apt-get install python-vobject
sudo apt-get install python-setuptools
sudo apt-get install python-webdav # for client
sudo apt-get install python-matplotlib
sudo apt-get install python-hippocanvas

# test server:
tar -xzf openerp-server-6.0.0.tar.gz
cd openerp-server-6.0.0/bin
python openerp-server.py

# install server:
tar -xzf openerp-server-6.0.0.tar.gz
cd openerp-server-6.0.0
sudo python setup.py install

# run server:
openerp-server


#GTK client v. 5.0.14:
sudo apt-get install openerp-client

Open ERP Folder:
/usr/local/share/doc/openerp-server-6.0.2

# You can find the OpenERP server configuration file at ~/openerp-server-6.0.0/doc/openerp-server.conf
/usr/local/share/doc/openerp-server-6.0.2/doc/openerp-server.conf
(Debian - /usr/share/doc/openerp-server-6.0.2/openerp-server.conf )

Database Configuration:
1. configure openerp-server.conf
2. run server (openerp-server)
3. install GTK client
4. configure client to server path
5. create database from client menu


To create database from command line:
openerp-server -d DB_NAME -r DB_USER -w DB_PASSWORD --init=модули [--without-demo=all]