guy labs guy labs

PostgreSQL – CET FATAL: could not create shared memory segment

Infrastructure, Linux
/by
Lately I updated to the latest PostgreSQL from the Ubuntu repositories and then I got the error "CET FATAL: could not create shared memory segment". As the following error message states, the  value of the kernel is too less or the shared memory propery of PostgreSQL is too high. The complete error message looked like this: My solution was to increase the  kernel parameter as I have a lot of memory left on my server. To see the current value of your  parameter execute the following command : And to check the size of the shared memory of your PostgreSQL instance open up the file   and search for the parameter  . To increase the  parameter of your system you need to edit the   file and add the following at the end of the file: That would increase the  value to 100 mega bytes (104857600 bytes). Next you need to reload the sysctl file with the following command: After that you should be able to restart the PostgreSQL server without any problems. Cheers and have a nice...

How to install fish shell in Ubuntu 13.04

Linux
/by
I used the fish shell for some time now and I'm really happy with it. The highlighting, the command completion etc. are great. Today I want to show you how to install it and use it as default shell in Ubuntu. Ok let's start by installing the fish package from the Ubuntu repository with the following command: If you want the newest version you can go to the developer website and download the newest .deb file for Ubuntu. Next we need to set fish as the default shell. Execute the following command, log out and login again and when you now open a shell it should show the fish shell. It's worth read the documentation about the fish shell because it's very powerful and has a lot of useful features you surely dreamed of. ...

Avahi and unicast domains .local

Linux
/by
Today I want to tell you something about the .local domains when you use Avahi. At edorasware we use vSphere from VMWare to manage our virtual machines. For accessing it we need to connect first to the local network via VPN and then connect to the vShere server. Inside the vSphere application you can connect yourself to the console of each VM with a browser plugin. But this didn't work because we use the .local domains for the VM's inside the local intranet. To resolve this issue I needed to open the file /etc/nsswitch.conf and replace the following line with this one here: But there are other ways to fix that: http://avahi.org/wiki/AvahiAndUnicastDotLocal What I also saw is that when I connect to the SSH daemon via VPN it connects a lot faster. I hope this helps someone...

How to convert a SVN repository to GIT in Linux

Development, Linux
/by
Today we want to convert a SVN repository to a GIT repository. I did the same conversion at edorasware too. What you need is direct access (SSH access to the server where the SVN repository lies) to the SVN repository which you want to convert and have GIT installed on that server. If you do this on a production SVN repository you need to tell all developers to stop committing while you are doing the conversion to prevent an inconsistent state of the GIT repository. Let's start by creating a dump of the SVN repository. (be sure you have enough disk space) Browse to the repository and execute the following command: Now we have a dump of the repository which you can copy into a temporary folder where the conversion takes place. Next we create an empty SVN repository and load the dump into this repository. Execute the following commands to do this: This process leaves the original SVN repository intact such that you can go back to SVN if something happens while converting. Next we need to download the svn2git tool which was used to convert the SVN repositories from the KDE project to GIT. Execute the following commands to clone the GIT repository: Now we need to install some dependencies in order to make the svn2git executable. Install the libsvn-dev dependency and qt4. In ubuntu you would execute the following commands: After the installation browse to the svn2git folder and execute the following commands to make the executable: After this process you have the svn-all-fast-export executable inside the...

How to install ownCloud 5 manually on Ubuntu 13.04 with Apache 2

Linux
/by
Today we want to install ownCloud such that we can host everything at home and it is under your control. You can check the features at https://owncloud.org Ok first step is to download the ownCloud distrubution to your server and extract it in your web directory. (Normally inside /var/www) You need to have an Apache HTTPD running. Now you need to install some php dependencies which are needed by ownCloud. To do this execute the following commands: Next you need to ensure that 'AllowOverride' is set to 'All' in the 'Directory /var/www' section of your virtual host file. This is usually in '/etc/apache2/sites-enabled/000-default'. Update 23.11.2013: If you have Apache version 2.4.3 or later (default in Ubuntu 13.10) installed you need to add the following to the /var/www section of your virtual hosts file (which now ends with the .conf extension): Next we need to enable some Apache 2 mods with the following commands: Now open the browser and connect to your server and add '/owncloud' to the URL. Follow the installation instructions and select a database. I use PostgreSQL but you can also use MySQL or SQLite (file based database). But for larger installations you should use PostgreSQL or MySQL. After the installation is finished, you can test your ownCloud instance. If you need more documentation or need support goto http://doc.owncloud.org Thats all on how to install ownCloud on your own...

Mount FTP directory with TLS and backup files in Ubuntu 13.04

Linux
/by
This howto shows you how we can download FTP files over TLS and backup them automatically. I have several Wordpress websites which are running on remote servers where I just have FTP access. I installed a Wordpress plugin (http://wordpress.org/plugins/backwpup/) which makes daily backups and now I want to store them on my server at home. First we need to install curlftpfs by executing the following command: Next we need to test if the FTP mount works with curlftpfs. To test this execute the following command: If your username or password contains special characters you need to convert them. For example you need to convert an @ to %40. You can use this converter: http://www.w3schools.com/tags/ref_urlencode.asp If you get the following error: You need to download the server certificate with the following command: and add it to the options of curlftpfs: Now the mount should work and if you browse into the /mnt directory you should see the files which are in the specified directory on your FTP server. Update 06.03.2014: After a comment on this post about how to hide the password from the process list I add the following addition from the FAQ of the curlFtpFS project website: You can put the user and password in a .netrc file in the home directory of the user that executes CurlFtpFS. It can have 600 permission. It's still clear text but at least is not accessible by all. The format is: Ok now it's time to create a simple backup script which copies the backups to a local folder...

Install ClamAV antivirus in Ubuntu Server and Client

Linux
/by
In this how to we will install ClamAV antivirus on an Ubuntu client and a server. First we will install it on the client with the following command: This will install ClamAV and the GUI frontend ClamTK. You can configure daily scans and virus definition updates inside this tool. To install ClamAV on an Ubuntu server we start by installing ClamAV and the daemon by executing the following commands: Next we need to reconfigure the ClamAV base package, update the virus definitions and start the daemon. Execute the following commands: Next we need to create a shell script which scans a specific directory and sends an email if a virus is found. Place that shell script inside the user home of the root user or somewhere else. I placed it inside /home/clamav. Ok now create a file with the command 'sudo vi clamav-scan.sh' and enter the following content: Next we need to make the file executable with the following command: After that we add this file as a cronjob which executes every night at 3am: Substitute the {PATH-TO-SCRIPT} placeholder with the path where the clamav-scan.sh script is stored. Next we infect the folder you want to scan with the EICAR test virus. For that create a text file and add the following content to it: Store it and then run the created clamav-scan.sh to see if the virus is found and the mail is sent. After everything worked as it should, delete the test virus text file. But be aware: The clamav-scan.sh script identifies the viruses and doesn't delete them, that has to be done manually. Ok...

Create a software RAID1 with mdadm on an active Ubuntu 13.04 till 16.10 hard drive

Linux
/by
Today we want to create a RAID1 array with an active Ubuntu 13.04 till 16.10 hard drive. I installed my server without a RAID array on a single hard drive. And now, after spending a lot of hours configuring it, I want to create a RAID1 array to have a security if one of the hard drives fail. Create a simple RAID1 array is easy with mdadm, but creating it with a hard drive that has data on it isn't that simple. I created the following howto with the help of this older blog post about the same problem: http://feeding.cloud.geek.nz/posts/setting-up-raid-on-existing Use this article with caution because this is the solution for my machine and I don't know if it works on other machines, but I gave my best to test everything in a virtual machine and on my server with the UEFI boot mechanism. Also create a backup of your hard disk first: Create a CloneZilla disk image Ok let's start and we first need to install the following packages: If you havent already installed postfix, set the option 'no configuration' for the postfix installation dialog. First attach your new hard drive (best to have one with the same size or bigger) and then execute the following commands to copy the partitions of /dev/sda to the second drive (in my case /dev/sdb): If you have a GPT partition table you need to install gdisk and copy the partition table with the following commands: The first command here copies the partition table from /dev/sda to...

How to resize a VirtualBox hard drive in Ubuntu 13.04

Linux
/by
Lately at work I needed to install Microsoft SQL Server on my Windows 7 virtual machine, and it was just to big for the free space left on my virtual hard drive. So I searched a way to resize it without spending too much time. You just need to open a terminal, browse to your .vdi virtual drive and then execute the following command: Inside the example command I resize the Windows-7-SP1-64-Bit.vdi virtual drive to a complete size of 30 GB (30'000 MB). Don't forget to format the free space or resize the partition with gparted or any other partitioning tool. I hope this helps someone  :wink: Have a nice...

Install BIND 9 in Ubuntu 13.04

Linux
/by
  Hi, today I want to show you how to install BIND 9 in Ubuntu 13.04. I have installed it on my own server at home, such that I am able to use the DNS names for my applications which I use from the outside. For example git.guylabs.ch etc. It also boosts the performance if you have an internal DNS server, because now the request doesn't need to be resolved on a public DNS name server anymore. Ok lets get started. First of all we need to install the necessary package by executing the following command: Next we need to add forwarder DNS name servers which are used when the internal name server cannot resolve the DNS name requested. For that open up the file /etc/bind/named.conf.options as root and add or uncomment the two name server IP addresses to the forwarders block. (Here we use the public DNS name server IP's from Google) After that we need to add the local name server and the search domains to the static local interface. To do this open up the file /etc/network/interfaces as root and add the following two properties to the static defined interface. (It's good to have the DNS server configured with a static IP address. If you don't know how to do this, please read this article) Next we need to define the zones for our local domain. For that open up the /etc/bind/named.conf.local as root and add the following two code blocks and adapt it for your environment. (In this example we use the network 192.168.1.0. And the...