Archive for July, 2009

XRDP on CentOS 5

$ yum install gcc pam-devel openssl-devel
$ tar -zxvf xrdp-0.4.1.tar.gz
$ cd xrdp-0.4.1
$ make
$ sudo make install
$ ln /usr/local/xrdp/xrdp_control.sh /etc/init.d/xrdesktop
$ gconftool-2 –type list –list-type=string –set /desktop/gnome/peripherals/keyboard/kbd/layouts [damnlayouts] # map keyboard layout
$ sudo nano /etc/xrdp/sesman.ini
change 127.0.0.1 to 0.0.0.0
$ /sbin/chkconfig –add xrdesktop
$ /sbin/service xrdesktop start

$ yum install gcc pam-devel openssl-devel

$ wget http://ncu.dl.sourceforge.net/sourceforge/xrdp/xrdp-0.4.1.tar.gz

$ tar -zxvf xrdp-0.4.1.tar.gz

$ cd xrdp-0.4.1

$ make

$ sudo make install

$ ln /usr/local/xrdp/xrdp_control.sh /etc/init.d/xrdesktop

$ gconftool-2 –type list –list-type=string –set /desktop/gnome/peripherals/keyboard/kbd/layouts [damnlayouts] # map keyboard layout

$ sudo nano /etc/xrdp/sesman.ini

change 127.0.0.1 to 0.0.0.0

$ /sbin/chkconfig –add xrdesktop

$ /sbin/service xrdesktop start

[optional]
$ cp startwm.sh startwm.sh.bak
$ nano /usr/local/xrdp/startwm.sh // change login env
export LANG=zh_TW.UTF-8

Install proftpd on CentOS5

$ nano /etc/yum.repos.d/dag.repo  // create dag.repo
[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
gpgcheck=1
enabled=1
$ rpm –import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt // import non-official GPG
$ yum install proftpd
$ nano /etc/proftpd.conf
Change ServerName
change DefaultRoot ~
$ nano /etc/xinetd.d/xproftpd
Change “DURATION USERID” to “HOST PID”
Change “USERID” to “HOST”
Change “disable = yes” to  ”disable = no”
$ /sbin/chkconfig xproftpd on
$ /sbin/chkconfig –list xproftpd
$ /etc/rc.d/init.d/xinetd restart

Source:

$ nano /etc/yum.repos.d/dag.repo // create dag.repo

[dag]

name=Dag RPM Repository for Red Hat Enterprise Linux

baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag

gpgcheck=1

enabled=1

$ rpm –import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt // import non-official GPG

$ yum install proftpd

$ nano /etc/proftpd.conf

Change ServerName

Change ServerType to inetd

change DefaultRoot ~

$ nano /etc/xinetd.d/xproftpd

Change “DURATION USERID” to “HOST PID”

Change “USERID” to “HOST”

Change “disable = yes” to  ”disable = no”

$ /sbin/chkconfig xproftpd on

$ /sbin/chkconfig –list xproftpd

$ /etc/rc.d/init.d/xinetd restart

Install oracle 11g x64 on CentOS5.3

1. Check packages
$ rpm -q grep binutils-2.*    \
elfutils-libelf-0.*        \
glibc-2.*                  \
glibc-common-2.*           \
libaio-0.*                 \
libgcc-4.*                 \
libstdc++-4.*              \
make-3.*                   \
compat-libstdc++-33        \
elfutils-libelf-devel-0.*  \
glibc-devel-2.*            \
gcc-4.*                    \
gcc-c++-4.*                \
libaio-devel-0.*           \
libstdc++-devel-4.*        \
unixODBC-2.*               \
unixODBC-devel-2.*         \
sysstat-7.*
2. Create Oracle account
$ /usr/sbin/groupadd oinstall
$ /usr/sbin/groupadd dba
$ /usr/sbin/useradd -m -g oinstall -G dba oracle
$ id oracle
(uid=501(Oracle) gid=501(oinstall) groups=501(oinstall),502(dba))
$ passwd oracle
3. Modified the sysctl.conf
$ cat >> /etc/sysctl.conf << EOF
kernel.sem=1055 32000 100 128
kernel.shmmax=2147483648
kernel.shmall = 2097152
net.ipv4.tcp_sack = 0
net.ipv4.tcp_timestamps = 0
net.ipv4.conf.default.rp_filter = 0
net.core.optmem_max = 65535
net.core.rmem_default = 4194304
net.core.wmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_max = 262144
fs.file-max = 6553600
net.ipv4.ip_local_port_range = 1024 65000
EOF
3.a Check parameters
$ /sbin/sysctl -p
4. Modified the limits.conf (Shell limits for oracle user)
$ cat >> /etc/security/limits.conf << EOF
*     soft      nproc          2047
*     hard      nproc         16384
*     soft      nofile         1024
*     hard      nofile        65536
EOF
5. Modified the login
# cat >> /etc/pam.d/login << EOF
session    required     /lib/security/pam_limits.so
session    required     pam_limits.so
EOF
6. Modified the config
$ nano /etc/selinux/config
(Leave the following two lines only)
SELINUX=disabled
SELINUXTYPE=disabled
7. Create Directories
mkdir -p /u01
mkdir -p /opt/oracle
mkdir –p /opt/oracle/product
chown -R oracle:oinstall /u01
chown -R oracle:oinstall /opt/oracle
chmod -R 775 /u01
chmod -R 775 /opt/oracle
chmod -R 775 /opt/oracle/product
8. For network configuration requirements (important!)
modified /etc/hosts to actual ip address
9. Change ownership to oracle
$ chown oracle:oinstall linux.x64_11gR1_database_1013.zip
10. Log in as oracle (GUI)
$ cd /opt/oracle
$ unzip linux.x64_11gR1_database_1013.zip
$ cd database
$ ./runInstaller
=====In the first screen========
a. /opt/oracle/ (ORACLE BASE LOCATIONS)
b. /opt/oracle/product/11.1.0/db_1 (ORACLE HOME LOCATIONS)
c. Change the UNIX DBA group from dba to oinstall
d. Create Starter Database
====In the second screen====
a. /opt/oracle/product/oraInventory (INVETORY LOCATIONS)
b. leave the group name oinstall
===In the complete screen===
Do not forget to execute two scripts
Note: connect from osx
./sqlplus sys/password@oracle as SYSDBA
Maintenance
To shut down everything Oracle:
$ . oraenv
<enter your SID>
$ sqlplus “/ as sysdba”
SQL> shutdown immediate
SQL> exit
$ lsnrctl
LSNRCTL> stop
LSNRCTL> exit
$ cd $ORACLE_HOME/bin
./emctl stop dbconsole
To start up everything Oracle:
$ . oraenv
<enter your SID>
$ sqlplus “/ as sysdba”
SQL> startup
SQL> exit
$ lsnrctl
LSNRCTL> start
LSNRCTL> exit
$ cd $ORACLE_HOME/bin
1. Check packages
$ rpm -q grep binutils-2.*    \
elfutils-libelf-0.*        \
glibc-2.*                  \
glibc-common-2.*           \
libaio-0.*                 \
libgcc-4.*                 \
libstdc++-4.*              \
make-3.*                   \
compat-libstdc++-33        \
elfutils-libelf-devel-0.*  \
glibc-devel-2.*            \
gcc-4.*                    \
gcc-c++-4.*                \
libaio-devel-0.*           \
libstdc++-devel-4.*        \
unixODBC-2.*               \
unixODBC-devel-2.*         \
sysstat-7.*
2. Create Oracle account
$ /usr/sbin/groupadd oinstall
$ /usr/sbin/groupadd dba
$ /usr/sbin/useradd -m -g oinstall -G dba oracle
$ id oracle
(uid=501(Oracle) gid=501(oinstall) groups=501(oinstall),502(dba))
$ passwd oracle
3. Modified the sysctl.conf
$ cat >> /etc/sysctl.conf << EOF
kernel.sem=1055 32000 100 128
kernel.shmmax=2147483648
kernel.shmall = 2097152
net.ipv4.tcp_sack = 0
net.ipv4.tcp_timestamps = 0
net.ipv4.conf.default.rp_filter = 0
net.core.optmem_max = 65535
net.core.rmem_default = 4194304
net.core.wmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_max = 262144
fs.file-max = 6553600
net.ipv4.ip_local_port_range = 1024 65000
EOF
3.a Check parameters
$ /sbin/sysctl -p
4. Modified the limits.conf (Shell limits for oracle user)
$ cat >> /etc/security/limits.conf << EOF
*     soft      nproc          2047
*     hard      nproc         16384
*     soft      nofile         1024
*     hard      nofile        65536
EOF
5. Modified the login
# cat >> /etc/pam.d/login << EOF
session    required     /lib/security/pam_limits.so
session    required     pam_limits.so
EOF
6. Modified the config
$ nano /etc/selinux/config
(Leave the following two lines only)
SELINUX=disabled
SELINUXTYPE=disabled
7. Create Directories
mkdir -p /u01
mkdir -p /opt/oracle
mkdir –p /opt/oracle/product
chown -R oracle:oinstall /u01
chown -R oracle:oinstall /opt/oracle
chmod -R 775 /u01
chmod -R 775 /opt/oracle
chmod -R 775 /opt/oracle/product
8. For network configuration requirements (important!)
modified /etc/hosts to actual ip address
9. Change ownership to oracle
$ chown oracle:oinstall linux.x64_11gR1_database_1013.zip
10. Log in as oracle (GUI)
$ cd /opt/oracle
$ unzip linux.x64_11gR1_database_1013.zip
$ cd database
$ ./runInstaller
=====In the first screen========
a. /opt/oracle/ (ORACLE BASE LOCATIONS)
b. /opt/oracle/product/11.1.0/db_1 (ORACLE HOME LOCATIONS)
c. Change the UNIX DBA group from dba to oinstall
d. Create Starter Database
====In the second screen====
a. /opt/oracle/product/oraInventory (INVETORY LOCATIONS)
b. leave the group name oinstall
===In the complete screen===
Do not forget to execute two scripts
Note: connect from osx
./sqlplus sys/password@oracle as SYSDBA
Maintenance
To shut down everything Oracle:
$ . oraenv
<enter your SID>
$ sqlplus “/ as sysdba”
SQL> shutdown immediate
SQL> exit
$ lsnrctl
LSNRCTL> stop
LSNRCTL> exit
$ cd $ORACLE_HOME/bin
./emctl stop dbconsole
To start up everything Oracle:
$ . oraenv
<enter your SID>
$ sqlplus “/ as sysdba”
SQL> startup
SQL> exit
$ lsnrctl
LSNRCTL> start
LSNRCTL> exit
$ cd $ORACLE_HOME/bin
1. Check packages
$ rpm -q grep binutils-2.*    \
elfutils-libelf-0.*        \
glibc-2.*                  \
glibc-common-2.*           \
libaio-0.*                 \
libgcc-4.*                 \
libstdc++-4.*              \
make-3.*                   \
compat-libstdc++-33        \
elfutils-libelf-devel-0.*  \
glibc-devel-2.*            \
gcc-4.*                    \
gcc-c++-4.*                \
libaio-devel-0.*           \
libstdc++-devel-4.*        \
unixODBC-2.*               \
unixODBC-devel-2.*         \
sysstat-7.*
2. Create Oracle account
$ /usr/sbin/groupadd oinstall
$ /usr/sbin/groupadd dba
$ /usr/sbin/useradd -m -g oinstall -G dba oracle
$ id oracle
(uid=501(Oracle) gid=501(oinstall) groups=501(oinstall),502(dba))
$ passwd oracle
3. Modified the sysctl.conf
$ cat >> /etc/sysctl.conf << EOF
kernel.sem=1055 32000 100 128
kernel.shmmax=2147483648
kernel.shmall = 2097152
net.ipv4.tcp_sack = 0
net.ipv4.tcp_timestamps = 0
net.ipv4.conf.default.rp_filter = 0
net.core.optmem_max = 65535
net.core.rmem_default = 4194304
net.core.wmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_max = 262144
fs.file-max = 6553600
net.ipv4.ip_local_port_range = 1024 65000
EOF
3.a Check parameters
$ /sbin/sysctl -p
4. Modified the limits.conf (Shell limits for oracle user)
$ cat >> /etc/security/limits.conf << EOF
*     soft      nproc          2047
*     hard      nproc         16384
*     soft      nofile         1024
*     hard      nofile        65536
EOF
5. Modified the login
# cat >> /etc/pam.d/login << EOF
session    required     /lib/security/pam_limits.so
session    required     pam_limits.so
EOF
6. Modified the config
$ nano /etc/selinux/config
(Leave the following two lines only)
SELINUX=disabled
SELINUXTYPE=disabled
7. Create Directories
mkdir -p /u01
mkdir -p /opt/oracle
mkdir –p /opt/oracle/product
chown -R oracle:oinstall /u01
chown -R oracle:oinstall /opt/oracle
chmod -R 775 /u01
chmod -R 775 /opt/oracle
chmod -R 775 /opt/oracle/product
8. For network configuration requirements (important!)
modified /etc/hosts to actual ip address
9. Change ownership to oracle
$ chown oracle:oinstall linux.x64_11gR1_database_1013.zip
10. Log in as oracle (GUI)
$ cd /opt/oracle
$ unzip linux.x64_11gR1_database_1013.zip
$ cd database
$ ./runInstaller
=====In the first screen========
a. /opt/oracle/ (ORACLE BASE LOCATIONS)
b. /opt/oracle/product/11.1.0/db_1 (ORACLE HOME LOCATIONS)
c. Change the UNIX DBA group from dba to oinstall
d. Create Starter Database
====In the second screen====
a. /opt/oracle/product/oraInventory (INVETORY LOCATIONS)
b. leave the group name oinstall
===In the complete screen===
Do not forget to execute two scripts
Note: connect from osx
./sqlplus sys/password@oracle as SYSDBA
Maintenance
To shut down everything Oracle:
$ . oraenv
<enter your SID>
$ sqlplus “/ as sysdba”
SQL> shutdown immediate
SQL> exit
$ lsnrctl
LSNRCTL> stop
LSNRCTL> exit
$ cd $ORACLE_HOME/bin
./emctl stop dbconsole
To start up everything Oracle:
$ . oraenv
<enter your SID>
$ sqlplus “/ as sysdba”
SQL> startup
SQL> exit
$ lsnrctl
LSNRCTL> start
LSNRCTL> exit
$ cd $ORACLE_HOME/bin
./emctl start dbconsole

1. Check packages

$ rpm -q grep binutils-2.*    \
elfutils-libelf-0.*        \
glibc-2.*                  \
glibc-common-2.*           \
libaio-0.*                 \
libgcc-4.*                 \
libstdc++-4.*              \
make-3.*                   \
compat-libstdc++-33        \
elfutils-libelf-devel-0.*  \
glibc-devel-2.*            \
gcc-4.*                    \
gcc-c++-4.*                \
libaio-devel-0.*           \
libstdc++-devel-4.*        \
unixODBC-2.*               \
unixODBC-devel-2.*         \
sysstat-7.*

2. Create Oracle account

$ /usr/sbin/groupadd oinstall
$ /usr/sbin/groupadd dba
$ /usr/sbin/useradd -m -g oinstall -G dba oracle
$ id oracle
(uid=501(Oracle) gid=501(oinstall) groups=501(oinstall),502(dba))
$ passwd oracle

3. Modified the sysctl.conf

$ cat >> /etc/sysctl.conf << EOF
kernel.sem=1055 32000 100 128
kernel.shmmax=2147483648
kernel.shmall = 2097152
net.ipv4.tcp_sack = 0
net.ipv4.tcp_timestamps = 0
net.ipv4.conf.default.rp_filter = 0
net.core.optmem_max = 65535
net.core.rmem_default = 4194304
net.core.wmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_max = 262144
fs.file-max = 6553600
net.ipv4.ip_local_port_range = 1024 65000
EOF

3.a Check parameters

$ /sbin/sysctl -p

4. Modified the limits.conf (Shell limits for oracle user)

$ cat >> /etc/security/limits.conf << EOF
*     soft      nproc          2047
*     hard      nproc         16384
*     soft      nofile         1024
*     hard      nofile        65536
EOF

5. Modified the login

# cat >> /etc/pam.d/login << EOF
session    required     /lib/security/pam_limits.so
session    required     pam_limits.so
EOF
6. Modified the config
$ nano /etc/selinux/config
(Leave the following two lines only)
SELINUX=disabled
SELINUXTYPE=disabled

7. Create Directories

$ mkdir -p /u01
$ mkdir -p /opt/oracle
$ mkdir –p /opt/oracle/product
$ chown -R oracle:oinstall /u01
$ chown -R oracle:oinstall /opt/oracle
$ chmod -R 775 /u01
$ chmod -R 775 /opt/oracle
$ chmod -R 775 /opt/oracle/product

8. For network configuration requirements (important!)

modified /etc/hosts to actual ip address

9. Change ownership to oracle

$ chown oracle:oinstall linux.x64_11gR1_database_1013.zip

10. Log in as oracle (GUI)

$ cd /opt/oracle
$ unzip linux.x64_11gR1_database_1013.zip
$ cd database
$ ./runInstaller
=====In the first screen========
a. /opt/oracle/ (ORACLE BASE LOCATIONS)
b. /opt/oracle/product/11.1.0/db_1 (ORACLE HOME LOCATIONS)
c. Change the UNIX DBA group from dba to oinstall
d. Create Starter Database
====In the second screen====
a. /opt/oracle/product/oraInventory (INVETORY LOCATIONS)
b. leave the group name oinstall
===In the complete screen===
Do not forget to execute two scripts

Note: connect from osx (download client software)

./sqlplus sys/password@oracle as SYSDBA

Maintenance

To shut down everything Oracle:

$ . oraenv
<enter your SID>
$ sqlplus “/ as sysdba”
SQL> shutdown immediate
SQL> exit
$ lsnrctl
LSNRCTL> stop
LSNRCTL> exit
$ cd $ORACLE_HOME/bin (optional)
./emctl stop dbconsole

To start up everything Oracle:

$ . oraenv
<enter your SID>
$ sqlplus “/ as sysdba”
SQL> startup
SQL> exit
$ lsnrctl
LSNRCTL> start
LSNRCTL> exit
$ cd $ORACLE_HOME/bin (optional)
./emctl start dbconsole

OO summary

Class and Object
Relationship
OO concept
Class
new
constructor
overload
constructor overload
this
static
package & import
access control
extends
override
final
Object
toString
equals
Casting
upcasting
downcasting
Polymorphism
abstract
interface
implements
  • Class and Object
  • Relationship
  • OO concept
  • Class
  • new
    • constructor
  • overload
    • constructor overload
  • this
  • static
  • package & import
  • access control
  • extends
  • override
  • final
  • Object
    • toString
    • equals
  • Casting
    • upcasting
    • downcasting
  • Polymorphism
  • abstract
  • interface
    • implements

Array in Java

array除了宣告外,亦需要初始化
靜態 – 數據類型 變數名 [] = {元素值列舉}
– int a [] = {10, 20, 30};
值一樣可以改變
動態 –
1. 宣告 – 數據類型 變數名 []
2. 創建 – 變數名 = new 數據類型 [元素個數]
3. 賦值 – 變數名[元素下標] = 元素值
array超過boundary在執行時才會錯誤(編譯會過)
值一樣可以改變
可以重新創建(不用重新宣告),舊的會被GC
  • array除了宣告外,亦需要初始化
  • array超過boundary在執行時才會錯誤(編譯會過)
  • 值可以改變,也可以重新創建(不用重新宣告),舊的會被GC
  • 一維靜態 – 數據類型 變數名 [] = {元素值列舉}  // int a [] = {10, 20, 30};
    • 值一樣可以改變
  • 一維動態
    1. 宣告 – 數據類型 變數名 [] // int a [];
    1. 創建 – 變數名 = new 數據類型 [元素個數] // a = new [5];
    1. 賦值 – 變數名[元素下標] = 元素值 // a[0] = 32;
  • 拷貝 – System.arraycopy(來源,起點,目標,起點,拷貝個數)
    • int b [] = new int [6];
    • int c [] = [12, 5, 33];
    • System.arraycopy(c, 0, b, 1, c.length);
  • 二維靜態 – int a [] []  = {{2,4}, {3, 5, 7}};
  • 二維動態 –
      1. a = new int [2] [];  // 先分配行
      2. a[0] = new int [2]; // 逐行分配列數
      3. a[1] = new int [3]; // 逐行分配列數
    • 宣告 – int a [] []
    • 創建 – 分成兩步(若不是矩陣)
    • 賦值 – a[0][2] = 3;
  • arrray.length : 返回行數
  • arrat[2].length : 返回第二行的列數