Author Archives: James Coyle

Reverse Proxy Subsonic with Apache

Get Social!

SubsonicLogoSubsonic is a web-based media player for playing audio and video files through a web browser. You can reverse proxy Subsonic using Apache

See my blog post on using Apache as a reverse proxy for more detailed information on Apache configuration files.

The below configuration expects the backend Subsonic port to be non-ssl as the encryption will be offloaded to the Apache reverse proxy server. The reverse proxy URL will be encrypted and available on the default SSL port 443. This has the advantage of not using any CPU on the Subsonic server for encrypting traffic allowing it to concentrate on transcoding.

Add the below text to a new sites-available Apache configuration file.
vi /etc/apache2/sites-available/subsonic

<VirtualHost *:443>
    SSLEngine On
    SSLCertificateFile /ssl-certs/cert.cer
    SSLCertificateKeyFile /ssl-certs/key.key
    SSLProxyEngine on
    ServerAdmin [email protected]
    DocumentRoot /var/www
    ServerName subsonic.jamescoyle.net
    # Possible values include: debug, info, notice, warn, error, crit ,alert, emerg.
    LogLevel warn
    CustomLog ${APACHE_LOG_DIR}/subsonic-access.log combined
    ErrorLog ${APACHE_LOG_DIR}/subsonic-error.logProxyHTMLStripComments on
    <Location />
        ProxyRequests off
        RequestHeader unset Accept-Encoding
        ProxyPass http://192.168.1.22:4040/
        ProxyPassReverse http://192.168.1.22:4040/
        Order allow,deny
        Allow from all
    </Location>
<VirtualHost>

 

Enable the new site in Apache and reload the configuration.
a2ensite subsonic
service apache2 reload


How to grow a mdadm RAID 5 array

Category : How-to

Get Social!

image

mdadm is a software RAID technology for creating local volumes with RAID functionality such as RAID 5. RAID 5 is used to provide redundancy in the even of a disk failure by using the equivalent space of one disk in the volume for parity data.
One advantage of using mdadm is that you can create volumes of disks to a given size and then expand them at a later date. For example, if you have a RAID 5 array with 3 disks you can expand it to four disks.
Before following these steps you should un-mount the file system using umount.
This example assumes your array is called md1 and the new disk is sdf.

mdadm --add /dev/md1 /dev/sdf1

Now we can grow /dev/md1 as follows.

mdadm --grow /dev/md1 --size=max

If this fails, you may need to remove the bitmap index before retrying the above command.

mdadm --grow --bitmap=none /dev/md1

The process will now start which can take a while. An Example, 5 x 2TB WD green disks took 3 days to complete. You can view the progress with:

watch cat /proc/mdstat

Once this completes, we run a file system check and resize the file system.

e2fsck -f /dev/md1
resize2fs /dev/md1
e2fsck -f /dev/md1
You can now re-mount your file system.
mount -a

Updates to Proxmox 3.1 including signed console applet

Category : Tech News

Get Social!

proxmox logo grad

New updates to Proxmox 3.1 have been released which can be applied using apt-get.

The main feature in this suite of updates is that the Java VNC console is now signed which should result in far fewer annoying messages when starting the console. There are a few other updates, including bug fixes and support for iSCSI targets (istgt) on ZFS.

Run the update and upgrade command to apply the recent updates. There is no need to shut down any running guests or restart your host with this update.

Run apt-get update to download the information on the latest available updates.

apt-get update

Run apt-get upgrade to download and install the latest update packages. Press y when prompted to download and install the displayed packages.

apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be upgraded:
 libpve-access-control libpve-common-perl libpve-storage-perl pve-manager vncterm
5 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 1,634 kB of archives.
After this operation, 1,024 B of additional disk space will be used.
Do you want to continue [Y/n]? y

Add a package to startup on Debian/ Ubuntu/ Red Hat/ CentOS

Get Social!

Linux penguin Most versions and distributions of Linux today have a start up manager application to easily set which programs are started when your Linux machine boots up. There are two distinct flavours of start up applications and a manual method for distributions without this feature installed.

Using a terminal and the command chkconfig on CentOS, Red Hat and Oracle Enterprise Linux; and update-rc.d on Debian and Ubuntu you can control which packages are available as services and which packages start with your computer.

Run Level

Before looking at the commands used to control startup services in Linux, it’s important to understand when a program should be running in relation to the current operating system state. For example, you probably don’t want your Apache service being started before you have networking.

Linux has the concept or a runlevel which dictates the state of the operating system as a number between 0 and 6 inclusive.

See my post on runlevels to understand when your application or service should be asked to start.

Start up with Red Hat, CentOS and Oracle Enterprise Linux

Controlling startup services in Linux distributions such as Red Hat Enterprise Linux (RHEL), CentOS and Oracle Enterprise Linux (OEL) is done using the chkconfig command.

See my chkconfig cheat sheet for more information on controlling startup services on RHEL based Linux.

Start up with Debian and Ubuntu

Debian and Ubuntu based Linux distributions use the command update-rc.d to control which services are started during machine boot.

For details of controlling such services, see my update-rc.d cheat sheet.

Start up for manually setting the start up services

For operating systems that are not managed by an application, such as upstart on Ubuntu, you will need to manually add the /etc/init.d/ start up script to the /etc/rc.local file.

The /etc/rc.local file contains a reference to all the services which are required on machine boot.

Run the below echo command to add a manual start up application. The application name must be the same as the /etc/init.d/ file which must exist.

echo "network" >> /etc/rc.local

To remove a service, edit the /etc/rc.local file and manually remove the service name.

vi /etc/rc.local

update-rc.d Cheat Sheet

Get Social!

Linux penguinDebian and Ubuntu use the service command to control services and update-rc.d for adding and removing services from start up. Using the service command we can start, stop, restart and display all available services. With update-rc.d we can add and remove services and add them to the Ubuntu/ Debian start up scripts. As Linux operating systems have multiple states, or runlevels, you need to make sure you add any new services to the correct runlevels. For example, you would not want to start a web service application before starting networking.

See my post on runlevels for more information about runlevels in Linux..

What services are available for startup?

Use the status-all switch to list all services which are registered with the OS and issues them a status command. You will then get one of the following displayed next to each service:

  • [ + ] – Services with this sign are currently running.
  • [ – ] – Services with this sign are not currently running..
  • [ ? ] – Services that do not have a status switch.
service --status-all

Sample output:

service --status-all
 [ ? ] acpid
 [ - ] apparmor
 [ ? ] apport
 [ ? ] atd
 [ - ] bootlogd
 [ ? ] console-setup
 [ ? ] cron
 [ ? ] dbus
 [ ? ] dmesg
 [ ? ] dns-clean
 [ ? ] friendly-recovery
 [ ? ] glusterfs-server
 [ - ] grub-common
 [ ? ] gssd
 [ ? ] hostname
 [ ? ] hwclock
 [ ? ] hwclock-save
 [ ? ] idmapd
 [ ? ] irqbalance
 [ ? ] killprocs
 [ ? ] module-init-tools
 [ ? ] network-interface
 [ ? ] network-interface-container
 [ ? ] network-interface-security
 [ ? ] networking
 [ ? ] ondemand
 [ ? ] passwd
 [ ? ] plymouth
 [ ? ] plymouth-log
 [ ? ] plymouth-ready
 [ ? ] plymouth-splash
 [ ? ] plymouth-stop
 [ ? ] plymouth-upstart-bridge
 [ ? ] portmap
 [ ? ] portmap-wait
 [ ? ] pppd-dns
 [ ? ] procps
 [ ? ] rc.local
 [ ? ] resolvconf
 [ ? ] rpcbind-boot
 [ - ] rsync
 [ ? ] rsyslog
 [ ? ] screen-cleanup
 [ ? ] sendsigs
 [ ? ] setvtrgb
 [ + ] ssh
 [ ? ] statd
 [ ? ] statd-mounting
 [ - ] stop-bootlogd
 [ - ] stop-bootlogd-single
 [ ? ] sudo
 [ ? ] udev
 [ ? ] udev-fallback-graphics
 [ ? ] udev-finish
 [ ? ] udevmonitor
 [ ? ] udevtrigger
 [ ? ] ufw
 [ ? ] umountfs
 [ ? ] umountnfs.sh
 [ ? ] umountroot
 [ - ] unattended-upgrades
 [ - ] urandom
 [ ? ] whoopsie

Start a service

Starting a service is done using the command service followed by the service name and the command to start the service.

service apache2 start

Stop a service

Use the stop keyword with service to stop a service.

service apache2 stop

Check the status of a service

Each service has a status, usually running or not running. Some services, such as network, may have a different output and output more information on the service.

service apache2 status

Remove a service

Use the remove keyword with update-rc.d to remove the service start up command for an application. You will need to use the -f switch if the applications /etc/init.d start up file exists.

update-rc.d -f apache2 remove

 Add a service

Adding a service to Ubuntu or Debian is done with the update-rc.d command. You can specify which runlevels to start and stop the new service or accept the defaults. The init.d file will be added to the relevent rc.d startup folders.

 update-rc.d apache2 defaults

Setting Start and Kill priority

If you need more control over when your service is asked to start and stop, you may need to set the start and kill (S and K) values.

For a given runlevel, you may have several services starting. For example, you may have apache2 and mysql both starting on runlevel 3. Ideally, you’d want mysql to start before apache2 and shutdown after apache2. In this case we need to give mysql the priority in startup, but apache2 the priority in shutdown.

When starting, the lower the number, the earlier it will start. A start priority of 10 will start before a priority of 20. When killing, it’s the opposite. A higher number will be killed before a lower number.

To set the start and kill priority we simply add them to the above update-rc.d command with the start priority first, followed by the kill priority.

update-rc.d apache2 defaults [START] [KILL]

The below command will start mysql first, then apache2. On shutdown, the kill will be the reverse of the start with apache2 being killed first and mysql second.

update-rc.d apache2 defaults 90 90
update-rc.d mysql defaults 10 10

Because, in our example, both start and kill priorities are the same we can shorted the command to just

update-rc.d apache2 defaults 90
update-rc.d mysql defaults 10

Manually set the RunLevel to Start and Kill a service

You can manually specify the Linux RunLevel that the system must be in to Start and Kill your service. See my other blog post for more information on RunLevels.

To extend the above example, we can specify exactly which RunLevel apache2 will be started and stopped.

update-rc.d apache2 start 10 2 3 4 5 . stop 90 0 1 6 .

apache2 will be started (as long as it isn’t already) when the system enters RunLevel 234 or 5 with a priority of 10. It will then be asked to stop when the system enters RunLevel 01 or 6 with a priority of 90.

Let me know in the comments if you think anything is missing.


Changing the OMS password on OpenNode

Tags :

Category : How-to

Get Social!

open-node

The OpenNode Management Server is installed with a default password. To help ensure your OpenNode server is secure, you must change the password to something more secure.

See my blog post to install OMS if you haven’t yet got it set up.

The default username and password for OMS as below:

  • Username: opennode
  • Password: changeme

You must SSH onto the OMS OpenVZ container to change the password. You could SSH directly to the IP address or use vzctl enter to access it from the OpenNode host.

vzctl enter 999

The above example assumes that the OMS container is running using VMID 999.

Change directory to the OMS bin directory:

cd /opt/oms/bin

Execute the change password command and enter your new password when promted:

omspasswd opennode

Your password will be changed immediately and you can use it to log into the web front end of OMS.

 


Visit our advertisers

Quick Poll

Do you use ZFS on Linux?

Visit our advertisers