Thursday Jun 04, 2009

How to start VNC session on OpenSolaris 2009.06 EC2 AMI

Following instructions describes steps to access GUI on OpenSolaris 2009.06 EC2 AMI Instance using VNC Viewer.

Enable following desktop related services

svcadm enable svc:/application/graphical-login/gdm:default
svcadm enable svc:/application/desktop-cache/icon-cache:default
svcadm enable svc:/application/desktop-cache/desktop-mime-cache:default
svcadm enable svc:/application/desktop-cache/mime-types-cache:default
svcadm enable svc:/application/desktop-cache/input-method-cache:default
svcadm enable svc:/application/desktop-cache/gconf-cache:default
svcadm enable svc:/application/desktop-cache/pixbuf-loaders-installer:default

Set xvm_vnc property to true for x11-server SMF service.

svccfg -s x11-server setprop options/xvm_vnc = boolean: true

Set the root password, you may need it to get back to your session in case if screen saver starts.

root@domU-12-31-39-02-5C-D1:~# passwd
passwd: Changing password for root
New Password:
Re-enter new Password:
passwd: password successfully changed for root
root@domU-12-31-39-02-5C-D1:~#

Setup VNC server

Create .vnc directory under /root if it does not exist
mkdir /root/.vnc/

Create /root/.vnc/xstartup file with following lines.
#!/bin/sh
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
gnome-terminal -geometry 100x60 -title "$VNCDESKTOP Desktop" &
/usr/bin/gnome-session
Note: if xstartup file is already exist, replace it with above lines to start gnome terminal session for VNC.

Provide execute permission on xtartup file.
chmod +x /root/.vnc/xstartup

Start the vncserver and set the password.

root@domU-12-31-39-02-5C-D1:~# vncserver

You will require a password to access your desktops.

Password:
Verify:
xauth: creating new authority file /root/.Xauthority

New 'domU-12-31-39-02-5C-D1:1 (root)' desktop is domU-12-31-39-02-5C-D1:1

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/domU-12-31-39-02-5C-D1:1.log

root@domU-12-31-39-02-5C-D1:~#

Authorize VNC Port
Here we are done with configuring EC2 instance for GUI Remote Access.
Finally we need to authorize the corresponding VNC port on users machine where VNC client is installed.

divyen-patels-macbook:~ divyen$ ec2-authorize default -p 5801
GROUP default
PERMISSION default ALLOWS tcp 5801 5801 FROM CIDR 0.0.0.0/0
divyen-patels-macbook:~ divyen$


Screen Shots
VNC client connection configuration
Snapshot1:http://blogs.sun.com/divyen/resource/snap_1_ec2_opensolaris_2009_06_vnc.jpg
Use public DNS address associated with EC2 instance as the host name.

VNC client connected to OpenSolaris 2009.06 EC2 Instance.
Snapshot2:http://blogs.sun.com/divyen/resource/snap_2_ec2_opensolaris_2009_06_vnc.jpg

For more details on OpenSolaris AMIs visit http://blogs.sun.com/ec2/

Wednesday May 06, 2009

Importing OpenSolaris EC2 Image on Local Xen Environment


In this blog entry, I am going to walk you through the steps for importing OpenSolaris Amazon EC2 AMI on local Xen environment running on OpenSolaris 2008.11.

I assume
- you are running OpenSolaris 2008.11 build rc2 dom0.
- ec2 ami/api tools installed at /opt/ec2
- your ec2 certificate and private key files available at /opt/ec2/keys
- your ec2 keypair file located at /opt/ec2



[ Step-1 ]
Launch fresh OpenSolaris 2008.11 AMI Instance
ec2-run-instances ami-7db75014 -k your-keypair

Login in with your keypair file
ssh -i /opt/ec2/your-keypair root@ec2-xxx-xxx-xxx-xxx.compute-1.amazonaws.com

[ Step-2 ]
Remove EC2 specific stuff from the instance.

Open “/etc/ssh/sshd_config” and replace "PermitRootLogin without-password" with "PermitRootLogin yes" and save the file.

Set the root password
passwd
passwd: Changing password for root
New Password:
Re-enter new Password:
passwd: password successfully changed for root

Disable and remove ec2 specific services

svcadm disable svc:/ec2/sshkey:default
svcadm disable svc:/ec2/fixes:default
svcadm disable svc:/ec2/mount:default

svccfg delete svc:/ec2/sshkey:default
svccfg delete svc:/ec2/fixes:default
svccfg delete svc:/ec2/mount:default

[ Step-3 ]
Log out of the ec2 instance and transfer your keys at /mnt/keys to begin re-bundling image.
scp -i /opt/ec2/id-your-keypair -r /opt/ec2/keys/ root@ec2-xxx-xxx-xxx-xxx.compute-1.amazonaws.com:/mnt

[ Step-4 ]
Login back to ec2 instance.
ssh -i /opt/ec2/your-keypair root@ec2-xxx-xxx-xxx-xxx.compute-1.amazonaws.com

[ Step-5 ]
Start bundling the image.

# cd /mnt
# /opt/ec2/sbin/rebundle.sh -v opensolaris_2008_11_ami.img
Creating image file /mnt/opensolaris_2008_11_ami.img
Preparing clone pool on /dev/lofi/1
Cloning
#

rebundle.sh will take about 10-15 minutes to create raw opensolaris image.

[ Step-6 ]
Bundle image and create parts.

export BUCKET=my-bucket
export JAVA_HOME=/usr/jdk/latest
export EC2_HOME=/opt/ec2
export PATH=$PATH:$EC2_HOME/bin
export RUBYLIB=$EC2_HOME/lib
export EC2_URL=https://ec2.amazonaws.com

export EC2_PRIVATE_KEY=/mnt/keys/pk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.pem
export EC2_CERT=/mnt/keys/cert-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.pem

export EC2_KEYID=xxxxxxxxxxxxxxxxxxxxxxx
export EC2_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

export DIRECTORY=/mnt
export IMAGE=opensolaris_2008_11_ami.img

# ec2-bundle-image -c $EC2_CERT -k $EC2_PRIVATE_KEY \\
--kernel aki-6552b60c --ramdisk ari-6452b60d \\
--block-device-mapping "root=rpool/52@0,ami=0,ephemeral0=1" \\
--user <user-id> --arch i386 \\
-i $DIRECTORY/$IMAGE -d $DIRECTORY/parts

[ Step-7 ]
Upload image parts on s3

# cd $DIRECTORY/parts

# ec2-upload-bundle -b $BUCKET -m opensolaris_2008_11_ami.img.manifest.xml \\
--url http://s3.amazonaws.com \\
--retry -a $EC2_KEYID -s $EC2_KEY

[ Step-8 ]
Log out of the instance.
Download image parts and unbundle it to re-create the raw image locally.

# mkdir /osol-ec2-image
# mkdir /osol-ec2-image/parts
# cd /osol-ec2-image/parts

# ec2-download-bundle -b my-bucket -m opensolaris_2008_11_ami.img.manifest.xml \\
-a <your-access-key-id> -s <your-secret-key-id> \\
--privatekey /opt/ec2/keys/pk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx .pem

# ec2-unbundle -m opensolaris_2008_11_ami.img.manifest.xml \\
-k /opt/ec2/keys/pk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx .pem

# mv opensolaris_2008_11_ami.img
# cd /osol-ec2-image/
[ Step-9 ]
Create “domu.py” at /osol-ec2-image with following lines

name = "opensolaris-ec2-image"
vcpus = 1
memory = "1024"

disk = ['file://osol-ec2-image/opensolaris_2008_11_ami.img,0,w']

vif = ['']

on_shutdown = "destroy"
on_reboot = "restart"
on_crash = "destroy"


[ Step-10 ]
Launch domu image and login with root user and the password you set during step-2

xm create domu.py

Using config file "./domu.py".
Started domain opensolaris-ec2-image

xm console opensolaris-ec2-image
v3.1.4-xvm chgset 'Mon Oct 13 22:14:51 2008 -0700 15904:94bd0a643efe'

SunOS Release 5.11 Version snv_101b 32-bit

Copyright 1983-2008 Sun Microsystems, Inc. All rights reserved.

Use is subject to license terms.
Hostname: dhcp-umpk16-85-23
Reading ZFS config: done.
Mounting ZFS filesystems: (5/5)

dhcp-umpk16-85-23 console login:

Tuesday Apr 28, 2009

Create a fully virtualized ubuntu-9.04 DomU on Sun xVM Hypervisor

Share/Save/Bookmark<script type="text/javascript">a2a_linkname="Create a fully virtualized ubuntu-9.04 DomU on Sun xVM Hypervisor";a2a_linkurl="http://blogs.sun.com/divyen/entry/create_a_fully_virtualized_ubuntu";</script><script type="text/javascript" src="http://static.addtoany.com/menu/page.js"></script>

Lets begin with the installation of xVM Hypervisor on OpenSolaris 2008.11.

You can follow exact steps mentioned on Dileep Kumar's blog - "How to create domU in OpenSolaris 2008.05". These steps are also valid for OpenSolaris 2008.11.

Once dom0 is up and running, walk through the below given steps to create a fully virtualized ubuntu 9.04 DomU. Fully virtualized DomU is also known as HVM Domain (Hardware-assisted Virtual Machine Domain), with that you can run unmodified guest operating system without the knowledge of underlying hypervisor.

Step-1: Download and save ubuntu 9.04 ISO file at /ubuntu-hvm

mkdir /ubuntu-hvm
cd /ubuntu-hvm
wget http://ftp.ucsb.edu/pub/mirrors/linux/ubuntu/jaunty/ubuntu-9.04-desktop-i386.iso


Step-2: Create a virtual Disk for the guest domain.

dd if=/dev/zero of=/ubuntu-hvm/ubuntu-9.04-desktop-i386.img bs=1k seek=10000k count=1


Step-3: Create guest configuration file install.py with following script at /ubuntu-hvm

Detailed explanation on each lines used in the script is given here.


disk = ['file:/ubuntu-hvm/ubuntu-9.04-desktop-i386.img,hda,w','file:/ubuntu-hvm/ubuntu-9.04-desktop-i386.iso,hdc:cdrom,r']

memory = 1024
vcpus=1
name = "ubuntu-904-hvm-install"
kernel = "/usr/lib/xen/boot/hvmloader"
builder='hvm'
vif = [ '' ]

on_poweroff = 'destroy'
on_reboot   = 'destroy'
on_crash    = 'destroy'

boot='dc'
vnc=1
sdl=0

vncdisplay=5

import os, re
arch = os.uname()[4]
if re.search('64', arch):
     arch_libdir = 'lib64'
else:
     arch_libdir = 'lib'
device_model = '/usr/' + arch_libdir + '/xen/bin/qemu-dm'





Launch the guest domain to begin the installation.

cd /ubuntu-hvm/
xm create install.py


Bring up VNC Session to proceed with the installation. In the install.py script we specified to bind VNC on port 127.0.0.1:5

vncviewer 127.0.0.1:5


If HVM guest is unsupported on your system, you may see following error message.
Error: HVM guest support is unavailable: is VT/AMD-V supported by your CPU and enabled in your BIOS?

Step-4: Install guest domain.

Snap-01
ubuntu_hvm_snap_01.gif

Snap-02
ubuntu_hvm_snap_02.gif

Snap-03
ubuntu_hvm_snap_03.gif

Snap-04
ubuntu_hvm_snap_04.gif

Snap-05
ubuntu_hvm_snap_05.gif
Do not click on the restart. Follow step-5 instead.

Step-5: Destroy the guest domain and create new configuration file to boot the domU from the disk image.

xm destroy ubuntu-904-hvm-install
cd /ubuntu-hvm/


Create new configuration file "domu.py" with following script at /ubuntu-hvm


disk = ['file:/ubuntu-hvm/ubuntu-9.04-desktop-i386.img,hda,w']

memory = 1024
vcpus=1
name = "ubuntu-904-hvm-guest"
kernel = "/usr/lib/xen/boot/hvmloader"
builder='hvm'
vif = [ '' ]

on_poweroff = 'destroy'
on_reboot   = 'destroy'
on_crash    = 'destroy'

boot='c'
vnc=1
sdl=0

vncdisplay=5

import os, re
arch = os.uname()[4]
if re.search('64', arch):
     arch_libdir = 'lib64'
else:
     arch_libdir = 'lib'
device_model = '/usr/' + arch_libdir + '/xen/bin/qemu-dm'



Step-6: Finally launch the HVM guest domain

cd /ubuntu-hvm/
xm create domu.py


Bring up VNC Session

vncviewer 127.0.0.1:5


Snap-05
ubuntu_hvm_snap_06.gif

Snap-06
ubuntu_hvm_snap_07.gif

Saturday Jan 17, 2009

Get GUI luxury on OpenSolaris 2008.11 EC2 Instance

The following instructions describes steps to access GUI on OpenSolaris EC2 Instance using VNC Viewer.

[ Step - 1]
First steps is to set xvm_vnc property to true for x11-server SMF service. For security reasons it is set to false.

On the terminal type in "svccfg" to modify the service configurations. More details on svccfg is available here.
To come out of svc prompt type in "quit" and hit enter.

root@domU-12-31-39-03-CC-A5:~# svccfg
svc:> select x11-server
svc:/application/x11/x11-server>
svc:/application/x11/x11-server> setprop options/xvm_vnc = true
svc:/application/x11/x11-server> quit

[ Step - 2]
Create .vnc directory under /root if it does not exist
root@domU-12-31-39-03-CC-A5:~# mkdir /root/.vnc/

Create /root/.vnc/xstartup file with following lines.

#!/bin/sh
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
gnome-terminal -geometry 100x60 -title "$VNCDESKTOP Desktop" &
/usr/bin/gnome-session


Note: if xstartup file is already exist, replace it with above lines to start gnome terminal session for VNC.

Provide execute permission on xtartup file.
root@domU-12-31-39-03-CC-A5:~#chmod +x /root/.vnc/xstartup

[ Step - 3]
Start the vncserver and set the password.

root@domU-12-31-39-03-CC-A5:~# vncserver

You will require a password to access your desktops.

Password:
Verify:
xauth: creating new authority file /root/.Xauthority

New 'domU-12-31-39-03-CC-A5:1 (root)' desktop is domU-12-31-39-03-CC-A5:1

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/domU-12-31-39-03-CC-A5:1.log

root@domU-12-31-39-03-CC-A5:~#


[ Step - 4 ]
Here we are done with configuring EC2 instance for GUI Remote Access.
Finally we need to authorize and open the listening VNC port on the server with the ec2 group you are using with your instance.

divyen-patels-macbook:~ divyen$ ec2-authorize default -p 5901
GROUP default
PERMISSION default ALLOWS tcp 5901 5901 FROM CIDR 0.0.0.0/0
divyen-patels-macbook:~ divyen$


Screen Shots
VNC client connection configuration
Snapshot1:http://blogs.sun.com/divyen/resource/opensolaris_ec2_vnc_client_img_1.gif
Use public DNS address associated with EC2 instance as the host name.

VNC client connected to OpenSolaris 2008.11 EC2 Instance.
Snapshot2:http://blogs.sun.com/divyen/resource/opensolaris_ec2_vnc_client_img_2.gif

For more details on OpenSolaris AMIs visit http://blogs.sun.com/ec2/

Sunday Oct 26, 2008

Install and configure libssh2 and ssh2 PECL module with AMP on OpenSolaris

Detailed information on libssh2 and SSH2 PECL module is available on

libssh2 - http://www.libssh2.org/wiki/index.php/Main_Page
SSH2 PECL Module - http://pecl.php.net/package/ssh2
Installing AMP on OpenSolaris is quite easy. below are the steps [1-4] for AMP stack installation.

[ Step:1 ]

-bash-3.2# pkg refresh
-bash-3.2#

[ Step:2 ]        
                   
-bash-3.2# pkg install amp
DOWNLOAD                                    PKGS       FILES     XFER (MB)
Completed                                  13/13   1633/1633 331.59/331.59

PHASE                                        ACTIONS
Update Phase                                     2/2
Install Phase                              2111/2111
-bash-3.2#

[ Step:3 ]

-bash-3.2# /usr/sbin/svccfg import /var/svc/manifest/network/http-apache22.xml
-bash-3.2# /usr/sbin/svcadm enable http:apache22
-bash-3.2#

[ Step:4 ]

-bash-3.2# /usr/sbin/svccfg import /var/svc/manifest/application/database/mysql.xml
-bash-3.2# /usr/sbin/svcadm enable mysql:version_50
-bash-3.2#


before we begin downloading libssh2 from sourceforge. We need to have gcc compiler installed to compile and build libssh2 library.

[ Step:5 ]

-bash-3.2# pkg install gcc-dev
DOWNLOAD                                    PKGS       FILES     XFER (MB)
Completed                                  18/18   2797/2797 105.65/105.65

PHASE                                        ACTIONS
Install Phase                              3545/3545


[ Step:6 ]

Download and extract libssh2 distribution.

-bash-3.2# cd /usr/src
-bash-3.2# wget http://voxel.dl.sourceforge.net/sourceforge/libssh2/libssh2-0.18.tar.gz
-bash-3.2# gunzip libssh2-0.18.tar.gz
-bash-3.2# tar xvf libssh2-0.18.tar

[ Step:7 ]

build and install libssh2

-bash-3.2# cd libssh2-0.18
-bash-3.2# ./configure
-bash-3.2# make all install

Next we need to link libssh2 and PHP with the SSH2 PECL module.

[ Step:8 ]

-bash-3.2# cd /usr/src
-bash-3.2# wget http://pecl.php.net/get/ssh2-0.10.tgz
-bash-3.2# gunzip ssh2-0.10.tgz
-bash-3.2# tar xvf ssh2-0.10.tar

-bash-3.2# cd ssh2-0.10

[ Step:9 ]

edit ssh2.c and change following if condition

#if LIBSSH2_APINO < 200412301450

to

#if LIBSSH2_VERSION_NUM < 0x001000

Save the file and execute phpize to prepare the build environment for the ssh2 PHP extension.

[ Step:10 ]

-bash-3.2# pwd
/usr/src/ssh2-0.10
-bash-3.2# /usr/php5/bin/phpize
Configuring for:
PHP Api Version:         20041225
Zend Module Api No:      20060613
Zend Extension Api No:   220060519


[ Step:11 ]

-bash-3.2# pwd
/usr/src/ssh2-0.10

-bash-3.2# ./configure --with-ssh2 --with-php-config=/usr/php5/bin/php-config
-bash-3.2# make
-bash-3.2# make install
Installing shared extensions:     /usr/php5/5.2.4/modules/

[ Step:12 ]

ssh2.so module is now installed. We can modify the php.ini file and make sure the module gets loaded by php.

-bash-3.2# vi /etc/php5/5.2.4/php.ini
add
extension=ssh2.so
under Dynamic Extensions section

restart the apache to and load the SSH2 php extension.

-bash-3.2# svcadm restart svc:/network/http:apache22
About

Divyen Patel

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today