Category: Server

ตัวอย่างการสร้าง Zone บน Solaris 10

ได้รับมอบหมายงานด่วนมาอีกเช่นเคย โจทย์คือมีเครื่อง Sun มาให้ 1 เครื่อง(Host) แล้วทำ Virtualization บนเครื่อง Sun อีก 3 เครื่อง(Guest) พี่เค้า Guide มาให้ว่าไปศึกษาเรื่อง Zone มา ก็ไปเจอข้อมูลจากเว็บไซต์ต่างประเทศเว็บนึง เลยขอนำมาแปะไว้เป็นวิทยาทานสำหรับผู้ที่กำลังศึกษาเรื่อง Solaris Containers (Zone) ครับ
สรุปโดยคร่าวๆ ตามที่ผมเข้าใจได้ว่า Zone เป็น Virtualization รูปแบบนึงซึ่งเป็นของ Sun ผู้ดูแลระบบไม่จำเป็นต้องติดตั้ง Software ใดๆ เพิ่มเติม สำหรับตัวอย่างขั้นตอนการ Config ดูได้จากด่านล่าง

------ Creating a Zone in Solaris 10 ------
-------------------------------------------

To view a list and status of currently installed zones:
------------------------------------------------------

# zoneadm list -vi 

  ID NAME             STATUS         PATH
   0 global           running        /
   1 jumpstart        running        /u01/zones/jumpstart

To create a new zone:
--------------------

# zonecfg -z <zonename>
     (if the zone has not been configured at all previously, you will receive:

<zonename> No such zone configured
Use 'create' to begin configuring a new zone.
                                                                              )
a full example of zone creation for a zone called 'zone1':
---------------------------------------------------------

# zonecfg -z zone1
zone1: No such zone configured
Use 'create' to begin configuring a new zone.
zonecfg:zone1> create
zonecfg:zone1> set zonepath=/u01/zones/zone1
zonecfg:zone1> set autoboot=true
zonecfg:zone1> add fs
zonecfg:zone1:fs> set dir=/opt
zonecfg:zone1:fs> set special=/opt
zonecfg:zone1:fs> set type=lofs
zonecfg:zone1:fs> add options [ro,nodevices]
zonecfg:zone1:fs> end
zonecfg:zone1> verify
zonecfg:zone1> add net
zonecfg:zone1:net> set address=10.67.1.151/24
zonecfg:zone1:net> set physical=eri0
zonecfg:zone1:net> end
zonecfg:zone1> verify
zonecfg:zone1> commit
zonecfg:zone1> exit
#
# zoneadm -z zone1 install
Preparing to install zone <zone1>.
Creating list of files to copy from the global zone.
Copying <1887> files to the zone.
Initializing zone product registry.
Determining zone package initialization order.
Preparing to initialize <951> packages on the zone.
Initialized <951> packages on zone.
Zone  is initialized.
Installation of <1> packages was skipped.
Installation of these packages generated warnings:
The file  contains a log of the zone installation.
# zoneadm -z zone1 boot
# zlogin -e \@ -C zone1                               # -e sets the escape sequence for console session
[Connected to zone 'zone1' console]                                  

To Delete a Zone Permanently:
----------------------------

zoneadm -z <zonename> halt
zoneadm -z <zonename> uninstall
zonecfg -z <zonename> delete

To Delete a zone in a weird state:
---------------------------------

If the install get interrupted, or the configuration has problems, the zone can end up in an incomplete
state.  In this state, it is difficult to uninstall or delete, or continue the configuration.  To remove
the incomplete zone and start fresh, do the following:

1. remove the zone entry in /etc/zones/index:

        global:installed:/
        zone1:installed:/u01/zones/zone1
        zone2:installed:/u01/zones/zone2
        zone3:incomplete:/u01/zones/zone3            <-----------

2. delete the xml file associated with the zone under /etc/zones

3. delete the directory associated with the zone (if it has been created)

ข้อมูลจาก : http://www.camelrichard.org/topics/Solaris/Creating_a_Zone_in_Solaris_10
รายละเอียดเพิ่มเติม : Consolidating Server and Applications with Solaris Containers.pdf

Leave a Comment September 1, 2010

Solaris 10 error : Not on system console, root logon rejected

วันนี้มีงานด่วนเข้ามาคือติดตั้งต้อง login Solaris 10 จาก Xmanager ให้ได้ แต่ตอน Login มันดันมี error “Not on system console, root logon rejected” ทำยังไงละทีนี้ ค้นไปค้นมาก็เจอคำตอบใน http://www.computing.net/answers/solaris/solaris-xmanager-root-logon/2163.html

ขั้นตอนเค้ามีอยู่ว่า
1. login เข้าระบบผ่าน console หรือ ssh เข้าไปก็ได้
2. เข้าไปแก้ไขไฟล์ /etc/default/login โดยให้ comment บรรทัด CONSOLE=/dev/console ซะเป็น (หากบันทึกไม่ได้ให้ chmod 644 /etc/default/login ก่อน)

#CONSOLE=/dev/console

3. ลอง login อีกทีสิ อิอิ

Leave a Comment July 17, 2010

HP ProLiant ML350 Gx And Windows Server 2008 Hyper-V Hypervisor is not running

ใครเจอปัญหารัน Hyper-V แล้วขึ้น Error “The virtual machine could not be started because the hypervisor is not running” ทั้งที่เราก็เปิด Hardware Virtualization ใน BIOS แล้วลองเข้าไปใน BIOS แล้ว Enable Advanced>Processor Options>No-Execute Memory ดูครับ

1 Comment May 15, 2010

Daily Tips : วิธีเปิด X Windows มากกว่าหนึ่งหน้าจอ

วันนี้ได้รับ News letter จากเว็บ cyberciti.biz ฉบับนึงมีบทความน่าสนใจเรื่อง Linux / UNIX: Run Multiple X Sessions ผมเลยคลิกตามไปดู ก็เป็นเรื่องการ Start X Windows ของ Linux ขึ้นมาอีก Session นึงนั่นเอง Vivek เค้าเขียนบอกไว้ว่า ปกติแล้วเวลาที่เราเปิด Linux ขึ้นมาแล้วเข้าหน้า X Windows แล้ว X Windows นั้นจะอยู่ที่ Screen 0 เราสามารถ Start X Windows เพิ่มเติมได้อีกโดยการกำหนดหมายเลข Screen ต่อท้าย

ซึ่งมีขั้นตอนดังนี้
1. กด CTRL + ALT + F1 เพื่อเข้าหน้า Console tty1 แล้วกรอกข้อมูล login ให้เรียบร้อย
2. รันคำสั่ง startx

mrgill@mrgill-laptop:~$ starx -- :1

3. หากต้องการรัน X Windows เพิ่มอีก Session ก็ให้กด CTRL + ALT + F2 แล้วกรอกข้อมูล login ให้เรียบร้อยเหมือนเดิม จากนั้นรันคำสั่ง startx

mrgill@mrgill-laptop:~$ starx -- :2


เราก็จะมี X Windows 3 Session นั่นก็คือ Session ที่ Screen 0 – 2

4. หากต้องการสลับหน้าจอกับมาที่ Screen 0 ให้กด CTRL + ALT + F7
หากต้องการเปลี่ยนมาที่ Screen 1 ให้กด CTRL + ALT + F8
และถ้าอยากกลับมาที่ Screen 2 ก็กด CTRL + ALT + F9

เราสามารถรัน X Windows ได้สูงสุดถึง 6 Session คือ login เข้า tty1 – tty6 ได้โดยการกด CTRL + ALT + F1 ไปจนถึง F6 แล้วใช้คำสั่ง startx ตามด้วย Screen id ตามตัวอย่างด้านบน
และเรียกเข้า X Windows ได้โดยกด CTRL + ALT + F7 ไปจนถึง F12

เป็นทิปที่ผมเองก็เพิ่งรู้และได้ทดสอบแล้วว่าใช้งานได้จริง

แหล่งข้อมูล : http://www.cyberciti.biz/faq/running-multiple-x-sessions/

3 Comments April 28, 2010

การ config squid3 ให้เก็บชื่อ hostname ของ client ใน access.log

วันก่อนพี่ที่บริษัทผมโทรมาสอบถามเรื่องโปรเจ็คตัวนึงที่กำลังทำกันอยู่ซึ่งเกี่ยวข้องกับการเก็บ log ไฟล์ของ squid 3 ว่าสามารถทำให้มันเก็บ log ชื่อ hostname + ip ได้ไหมเพราะถ้าเป็นไอพีอย่างเดียว คนที่มีความรู้ด้านไอทีก็สามารถเข้าไปเปลี่ยนไอพีของเครื่อง client ได้ ซึ่งตอนนั้นผมก็ยังไม่มีเวลาศึกษา จนกลับมาจากงานอบรมที่ชัยภูมิก็มานั่งทำการบ้านที่พี่เค้าสั่งมาจนได้คำตอบดังนี้

หากคุณต้องการให้ squid เก็บ log ทั้ง hostname + ip ตามตัวอย่างด่านล้าง

root@proxy:/etc/squid3# tail -f /var/log/squid3/access.log mrgill-laptop 192.168.1.34 - - [13/Mar/2010:23:12:29 +0700] "GET http://imrgill.com/wp-admin/index.php? HTTP/1.1" 200 1008 "http://imrgill.com/wp-admin/index.php?page=stats" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.2pre) Gecko/20100311 Ubuntu/9.10 (karmic) Namoroka/3.6.2pre GTB6" TCP_MISS:DIRECT mrgill-laptop 192.168.1.34 - - [13/Mar/2010:23:12:29 +0700] "GET http://imrgill.com/wp-admin/index.php? HTTP/1.1" 200 1780 "http://imrgill.com/wp-admin/index.php?page=stats" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.2pre) Gecko/20100311 Ubuntu/9.10 (karmic) Namoroka/3.6.2pre GTB6" TCP_MISS:DIRECT mrgill-laptop 192.168.1.34 - - [13/Mar/2010:23:12:30 +0700] "GET http://imrgill.com/wp-content/plugins/flickr-gallery/flickr-gallery.css? HTTP/1.1" 304 260 "http://imrgill.com/wp-admin/index.php?page=stats" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.2pre) Gecko/20100311 Ubuntu/9.10 (karmic) Namoroka/3.6.2pre GTB6" TCP_REFRESH_UNMODIFIED:DIRECT

ให้คุณตั้งค่า squid3.conf ดังนี้

#เอา # หน้าบรรทัด logformat combined ออกแล้วเพิ่ม %>A เข้าไปหน้า %>a logformat combined %>A %>a %ui %un [%tl] "%rm %ru HTTP/%rv" %Hs %h" "%{User-Agent}>h" %Ss:%Sh #กำหนด logformat เป็น combined access_log /var/log/squid3/access.log combined #กำหนด log_ip_on_direct เป็น off log_ip_on_direct off #กำหนด log_fqdn เป็น on log_fqdn on

แต่มีข้อแม้ว่า proxy server ของเราต้อง resolv hostname จาก dns server ของเราได้ด้วยนะครับ หมายถึงต้องมีชื่อเครื่อง client ใน dns server ของเราด้วย ถ้าใครไม่มี dns ก็สามารถ map เครื่องกับไอพีได้เองในไฟล์ /etc/hosts
ตัวอย่าง

127.0.0.1 localhost 127.0.1.1 proxy 192.168.1.34 mrgill-laptop

เสร็จแล้วก็อย่าลืม restart squid3 กันด้วยนะครับ

Leave a Comment March 13, 2010

Daily Command : แอบดูคน logon ด้วย w

คิดไว้นานแล้วครับว่าจะทำหมวดพวก Daily tips และ Daily command ซึ่ง Daily tips เปิดตัวไปก่อนหน้าแล้ววันนี้มาถึงคิวของ Daily command กันบ้าง วันนี้ขอเสนอคำสั่ง w ครับ สั้นๆ ง่ายๆ เอาไว้ตรวจสอบสถานะของเครื่องและการ logon ของ user

[mrgill@Webserver ~]$ w 21:40:35 up 45 days, 15:33, 2 users, load average: 0.05, 0.03, 0.00 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT mrgill pts/1 ppp-124-120-45-1 21:37 0.00s 0.03s 0.00s w root :0 - 18Dec09 ?xdm? 2:22m 0.20s /usr/bin/gnome-session

รายงานทั้ง

  • วันเวลา : 21:40:35
  • uptime : up 45 days, 15:33
  • จำนวน user ที่ logon : 2 users
  • รวมทั้ง load ของ cpu ด้วย : load average: 0.05, 0.03, 0.00

Leave a Comment January 26, 2010

Daily Tips : Logout ออกจาก Command Line แบบทันใจ

ทิปสั้นๆ ครับสำหรับใครที่ใช้ Linux mod command line หรือ SSH แล้วต้องการ Logout ออกจากระบบแบบเร็วๆ โดยที่ไม่ต้องพิมพ์คำสั่ง exit หรือ logout ลองกด Ctrl + d ดูครับก็จะเป็นการ Logout อีกรูปแบบนึง

1 Comment January 21, 2010

Apache กำลังจะหยุดพัฒนาเวอร์ชัน 1.3, 2.0 Release

Apache HTTP Server เป็นโปรเจ็คที่ประสบความสำเร็จและได้รับความนิยมมากที่สุดของ Apache Software Foundation (ASF) ซึ่งตอนนี้มีข่าวมาว่า ASF จะหยุดพัฒนาไมเนอร์เวอร์ชันของ 1.3 กับ 2.0 และจะมุ่งไปพัฒนาเวอร์ชัน 2.2  โดย Colm MacCárthaigh หนึ่งในสมาชิก ASF ให้ความเห็นไว้ว่า

“How about we formally deprecate the 1.3.x branch? Make one more release, but attach a notice to the effect that it will be the final release, and that in future we’ll be distributing security updates by other means,”

ข่าวจาก : techworld

Leave a Comment January 13, 2010

Tune Apache 2.x ยังไงให้รองรับ 20,000 Concurrent

ยังไม่เคยลองจริงเหมือนกันครับ แต่ไปเจอมาหวังว่าคงเป็นประโยชน์
เนื้อหา
1 Introduction 3
1.1 What ftp.heanet.ie is 3
1.2 What ftp.heanet.ie is not 3
1.3 Motivation 4
1.4 The Numbers 4
2 Benchmarking 6
2.1 Webserver benchmarking 6
2.2 Filesystem benchmarking 8
2.3 VM and Scheduler benchmarking 9
3 Tuning Apache 12
3.1 Choosing an MPM 12
3.2 Static Vs DSO 13
3.3 Configuration changes 14
3.4 Sendfile 15
3.5 Mmap 15
3.6 mod cache 16
3.7 Compile options 17
4 Tuning the Operating System 19
4.1 Choosing and tuning filesystems 19
4.2 NFS 21
4.3 Choosing a kernel 22
4.4 Tuning the Kernel 23
4.4.1 Tuning the VM 23
4.4.2 Tuning the Networking Stack 24
4.4.3 Pluggable I/O schedulers 25
4.5 Hyperthreading 25
5 System Design 26
5.1 Hardware and Operating System choice 26
5.2 Canyonero.heanet.ie 27
5.3 Attempted Multi-system architecture 28
5.4 Cassandra.heanet.ie 29
5.5 Summary: Time-line of ftp.heanet.ie 30
6 Future changes for ftp.heanet.ie 31
6.1 Jumboframes 31
6.2 Multicast services 31
6.3 mod ftpd? 31
6.4 64-bit and FreeBSD 31
Bibliography 33
Acknowledgements 33

White Papers [35 Pages]
Presentation
ขอบคุณ
Author : Colm MacCarthaigh

Leave a Comment January 13, 2010

Shell Script แจ้งเตือน SMS เมื่อ Hard Disk ใกล้เต็มแบบฟรีๆ

สวัสดีครับต่อยอดจากเรื่อง Server Down รู้ได้ทันทีผ่าน SMS แถมฟรี ที่เขียนไว้วันก่อน วันนี้เอามาประยุกต์ให้ script เช็คสถานะของ hard disk ครับโดยให้ส่ง sms เตือนเมื่อมีการใช้งาน partition ใดๆ เกิน 90%
มาดูตัว code ของ script กันครับ

#!/bin/sh # Simple SHELL script for Linux and UNIX system monitoring with # df command # ------------------------------------------------------------------------- # Copyright (c) 2009 mrGilL # This script is licensed under GNU GPL version 2.0 or above # ------------------------------------------------------------------------- # Setup SMS User below # See URL for more info: # http://imrgill.com/2009/12/13/monitor-server-with-sms-alert-shell-script/ # ------------------------------------------------------------------------- # Hard type (hdx,sdx,scx) HDD_TYPE="sd" # Partition lists PLIST=`df -h | grep $HDD_TYPE | awk '{ print $1 }' | sed -e 's/\/dev\///g'` # Setting SMS User (Gmail) GCUSER="user@gmail.com" GCPASSWD="gmail-passwd" for p in $PLIST do disk=$(df -h | grep $p | awk '{ print $5 }' | sed -e 's/\%//g') pname=$(df -h | grep $p | awk '{ print $6 }') if [ $disk -ge 90 ]; then # disk less than 90% wget --force-html --recursive --no-check-certificate -nd --delete-after "https://imrgill.com/google_sms/gsms.php?username=$GCUSER&password=$GCPASSWD&title=$(hostname) partition $pname < 90%" fi done

วิธีนำไปใช้

1. แก้ไข HDD_TYPE เป็นประเภท hard disk ที่คุณใช้ ดูได้จากคำสั่ง fdisk -l หรือ df ผลลัพธ์ที่ได้จะประมาณ /dev/sda ตัวอย่างผมได้ sda ให้ใส่เป็น HDD_TYPE=”sd”

[mrgill@Webserver ~]$ df Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda2 59515556 1260296 55183232 3% / /dev/sda8 11710104 2895576 8210084 27% /usr /dev/sda7 1019208 37992 928608 4% /tmp /dev/sda6 109109796 9092520 94385292 9% /var /dev/sda5 287660612 11604092 261208448 5% /home /dev/sda1 101086 33812 62055 36% /boot tmpfs 517284 0 517284 0% /dev/shm

*เหตุผลที่ไม่ใส่ sda ไปตรงๆ เลยก็เพราะ กรณีมี hard disk หลายลูกเช่น sda, sdb ทำให้ script ไม่สามารถตรวจสอบ hard disk ที่เป็น sdb ได้

2. แก้ไข GCUSER และ GCPASSWD เป็น user gmail ของเรา

3. กำหนดสิทธิ์ให้สามารถรันได้

[root@Webserver ~]$ chmod +x observman_disk.sh

4. นำ script ไปใส่ /etc/cron.daily/ เพื่อให้ script ทำงานทุกวัน

[root@Webserver ~]$ cp observman_disk.sh /etc/cron.daily/

หรือใครจะนำไปใส่ใน crontab ก็ไม่ว่ากัน

[root@Webserver ~]$ crontab -e
# m h dom mon dow command @daily /root/observman_disk.sh > /dev/null

หวังว่าบทความนี้คงเป็นประโยชน์ต่อผู้อ่าน

4 Comments December 13, 2009

  • Page 1 of 2
  • 1
  • 2
  • >

Chat

Recent Entries

Random Posts

Social Network

Tag Cloud

Calendar

September 2010
S M T W T F S
« Aug    
 1234
567891011
12131415161718
19202122232425
2627282930  

RSSTwitter: imrgill

  • Could not connect to Twitter

RSS LinuxToday

RSS UbuntuClub

RSS Blognone

Tag

ภาษาไทย adobe amsn antivirus apt-get bash chat clip dns emesene entertainment Facebook firefox Forward mail free google graphic grave accent How to howto im install Internet karmic keyboard Linux monitoring msn operating system os Programming recovery Server shell script sms Social network Software themes troubleshooting twitter Ubuntu utility virtualization Windows wine

Categories

Archives

Blogroll

Meta

Get Adobe Flash playerPlugin by wpburn.com wordpress themes