หน้าเว็บ

วันจันทร์ที่ 15 สิงหาคม พ.ศ. 2554

Howto change IP on Solaris 10

Ifconfig command  ใช้สำหรับตั้งค่าอุปกรณ์การ์ดเครือข่าย  ( network card )

1. Enable the network card
#ifconfig hme0 plumb
ifconfig -a command should show following type of output which means device is enabled and is ready to configure ip address and netmask :
hme0: flags=842 mtu 1500
inet 0.0.0.0 netmask 0
ether 3:22:11:6d:2e:1f



2. Configuring ipaddress and netmask and making the interface status as up .
#ifconfig hme0 192.9.2.106 netmask 255.255.255.0 up
#ifconfig -a will now show the ip address , netmask and up status as follows :
hme0: flags=843 mtu 1500
inet 192.9.2.106 netmask ffffff00 broadcast 192.9.2.255
ether 3:22:11:6d:2e:1f

The file /etc/netmasks is used to define netmasks for ip addresses .

127.0.0.1, is the standard loop back route and 127.0.0.0 is the default loopback ipaddress used by the kernel when no interface is configured this will be the only entry displayed by the system on invoking ifconfig -a command..


3. Configuring Virtual interface
Virtual interface can be configured to enable hme0 reply to more then one ip addresses. This is possible by using hme0 alias which can be configured by ifconfig command only . The new alias device name now becomes hme0:1 hme:2 etc.
#ifconfig hme0:1 172.40.30.4 netmask 255.255.0.0 up
ifconfig -a will show the original hme0 and alias interface :
hme0: flags=843 mtu 1500
inet 192.9.2.106 netmask ffffff00 broadcast 192.9.2.255
ether 3:22:11:6d:2e:1f
hme0:1: flags=842 mtu 1500
inet 172.40.30.4 netmask ffff0000 broadcast 172.40.255.255



4. Ip-forwarding
IP forwarding allows you to forward all requests coming for a certain port or URL to be redirected to a specified IP address.
ip forwarding becomes enabled automatically when system detects more then one interface at the booting time . The file involved is /etc/rc2.d/S69inet .
ipforwarding is on by default but can be turned off by following command :
#ndd -set /dev/ip ip_forwarding 0


5. Router Configuration
After interfaces and ipaddess have been configured the system needs a default router which will allow the machine to talk to world outside of local network .
You can specify a particular route for a particular address as in following example
#route add -net 10.0.0.0 -netmask 255.0.0.0 172.40.30.1 1
if the the destination ipaddess is not defined in this manner system forwards all requests to the default router .
default route is defined manually by editing /etc/defaultrouter file and putting router’s ipaddress entry in it. This file is read by /etc/rc2.d/S69inet file during the booting process and entry added to the routing table .
The route can be defined online also using routeadd command but the changes will be lost on reboot .To make changes permanent make sure to put an entry in /etc/defaultrouter.
#route add default 205.100.155.2 1
#route change default 205.100.155.2 1
The 1 at the end is the number of hops to the next gateway.
If an interface is not responding to the network, check to be sure it has the correct IP address and netmask , network cables are fine .

Thanks  :  adminschoice.com

วันศุกร์ที่ 27 พฤษภาคม พ.ศ. 2554

Howto check services on Solaris 10

ในการดูว่า services อะไรบ้าง กำลัง online ใช้คำสั่ง

#  svcs

หากต้องการดูรายละเอียด ใช้คำสั่ง

# svcs -l <service_name>

หากต้องการ enable service

svcadm enable <service_name

หากต้องการ disable  service 

svcadm disable  <service_name>

หากต้องการ restart service  ใช้คำสั่ง

# svcadm restart <service_name>


Thanks :  www.experts-exchange.com


**command line for check services on solaris 10

วันพฤหัสบดีที่ 26 พฤษภาคม พ.ศ. 2554

Howto exact .tar.gz on solaris 10/ubuntu .




solaris    :  gunzip -c file_name.tar.gz |tar xvf -




ubuntu :  tar -xzvf   file_name.tar.gz



Thanks : www.tek-tips.com

วันอังคารที่ 17 พฤษภาคม พ.ศ. 2554

Howto use basic find command unix/linux.

syntax : find where-to-look criteria what-to-do


ตัวอย่างต่อไปนี้เป็นการใช้คำสั่ง find เพื่อค้นหา file ที่มีชื่อ "Toneation" โดยค้นหาไฟล์ทั้งหมดของระบบ filesystem  ("/')  แล้วโชว์ขึ้นหน้าจอ

find / -name Toneation -type f -print


หรืออาจระบุ directory ที่ต้องการจะค้นหาโดยเฉพาะ เช่น /usr และ /home


find /usr /home -name Toneation -type f


หรือให้ค้นหาเฉพาะ current directory


find . -name Toneation -type f


หรือใช้ค้นหา  ไฟล์ที่มีหลายนามสกุล หรือขึ้นต้นด้วย Toneation เช่น Toneation1,Toneation.txt


find /usr -name "Toneation*" -type f


หรือใช้ค้นหา ไฟล์ที่ลงท้ายด้วยนามสกุลที่ต้องการ

find /usr/local -name "*.html" -type f

 
และกรณีปิด error message ให้เพิ่ม 2>/dev/null  ดังนี้



find / -name "Toneation" 2>/dev/null 
 
 
  
Thanks:  http://www.devdaily.com/  , content.hccfl.edu

วันพุธที่ 11 พฤษภาคม พ.ศ. 2554

Howto add user on Soloris 11.

How to add user on Soloris 11.


  ใช้   useradd เพื่อทำการ สร้าง user ใหม่

useradd -u 1002 -g sysadmin -m -d /home/export/toneation -s /bin/sh toneation
 กรณีมี user อยู่แล้ว ใช้ usermod เพื่อแก้ไขค่าอื่นๆ

usermod -c "Sysadmin" toneation
ทำการตั้งค่ารหัสผ่านด้วย passwd

passwd toneation

Remark :   Red คือ syntax  Blue คือ option
                
 
 
  
 ตัวอย่างการใช้งาน คำสั่ง useradd


ตัวอย่างการใช้งาน คำสั่ง passwd


ผลลัพท์ที่ได้จากการใช้งานคำสั่ง logins
 
usage: useradd [-u uid [-o] | -g group | -G group[[,group]...] |-d dir |
-s shell | -c comment | -m [-k skel_dir] | -f inactive |
-e expire | -A authorization [, authorization ...] |
-P profile [, profile ...] | -R role [, role ...] |
-K key=value | -p project [, project ...]] login
useradd -D [-g group | -b base_dir | -f inactive | -e expire
-A authorization [, authorization ...] |
-P profile [, profile ...] | -R role [, role ...] |
-K key=value ... -p project]
 
Thanks : http://www.unix.com

วันจันทร์ที่ 9 พฤษภาคม พ.ศ. 2554

Howto set DNS Client on Solaris.

DNS Client Setup

แก้ไฟล์  /etc/resolv.conf 

# vi /etc/resolv.conf

Add the following lines to it:

search tot.co.th
nameserver 192.168.1.1

ซึ่ง,
  • nameserver IP :  คือ Primary  DNS server
  • search tot.co.th  : Default domain name to search. For example, if you type command nslookup www, it will search it as www.tot.co.th
Thanks : tech-recipes.com

วันพุธที่ 27 เมษายน พ.ศ. 2554

Howto install Oracle 11gR2 on Oracle Solaris 10

ในการทดสอบครั้งนี้  ทำการติดตั้งบน เครื่อง i3 3.2 GHz  RAM 4G  VMware  Workstation 

1.ตรวจสอบ Hardware
-  RAM ขั้นต่ำ อย่างน้อย 1 G  แต่แนะนำ 2 G
-  Harddisk ที่ใช้งานประมาณ 15G  แต่แนะนำ สร้างไว้อย่างน้อย 30G โดยจัดแบ่ง
ดังนี้     /         ใช้ประมาณ  15 G
            swap  2 เท่าของ RAM 
            /export/home/oracle/  แล้วแต่ต้องการ       


2.ตรวจสอบ package on solaris

run command:
pkginfo -i SUNWarc SUNWbtool SUNWhea SUNWlibC SUNWlibms SUNWsprot SUNWtoo SUNWi1of SUNWi1cs SUNWi15cs SUNWxwfnt

run command:
pkgadd -d /cdrom/sol_10_910_x86/Solaris_10/Product SUNWi1cs SUNWi15cs

3.สร้าง user and group
run command:
groupadd oinstall
groupadd dba
useradd -g oinstall -G dba -d /export/home/oracle -s /usr/bin/bash oracle
passwd oracle

4.สร้าง directory ไว้ติดตั้งโปรแกรม
mkdir -p /export/home/oracle/product/11.2.0/dbhome_1
mkdir /export/home/oracle/tmp
chown -R oracle:oinstall /export/home/oracle

5.เพิ่ม kernel parameters
projadd -U oracle -K "project.max-shm-memory=(priv,4g,deny)" oracle
projmod -sK "project.max-sem-nsems=(priv,256,deny)" oracle
projmod -sK "project.max-sem-ids=(priv,100,deny)" oracle
projmod -sK "project.max-shm-ids=(priv,100,deny)" oracle
echo "set maxuprc=16384" >> /etc/system
echo "set max_nprocs=30000" >> /etc/system
echo "set shmsys:shminfo_shmmax=4294967295" >> /etc/system

6.กรณีต้องการเพิ่ม swap file
mkfile 1024m /export/home/oracle/orcl_swap
2swap -a /export/home/oracle/orcl_swap
 
7.ทำการ set profile ของ user oracle
export ORACLE_BASE=/export/home/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export PATH=$ORACLE_HOME/bin:$PATH
export TMP=/export/home/oracle/tmp
export TMPDIR=/export/home/oracle/tmp
export DISPLAY=:0.0
 
8.สร้าง directory “installation” ภายใต้ /export/home/oracle เพื่อทำการเก็บ source  ของตัวติดตั้ง
แล้ว คัดลอก โปรแกรม มาเก็บไว้  หรือทำการ  download โปรแกรมจาก เว็บ ของ oracle
 
จากนั้นทำการแตกไฟล์ แล้วรันคำสั่งติดตั้งโปรแกรม
 
unzip your_file1.zip
unzip your_file2.zip

cd database

./runInstaller
 
**หมายเหตุ  ก่อนการติดตั้งให้ใช้ login root   ทำการรันคำสั่ง  xhost +  เพื่อ enable security
ภาพประกอบตาม link ด้านบน
 

วันพุธที่ 20 เมษายน พ.ศ. 2554

Howto change hostnme on solaris 10

Step 1: Update /etc/hosts

192.168.0.1 newhostname


Step 2: Change /etc/nodename

echo "newhostname" > /etc/nodename


Step 3: Update /etc/hostname.

echo "newhostname" > /etc/hostname.e1000g0

Reboot or

Apply the new hostname, do it manually:
 
uname -S newhostname




Thanks :  solaris.reys.net

วันพฤหัสบดีที่ 7 เมษายน พ.ศ. 2554

Howto change TIMEZONE on Solaris 10


1. Edited the /etc/TIMEZONE file ,set TZ


TZ=Asia/Bangkok


2. Run command 


#rtc -z Asia/Bangkok
#rtc -c


3. Reboot the system to effect the change 






Thanks : blogs.sun.com

วันพฤหัสบดีที่ 31 มีนาคม พ.ศ. 2554

Introduction to VMware ESXi and Install ESXi 4.1 from a USB stick


System Requirements
CPU          รองรับ 64-bit และ Intel VT-x/ AMD-V
Memory     2 GB หรือสูงกว่า
Network     1 Ethernet Card
Hard disk     มีพื้นที่ว่างอย่างน้อย 8GB (แนะนำ 20 GB สำหรับติดตั้ง Guest OS เพิ่ม)
Software     VMWare ESXi 4.0
Note:    สำหรับ Intel VT-x/ AMD-V จะต้องสั่ง enable ใน BIOS ด้วย เพราะโดย default แล้วจะถูกเซตเป็น disable ไว้

เนื่องจาก VMware Esxi ออกแบบมาเฉพาะกับ Hardware บางประเภท ทำให้คอมพิวเตอร์ทั่วไปที่เราใช้กันอยู่นั้นไม่สามารถติดตั้ง VMware Esxi ได้ แต่เราสามารถใช้ VMware Workstation จำลองสภาพแวดล้อม ให้มีลักษณะเหมาะสมเพื่อติดตั้ง VMware Esxi ลงไป
Note:    ดูรายละเอียด Hardware ที่รองรับการทำงานของ VMware Esxi ได้ที่
http://www.vm-help.com/esx40i/Hardware_support.php

ติดตามต่อที่นี้ 

Install VMware ESXi 4.1 from bootable USB stick



Ref 


     1 . http://www.jonathanmedd.net/2011/01/install-esxi-4-1-from-a-usb-stick.html

     2.  http://www.ivobeerens.nl/?p=699
  
     3.  http://www.kernel.org/pub/linux/utils/boot/syslinux/

     4.  http://www.techhead.co.uk/how-to-create-a-bootable-vmware-esxi-usb-pen-drive

     5.  http://benincosa.org/blog/?p=171

วันพฤหัสบดีที่ 24 มีนาคม พ.ศ. 2554

Install nagios nrpe on ubuntu

First, you need to install the nagios-nrpe-server. There is a nagios-nrpe-plugin but that’s not what you need because that is just the plugin and you need this daemon (Linux equivalent of a Windows Service for all you Windows guys).
sudo apt-get install nagios-nrpe-server
next, we should check and make sure that the service is actually running. We can do this two ways
sudo ps -Al | grep nrpe
This will show a line where the process is started. If it just comes back without stating anything something is wrong. Another check is to make sure you machine is listening on the nrpe port
netstat -an | grep 5666
Next, we need to set up the Nagios server to be able to check our machine.
sudo nano /etc/nagios/nrpe.cfg
and change
allowed_hosts=127.0.0.1
to
allowed_hosts=127.0.0.1,x.x.x.x
where “x.x.x.x” is the ip address of your nagios server. Now restart the nrep daemon so it reloads the settings
sudo /etc/init.d/nagios-nrpe-server restart
Now go on the Nagios server and run the following command
/usr/local/nagios/libexec/check_nrpe -H y.y.y.y
where “y.y.y.y” is the ip address of the machine you just installed nrpe on. If it works it will respond with the version of NRPE you just installed on the machine.

วันจันทร์ที่ 21 มีนาคม พ.ศ. 2554

Linux / Unix Command: vmstat

vmstat - Report virtual memory statistics  

SYNOPSIS

vmstat [-n] [delay [ count]]
vmstat[-V]  

DESCRIPTION

vmstat reports information about processes, memory, paging, block IO, traps, and cpu activity. The first report produced gives averages since the last reboot. Additional reports give information on a sampling period of length delay. The process and memory reports are instantaneous in either case.
 

Options

The -n switch causes the header to be displayed only once rather than periodically. delay is the delay between updates in seconds. If no delay is specified, only one report is printed with the average values since boot.
count is the number of updates. If no count is specified and delay is defined, count defaults to infinity.
The -V switch results in displaying version information.
 

FIELD DESCRIPTIONS

 

Procs

r: The number of processes waiting for run time.  
b: The number of processes in uninterruptable sleep.
w: The number of processes swapped out but otherwise runnable.  This 
   field is calculated, but Linux never desperation swaps.
 

Memory

swpd: the amount of virtual memory used (kB).
free: the amount of idle memory (kB).
buff: the amount of memory used as buffers (kB).
 

Swap

si: Amount of memory swapped in from disk (kB/s).
so: Amount of memory swapped to disk (kB/s).
 

IO

bi: Blocks sent to a block device (blocks/s).
bo: Blocks received from a block device (blocks/s).
 

System

in: The number of interrupts per second, including the clock.
cs: The number of context switches per second.

These are percentages of total CPU time.
us: user time
sy: system time
id: idle time 
 
 
Example
$ vmstat 1 5
 
Example for add timestamp
 
Create perl script 
$ vi timestamp.pl
#!/usr/bin/perl
while (<>) { print localtime() . ": $_"; }
 
$ vmstat 1 5 | ./timestamp.pl 
 
Example for monitor Memory and CPU
 
$/usr/bin/watch -n 5 '/usr/bin/vmstat -s -S M | /bin/grep -E "memory|cpu"' 
 
Thanks : www.thegeekstuff.com

วันพฤหัสบดีที่ 17 มีนาคม พ.ศ. 2554

SQL: BETWEEN Condition

BETWEEN Condition

เมื่อกล่าวถึงการใช้งาน   BETWEEN  หลายคนคงสงสัยว่าใช้งานอย่างไร ลองมาดูกัน
       
       Syntax : SELECT columns
                     FROM tables
                     WHERE column1 between value1 and value2;

       โดย  columns => ค่าในคอลัมน์ที่เราต้องการ
               tables     => ตารางที่เราจะหา
               column1 => คอลัมน์ที่เรามาตรวจสอบ
               value1,value2 => ค่าสองตัวที่เราจะให้ไปตรวจสอบ


        Example1SELECT * FROM suppliers WHERE supplier_id between 500 AND 510;

       Example2SELECT * FROM orders WHERE order_date between to_date ('2011/03/17', 'yyyy/mm/dd') AND to_date ('2011/03/31', 'yyyy/mm/dd');


วันพฤหัสบดีที่ 3 มีนาคม พ.ศ. 2554

How to test a POP server by using telnet


The initial telnet: >  telnet pop.example.com pop3
client: USER MyUsername                     //ใส่ username
server: +OK please send PASS command
client: PASS MyPassword                     //ใส่ password
server: +OK MyUsername is welcome here
client: LIST                        // คำสั่งดู รายการ
server: +OK 1 messages
server: 1 1801
client: RETR 1                    // เปิดดูเมลล์
***********Show data in mail*************
client: DELE 1                    // ลบเมลล์
server: +OK
client: quit                        //  ออก
server: +OK MyUsername InterMail POP3 server signing off.


Thanks : anta.net