4 Awesome ways to find top memory consuming processes in Linux.

1. Finding out  top memory consuming processes in Linux using ps command.

There is one liner code available with ps command which will help you  to find top memory consuming processes in Linux.

Command:

Sample Output:

Here output get sorted according to memory utilisation which will help you find out top memory consuming processes in Linux very easily.

2. Continuously monitoring top memory consuming processes in Linux.

If in case you need to monitor the output continuously. Below command which is using watch command comes very handy.

Command:

Sample output:

3. Top memory consuming processes in Linux using top command.

The same output of the ps command can also be achieved using the native top command in Linux to find top memory consuming processes in Linux.

Command:

Sample output:

4. Find Top memory consuming processes in Linux using htop command.

There is one more utility called htop which will help you to find the top cpu consuming processes in Linux.  In case its not installed by default follow this article.

Command:

Once you execute htop command, a continuous running window will open same like top as below:

top memory consuming processes in Linux

In order to sort out the processes by memory utilisation  simply press “F6” button and then select memory and hit enter. You will able to see the processes sorted according to memory utilisation as below:

 top memory consuming processes in Linux

Source: https://linuxroutes.com/4-awesome-ways-to-find-top-memory-consuming-processes-in-linux/

Advertisements

How to migrate a Windows PC to a Parallels Desktop virtual machine

Symptoms

You have a Windows PC, and you want to migrate it, along with all its content, to a Parallels Desktop for Mac virtual machine.

Resolution

You can import all your data from a Windows PC to Parallels Desktop on your Mac. Then you can continue to work with all your Windows programs, files, and data side-by-side with OS X.

Important: After importing your data from your PC, you may need to reactivate some of your Windows programs using the activation keys you received when you purchased the programs.


Note: After migration is complete your PC will remain unmodified. See related article KB 117639


Requirements for importing your data

To import data to your Mac, you need a Windows computer with the following specifications:

For Parallels Transported Agent v.9:

  • Windows XP with Service Pack 2 or later, Windows Vista, Windows 7 or Windows 8.

    Note: You can also use a computer running Windows Server 2008 R2 (64-bit only), Windows Server 2008, or Windows 2000 Professional (32-bit only).

  • An Intel or AMD (700 MHz or higher) x86 or x64 processor
  • At least 256 MB of RAM
  • At least 70 MB of hard disk space for installing Parallels Transporter Agent
  • One of the following:
    • An Ethernet port for transferring your data over the network
    • A USB port for transferring your data using the Parallels USB cable
  • An external storage device, such as a USB hard disk
  • Supported Windows and Linux versions:**
    • Windows 8.1
    • Windows 7
    • Windows Vista
    • Windows XP
    • Windows Server 2003
    • Windows 2000
    • Red Hat Enterprise Linux 5.x, 6.x
    • Ubuntu Linux 10.04 LTS, 14.04

For Parallels Transporter Agent v.10

See the Parallels Transporter Agent User’s Guide)

  • 700 MHz (or higher) x86 or x64 processor (Intel or AMD)
  • 256 MB or more of RAM
  • 50 MB of hard disk space for installing Parallels Transporter Agent
  • Ethernet or WiFi network adapter for migrating over network
  • Supported Windows and Linux versions:
    • Windows 8.1
    • Windows 7
    • Windows Vista
    • Windows XP
    • Windows Server 2003
    • Windows 2000
    • Red Hat Enterprise Linux 5.x, 6.x
    • Ubuntu Linux 10.04 LTS, 14.04

Note: Parallels Desktop does not support migrating Windows dynamic volumes (in which size is not fixed, as it is in basic volumes). They are migrated as data disks only. You can add them later to an existing virtual machine.

Also read KB #119172 before proceeding with migration.

Step 1: Install Parallels Transporter Agent on your Windows PC

To import your data, you must first install the Parallels Transporter Agent software on the Windows PC.

Do one of the following:

  • If you purchased a physical copy of Parallels Desktop, insert the installation DVD into your Windows PC. If the installation doesn’t start automatically, locate and double-click the Parallels Transporter Agent.exe file.
  • Download Parallels Transporter Agent for Windows from the Parallels website and double-click the installation file.

If your computer is connected to the Internet, Parallels Transporter Agent checks for available updates. If an update is available, click Download and Install New Version. Follow the onscreen instructions to install Parallels Transporter Agent.

Step 2: Import Your Data

Choose one of the methods below for importing your data from your PC to your Mac.

Using a Parallels USB cable

The Parallels USB cable required for this method is included with Parallels Desktop Switch to Mac Edition. If you don’t have the Parallels USB cable, import your data using one of the other methods.


Note: Parallels USB Cable is available only for Parallels Desktop 8 Switch to Mac Edition and earlier.


  1. Turn on your Mac and your Windows PC then log in to both computers.
  2. On the Windows PC, open Parallels Transporter Agent by clicking the Start menu and selecting All Programs > Parallels > Parallels Transporter Agent.
  3. Connect the Parallels USB cable to your Windows PC and your Mac.
  4. If the Windows PC is running Windows XP, the Found New Hardware wizard opens. In this wizard:
    • Select Yes, this time only, and click Next.
    • Select Install the software automatically (Recommended), and click Next.
    • A Hardware Installation warning appears. Click Continue Anyway.
    • Drivers for the Parallels USB cable are installed. Click Finish to exit the wizard.
  5. On your Mac, open Parallels Desktop and choose File > New.
  6. Select Migrate from a PC and click Continue.
  7. Select Parallels USB cable and click Continue. Parallels Transporter will start collecting information about the source computer.
  8. If the Windows Installation Files window appears, insert the Windows installation disc into your Mac and click Continue.
  9. If you don’t want to log in to Windows automatically whenever you start up, select “Do not enable Automatic Logon”. Then click Continue.
  10. Choose whether you want to migrate all your files and data or only Windows applications. Then click Continue.
  11. Choose where you want to install your data. You can also click Customize and select which Windows volumes to migrate. Then click Continue.
  12. In the next step you will see a warning about Windows activation that might be required when you start using it. To proceed, read this message, select I want to continue and click Continue.
  13. Once the migration is complete, click Done.
  14. Start Windows.
  15. Once Windows starts up, choose Virtual Machine > Install Parallels Tools and follow the onscreen instructions.

Note: To be able to install Parallels Tools, you must be logged in to Windows as an administrator.

Over a network

Important: After importing your data, you may need to reactivate some of your Windows programs using the activation keys you received when you purchased the programs. To import your data from a PC over a network:

  1. Turn on your Mac and your Windows PC then log in to both. Verify sure that the computers are connected over the same network.
  2. Make sure that the Windows firewall is turned off. You can turn it on again after the import is finished.
  3. On the Windows PC, open Parallels Transporter Agent. From the Start menu select All Programs > Parallels > Parallels Transporter Agent.
  4. On your Mac, open Parallels Desktop and choose File > New.
  5. Select “Migrate from a PC” and click Continue.
  6. Select “Network” and click Continue.
  7. Find the passcode displayed in Parallels Wizard on your Mac and enter it in Parallels Transporter Agent on your Windows PC. You can also connect to the source Windows PC using its name or IP address: click “Use IP address instead”, select the Windows PC name from the list or type the IP address, and click Continue.
  8. If you have chosen to use the computer name or IP address, provide the Windows administrator credentials. Parallels Desktop will connect to Parallels Transporter Agent and start collecting information about the source computer.
  9. If the Windows Installation Files window appears, insert the Windows installation disc into your Mac and click Continue.
  10. If you don’t want to log in to Windows automatically whenever you start up, select “Do not enable Automatic Logon”. Then click Continue.
  11. Choose whether you want to migrate all your files and data or only Windows applications. Then click Continue.
  12. Choose where you want to install your data. You can also click Customize and select which Windows volumes to migrate. Then click Continue.
  13. In the next step you will see a warning about Windows activation that might be required when you start using it. To proceed, read this message, select “I want to continue” and click Continue.
  14. Once the migration is complete, click Done.
  15. Start Windows.
  16. When Windows boots up, choose Virtual Machine > Install Parallels Tools and follow the onscreen instructions.

Note: To be able to install Parallels Tools, you must be logged in to Windows as an administrator.

Using an External Storage Device

Important: After importing your data, you may need to reactivate some of your Windows programs using the activation keys you received when you purchased the programs. To import your data from a PC using an external storage device:

  1. Connect an external storage device to your Windows PC.
  2. In the Windows PC, open Parallels Transporter Agent by clicking the Start menu and selecting All Programs > Parallels > Parallels Transporter Agent.
  3. Click the external storage device icon.
  4. Click Next. Parallels Transporter Agent will collect information about the Windows PC.
  5. If you don’t want to log in to Windows automatically whenever you start up, select “Do not enable Automatic Logon”. Then click Next.
  6. Choose whether you want to migrate all your files and data or only Windows applications. Then click Next.
  7. Choose where you want to store your data. You can also click Customize and select which Windows volumes to migrate. Then click Next.
  8. In the next step you will see a warning about Windows activation that might be required when you start using it. To proceed, read this message, select “I want to continue” and click Next.
  9. Once the migration is complete, click Done to quit Parallels Transporter Agent.
  10. Disconnect the storage device from the Windows PC and connect it to your Mac.
  11. On your Mac, open Parallels Desktop and choose File > New.
  12. Select “Migrate from a PC” and click Continue.
  13. Select “External Storage Device” and click Continue.
  14. Click “Choose” and locate where you chose to store your data in step 7. Then click Continue.
  15. Choose where you want to install Windows and your data, then click Continue.
  16. Once the migration is complete, click Done.
  17. Start Windows.
  18. When Windows boots up, choose Virtual Machine > Install Parallels Tools and follow the onscreen instructions.

Note: To be able to install Parallels Tools, you must be logged in to Windows as an administrator.

For more information about migrating your PC to Mac please also visit our on-line User’s Guide

If you have an issue with migration, please follow the solution outlined in KB #113269.


Related articles:

Source: http://kb.parallels.com/eu/115007

How to use StatSVN to Monitor Developer Commits and Lines of Code

StatSVN can be used to monitor Subversion repositories and generate timelines for lines of code, commits by days/hours, directory stats, file sizes, graphs and more. This can be a very useful tool for monitoring developers and the lines of code they touch per day. In the following article I give examples of how to use StatSVN using CentOS command line (CentOS release 6.7 in this example).

Install Java

StatSVN requires Java, so check if it is installed: # which java

/usr/bin/javaIf no Java program is displayed install Java, for example: # yum install java-1.8.0-openjdk.x86_64Check install: # java -Xmx4m -version

openjdk version "1.8.0_65"

OpenJDK Runtime Environment (build 1.8.0_65-b17)

OpenJDK 64-Bit Server VM (build 25.65-b01, mixed mode)

Get StatSVN

Download the latest StatSVN JAR file here or download v0.7.0 here

Run StatSVN

Next run StatSVN to generate a series of report files. First, a Subversion repository log is required for StatSVN. Create this log file by running a Subversion command, for example: # cd /var/svn/my-project

# svn log --xml -v > svn.logNext execute the StatSVN JAR file using the command java -jar statsvn.jar <svn log path> <svn project directory path>, for example: # cd /var/svn/my-project

# mkdir statsvn

# cd statsvn

# cp /my-downloads/statsvn.jar ./

# java -jar statsvn.jar /var/svn/my-project/svn.log /var/svn/my-projectThis should execute the JAR file and begin generating files. After the output is complete open the /var/svn/my-project/statsvn/index.html in a Web browser – which should display development statistics for the Subversion repository.

Source: http://www.shayanderson.com/linux/how-to-use-statsvn-to-monitor-developer-commits-and-lines-of-code.htm

Tail a Log File on Windows & Linux

It turns out there are a bunch of people on StackOverflow looking for ways to tail a log file, but there don’t appear to be many resources for all the different tips and tools to do this. If you’re a Java or .NET developer, just getting started with tailing log files, or a seasoned developer who needs something quick and easy to set up and go, there are several options. In fact, there may be too many.

Check out some tools I found that make tailing a log file a walk in the park. Tailing multiple log files? Want to tail logs remotely from a web browser? This list covers a whole array of needs.

 

The Standard Linux Tail Command

The de facto standard for linux systems is the ever-handy “tail” command. Need I say more?

$ tail -f /var/log/syslog -f /var/log/myLog.log

  • Quick and easy
  • No additional installation required
  • Can be used with multiple –f filenames in the same window as shown in the script example above
  • Unix only. See Tail for Win32 at the bottom of this post for a port to Windows.

less -F

Less +F

Brian Storti (@brianstorti) offers an alternative method to the standard tail -f: less +F, which causes similar behavior as tail -f but allows for easily switching between navigation and watching mode. However, he notes that if you need to watch multiple files simultaneously, the standard tail -f offers better output.

  • Easy to use
  • Creates behavior comparable to tail -f
  • Allows for easy switching between navigation and watching mode
  • Not ideal for watching multiple files simultaneously

 

Windows Powershell

Windows Powershell

Powershell is one of the most overlooked windows apps for ops. This approach doesn’t have any extra features but can be perfect for opening a quick commandlet window and keeping an eye on the status of a file.

Use the following simple syntax to show the tail end of a log file in real-time.

Get-Content myTestLog.log –Wait

You can also filter the log right at the command line using regular expressions:

Get-Content myTestLog.log -wait | where { $_ -match “WARNING” }

  • Quick and easy to get going
  • Practically zero learning curve
  • No additional installation necessary for newer windows machines
  • Requires Windows Powershell (duh!)
  • Slow for large files
  • Basic functionality but some 3rd party extensions are available. For example, you need multiple cmdlet windows to monitor multiple files
  • How-To Geek provides a step-by-step tutorial for getting tail-like functionality with Powershell that you may find useful.

 

Stackify Tail a Log

Stackify’s Retrace

Retrace is an APM tool that provides all the support you need to monitor and optimize your applications, including enhanced log management which fully indexes and tags your logs.  Retrace also tails log files in real-time.

  • Remotely tail log files via web browser
  • Search all log files, including iis logs
  • See how log files are trending and monitor specific logs
  • Supported for Windows & Linux systems
  • Free trial, low monthly cost

 

 

 

Vim log file tailing

Vim (Using Tail Bundle Plugin)

Developed by Martin Krischik (@martin_krischik), this handy-dandy plugin for Vim allows you to use “the best tail plugin you can get.”

  • Vim die-hards can tail log files without ever leaving their favorite editor!
  • Multiple file tailing using tabs
  • “Preview” window updated according to your Vim usage
  • Read the open issues on the Google Code page before installing
  • Check out Krischik’s other projects here

Emacs

Emacs

To tail a file in Emacs (@emacs): start Emacs, hit M-x (Alt and x keys together), and type “tail-file”. Then, enter the filename to tail. The net result is that this will spawn an external tail -f process. Emacs is much more than a tool for tailing log files, however; it’s packed with other features and functionality ranging from project planning tools to debugging, a mail and news reader, calendar, and more.

  • Customizable using Emacs Lisp code or a graphical interface
  • Packaging system for downloading and installing extensions
  • Unicode support for nearly all human scripts
  • Built-in documentation
  • Tutorial for new users
  • Content-aware editing modes including syntax highlighting

 

Multitail for UNIX log files

MultiTail

Developed by Folkert van Heusden (@flok99), MultiTail was inspired by wtail, which was written by André Majorel. This is one of the more complete UNIX offerings, in my humble opinion. It’s a relatively newer tool compared to some others on this list, with a stable version released in February 2015.

  • Uses wildcard matching to see if a more recently spawned logfile needs to be monitored
  • Uses regular expressions for filtering
  • Source code available in public Github repository
  • All major UNIX platforms supported

 

BareTail log tailing for Windows

BareTail

Developed by Bare Metal Software, BareTail is a free tool for monitoring log files in real-time. The “Bare” in the name might prompt some to ask, “How can you get any barer than regular Tail?” It turns out the name is a carryover from the software development group that built it, and this tool provides a color-coded GUI above and beyond good ‘ole Unix Tail.

  • Developed for Windows
  • Monitors multiple files using tabs
  • Configurable highlighting
  • Allows instant scrolling to any point in the file, even for large files
  • Free version available; a registered license is $25. There’s also a BareTailPro, which is packed with even more features and offers a free demo.

LogTail

LogTail

Developed by John Walker of Fourmilab (@Fourmilab), this tool doesn’t appear to have been supported in a long time (the website is dated 1997) and may not play well with the latest distros of Unix. You have been warned.

  • Allows you to monitor multiple log files on multiple servers at once
  • Automatically checks if the monitored process has spawned a fresh log file and adjusts monitoring accordingly
  • Old script (circa 1997) may not play well with newer Unix distros/Perl patches (built withi Perl 4.0, patch level 36)
  • UNIX only

 

TraceTool error logging

TraceTool

Developed by Thierry Parent, TraceTool is a great option for .NET developers needing to build their own log tailing feature. The code comes with a lot of power and features, but it might not be as good a choice if you simply want to run a quick program and be off on your merry way. You can also check it out on SourceForge.

  • Powerful tool with lots of customizability via code.
  • There is a learning curve, depending on how far you want to take TraceTool. Check out the “TraceTool Overview” screenshot on the CodeProject page and you’ll see what I mean.
  • Not a quick fix. If you simply want to open a quick executable and see the tail of a few log files, pick something else. This will take you some time to set up and get configured.
  • With great power comes great responsibility. The CodeProject discussion section has comments from users experiencing several different kinds of problems. Yet despite any problems users have, they consistently ranked the page highly, with an average vote of 4.97 at the time of this writing.
  • Source code is readily available for download, but you’ll need a .NET development environment setup to compile it.
  • Windows only.

 

SnakeTail

SnakeTail.net

SnakeTail.net is developed by SnakeNest. Looks can be deceiving – I thought this Google Project was long dead but was pleasantly surprised that bugs are still being fixed and features added as recently as September 2016.

  • Low memory & CPU footprint even with large files
  • Customizable shortcut keys to jump around files quickly
  • Can tail a log directory where the latest log files are stored
  • Windows only

 

image_thumb

Notepad++

Hardcore fans of Notepad++ (@Notepad_plus) often like to work in it all day, every day. Now you can tail a log file in Windows without ever leaving Notepad++ by using the Document Monitor plugin (granted – hardcore fans probably already know all about this!):

  1. Open Notepad++ then from the top menu select “Plugins > Plugin Manager > Show Plugin Manager,” then check the option for “Document Monitor,” then click “Install.”
  2. Notepad++ will prompt you to restart the program (not restart your computer).
  3. Upon opening Notepad++ again, select “Plugins” and you should now see the “Document Monitor > Start to monitor” option. This will refresh the view of your document automatically every 3 seconds.

 

image_thumb_11

inotail

Developed by Tobias Klauser (@t_klauser), inotail is a basic tool with minimal options compared to the others on this list. But for those of you yearning for simplicity, this just might be the log tail tool you’re looking for. The most recent update, however, is from back in 2009, and the most recent version, inotail 0.5, was released in 2007.

  • Git and GitHub repos available
  • Uses the inotify API to determine if a file needs to be reread

 

tail windows log files

Tail for Win32

Developed by Paul Perkins, Tail for Win32 is a Windows version of the UNIX ‘tail’ command, providing a quick and dirty way to use the Unix Tail command you’re used to on Windows systems. Many folks might consider this completely unnecessary on a windows system with the prevalence of Powershell these days, but it does provide a couple nice features you wouldn’t otherwise have:

  • Highlighted keyword matching
  • Can send email notifications via SMTP or MAPI when keywords are found
  • The ability to watch multiple files in real-time simultaneously
  • Can process files of any size on both local and networked drives
  • Download Tail for Win32 on SourceForge

 

JLogTailer

JLogTailer

JLogTailer is a Java log tailer with regular expression features that makes it possible to view any log file entries in real-time. It’s an easy-to-use tool that’s helpful when you need to see what’s going into the end of your log files as it happens while you tinker with your code. Additionally, you can use JLogTailer to tail multiple log files if needed.

  • View log entries in real-time
  • Simple to use
  • Works for tailing multiple log files

WebTail

WebTail

With so many programs generating log files, other tools are useful when you have direct access to the file system that stores each log. But what if you don’t have direct access to your log file? That’s where WebTail comes in, enabling you to tail any log file that can be viewed via a web server. In addition to allowing you to view entries the moment they’re appended to log files, WebTail requires less bandwidth than you’d otherwise use to download the entire file several times.

  • Useful for tailing log files stored on web servers
  • Save bandwidth by eliminating the need to download complete files multiple times
  • Tail any log file viewable via a web server

MakeLogic

MakeLogic Tail

An advanced tail -f command with GUI, MakeLogic Tail is the tail for Windows. It can be used to monitor the log files of various servers and comes with a variety of other intuitive and useful features.

  • Shows the last several lines of growing log files
  • Real-time monitoring
  • Requires JRE 5.0
  • Easy to use GUI
  • Search current and all open log files
  • Highlight select keywords in various colors
  • Monitor most recently opened documents
  • Cascade or Tile the log file windows

Wintail

Wintail

Wintail is a free program created by Andy Hofle after he struggled with viewing log files in real-time with Windows Notepad. There was no program like tail -f in UNIX for Windows at the time, so he wrote his own. It’s a useful tool enabling you to have multiple tiled windows open simultaneously, and you can also pause updates to examine files more closely when needed.

  • Supports large files over 2GB
  • Error highlighting
  • Drag-and-drop files you wish to monitor into the title or menu bar to open them
  • Create shortcuts to frequently-monitored files
  • Added support for Windows Server 2012 in November 2015

LogExpert

LogExpert

If you’re looking for an intuitive, easy-to-use tail application for Windows, LogExpert is a solid option offering search functionality, bookmarking, filter views, highlighting, time stamps, and other useful features that make monitoring a less frustrating task.

  • Search functions including RegEx
  • Flexible filter view
  • Columnizers
  • Highlight lines using search criteria
  • Supports Unicode, SFTP, log4j XML files, and third-party plugins
  • Plugin API for more log file data sources

glogg

glogg

A multi-platform GUI application for browsing and searching through long, complex log files, glogg can be described as a graphical, interactive combination of grep and less. An open-source tool released under the GPL by Nicolas Bonnefon, glogg functions on both Windows and Mac, making it a functional tool for any developer.

  • Use regular expressions to search for events in log files
  • Designed to help you spot and understand problems in the massive logs generated by embedded systems
  • Also useful for sysadmins searching through logs on databases or servers
  • Second window shows results from the current search
  • Supports grep/egrep like regular expressions
  • Colorizes logs and search results
  • Follows logs written to a disk in real-time

Source: https://stackify.com/13-ways-to-tail-a-log-file-on-windows-unix/

Build Your Own OpenStreetMap Tile Server on Ubuntu 16.04

OpenStreetMap, aka, OSM is a user contributed world map that is freely editable. This tutorial will show you how to build your own OpenStreetMap tile server on Ubuntu 16.04. 2GB RAM, 40GB disk space should be the minimum OpenStreetMap server requirements.

Step 1: Upgrade Software

sudo apt update

sudo apt upgrade

Step 2: Install PostgreSQL Database Server with PostGIS

We will use PostgreSQL to store map data. PostGIS is a geospatial extenstion to PostgreSQL. Run the following commands to install them.

sudo apt install postgresql postgresql-contrib postgis postgresql-9.5-postgis-2.2

A user named

postgres will be created during the installation process. This allows the use of peer authentication. Let’s switch to the postgres user:

sudo -u postgres -i

Create a PostgreSQL database user osm.

createuser osm

Create a database named gis and at the same time make osm as the owner of the database. -E UTF8 specifies the character encoding scheme to be used in the database is UTF8.

createdb -E UTF8 -O osm gis

Create hstore and postgis extension.

psql -c "CREATE EXTENSION hstore;" -d gis

psql -c "CREATE EXTENSION postgis;" -d gis

Exit from the postgres user.

exit

Create osm user on your operating system so the tile server can run as osm user.

sudo adduser osm

Step 3: Download Map Stylesheet and Map Data

First switch to osm user

su - osm

Download the latest CartoCSS map stylesheets to the osm user’s home directory.

wget https://github.com/gravitystorm/openstreetmap-carto/archive/v2.41.0.tar.gz

Extract it.

tar xvf v2.41.0.tar.gz

Next, download map data to the osm user’s home directory. Use the below command to download the map data of the whole planet (32G).

wget -c http://planet.openstreetmap.org/pbf/planet-latest.osm.pbf

If you want a map of individual country or state, go to http://download.geofabrik.de. Also, BBBike.org provides extracts of more than 200 cities and regions world-wide in different formats.

For example, download the map data of Great Britain (847M).

wget -c http://download.geofabrik.de/europe/great-britain-latest.osm.pbf

Now exit from the osm user.

exit

Recommendations before Importing Map Data

Importing map data takes a lot of RAM. If your physical memory is small, you can easily add a swap file. First we use fallocate command to create a file. For example, create a file named swapfile with 2G capacity in root file system:

sudo fallocate -l 2G /swapfile

Then make sure only root can read and write to it.

sudo chmod 600 /swapfile

Format it to swap:

sudo mkswap /swapfile

Output:

Setting up swapspace version 1, size = 2097148 KiB
no label, UUID=h32b3e10-0779-4865-9ea0-6e2af8f3kea9

Enable the swap file

sudo swapon /swapfile

The import process can take some time. It’s recommended to configure SSH keepalive so that you don’t lose the SSH connection. It’s very easy to do. Just open the SSH client configuration file on your local Linux machine.

sudo nano /etc/ssh/ssh_config

And paste the following text at the end of the file.

ServerAliveInterval 60

Then save the file and connect to your Ubuntu 16.04 server

Step 4: Import the Map Data to PostgreSQL

To import map data, we need to install osm2pgsql which converts OpenStreetMap data to postGIS-enabled PostgreSQL databases.

sudo apt install osm2pgsql

Switch to osm user again.

su - osm

Run the following command to load map stylesheet and map data into the gis Database. Replace great-britain-latest.osm.pbf with your own map data file.

osm2pgsql --slim -d gis -C 3600 --hstore -S openstreetmap-carto-2.41.0/openstreetmap-carto.style great-britain-latest.osm.pbf

osm2gpsql will run in slim mode which is recommended over the normal mode. -d stands for --database. -C flag specify the cache size in MB. Bigger cache size results in faster import speed but you need to have enough RAM to use cache. -S flag specify the style file. And finally you need to specify the map data file.

Once the import is complete, exit from the osm user.

exit

Step 5: Install mod_tile

mod_tile is an Apache module that is required to serve tiles. Currently no binary package is available for Ubuntu. We can compile it from Github repository.

First install build dependency.

sudo apt install git autoconf libtool libmapnik-dev apache2-dev

Then clone the repository from Github.

git clone https://github.com/openstreetmap/mod_tile.git

cd mod_tile/

Compile and install

./autogen.sh
./configure
make
sudo make install
sudo make install-mod_tile

Step 6: Generate Mapnik Stylesheet

Install required packages.

sudo apt install curl unzip gdal-bin mapnik-utils node-carto

Switch to osm user.

su - osm

Cd into the carto style directory.

cd openstreetmap-carto-2.41.0/

Get shapefiles.

./get-shapefiles.sh

Now build the Mapnik xml stylesheet.

carto project.mml > style.xml

Exit from the osm user.

exit

Step 7: Configuring renderd

Edit renderd config file.

sudo nano /usr/local/etc/renderd.conf

In the [default] section, change the value of XML and HOST to the following.

XML=/home/osm/openstreetmap-carto-2.41.0/style.xml
HOST=localhost

In [mapnik] section, change the value of plugins_dir.

plugins_dir=/usr/lib/mapnik/3.0/input/

Save the file.

Install renderd init script by copying the sample init script.

sudo cp mod_tile/debian/renderd.init /etc/init.d/renderd

Grant execute permission.

sudo chmod a+x /etc/init.d/renderd

Edit the init script file

sudo nano /etc/init.d/renderd

Change the following variable.

DAEMON=/usr/local/bin/$NAME
DAEMON_ARGS="-c /usr/local/etc/renderd.conf"
RUNASUSER=osm

Save the file.

Create the following file and set osm the owner.

sudo mkdir -p /var/lib/mod_tile

sudo chown osm:osm /var/lib/mod_tile

Then start renderd service

sudo systemctl daemon-reload

sudo systemctl start renderd

sudo systemctl enable renderd

Step 8: Configure Apache

Install Apache web server

sudo apt install apache2

Create a module load file.

sudo nano /etc/apache2/mods-available/mod_tile.load

Paste the following line into the file.

LoadModule tile_module /usr/lib/apache2/modules/mod_tile.so

Create a symlink.

sudo ln -s /etc/apache2/mods-available/mod_tile.load /etc/apache2/mods-enabled/

Then edit the default virtual host file.

sudo nano /etc/apache2/sites-enabled/000-default.conf

Past the following line in <VirtualHost *:80>

LoadTileConfigFile /usr/local/etc/renderd.conf
ModTileRenderdSocketName /var/run/renderd/renderd.sock
# Timeout before giving up for a tile to be rendered
ModTileRequestTimeout 0
# Timeout before giving up for a tile to be rendered that is otherwise missing
ModTileMissingRequestTimeout 30

Save and close the file. Restart Apache.

sudo systemctl restart apache2

Then in your web browser address bar, type

your-server-ip/osm_tiles/0/0/0.png

You should see the tile of world map. Congrats! You just successfully built your own OSM tile server.

Display Your Tiled Web Map

Tiled web map is also known as slippy map in OpenStreetMap terminology. There are two free and open source JavaScript map libraries you can use for your tile server: OpenLayer and Leaflet. The advantage of Leaflet is that it is simple to use and your map will be mobile-friendly.

OpenLayer

To display your slippy map with OpenLayer, first create a web folder.

sudo mkdir /var/www/osm

Then download JavaScript and CSS from openlayer.org and extract it to the web root folder.

Next, create the index.html file.

sudo nano /var/www/osm/index.html

Paste the following HTML code in the file. Replace red-colored text and adjust the longitude, latitude and zoom level according to your needs.

<!DOCTYPE html>
<html>
<head>
<title>Accessible Map</title>
<link rel="stylesheet" href="http://your-ip/ol.css" type="text/css">
http://your-ip/ol.js
<style>
  a.skiplink {
    position: absolute;
    clip: rect(1px, 1px, 1px, 1px);
    padding: 0;
    border: 0;
    height: 1px;
    width: 1px;
    overflow: hidden;
  }
  a.skiplink:focus {
    clip: auto;
    height: auto;
    width: auto;
    background-color: #fff;
    padding: 0.3em;
  }
  #map:focus {
    outline: #4A74A8 solid 0.15em;
  }
</style>
</head>
<body>
  <a class="skiplink" href="#map">Go to map</a>

<button id=”zoom-out”>Zoom out</button> <button id=”zoom-in”>Zoom in</button> var map = new ol.Map({ layers: [ new ol.layer.Tile({ source: new ol.source.OSM({ url: ‘http://your-ip/osm_tiles/{z}/{x}/{y}.png’ }) }) ], target: ‘map’, controls: ol.control.defaults({ attributionOptions: /** @type {olx.control.AttributionOptions} */ ({ collapsible: false }) }), view: new ol.View({ center: [244780.24508882355, 7386452.183179816], zoom:5 }) }); document.getElementById(‘zoom-out’).onclick = function() { var view = map.getView(); var zoom = view.getZoom(); view.setZoom(zoom – 1); }; document.getElementById(‘zoom-in’).onclick = function() { var view = map.getView(); var zoom = view.getZoom(); view.setZoom(zoom + 1); }; </body> </html>

Save and close the file. Now you can view your slippy map by typing your server IP address in browser.

your-ip/index.html           or          your-ip

Leaflet

To display your slippy map with Leftlet, first create a web folder.

sudo mkdir /var/www/osm

Then download JavaScript and CSS from leftletjs.com and extract it to the web root folder.

Next, create the index.html file.

sudo nano /var/www/osm/index.html

Paste the following HTML code in the file. Replace red-colored text and adjust the longitude, latitude and zoom level according to your needs.

<html>
<head>
<title>My first osm</title>
<link rel="stylesheet" type="text/css" href="leaflet.css"/>
http://leaflet.js
<style>
   #map{width:100%;height:100%}
</style>
</head>

<body>

var map = L.map(‘map’).setView([53.555,9.899],5); L.tileLayer(‘http://your-ip/osm_tiles/{z}/{x}/{y}.png’,{maxZoom:18}).addTo(map); </body> </html>

Save and close the file. Now you can view your slippy map by typing your server IP address in browser.

your-ip/index.html           or          your-ip

To pre-render tiles instead of rendering on the fly, use render_list command. Pre-rendered tiles will be cached in /var/lib/mod_tile directory. -z and -Z flag specify the zoom level.

render_list -m default -a -z 0 -Z 10

This tutorial is made available with the help from Miles B. Dyson.

HOW TO TROUBLESHOOT “THE TERMINAL SERVER SECURITY LAYER DETECTED AN ERROR IN THE PROTOCOL STREAM AND HAS DISCONNECTED THE CLIENT. CLIENT IP:” AND “THE RDP PROTOCOL COMPONENT X.224 DETECTED AN ERROR IN THE PROTOCOL STREAM AND HAS DISCONNECTED THE CLIENT”ERROR MESSAGES

PROBLEM DESCRIPTION :

You may experience problems if you try to connect to a Windows Server 2008 R2 via RDP. This can also occur in a XenDesktop 7 site with a Windows Server 2008 R2 broker server.

SYMPTOMS :

– RDP Session may freeze.
– Black screen inside RDP window.
– Slow connection.
– You may also be disconnected.
-ICA Sessions may be disconnected without notice

ERROR MESSAGES :

Log Name: System
Source: TermDD
Date: 28.02.2012 08:49:40
Event ID: 56
Task Category: None
Level: Error
Keywords: Classic
User: N/A
Computer: XXXXX
Description:
The Terminal Server security layer detected an error in the protocol stream and has disconnected the client. Client IP: 
xx.xx.xx.xx
Log Name: System
Source: TermDD
Date: 25.02.2012 23:00:59
Event ID: 50
Task Category: None
Level: Error
Keywords: Classic
User: N/A
Computer: XXXXX
Description:
The RDP protocol component X.224 detected an error in the protocol stream and has disconnected the client.

SOLUTION :

The following actions solved the problem in our case.

1) Configure TCP Chimney Offload in the operating system
• To disable TCP Chimney Offload, follow these steps:
a. Use administrative credentials to open a command prompt.
b. At the command prompt, type the following command, and then press ENTER:
netsh int tcp set global chimney=disabled

2) Disable RSS in Windows Server 2008 R2
• To disable RSS, follow these steps:
1. Use administrative credentials to open a command prompt.
2. At the command prompt, type the following command, and then press ENTER:
netsh int tcp set global rss=disabled
• To determine the current status of RSS, follow these steps:
a. Use administrative credentials to open a command prompt.
b. At the command prompt, type the following command, and then press ENTER:
netsh int tcp show global


3
) Disable NetDMA in Windows Server 2008 R2
• To disable NetDMA, follow these steps:
1. Click Start, click Run, type regedit, and then click OK.
2. Locate the following registry subkey, and then click it:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
3. Double-click the EnableTCPA registry entry.
Note If this registry entry does not exist, right-click Parameters, point to New, click DWORD Value, type EnableTCPA, and then press ENTER.
4. To enable NetDMA, type 1 in the Value data box, and then click OK.
5. To disable NetDMA, type 0 in the Value data box, and then click OK.

Information about the TCP Chimney Offload, Receive Side Scaling, and Network Direct Memory Access features in Windows Server 2008
Source : http://support.microsoft.com/kb/951037/en-us

If none of the above does the trick, you can change the Security Layer at the RDP stack and set it to RDP Security Layer from Negotiate

You can change it by going to Remote Desktop Host Configuration – General

Capture10

If the above doesn’t solve the issue for you, the NW card could have gone faulty.