Error 29506 เมื่อติดตั้ง SQL Server Management Studio บน Windows 7

2011-09-21 / Computer, SQL/Database / No Comment

วันนี้ผมเจอปัญหา Error 29506 ตอนที่ติดตั้ง SQL Server Management Studio บน Windows 7
หลังจากหาไป ก็พบว่าต้องรันเป็นแบบ Admin ถึงจะติดตั้งได้ ผมก็ลองคลิดขวาดู ปารกฏว่าตัว Setup (SQLServer2005_SSMSEE_x64.msi)
ไม่สามารถ ตั้งค่าให้ รันแบบ Admin ได้ ต้องไปใช้วิธีการเรียกผ่านทาง CMD แทน

โดยเรก CMD แบบ Admin
1.คลิกขวาที่ cmd เลือก Run as administrator
2.cd ไปที่ path ที่เก็บไฟล์ setup
3.สั้งรันไฟล์ setup ก็เป็นที่เรียบร้อยครับ

Tags: , , , ,
Read More

Solaris Bus Error (core dumped) เหตุจากการ cast ค่าใน Memory ตำแหน่งที่เป็นเลขคี่

เมื่ออาทิตย์ที่แล้ว ในขณะที่นั่งเขียนโปรแกรมอยุ่เพลิน อยุ่ๆ Terminal ก็ขึ้นว่า Bus Error (core dumped)
(ชิกหายแล้วกรู) นั่งหาอยู่พักใหญ่ก็พบ ว่า ปัญหาที่เกิด มาจาก การ cast ค่าจาก Memory Index ที่เป็น เลขคี่ ผมเลยลองเขียน code ตัวอย่าง ขึ้นมา อธิบายดู ตามนี้ครับ

#include <stdio.h>

#define U8 unsigned char

int main()
{
short sh_1_data;
short sh_2_data;

short *sh_1_ptr;
short *sh_2_ptr;

U8 arr_data[10];
int i;

for(i = 0; i < 10; i++)
{
arr_data[i] = 1;
}
sh_1_ptr = (short *)&arr_data[2];
printf(“before cast sh_data_1 from array index 2[memory index %u]\r\n”,(int)&arr_data[2]);

sh_1_data = *sh_1_ptr;
printf("after cast sh_1_data = %d from memory index %u\r\n\r\n",sh_1_data,(int)sh_1_ptr);

sh_2_ptr = (short *)&arr_data[3];
printf("before cast sh_data_2 from array index 3[memory index %u]\r\n",(int)&arr_data[3]);

sh_2_data = *sh_2_ptr;
printf("after cast sh_2_data = %d from memory index %u\r\n",sh_2_data,(int)sh_2_ptr);

}

จาก code และผลจาก run จะได้ว่า ถ้าหาก เราจะ cast ค่าจาก memory ที่เป็น เลขคี่ โปรแกรมจะขึ้น bus error ทันที

ปัญหานี้ผลเจอกับ Solaris อย่างเดียวนะครับ ใน Ubuntu ลองแล้ว ไม่เป็นครับ

Tags: , ,
Read More

การติดตั้ง Virtual Box ใน Ubuntu ใน Ubuntu

2011-09-21 / Ubuntu, Unix/Linux / No Comment

วิธีการติดตั้ง Virtual Box
1.Download  Virtual Box &  VirtualBox Extension Pack ที่เว็ปของ Virtual Box ได้เลย
1.1  Virtual Box (http://download.virtualbox.org/virtualbox/4.1.2/virtualbox-4.1_4.1.2-73507~Ubuntu~natty_i386.deb)
1.2  VirtualBox Extension Pack (http://download.virtualbox.org/virtualbox/4.1.2/Oracle_VM_VirtualBox_Extension_Pack-4.1.2-73507.vbox-extpack)

 

2. ติดตั้ง package ที่จำเป็นต้องใช้
2.1 #sudo apt-get install libqt4-network
2.2 #sudo apt-get install libqt4-opengl
2.3 #sudo apt-get install libcurl3
2.4 #sudo apt-get install dkms

3. ติดตั้ง Virtual Box ด้วยคำสั่ง sudo dpkg -i [FILE_NAME]         //[FILE_NAME]  คือชื่อไฟล์ 1.1

4. ติดตั้ง VirtualBox Extension Pack ด้วยคำสั่ง sudo VBoxManage extpack install [FILE_NAME]         //[FILE_NAME]  คือชื่อไฟล์ 1.2

 

5. เปลี่ยน Group User เพื่อให้ใช้ อุปกรณ์จำพวก USB ได้
5.1 #sudo usermod -a -G vboxusers $(whoami)
5.2 #sudo usermod -a -G vboxsf $(whoami)
5.3 #sudo usermod -a -G lp $(whoami)

 

6.จากนั้น logout แล้ว login  แล้วลองเล่นดูได้เลยครับ

อ้างอิง
http://opensource.cc.psu.ac.th/%E0%B8%95%E0%B8%B4%E0%B8%94%E0%B8%95%E0%B8%B1%E0%B9%89%E0%B8%87_virtualbox_%E0%B8%9A%E0%B8%99_ubuntu
http://www.howtoforge.com/virtualbox_ubuntu

Envi : Ubuntu 11.04 & VBox 4.1.2

 

 

 

 

 

 

 

Tags: , , , , ,
Read More

วิธีการ Config IIS ใน Windows 2003 เพื่อรัน ASP.NET

การ Install IIS

ไปที่ “Add or Remove Programs > Add/Remove Windows Components “   แล้วเลือก check box ที่ Application Server

 

การ Install ASP.NET ใน IIS

Command Line ไปที่ \Windows\Microsoft.NET\Framework\v2.0.5.0727

จากนั้นพิม

  • aspnet_regiis -i   ; for install
  • aspnet_regiis -e

จากนั้นไปที่ start > run > open : inetmgr  แล้วไปที่ Folder Web Service Extensions เพื่อ Allow Module ต่างๆ ตามนี้

 

จากนั้น Restart Server ของ IIS ใหม่อีกครั้ง


Tags: , , ,
Read More

คำสั่งในการ create flash file สำหรับ solaris

คำสั่งในการ create flash file สำหรับ solaris

flarcreate -n [flash_name] [-x exclude-file ..... -x exclude-file]  -c [file_name]

ตัวอย่างนะครับ

#flarcreate -n solaris_10 -x /store/solaris_10.flar -c /store/solaris_10.flar

หลังจากนั้นถ้าเสร็จเราก็จะได้ Flash File มา  1 ก้อน เวลาที่เราจะไป Install ก็ใส่แผ่น Install Solaris ลงไป

แล้วขั้นตอนการเลือกวิธีลง ก็ให้เลือก แบบ flash จากนั้น ก็เลือกวิธี stream file โดยจะใช้เป็นแบบ http, ftp, nfs ก็ได้ แล้วแต่สะดวกเลยครับ

 

Tags: , ,
Read More

Solaris Set System Console to Local Graphics Monitor

2011-04-22 / Server, Unix/Linux / 56 Comments

Solaris Set System Console to Local Graphics Monitor :
วิธีการทำ set ค่า Standard Input & Output ของเครื่อง Server Sun ออกทาง จอมอนิเตอร์ (Card จอ)
โดยในเครื่องรุ่งใหม่ ๆ  ที่ออกจากโรงงานส่วนใหญ่จะไม่มี การ์ดจอใส่มาให้ (ต้องซื้อใส่เพิ่ม)
และ Default  Standard Input & Output จะออกทาง Console
ส่วนวิธีการ Set Output ให้ออก การ์ดจอ และ Input รับทาง Keyboard ก็มีวิธีง่ายๆ  ครับ

1.วิธี set ผ่านทาง Service CPU (ILOM)
1.1 set input device

set /HOST/bootmode script=”setenv input-device keyboard”

1.2 set output device

set /HOST/bootmode script=”setenv output-device screen”

 

2.วิธี set ผ่าน ok prompt

2.1 set input device

#ok setenv input-device keyboard

2.2 set output device

#ok setenv output-device screen

2.3 reset

#ok reset-all

 

แค่นี้ก็เรียนร้อยแล้วครับ ^^
ส่วนใครที่จะ เซตกลับไปทาง Console ก็ เซตง่าย ๆ ตามนี้ครับ (ดูตาม diagram ได้เลยนะครับ)

#ok setenv virtual-console
#ok setenv virtual-console


Ref : Sun SPARC® Enterprise T5120 and T5220 Servers Administration Guide

 

 

Tags: , , , , ,
Read More

Message Queue C on Unix/Linux

วันนี้อยู่บ้านวันอาทิตย์ว่าง ๆ ไม่ได้ทำอะไร ก็เลยมานั่งหาอะไรอ่าน เอาความรู้ใส่สมอง ซักหน่อย
ก็เลยมาอ่านเกี่ยวกับเรื่อง Message Queue และก็ลองเขียนเล่นๆ ดู ก็ผมจะสรุปตามความเข้าใจของผม และย่อตัวอย่าง Code ที่ใช้งานดูนะครับ

Message Q คืออะไร และใช้ทำอะไร ?

ก่อนที่จะมาทำความรู้จักกับ Message Queue เรามาทำความรู้จักกับ IPC กันก่อน IPC หรือ Interprocess Communication มีไว้เพื่อการติดต่อสื่อสาร จะใช้ในการติดต่อสื่อสารระหว่าง Thread ภายใน Process เดียวกันก็ได้ หรือ จะใช้ในการติดต่อสารระหว่าง Process ก็ได้
โดยการสื่อสารของ IPC มีหลายชนิด และแต่ละชนิดมีข้อดีข้อเสียแตกต่างกันไปครับ

  • Pipes
  • Signal
  • Message Queue
  • Shared Memory
  • Socket
  • Semaphores

Page จะพูดเรื่อง Message Queue ก่อนนะครับ แล้วผมจะค่อย ๆ เพิ่มในส่วนอื่นให้ภายหลัง Message Queue สามารถติดต่อสื่อสารกันภายใน OS เดียวกันได้เท่านั้น คือ ตัว Message Queue ไม่สามารถสื่อสารข้ามเครื่องได้ ต้องอยู่ภายใต้เครื่องเดียวกันเท่านั้น

โดยการทำงานคร่าวๆ ของ Message Queue นั้นแน่นอนว่าจะมีในส่วนของการส่งและการรับ และที่เพิ่มเข้ามาจะเป็นในส่วนของ Passing Module ซึ่งทำหน้าที่เป็นตัวกลางในการจัดการ รับ-ส่ง Message ให้กับทั้ง 2 Process และ ใน Process ทั้งสองจะต้องกำหนดค่า Key ขึ้น ให้ตรงกัน เช่น Process ที่ส่ง ส่งด้วย Key 1234 ใน Process ในการรับก็ต้องรับ ด้วย Key 1234 ด้วย

ในใช้งาน Function หรือ type ต่าง ๆ ของ Message Queue จะต้อง include header file 3 file ดังนี้

  • #include <sys/types.h>
  • #include <sys/ipc.h>
  • #include <sys/msg.h>

function หลักๆ ของ Message ที่ใช้มีดังนี้ msgget(), msgsnd(), msgrcv()

  • int msgget(key_t key, int msgflg)
  • int msgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg);
  • int msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg);

1. msgget ใช้ในการสร้างช่องทางในการรับ-ส่ง

  • return ค่าของ Messsage Queue ID มาให้หาก function นี้ทำงานสำเร็จ และ return -1 หาก error
  • key คือเลขคือ ซื่งตัวแปล key จะมีขนาด เทียบเท่า unsigned long
  • msgflg คือ parameter ที่ใช้ตั้งค่า permission และ control flag ของ message queue

2. msgsnd ใช้ในการส่ง

  • return หาก function นี้ทำงานไม่สำเร็จจะ return -1
  • msqid คือ message queue id ที่ได้จากการ call function msgget
  • msgp คือ structure ของ message ที่ จะส่งออกไป
  • msgsz คือ ขนาดของ structure ของ message ที่จะส่งออก
  • msgflg คือ flag เพื่อบอกว่า call function นี้แล้วให้ทำอะไร ส่วนใหญ่ที่ผมใช้คือ IPC_NOWAIT

3.msgrcv ใช้ในการรับ

  • return หาก function นี้ทำงานสำเร็จจะ return ขนาดของ Message ที่รับเข้ามา แต่หากไม่สำเร็จจะ return -1
  • msqid คือ Qessage Queue id ที่ได้จากการ call function msgget
  • msgp คือ structure ของ message ที่ จะรับเข้ามา
  • msgsz คือ ขนาดของ structure ของ message ที่จะรับเข้ามา
  • msgtyp คือ จะรับ Message type อะไร
  • msgflg คือ flag เพื่อบอกว่า call function นี้แล้วให้ทำอะไร

Code Example

โดยตัวอย่างผมจะแบ่งออกเป็น 2 Process (2 โปรแกรม)

  1. โปรแกรมส่ง Send Process
  2. โปรแกรมรับ Receive Process

1.msgq_send.c

/*************************
*@author Ultra MCU
*@file-name msgq_send.c
*@date 2011 02 13
*compile apple-darwin10-gcc-4.2.1 on OSX 10.6.4
*@e-mail ultra_mcu[AT]msn>com
*@website http://www.im-ai.com
*************************/

#include
#include
#include
#include

#define _TRUE_ 0
#define _FALSE_ -1

typedef struct struct_message_text
{
long message_type;
char message_text[100];

}st_msg_txt;

int main (int argc, const char * argv[]) {

printf(“Hello, I’m send process.\r\n”);
send_process();
return 0;
}

int send_process()
{
st_msg_txt my_send_msg;
key_t msg_key;
int msg_flag;
int msg_q_id;
int msg_number;

msg_number = 0;
msg_key = 822; /* Message Queue Key 822 */
msg_flag = IPC_CREAT | 0666; /* IPC Create + Permission rw_rw_rw_ */
my_send_msg.message_type = 1; /* Message type 1 */
msg_q_id = msgget(msg_key, msg_flag);

if(msg_q_id > -1)
{
while(1)
{
sprintf(my_send_msg.message_text,”Message msg_number = %d”,msg_number);

if(msgsnd(msg_q_id, &my_send_msg, sizeof(st_msg_txt), IPC_NOWAIT) == _TRUE_)
{
printf(“SEND PROCESS : %s\r\n”,my_send_msg.message_text);
}
else
{
perror(“msgsnd”);
printf(“send message failed\r\n”);
return _FALSE_;
}

msg_number++;
sleep(1);
}
}
else
{
printf(“get message queue id failed\r\n”);
return _FALSE_;
}

return _TRUE_;

}

2.msgq_recv.c

/*************************
*@author Ultra MCU
*@file-name msgq_recv.c
*@date 2011 02 13
*compile apple-darwin10-gcc-4.2.1 on OSX 10.6.4
*@e-mail ultra_mcu[AT]msn>com
*@website http://www.im-ai.com
*************************/

#include
#include
#include
#include

#define _TRUE_ 0
#define _FALSE_ -1

typedef struct struct_message_text
{
long message_type;
char message_text[100];

}st_msg_txt;

int main (int argc, const char * argv[]) {

printf(“Hello, I’m recv process.\r\n”);
recv_process();
return 0;
}
int recv_process()
{
st_msg_txt my_recv_msg;
key_t msg_key;
int msg_flag;
int msg_q_id;
int recv_msg_type;

msg_key = 822; /* Message Queue Key 822 */
msg_flag = IPC_CREAT | 0666; /* IPC Create + Permission rw_rw_rw_ */
recv_msg_type = 1; /* Receive Message type 1 */

msg_q_id = msgget(msg_key, msg_flag);

if(msg_q_id > -1)
{
while(1)
{
if(msgrcv(msg_q_id, &my_recv_msg, sizeof(st_msg_txt),recv_msg_type , 0) < 0)
{
perror(“msgrcv”);
printf(“recv message failed\r\n”);
return _FALSE_;
}
else
{
printf(“RECV PROCESS : %s\r\n”,my_recv_msg.message_text);
}
}
}
else
{
printf(“get message queue id failed\r\n”);
return _FALSE_;
}

return _TRUE_;

}

ดังไฟล์ source code ตัวอย่างเป็นการรับส่ง message queue ด้วย key 822 และใช้ message type เป็น 1 โดย ทุกๆ 1 วินาที Process ที่ส่งจะส่งข้อความ “Message msg_number =XXX” ไปหา Process รับโดยเลข XXX จะนับเพิ่มขึ้นเรื่อย ๆ

Message Queue

จากตัวอย่าง หน้าจอสีแดงคือ Process รับ ส่วนหน้าจอสีขาวคือ Process ส่ง

นี่ก็เป็นตัวอย่างง่าย ๆ ของการสร้างการสื่อสารภายใน Application หรือระหว่าง Application ได้ง่ายและรวดเร็ว เพียงแค่เขียน code เพิ่มไม่กี่บรรทัด ซึ่งข้อดีของการใช้ Message Queue คือพัฒนาได้เร็ว รับส่งเร็ว แต่ข้อเสียคือขนาดของการส่งมีจำกัด ดูได้จากคำสั่ง ulimit -q แต่สามารถเปลี่ยนแปลงได้ ตามคำสั่งของ Unix นั้นๆ ครับ

ปล.หากต้องการนำไปเผยแพร่ ขอความกรุณาใส่เครดิต ให้ด้วยครับ ขอบคุณครับ

Ref : http://www.cs.cf.ac.uk/Dave/C/node25.html
Ref : http://linux.die.net/man/3/msgget

Tags: , , , ,
Read More

เปิด FTP Server ใน Solaris 10

2010-12-26 / Computer, Server / 45 Comments

วิธีการเปิด FTP Server ใน Solaris 10 นั้นค่อยข้างง่ายครับ
เนื่องจากโดยปกติการติดตั้ง Solaris 10 นั้นจะติดตั้ดตั้งตัว FTP Server มาให้พร้อมอยู่แล้ว

1.ลองใช้คำสั่งในการตรวจสอบ ดูก่อนว่าในเครื่องเรามี FTP Server อยู่หรือไม่
# inetadm -l network/ftp    ซึ่งคำสั่งนี้ใช้ในการตรวจสอบ status ของ service ครับ

2.จากนั้นใช้คำสั่ง svcadm เพื่อจัดการ service
ซึ่งมีรูปแบบตามนี้ครับ svcadm [operation] serivce_name
เช่น # svcadm enable network/ftp    //คำสั่งในการเปิด service
# svcadm restart network/ftp    //คำสั่งในการ restart service

3.ส่วนการจัดการเกี่ยวกับในส่วนของ user ที่จะ login เข้ามานั้นจะใช้ user ชุดเดียวกับ OS ครับ (รวมทั้ง Home Dir ด้วย ดูที่ /etc/passwd)
แต่เราสามารถกำหนดกฏ หรือการ Block ได้ดังนี้ครับ

3.1 การ block user นั้นสามารถเลือก block ได้โดยใส่ user name ของ user ที่เราต้องการ block ลงในไฟล์ /etc/ftpd/ftpusers
3.2 กฏต่างของ FTP Server จะอยู่ในไฟล์ /etc/ftpd/ftpaccess

เพิ่มเติม :
http://wiki.bath.ac.uk/display/~ccsnjf/Solaris10+-+notes
http://sysinfo.bascomp.org/solaris/ssh-in-solaris/



Tags: , , , , , , , , ,
Read More

install oci8 on RedHat

2010-11-29 / Server / 153 Comments

RED HAT ENTERPRISE LINUX 5
ORACLE 10g R2

1.Download
1.1.instantclient-basic-linux-x86-64-10.2.0.3-20070103.zip
1.2.instantclient-sdk-linux-x86-64-10.2.0.3-20070103.zip
1.3 oci8-1.4.4.tgz (http://pecl.php.net/package/oci8)

2.Make Dir
#mkdir /opt/oracle

3.unzip all file int /opt/oracle
#unzip instantclient-basic-linux-x86-64-10.2.0.3-20070103.zip
#unzip instantclient-sdk-linux-x86-64-10.2.0.3-20070103.zip

4.crate symbol links

#ln -s libclntsh.so.10.1 libclntsh.so
#ln -s libocci.so.10.1 libocci.so

5.add oracle instant client to system id

#echo /opt/oracle/instantclient_10_2 > /etc/ld.so.conf.d/oracle-instantclient

6.compile oci   (in section redhat need to intsalled php)

#pecl install oci8-1.4.4.tgz  ; type instantclient,/opt/oracle/instant_10_2 after pecl show prompt

8.enable oci8.so in php.ini

#nano /etc/php.ini

and insert “extension=oci8.so”  below section   “; Dynamic Extensions ; ”

9.reboot service httpd
#service httpd restart

NOTICE:
set LD_LIBRARY_PATH to /opt/oracle/instantclient_10_2

install php-pear
Tags: , ,
Read More

How to make and install samba server on solaris

1.Download Soure at : http://www.samba.org/samba/download/
Now(2010-11-09) I get a lasted version “samba 3.5.6″ (file : samba-3.5.6.tar.gz)

2.Put in your’s solaris (I put via WinSCP.)

3.Extract gz and tar
3.1 Extract gz via cmd “gunzip samba-3.5.6.tar.gz ”

3.2 Extract tar via cmd “gunzip samba-3.5.6.tar”

4.after step 3 you got a new directory name “samba-3.5.6″

in samba-3.5.6 in source directory  “samba-3.5.6/source3″ for samba version 3 and “samba-3.5.6/source4″ for version 4

execute “./configure”  and “./make”

Oop. I use samba-3.5.6 when I make it’s,I  get this error.

“make: Fatal error in reader: Makefile, line 1396: Extra `:’, `::’, or `:=’ on dependency line”
and I found a solution for It.

A. Execute configuration by this command

./configure --with-automount --without-ldap --enable-socket-wrapper \
--with-quotas --with-sys-quotas --with-acl-support --with-aio-support \
--without-pam --enable-shared --prefix=/usr/local/opt/samba-3.5.2

B.In Makefile

B.1 search for -lthread and insert -lintl after (4 times)

B.2 remove “-Wl,-z,defs” (2 times)

B.3 search for option -G and replace with “-fPIC -shared”

B.4 search for “SHELL=” and replace “/bin/sh” with “/bin/bash”

B.5 edit file “include/config.h” and comment #define HAVE_IPV6 1

เรียบร้อย ^^

จากนั้นใช้คำสั่ง gmake -j และ gmake -j install

C1. สร้างไฟล์ comfig ไว้ใน /etc/sfw/ โดยจะมีตัวอย่าง อยู่ คือไฟล์ smb.conf-example
C2. สร้าง Password ให้กับ user โดย user นี้จะใช้ user เดียวกับ OS คำสั่งคือ smbpasswd -a “username” ไฟล์อยู่ที่ /usr/sfw/bin
C3. สร้าง Script Auto run ไว้ที่ /etc/rc3.d

#!/sbin/sh
#
# Copyright (c) 2001 by Sun Microsystems, Inc
# All rights reserved.
#
#ident  “@(#)samba      1.1     01/09/24 SMI”

case “$1″ in
start)
[ -f /etc/sfw/smb.conf ] || exit 0

/usr/sfw/sbin/smbd -D
/usr/sfw/sbin/nmbd -D
;;
stop)
pkill smbd
pkill nmbd
;;
*)
echo “Usage: $0 { start | stop }”
exit 1
;;
esac
exit 0

จากนั้นลองเทส โดยเรียก scritp นี้

Ref : http://panoramicsolution.com/blog/?p=134

Tags: , , , , ,
Read More