Sunday, June 28, 2009

GMF with Eclipse

Use the CheatSheet




parent folder:
org.eclipse.gmf.examples.mindmap

file name:
mindmap.gmfgraph

domain model:
download it from here
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.gmf/examples/org.eclipse.gmf.examples.mindmap.lite/model/mindmap.ecore?view=log&root=Modeling_Project&pathrev=HEAD

Thursday, June 25, 2009

Oracle create database in Linux

so you have installed your oracle 10g in $ORACLE_HOME, as a sysdba Unix user.

Next steps:

edit ~/.bash_profile and add:
export ORACLE_HOME=/opt/oracle/product/10g
export ORACLE_SID=MYSID


start listener:
cd $ORACLE_HOME/bin
lsnrctl start

cp $ORACLE_HOME/dbs/init.ora $ORACLE_HOME/dbs/initMYSID.ora

edit initMYSID.ora and set db_name=MYSID


and set


start database

$ORACLE_HOME/bin/sqlplus / as sysdba

startup nomount

and create database:

create database MYSID;

alter user sys identified by oracle;

alter user system identified by oracle;
@?/rdbms/admin/catalog.sql
@?/rdbms/admin/catproc.sql

if the second fails, then drop the database, create it again,
run
select * from V$DATAFILE
see which one is the .dbf file for SYSTEM,
then run
ALTER DATABASE DATATILE 'full.path.to/somefile.dbf' resize 500M;

then do also
create user YOURAPPLICATIONUSER;
grant create session to YOURAPPLICATIONUSER;
GRANT ALL PRIVILEGES to YOURAPPLICATIONUSER;

also run /opt/oracle/product/10g/sqlplus/admin/pupbld.sql as system (pw manager)


if anything goes wrong, use "startup UPGRADE" and rerun the scripts

Remember also how to drop a database:

shutdown abort;
startup mount exclusive restrict;
drop database;


For ALSB, sqlplus and login as your application user and run
@/opt/bea/alsb/3.0/alsb_3.0/dbscripts/oracle/reporting_runtime.sql


In the morning, to startup your stuff:
cd $ORACLE_HOME/bin
./lsnrctl start
./sqlplus / as sysdba
startup
exit

then do
./lsnrctl status
to verify that your instance has been dynamically registered (no need to edit listener.ora)




see also:
http://www.tek-tips.com/faqs.cfm?fid=6435

http://www.dba-oracle.com/oracle_create_database.htm

Friday, June 19, 2009

Installing Oracle 10 on a CentOS VMWare image by bagvapp

you should run these adjustments to the Linux kernel (sudo into root)

echo "250 32000 100 128"> /proc/sys/kernel/sem
echo "1024 65000" >/proc/sys/net/ipv4/ip_local_port_range
echo 262144 > /proc/sys/net/core/rmem_default
echo 262144 > /proc/sys/net/core/rmem_max
echo 262144 > /proc/sys/net/core/wmem_default
echo 262144 > /proc/sys/net/core/wmem_max


otherwise edit your /etc/sysctl.conf and add

kernel.sem = 250 32000 100 128
etc


also, run
yum -y install compat-libstdc++-296 compat-libstdc++-33
yum install xorg-x11-deprecated-libs


also, make sure your NIC is configured for STATIC ip addresses

Thursday, June 18, 2009

SSH and SSHExec from Java client

you can reuse the existing Ant implementation of SSHExec:

import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.optional.ssh.SSHExec;

public class UnixShellTest {
public static void main(String[] args) throws Exception {
UnixShellTest shellTest = new UnixShellTest();
shellTest.test();
}

private void test() throws Exception {
Project p = new Project();
final SSHExec sshexec = new SSHExec();
sshexec.setProject(p);
sshexec.setCommand("ls");
sshexec.setHost("yourunixhosthere");
sshexec.setPassword("yourunixpassword");
sshexec.setUsername("yourunixusername");
sshexec.setTrust(true);
sshexec.setOutputproperty("result");
sshexec.execute();
String result = sshexec.getProject().getProperty("result");
System.out.println("result= " + result);
}
}

Wednesday, June 17, 2009

Change username in Unix

usermod -l newuser olduser
groupmod oldgroup -n newgroup
usermod -d /home/newuser newuser (to change home directory, must be root)
cat /etc/passwd to verify that it worked
cat /etc/group

vi /etc/sudoers to change entry (as root)

Monday, June 15, 2009

HTTP Connection Refused on Weblogic Server

(from a LinkedIn discussion, just making the results public)

try the following:


netstat, lsof, traceroute, ping

telnet into the ip:port and type GET
check firewall
check exclusion list of a proxy
trace http session using wireshark or httpfox and see where does the http transaction gets stopped before reaching server

try also connecting from the same machine where the Server is running, that would rule out most networking/firewall issues - I believe. Simply opening a telnet client from the box itself and do the GET thing would be good enough.
Possibly, also, see if you can hack the config.xml and enable the debug flags concerning TCP-IP.
Also, from the server's log, during the startup phase try to identify something like:
network channel BLA started,
just to make sure your server is ACTUALLY listening on that port.




locate and updatedb

if you run:
locate lsof

and you get this error message:
can not open /var/lib/mlocate/mlocate.db

what you should try is running
updatedb

if you get this:
can not open a temporary file for /var/lib/mlocate/mlocate.db

try
sudo updatedb

Friday, June 12, 2009

Log rotation in Unix

put this code in loopforever.sh:

while [ true ]
do
echo ciao
sleep 1
done


then run loopforever.sh > loop.log

in another shell do
echo > loop.log

if everything works well, the first process can keep writing to the loop.log file...

SSH and keygen

good tutorial here:

http://www.virtualhelp.me/copyright/65-ssh-and-authorized-keys
and here
http://www.modwest.com/help/kb20-90.html

in a nutshell:

ssh-keygen
ssh-keygen -t dsa
cat id_rsa.pub >> authorized_keys
cat id_dsa.pub >> authorized_keys2

Thursday, June 11, 2009

WLST, JMX and ALSB

Using the Deployment APIs

http://download.oracle.com/docs/cd/E13171_01/alsb/docs30/deploy/config_appx.html

CentOS on VMWare Player

download the latest VMWare player here:

http://www.vmware.com/download/player/

and some CentOS images here:

http://www.thoughtpolice.co.uk/vmware/

Wednesday, June 10, 2009

Troubleshooting Weblogic startup

if your Weblogic hangs while starting up, try the following:

- use the startWeblogic.sh in foreground more
- use lsof to check which files/sockets are open, and which libraries are loaded
- make sure you are using the right Unix user
- check for the existence of .lock file especially in the server/data/ldap directory
- use some JVM parameters such as -verbose:class print



Monday, June 8, 2009

Python to create 2 JMS Queues complete of JMSServer

replace pvserver with yourserver


cd('/')
cmo.createFileStore('FileStore-0')

cd('/Deployments/FileStore-0')
set('Targets',jarray.array([ObjectName('com.bea:Name=pvserver,Type=Server')], ObjectName))

cd('/')
cmo.createJMSServer('JMSServer-0')

cd('/JMSServers/JMSServer-0')
cmo.setPersistentStore(getMBean('/Deployments/FileStore-0'))
set('Targets',jarray.array([ObjectName('com.bea:Name=pvserver,Type=Server')], ObjectName))

cd('/')
cmo.createJMSSystemResource('SystemModule-0')

cd('/JMSSystemResources/SystemModule-0')
set('Targets',jarray.array([ObjectName('com.bea:Name=pvserver,Type=Server')], ObjectName))

cd('/JMSSystemResources/SystemModule-0/JMSResource/SystemModule-0')
cmo.createConnectionFactory('ConnectionFactory-0')

cd('/JMSSystemResources/SystemModule-0/JMSResource/SystemModule-0/ConnectionFactories/ConnectionFactory-0')
cmo.setJNDIName('jms/Pid1QueueConnectionFactory')

cd('/JMSSystemResources/SystemModule-0/JMSResource/SystemModule-0/ConnectionFactories/ConnectionFactory-0/SecurityParams/ConnectionFactory-0')
cmo.setAttachJMSXUserId(false)

cd('/JMSSystemResources/SystemModule-0/JMSResource/SystemModule-0/ConnectionFactories/ConnectionFactory-0')
cmo.setDefaultTargetingEnabled(true)

cd('/JMSSystemResources/SystemModule-0')
cmo.createSubDeployment('Queue-0')

cd('/JMSSystemResources/SystemModule-0/JMSResource/SystemModule-0')
cmo.createQueue('Queue-0')

cd('/JMSSystemResources/SystemModule-0/JMSResource/SystemModule-0/Queues/Queue-0')
cmo.setJNDIName('jms/Pid1TestQueue')
cmo.setSubDeploymentName('Queue-0')

cd('/JMSSystemResources/SystemModule-0/SubDeployments/Queue-0')
set('Targets',jarray.array([ObjectName('com.bea:Name=JMSServer-0,Type=JMSServer')], ObjectName))

cd('/JMSSystemResources/SystemModule-0/JMSResource/SystemModule-0')
cmo.createQueue('Queue-1')

cd('/JMSSystemResources/SystemModule-0/JMSResource/SystemModule-0/Queues/Queue-1')
cmo.setJNDIName('QueueB')
cmo.setSubDeploymentName('Queue-0')

cd('/JMSSystemResources/SystemModule-0/SubDeployments/Queue-0')
set('Targets',jarray.array([ObjectName('com.bea:Name=JMSServer-0,Type=JMSServer')], ObjectName))

activate()

Friday, June 5, 2009

CentOS, change hostname and IPs

first, become root:

sudo su -
(enter your pw)

To change IP:

ifconfig add eth0 192.168.63.129

see http://dhika.cikul.or.id/how-to-change-centos-ip-address.html

quote:
ifconfig command create temporary IP address change, if you reboot your server, you will see that your IP still not change. If you want make permanent ip change, you must edit files under /etc/sysconfig/network-scripts/
unquote.


and edit your /etc/hosts file

cd /etc/sysconfig/network-scripts/
vi ifcfg-eth0

DEVICE=eth0
BOOTPROTO=static
IPADDR=172.17.17.10
NETMASK=255.255.255.248
ONBOOT=yes

cp ifcfg-eth0:0
and edit correspondingly
service network restart

MAKE SURE your NETMASK is the same as the host machine, otherwise the 2 won't be able to communicate....

here the instructions are more precise:

http://www.xenocafe.com/tutorials/linux/redhat/bind_multiple_ip_addresses_to_single_nic/index.php


To change hostname:


then echo “newhostname” > /proc/sys/kernel/hostname

or

sysctl kernel.hostname=NEW_HOSTNAME

and edit /etc/sysconfig/network to set HOSTNAME to the value you need

see here http://www.ducea.com/2006/08/07/how-to-change-the-hostname-of-a-linux-system/

also, run system-config-network and change hostname under DNS tab,
logout then login again

finally, add the new hostname to the hosts file