2011年12月28日星期三

solaris container with dedicated cpu

solaris with pooladm, poolcfg.
It will generate our cpu usage less, once your have the dedicated cpu the whole cpu number will reduce, that will caused your server has problem with shared, the load average will raise immediately.

blogspot merge with google +

blogspot 被merge 到了google+, 在google +上还没看到效果

2011年12月12日星期一

ssh issue

The GSS-API protected key exchange has failed without indication
from the server, possibly due to misconfiguration of the server.
Use the GssKeyEx option to disable GSS-API key exchange and try agai


change the sshd_config

# GSSAPI options
GSSAPIAuthentication no
#GSSAPICleanupCredentials yes
#GSSAPIStrictAcceptorCheck no
GSSAPIKeyExchange no


the authen and key line to no

nfs isse

after my reconfigure /etc/fstab, it was not working after reboot, the thing is the nfs client is not boot.
To solve this issue.
chkconfig nfs on

2011年12月6日星期二

Jenkins

#!/bin/bash
# Author: Alex Tu, 2011
#


### BEGIN INIT INFO
# Provides:          gbv-hudson-integration
# Required-Start:    $local_fs $network
# Required-Stop:
# Default-Start:     3 5
# Default-Stop:      0 1 2 6
# Short-Description: Starts the hudson server for CI
# Description:       Starts Continuous Integration System for VZG SOA
### END INIT INFO

# to avoid conflict with functions local $1
ARG=$1

APP="jenkins"

HUDSON_USER=jenkins
HUDSON_GROUP=jenkins
JAVA=/usr/bin/java
export HOME=/opt/${HUDSON_USER}
export HUDSON_WAR=/opt/${HUDSON_USER}/jenkins.war

# include rc.status functions
test -s /etc/rc.status && . /etc/rc.status && rc_reset

# use test_for_app (x|f)
test_for_app ()
{
    app_found=0
    if [ "f" = "$2" ] && [ -f $1 ]; then
        app_found=1
    elif [ "x" = "$2" ] && [ -x $1 ]; then
        app_found=1
    fi
    if [ 0 = $app_found ]; then
        echo -n "Warning:  Couldn't find $1"
        if [ "$ARG" = "stop" ] ; then
            rc_failed 0
        else
            rc_failed 5
        fi
        rc_status -v
        rc_exit
    fi
}


HUDSON_CMD="${JAVA} -jar ${HUDSON_WAR}"

HUDSON_PIDFILE=/var/run/jenkins.pid
HUDSON_LOG=/var/log/jenkins

usage ()
{
    echo ""
    echo "Usage: $0 "
    echo ""
    echo "where is one of the following:"
    echo "    start - start $APP if not running"
    echo "    stop - stop $APP if running"
    echo "    status - report whether $APP is running"
    echo "    restart - stop and restart $APP"
    echo "    usage, help - print this message"
}

get_pid_for_cmd ()
{
    for pid in `ls /proc`; do
        if [ -d /proc/$pid ] && [ -f /proc/$pid/cmdline ]; then
            if [ "$1" = "$(        # return with current pid
                return
            fi
        fi
    done
    pid=0
}

# checkport
# returns port_used
check_port()
{
    port=$1
    if netstat -nlept 2>/dev/null | grep --regexp=":$port " &>/dev/null ; then
            port_used=1
        else
            port_used=0
        fi
}

# checks hudson, sets/returns status -
# 0 if pidfile same as pid, running
# 3 no pidfile, not running (what with running?)
# 2 pidfile, but no process (remove file ...), not running
# 1 pidfile != pid, but running
# 4 no pidfile, but running
#
# @todo: check port usage
check_hudson()
{
    get_pid_for_cmd `eval echo ${HUDSON_CMD} | sed -e 's/ //g'`

    if [ -f $HUDSON_PIDFILE ]; then
                chown jenkins:jenkins ${HUDSON_PIDFILE}
        pidfile_pid=`cat $HUDSON_PIDFILE`
        if [ 0 = $pid ]; then
            status=2
        elif [ "$pid" = "$pidfile_pid" ]; then
            status=0;
        else
            status=1;
        fi       
    else
        if [ 0 = $pid ]; then
            status=3;
        else
            status=4;
        fi
    fi

}


test_for_app ${JAVA} x
test_for_app ${HUDSON_WAR} f

case "$1" in
    start)
        check_hudson
        case "$status" in
            0)
                echo "${APP} already running"
        rc_failed 0
        rc_status -v1
               rc_exit
                ;;
        1|4)
        echo "${APP} seems running but pidfile is not up to date or doesn't exist, please check!"
        rc_failed
                rc_status -v1
                rc_exit
        ;;
            2)
                echo "Found stale pidfile for ${APP} - unclean shutdown?"
                rm ${HUDSON_PIDFILE}
                ;;
            3)
                # not running - ok
            check_port $CI_HTTP_PORT
        if [ $port_used = 1 ]; then
            echo "Port $CI_HTTP_PORT already in use, pleas check!"
                    rc_failed
                    rc_status -v1
                    rc_exit
        fi
                ;;
            *)
                echo "Check for ${APP} failed"
                rc_failed
                rc_status -v1
                rc_exit
        esac

        echo -n "Starting ${APP}"
        startproc -f -u $HUDSON_USER -g $HUDSON_GROUP -p ${HUDSON_PIDFILE} ${HUDSON_CMD} >> ${HUDSON_LOG} 2>&1
        if ! [ 0 = $? ]; then
            echo -n "(Error - "
            case $? in
                2)
                    echo -n "invalid arguments"
                    ;;
                4)
                    echo -n "insufficient permission"
                    ;;
                5)
                    echo -n "no such program"
                    ;;
                7)
                    echo -n "launch failure"
                    ;;
                *)
                    echo -n "unspecified error"
                    ;;
            esac
            echo -n ")"
            rc_failed
            rc_status -v1
            rc_exit
        fi
    # removing spaces from commandline to be able to compare with /proc//cmdline
        get_pid_for_cmd `eval echo ${HUDSON_CMD} | sed -e 's/ //g'`
        if [ 0 = $pid ]; then
            echo "Warning - Couldn't obtain PID for ${APP} "
        else
            echo $pid > ${HUDSON_PIDFILE}
        fi
        rc_status -v
        ;;
    stop)
        if [ $1 = "stop" ]; then
            check_hudson
        if ! [ $status = 0 ]; then
        echo "Warning - not running!"
        fi
            killproc -p ${HUDSON_PIDFILE} -t 10 ${JAVA}
            rc_status -v
        fi
        ;;
    status)
        check_hudson
    case "$status" in
        0)
            echo -n "(running)"
            rc_failed 0
            ;;
    1|4) 
        echo -n "(running)"
        echo -n  "Warning - PID corrupted"
            rc_failed 0
            ;;
        2)
            echo "(not running)"
            echo -n "Warning - PID file found"
            rc_failed 3
            ;;
        3)
            echo -n "(not running)"
            rc_failed 1
            ;;
        *)
            echo "(unknown)"
            echo "Warning - Couldn't get status"
            rc_failed 1
            rc_status -v1
            rc_exit
    esac
    rc_status -v
        ;;
    restart)
        $0 stop &>/dev/null
        $0 start &>/dev/null
        rc_status -v
        ;;
    usage|help)
        usage
        rc_exit
        ;;
    *)
        usage
        rc_failed 1
        rc_status -v
        rc_exit
esac

2011年11月22日星期二

4 steps to delete account in Gerrit DB




4 steps to delete account in DB.

Delete from accounts where preferred_email=’’;
delete from account_ssh_keys where account_id='';
delete from account_external_ids where external_id='gerrit:*’;
delete from account_external_ids where external_id='username:*’;
whatever it was in H2 database and postgres db .

H2:

ssh -p 24198 localhost gerrit gsql

Postgres:
psql


2011年11月19日星期六

tar with /

When I try to tar -jcvf /, that will caused error
tar: Removing leading `/' from member names

The fix coomand
tar -jcvPf /opt.tar /opt
If you put the P after f, it will create P file...

untar tar -jxvPf /opt.tar if no P option, it will have the error as the same.

#!/bin/bash
DATE=`date "+%F-%H-%M"`
/u01/postgres/9.0/bin/pg_dump reviewdb > /var/backup/reviewdb_$DATE.sql
/usr/bin/bzip2 /var/backup/reviewdb_$DATE.sql
find . -name "*.sql.bz2" -mtime +90 -exec rm -rf {} \;

2011年11月18日星期五

Gerrit send mail without to and error with reviewers

We have problem since users said they can't receive mail from the gerrit server. For IT perspective, we do nothing, because of Gerrit (2.2.X) is different with the others, especially for access control.
The fix thing, disable the group options and unchecked two options.



2011年11月17日星期四

Oralce Solaris 11 released

Oracle released Solarsi 11 on 2011/11/11.
http://www.oracle.com/technetwork/server-storage/solaris11/overview/index.html

But apparently it was not so good at what they expect for the release, no one cheer for that.

RazorSQL

RazorSQL有Windows版

注册码为:G84BKS8JQC7HRJ8V
www.razorsql.com
 
不是一般的好用 

2011年3月15日星期二

redmine installation guide

 1.  Prepare all the applications.

     1) ruby. highly recommend use 1.8.6-1.8.7 http://www.ruby-lang.org/en/downloads/
           ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-linux]
         mysql 5.1.45


     2) install all required gem/ gem install *.gem
          rubygem 
      actionmailer (2.3.11)
      actionpack (2.3.11)
      activerecord (2.3.11)
      activeresource (2.3.11)
      activesupport (2.3.11)
      i18n (0.4.2)
      mysql (2.8.1)
      rack (1.1.0, 1.0.1)
      rails (2.3.11)
      rake (0.8.7)
      rubygems-update (1.4.2)
       
  • Ruby 1.9 is not supported yet. You have to use Ruby 1.8.x as stated above.
  • RubyGems 1.3.1 or higher is required (Rails 2.3.5 will fail with RubyGems 1.5.0 and later, stick to previous versions of RubyGems)
  • Rake 0.8.3 or higher is required
  • Rack 1.0.1 is required. If you don't have this exact version, database migration would fail.
  • I18n 0.4.2 is required for Redmine >= 1.0.5

     3) download redmine http://www.redmine.org/projects/redmine/wiki/Download and unpack it.
     4) Create an empty database and accompanying user named redmine for example.

For MySQL:

 create database redmine character set utf8; create user 'redmine'@'localhost' identified by 'my_password'; grant all privileges on redmine.* to 'redmine'@'localhost'; 

For versions of MySQL prior to 5.0.2 - skip the 'create user' step and instead:

 grant all privileges on redmine.* to 'redmine'@'localhost' identified by 'my_password'; 

For PostgreSQL:

 CREATE ROLE redmine LOGIN ENCRYPTED PASSWORD 'my_password' NOINHERIT VALID UNTIL 'infinity'; CREATE DATABASE redmine WITH ENCODING='UTF8' OWNER=redmine; 

3. Copy config/database.yml.example to config/database.yml and edit this file in order to configure your database settings for "production" environment.

Example for a MySQL database:

 production:   adapter: mysql   database: redmine   host: localhost   username: redmine   password: my_password 

If your server is not running on the standard port (3306), use this configuration instead:

 production:   adapter: mysql   database: redmine   host: localhost   port: 3307   username: redmine   password: my_password 

Example for a PostgreSQL database (default port):

 production:   adapter: postgresql   database: <your_database_name>   host: <postgres_host>   username: <postgres_user>   password: <postgres_user_password>   encoding: utf8   schema_search_path: <database_schema> (default - public)
    5) run " rake generate_session_store"
6) under redmine path;
vi ./config/boot.rb
add "require 'thread'" in the first line
7) run "RAILS_ENV=production rake db:migrate"
but it will have problems, although they said the issue been fixed in gem2.3.11.
The workaround :
vi vendor/rails/railties/lib/rails/gem_dependency.rb
add
if Gem::VERSION >= "1.3.6"
module Rails
class GemDependency
def requirement
r = super
(r == Gem::Requirement.default) ? nil : r
end
end
end
end
in the last line. and export LD_LIBRARY_PATH=/opt/ruby/lib:/lib/ 

then the command is running successfully.

8) the tricky thing is, my mysql didn't use the local one, but redmine will search for default I don't how to modify this, just add the soft link with my own mysql's socket. then continue.
9) then run RAILS_ENV=production rake redmine:load_default_data
10)Setting up permissions

Assuming you run Redmine with a redmine user:

 mkdir tmp public/plugin_assets sudo chown -R redmine:redmine files log tmp public/plugin_assets sudo chmod -R 755 files log tmp public/plugin_assets
11) use admin/admin to login
--
Alex Tu
-----------------------------------------------------------
ShangHai,China