Showing posts with label Debian. Show all posts
Showing posts with label Debian. Show all posts

Wednesday, December 27, 2017

LVM Resize - Debian Virtual Machine

I recently setup an installation of Owncloud on a Debian virtual machine so that my family members could more easily share some holiday pictures.  Within a few weeks the usage increased substantially and I soon found that the VM was nearing capacity.  I had purposely utilized LVM just in case resizing became necessary.
There are multiple ways to accomplish this task and this is but one way that works for me and the Debian OS.  I opted to add a new (second) virtual disk and then expand the LVM, but it is possible to increase the original disk size and then follow similar steps.  While the utilities are the same, the process is different.  Please take note.
Critical Note: A mistake with the following commands could render your Virtual Machine unusable.  I take careful precautions when doing maintenance of this nature.  Due to this system being a VM, I was able to make a clone prior to making any changes.  A snap shot or copying the VM would also provide some protection.
My Victual Machine is running on OSX and VMware Fusion.  The Fusion software varies slightly from other VMware products.  I had to shutdown my VM to add the hard drive but I know in other VMware variants, that I've been able to add the disk on the fly.

Identifying the partition type

Confirm that the partition type is actually Linux LVM.
fdisk -l
fdisk of newly added disk
 /dev/sda5 is listed as Linux LVM and it has the ID of 8e. The 8e hex code shows that it is a Linux LVM, while 83 shows a Linux native partition. 
Below is the disk information showing that our initial setup only has the one 20gb disk currently, which is under the logical volume named /dev/mapper/Mega-root – this is what we will be expanding with the new disk.
Disk free newly added disk
Note that /dev/mapper/Mega-root is the volume made up from /dev/sda5 currently – this is what we will be expanding.

Adding a new virtual hard disk

First add a new disk to the virtual machine. Be sure to match the drive type.  Create the size disk that is needed for the increased capacity.  
Detect the new disk space
In my test for this example, as soon as I added the additional disk in through VMware it displayed through “fdisk -l” for me, you can see the second disk labelled /dev/sdb 
fdisk of newly added disk
If your system doesn't read the disk, you can run the following command to rescan.  Change host0 depending on your setup.
echo "- - -" > /sys/class/scsi_host/host0/scan
Reboot if needed...Ultimately a reboot will make the partition visible.

Partition the new disk

We now need to partition the new /dev/sdb disk so that it can be used, this is done by using fdisk.
fdisk /dev/sdb
This should provide us with the below prompt, the inputs I have entered in are shown in bold.
‘n’ was selected for adding a new partition.
root@Mega:~# fdisk /dev/sdb
Command (m for help): n
‘p’ is then selected as we are making a primary partition.
Command action
   e   extended
   p   primary partition (1-4)
p
As this is a new disk, we do not yet have any partitions on it so we will use partition 1 here.
Partition number (1-4): 1
Next we press the enter key twice, as by default the first and last cylinders of the unallocated space should be correct.
First cylinder (1-2610, default 1): "enter"
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610): "enter"
Using default value 2610
‘t’ is selected to change to a partitions system ID, in this case we change to ’1′ automatically as this is currently our only partition.
Command (m for help): t
Selected partition 1
The hex code ’8e’ was entered as this is the code for a Linux LVM which is what we want this partition to be, as we will be joining it with the original Linux LVM which is currently using /dev/sda5.
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)
‘w’ is used to write the table to disk and exit, all changes that have been done will be saved and then you will be exited from fdisk.
Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
By using “fdisk -l” now you will be able to see that /dev/sdb1 is listed, this is the new partition created on our newly added /dev/sdb disk and it is currently using all 20gb of space.
fdisk after partition created

Increasing the logical volume

Next we will use the pvcreate command to create a physical volume for later use by the LVM. In this case the physical volume will be our new /dev/sdb1 partition.
root@Mega:~# pvcreate /dev/sdb1
  Physical volume "/dev/sdb1" successfully created
Now we need to confirm the name of the current volume group using the vgdisplay command. The name will vary depending on your setup, for me it is the name of my test server. vgdisplay provides plenty of information on the volume group, I have only shown the name and the current size of it for this example.
root@Mega:~# vgdisplay
  --- Volume group ---
  VG Name               Mega
  VG Size               19.76 GiB
Now using the vgextend command, we extend the ‘Mega’ volume group by adding in the physical volume of /dev/sdb1 which we created using the pvcreate command just before.
root@Mega:~# vgextend Mega /dev/sdb1
  Volume group "Mega" successfully extended
Using the pvscan command we scan all disks for physical volumes, this should confirm the original /dev/sda5 partition and the newly created physical volume /dev/sdb1
root@Mega:~# pvscan
  PV /dev/sda5   VG Mega   lvm2 [19.76 GiB / 0    free]
  PV /dev/sdb1   VG Mega   lvm2 [19.99 GiB / 19.99 GiB free]
  Total: 2 [39.75 GiB] / in use: 2 [39.75 GiB] / in no VG: 0 [0   ]
Next we need to increase the logical volume with the lvextend command (rather than the physical volume which we have already done). This means we will be taking our original logical volume and extending it over our new disk/partition/physical volume of /dev/sdb1.
Firstly confirm the name of the logical volume using lvdisplay. The name will vary depending on your setup.
root@Mega:~# lvdisplay
  --- Logical volume ---
  LV Path                /dev/Mega/root
  LV Size                18.91 GiB
The logical volume is then extended using the lvextend command. We are extending the original logical volume of /dev/Mega/root over the newer /dev/sdb1
root@Mega:~# lvextend /dev/Mega/root /dev/sdb1
  Extending logical volume root to 38.90 GiB
  Logical volume root successfully resized
If you like you can then run vgdisplay and lvdisplay again to confirm the size of the volume group and logical volume respectively, I have done this and I now have the following.
  LV Size                38.90 GiB
  VG Size                39.75 GiB
However if you run a “df” command to see available disk space it will not have changed yet as there is one final step, we need to resize the file system using the resize2fs command in order to make use of this space.
root@Mega:~# resize2fs /dev/Mega/root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/Mega/root is mounted on /; on-line resizing required
old desc_blocks = 2, new_desc_blocks = 3
Performing an on-line resize of /dev/Mega/root to 10196992 (4k) blocks.
The filesystem on /dev/Mega/root is now 10196992 blocks long.
Alternatively if you’re running the XFS file system (default as of RedHat/CentOS 7) you can grow the file system with “xfs_growfs /dev/Mega/root”.
Rather than resizing the file system manually, you could instead use the -r option of the lvextend command which will automatically resize the file system to make use of the additional disk space.
The resize took a minute or so to complete (it will depend on the disk speed and size), running the “df” command now shows the correct disk space for /dev/mapper/Mega-root
Disk free on expanded LVM

Tuesday, August 18, 2015

Hobbit System Montoring | Debian

Hobbit monitors your hosts, your network services, and anything else you configure it to do via extensions. Hobbit can periodically generate requests to network services - http, ftp, smtp and so on - and record if the service is responding as expected. You can also monitor local disk utilisation, logfiles and processes through the use of agents installed on the servers.
Before you install, make sure you have Apache web server installed.


apt-get install apache2

Configure /etc/apach2/sites-enabled/000-default

Example: Apache conf here.


Install hobbit packages

apt-get install hobbit hobbit-client hobbit-plugins


By default hobbit only allows connections from local host. Append the IP addresses you want to allow here in all three of the Allow from[...] lines like shown here

vi /etc/apache2/conf.d/hobbit

Allow from localhost ::1/128 192.168.0.5


In this case I have added the 192.168.0.5 but you should replace it to the one on your computer

Restart apache

/etc/init.d/apache2 restart


Now you can access the hobbit monitoring console on this location http://youservername/hobbit/ (Make sure you include the trailing slash)

Client Install

apt-get install hobbit-client hobbit-plugins

Server Configuration for Client Data

vi /etc/hobbit/bb-hosts

Example bb-hosts:


Note:  Be sure to use the fully qualified name of the server along with the IP Address.  If you do not, you will not get all or any of the information desired.

If desired, you may use the local configuration file to monitor more finitely.   This also requires adding "--local" setting to FILENAMEHERE.  I found that in Ver. 4.2.0 if you must copy the hobbitd_client file from the "hobbit-server".

Sunday, January 25, 2015

SoftEther VPN

OpenVPN has provided a great solid solution over the years and I've installed many point to point solutions as well as VPNs for commercial and private use.  While I'm certainly a fan, circumstances have warranted investigating a new solution, specifically one that provides L2TP/IPsec server functionality and additional throughput.  Enter SoftEther.

SoftEther is a multi-protocol VPN software that runs on Mac, Linux, FreeBSD and Windows.  Due to the clone function, it even allows for easy integration from OpenVPN, meaning you can connect using the client you previously used to connect to an OpenVPN server.  Furthermore the L2TP capability aids in connectivity with iOS and Android devices.  A full review of the specifications and capability can be found at softether.org.

For my purposes, I needed the ability to provide VPN access from an iPhone, and a LAN to LAN bridge to connect several commercial offices. 

My specifications as you can see were initially very conservative.  I found that even a system with as little as 512MB and 5G of storage was capable of providing a reasonable VPN for a small office or home use.  While not necessary, I choose to run a separate server or virtual machine for VPN access.

  • Virtual Machine
    • Debian 7
    • 1G (Virtual allows for easy modification based on usage)
    • 10G Storage

1. Install Debian 

I used the mini.iso, no options other than system tools.  I like to run lean and don't use a gui for any production system.

Acquire the necessary tools for compiling SoftEther.

apt-get install build-essential

2. Download & Install SoftEther

Wget or Lynx are your best options.

apt-get install lynx
lynx http://www.softether-download.com/files/softether/
You have multiple different versions to choose from.  I've typically utilized the 'rtm' versions instead of 'beta' but the choice is yours. 

Once you locate your version of choice and architecture, highlight it and press "d" to download.  When prompted, choose "save to disk".

I keep my downloads in /usr/local/src.

cd /usr/local/src
tar xvfz softether-vpnserver-version-number-you-downloaded.tar.gz
The archive will extract and create a vpnserver directory.

cd /usr/local/src/vpnserver
make
You'll be prompted to read the License Agreement, confirm you read it and agree to the License Agreement.

Any issues with 'make' are likely due to unmet dependancies.  Verify you completed the step of installing the 'build-essential' components.

My habit is to move services to the /etc folder.

mv /usr/local/src/vpnserver /etc
cd /etc/vpnserver
chmod 600 *
chmod 700 vpnserver
chmod 700 vpncmd
Create startup script

vi /etc/init.d/vpnserver
Example:

#!/bin/sh
# SoftEther
DAEMON=/etc/vpnserver/vpnserver
LOCK=/var/lock/subsys/vpnserver
test -x $DAEMON || exit 0
case "$1" in
start)
$DAEMON start
touch $LOCK
;;
stop)
$DAEMON stop
rm $LOCK
;;
restart)
$DAEMON stop
sleep 3
$DAEMON start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit 0
chmod 755 /etc/init.d/vpnserver
Debian makes it easy to update the run levels and have SoftEther start on boot up.

update-rc.d vpnserver defaults
Note the use of /var/lock/subsys, you'll need to create the directory.

Start SoftEther

/etc/init.d/vpnserver start

3. Check Installation and configure.

cd /etc/vpnserver
./vpncmd

Check installation by choosing option 3.

check
exit

Virtual Hub

./vpncmd
Choose option 1 this time

HubCreate SoftVPN
You now need to choose the Hub you just created (like a database).

Hub SoftVPN
SecureNatEnable
UserCreate NewUserName
There are different ways for authentication (please read and determine how best to proceed for your circumstances).

UserPasswordSet NewUserName
Enable L2TP

IPsecEnable

This is a very basic configuration.  There are a multitude of other options available, far beyond what I've described here.  I'd also suggest changing/setting an administrative password which wasn't covered, but is a simple command.

A few items that I intend to write a follow up on are:
  • Certificate Setup & Generation
  • OpenVPN Compatibility Configuration
  • SSTP Config
  • Client Configuration
  • LAN to LAN Bridge




Saturday, January 28, 2012

mount error(12): Cannot allocate memory

Do you have the following situation:
  • You’ve got a share on Windows (XP, Vista, 7) that you’re trying to access from a Linux system, in this case Ubuntu.
  • Mounted through /etc/fstab or directly through the command line.
  • Initially, it works great, but then loses the mountpoint – you’ll go to, say, /mnt/server/mountpoint but there are no directory contents. “mount” shows the path as still mounted.
  • umount’ing the directory and then trying to remount it provides this gem of a message:
    mount error(12): Cannot allocate memory
    Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
Of course, since you’re probably a reasonable system administrator, you go and check the memory allotment. top looks fine and nothing else on the system is complaining.
The solution, kindly provided by Alan LaMielle’s blog, gives a registry fix on the Windows side of things. In case that link ever breaks, here is the summary of what needs to happen on the Windows system:
  • In HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management, set the LargeSystemCache key to 1 (hex).
  • In HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters, set the Size key to 3 (hex).’
  • Restart the “Server” service and its dependencies (on my Windows 7 box, these were “Computer Browser” and “Homegroup Listener”, and I had to restart the service twice for the dependencies to also come back up.) Alternatively you can just restart the Windows system as you’re probably due for a large set of updates anyway.
Then re-run the mount command (for entries defined in /etc/fstab, use sudo mount -a) and your shares should be restored to their former glory.

Wednesday, November 17, 2010

VMWare 2.0.2 Install on Debian Squeeze

These instructions are vital in order to get a working copy of VMWare on Debian Squeeze.  This information was originally available at http//:wiki.debian.org/VMware.  Please check there first for any further updates or information.  The document listed below is for my reference and in the event the wiki is unavailable. 

Installing VMware Server 2 on Squeeze


In general the installation is similiar to that in Lenny, with the following differences:
  • There are different versions of the linux kernel and gcc.
  • Different patches are required for the installer and the modules.
Instructions:
  1. Get the VMWare Server archive (at least version 2.0.2) and your license. Hopefully the issues will be fixed in later versions.
  2. Install the prerequisites (including kernel-headers for your version, and gcc version 4.3).
  3. Unzip the VMWare archive, install VMWare, but do not configure it yet, i. e. answer the question to run "vmware-config.pl" with "no".
  4. Patch vmware-config.pl using a file from the patch archive (choose the directory where you installed the binaries, if not "/usr/bin").
cd /usr/bin
patch -p3 < vmware-config.patch

  1. Patch the module sources using another file from the patch archive (choose the directory where you installed the libraries, if not "/usr/lib").
cd /usr/lib/vmware/modules/source
for i in *.tar ; do tar xpf $i ; done
patch -p4 < vmware-server-2.0.2-203138-update.patch
for i in vmci vmmon vmnet vsock ; do tar cpf $i.tar $i-only ; done

  1. Now run vmware-config.pl.
After that the installation is complete, but a bug related to Tomcat/Java may prevent the web admin interface at http://localhost:8222 from being operational. If you get the message "Error 503: Service unavailable", then continue patching.
[Note: If you want to learn more about this issue, see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=572048. As Java is embedded in VMWare, switching to a current version is no option, neither should be disabling IPv6.]
  1. IPv6 must be disabled for the "WebAccess" service only. Create a patch file named "vmware.patch" (see the "Lenny" section for how to do this using an editor):
--- vmware.orig 2010-05-24 17:05:09.251864323 +0200
+++ vmware      2010-05-24 21:40:37.563871986 +0200
@@ -675,7 +675,7 @@
 watchdog="${vmdb_answer_BINDIR}/vmware-watchdog"
 webAccessServiceName="VMware Virtual Infrastructure Web Access"
 CATALINA_HOME="${vmdb_answer_LIBDIR}/webAccess/tomcat/apache-tomcat-6.0.16"
-webAccessOpts="-client -Xmx64m -XX:MinHeapFreeRatio=30 -XX:MaxHeapFreeRatio=30 -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=$CATALINA_HOME/common/endorsed -classpath $CATALINA_HOME/bin/bootstrap.jar:$CATALINA_HOME/bin/commons-logging-api.jar -Dcatalina.base=$CATALINA_HOME -Dcatalina.home=$CATALINA_HOME -Djava.io.tmpdir=$CATALINA_HOME/temp org.apache.catalina.startup.Bootstrap"
+webAccessOpts="-Djava.net.preferIPv4Stack=true -client -Xmx64m -XX:MinHeapFreeRatio=30 -XX:MaxHeapFreeRatio=30 -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=$CATALINA_HOME/common/endorsed -classpath $CATALINA_HOME/bin/bootstrap.jar:$CATALINA_HOME/bin/commons-logging-api.jar -Dcatalina.base=$CATALINA_HOME -Dcatalina.home=$CATALINA_HOME -Djava.io.tmpdir=$CATALINA_HOME/temp org.apache.catalina.startup.Bootstrap"
 
 #
 # Utilities

  1. Patch /etc/init.d/vmware, and restart the daemon.
cd /etc/init.d
patch < vmware.patch
./vmware-mgmt restart 
Done.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2013 - Squeeze Update
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

After running VMware install but BEFORE the configuration....


3. Patching vmware-server-2.0.2

At this point we need to patch vmware-config.pl file as well as vmware modules. First download and decompress patch provided by: Radu Cotescu:
# cd
# wget http://linuxconfig.org/images/files/2.6.3x-vmware-patch.tar.bz2
# tar xjf 2.6.3x-vmware-patch.tar.bz2
Apply patch:
First apply patch to vmware-config:
# cd /usr/bin/
# patch -p3 < ~/2.6.3x-vmware-patch/config.patch
203138-update.patch
config.patch
LICENSE
README
start-VMware-console.sh
vmware-server-2.0.x-kernel-2.6.3x-install.sh
Apply patch to all modules:
# cd /usr/lib/vmware/modules/source
# for f in *.tar ; do tar pxf $f ; done
# patch -p4 < ~/2.6.3x-vmware-patch/203138-update.patch
patching file vmci-only/include/pgtbl.h
patching file vmnet-only/vnetUserListener.c
patching file vmci-only/Makefile
patching file vmmon-only/common/vmx86.c
patching file vmmon-only/include/compat_cred.h
patching file vmmon-only/include/x86svm.h
patching file vmmon-only/linux/driver.c
patching file vmmon-only/linux/hostif.c
patching file vmmon-only/Makefile
patching file vmnet-only/Makefile
patching file vmnet-only/netif.c
patching file vsock-only/Makefile
# for f in vmci vmmon vmnet vsock ; do tar pcf $f.tar $f-only ; done
# rm -fr *-only

4. Set correct gcc version

The kernel on Debian squeeze was compiled with gcc 4.3 and this is the version of gcc we want to use. By default gcc is set to gcc version 4.4:
# ls -l `which gcc`
lrwxrwxrwx 1 root root 7 Mar 20 11:15 /usr/bin/gcc -> gcc-4.4 
Therefore, we need to change gcc compiler to match our kernel compiler version. The easiest way is to set CC environmental variable to point to gcc v4.3.
The second option is to create a new symlink ( when you finish do not forget to put everything where it belongs ) :
# ln -fs /usr/bin/gcc-4.3 /usr/bin/gcc
# ls -l `which gcc`
lrwxrwxrwx 1 root root 16 Mar 20 12:09 /usr/bin/gcc -> /usr/bin/gcc-4.3

5. Configure vmware-server-2.0.2

We are almost done. At this stage we need to configure vmware-server. Follow vmware-config.pl and change default values where appropriate. Start configuration with:
# vmware-config.pl
After successful build you should see:
Enjoy,

--the VMware team

Starting VMware services:
   Virtual machine monitor                                             done
   Virtual machine communication interface                             done
   VM communication interface socket family:                           done
   Virtual ethernet                                                    done
   Bridged networking on /dev/vmnet0                                   done
   Host-only networking on /dev/vmnet1 (background)                    done
   DHCP server on /dev/vmnet1                                          done
   Host-only networking on /dev/vmnet8 (background)                    done
   DHCP server on /dev/vmnet8                                          done
   NAT service on /dev/vmnet8                                          done
   VMware Server Authentication Daemon (background)                    done
   Shared Memory Available                                             done
Starting VMware management services:
   VMware Server Host Agent (background)                               done
   VMware Virtual Infrastructure Web Access
Starting VMware autostart virtual machines:
   Virtual machines                                                    done

The configuration of VMware Server 2.0.2 build-203138 for Linux for this 
running kernel completed successfully.



Sunday, October 24, 2010

LifeRay - Init.d Script

Example of my init.d LifeRay startup script (Debian).

#!/bin/bash
# description: LifeRay Start|Stop|Restart
export PATH
export JAVA_HOME=/usr/lib/jvm/java-6-sun-1.6.0.20/
export CLASSPATH=//usr/lib/jvm/java-6-sun-1.6.0.20/lib/tools.jar:/usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/rt.jar:./
export CATALINA_HOME=/usr/local/liferay/tomcat

start()
        {
        cd $CATALINA_HOME/bin
        sh startup.sh
        }

stop()
        {
        cd $CATALINA_HOME/bin
        sh shutdown.sh
        }

case "$1" in
start) 
        start
        ;;
stop)
        stop
        ;;
restart)
        stop
        start
        ;;
*)
echo "start|stop|restart"
esac

I saved this into /etc/init.d/ as the name liferay, then updated the run levels.

update-rc.d liferay defaults

Thursday, July 22, 2010

VMware Server 2.0 - Tuning

I made the following enhancements in an attempt to improve my VMware performance on a Debian 2.6.26-1-686-bigmem. 

Edit VMware configuration file and add the following:

vi /etc/vmware/config

mainMem.useNamedFile tells VMWare where to put it's temporary workspace file. This file contains the content of the Virtual Machine memory which is not used. By default it is placed in the directory with the virtual machine, however that can seriously impact performance so we'll turn it off.
mainMem.useNamedFile = FALSE

tmpDirectory is the default path for any temp files. We need to change that to be a shared memory filesystem (in RAM).
tmpDirectory="/dev/shm"

prefvmx.useRecommendedLockedMemSize and prefvmx.minVmMemPct tell VMWare to either use a fixed sized memory chunk or balloon and shrink memory as needed. With 4GB of memory we'll use a fixed size of memory to reduce disk IO.

prefvmx.useRecommendedLockedMemSize="TRUE"
prefvmx.minVmMemPct="100"


Be sure to install VMware tools followed by:

Set the time in the Virtual Machine to the hosts time.

tools.syncTime = "TRUE"

Force gracefully stop on each VM.

autostop = "softpoweroff"

I don't care about collapsing memory into a shared pool, this tells the VM to not share which saves CPU cycles:

mem.ShareScanTotal=0
mem.ShareScanVM=0
mem.ShareScanThreshold=4096
sched.mem.maxmemctl=0
sched.mem.pshare.enable = "FALSE"


This basically performs the same action as the configuration I put in /etc/vmware/config by telling the VM to eliminate the temp files and not to balooning and shrink memory, however it doesn't hurt anything to have it in both locations:

mainMem.useNamedFile = "FALSE"
MemTrimRate = "0"
MemAllowAutoScaleDown = "FALSE"


In order for the VMWare configuration to work properly with shared memory, you'll need to increase the default shared memory size for tmpfs to match the amount of memory in your system. This can be done by editing /etc/default/tmpfs:

SHM_SIZE=4096

Wednesday, July 21, 2010

OpenVPN - Linux Client

How-to connect a Linux server to another Linux server via OpenVPN, command line style.

apt-get install openvpn

Copy the example client.conf file

cp /usr/share/doc/openvpn/examples/sample-config-files/client.conf /etc/openvpn

I then edited the client.conf file down as listed below for my initial testing.  Please be sure to adjust according to your own Server configuration as well as proper names for the ca, key and crt files.


#---- OpenVPN Client.conf --------------
dev tap0
proto tcp
resolv-retry infinite
nobind
persist-key
persist-tun
remote hostname.com 1194
ca ca.crt 
cert hostname.crt
key hostname.key
verb 3
 
Restart OpenVPN

/etc/init.d/openvpn start
Test by pinging or logging into the remote server

Thursday, March 25, 2010

Convert FUSION Virtual Machine to VMWare Server

While moving Virtual Machines created on my Mac using FUSION to a Linux VMware Server environment, I found that it was necessary to remove the following line from the MyVirtualMachineName.vmx file.

serial0.fileType = "thinprint"

After doing so, I was then able to successfully add my Virtual Machines to the "Inventory" of the Linux VMware server.

Tuesday, February 23, 2010

LifeRay Portal 5.2.3 - TomCat 6.0 - PostgreSQL on Debian (sid)

I was recently introduced to LifeRay and determined that I would setup a Virtual Machine & configure it to run LifeRay on TomCat 6.0 with a Postgres database.

I have a preference toward Debian and since I had a base install on a Virtual Machine, I began by duplicating it and updating it to Sid.  (I later installed on a testing version as well following the same procedures outlined below.)

After some light reading on the Liferay site I realized that they didn't have complete documentation for a PostgreSQL installation for the 5.x versions.   It appears that there have been extensive changes since these most recent releases.
_____________________________________

To begin I downloaded the LifeRay Portal bundle with TomCat 6.0 :

cd /usr/local/src/

wget http://sourceforge.net/projects/lportal/files/Liferay%20Portal/liferay-portal-tomcat-6.0-5.2.3.zip

cd /usr/local

unzip liferay-portal-tomcat-6.0-5.2.3.zip

Make the shell scripts executable.

cd /usr/local/liferay-portal-5.2.3/tomcat-6.0.18/bin/

chmod +x *.sh

Obtain the following package: 
Note:  You must have the option of "non-free" in your apt sources list.

apt-get install sun-java6-jdk

Check the java version

java -version

Update ./home/user/.bashrc and add the following line.

# JAVA6
export JAVA_HOME=/usr/lib/jvm/java-6-sun

Note: DEBIAN Users must modify the setenv.sh file for TomCat and add the following variable if using a testing version Debian or have upgraded from a testing version of Debian. (Thanks to Mr. LBR for pointing this out) You may reference this issue at the following website http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=572048

Add the following to JAVA_OPTS line

-Djava.net.preferIPv4Stack=true

OPTIONAL:  If desired, you can simply start TomCat and allow LifeRay to use it's built in database HyperSQL.  I initially installed LifeRay with its default configuration so I could verify that I had a working installation prior to moving to PostgreSQL.

/usr/local/liferay-portal-5.2.3/tomcat-6.0.18/bin/start.sh

The default configuration starts TomCat on port 8080.

The log file is located at:

/usr/local/liferay-portal-5.2.3/tomcat-6.0.18/logs/

Tail the log file.

tail -f catalina.out

Once you see a line similar to the following, you may access your portal.

INFO:  Server startup in 62000 ms

Continuing on with a PostgreSQL database installation, you will need to stop TomCat by running the "Shutdown.sh" script found in the same location as the "start.sh" script.

 Obtain Postgres.  I also installed "-doc" package but didn't note it here.

 apt-get install postgresql 

 Start Postgres, setup a user for postgres, create a new database.

/etc/init.d/postgresql start

adduser newuser

Become a superuser

su postgres

Connect to the Database server.

psql template1 
template1=# CREATE USER newuser WITH PASSWORD 'newuserpassword';
template1=# CREATE DATABASE liferay;
template1=# GRANT ALL PRIVILEGES ON DATABASE liferay to newuser;
template1=# \q

Configure Liferay to use the PostgreSQL Database.

I found that the version or package that I downloaded did not actually have the following file.  I had to create this file.  If your version has this file please modify it with the following.

cd /usr/local/liferay-portal-5.2.3/tomcat-6.0.18/webapps/ROOT/WEB-INF/classes

vi portal-ext.properties

Insert the following lines with modifications to the database name, username & password to match your configuration.

jdbc.default.driverClassName=org.postgresql.Driver
jdbc.default.url=jdbc:postgresql://localhost:5432/liferay
jdbc.default.username=newuser
jdbc.default.password=newuserpassword

Start TomCat and tail the log file.

/usr/local/liferay-portal-5.2.3/tomcat-6.0.18/bin/start.sh

The default configuration starts TomCat on port 8080.

The log file is located at:

/usr/local/liferay-portal-5.2.3/tomcat-6.0.18/logs/

Tail the log file.

tail -f catalina.out

Once you see a line similar to the following, you may access your portal.

INFO: Server startup in 62332 ms

Login at:  http://localhost:8080

Admin access can be obtained by logging in with the following credentials (as per LifeRay.com)
Username: bruno@7cogs.com
Password: bruno

Overview:  Overall this was not a difficult process.  There were a few hurdles along the way getting the postgres database configured as I wanted with a different user than "postgres".  These were very minor and were primarily resolved once I found the proper location for the portal-ext.properties file.

Reference  & Info Links: 
LifeRay - LifeRay - website, documentation and wiki.
PostgreSQL - Postgresql - website & database commands.
YouTube - Howto change the default Logo on Liferay.  Saved me hunting around in the "control panel".

UPDATE 8/3/2010 - Tested ver. 6.0.4 GA2
  • Found documentation still applicable.  
  • Removed "SevenCogs" data in WEBAPPS folder prior to start up so no "example" data was deployed.  This required using the default username of test@liferay.com and password of "test" to access the admin console.
UPDATE 1/15/2011 - Tested ver. 6.0.5 GA3
  • Debian (testing) users will need to download and install (apt-get) default-java instead of sun-java6-jdk.
  • All other steps worked as documented