Jaime Frutos Morales's blog

30/12/2010

How to connect to Cisco devices via serial port using GNU/Linux

Filed under: Linux, SysAdmin — acidborg @ 10:17

Description: to connect your computer to a Cisco device via its console port, you usually need a RJ45 rolled cable. You can use a RJ-45 to DB-9 Female if your computer has a serial port.

RJ-45 to DB-9 Female

To communicate through the serial port with the Cisco device, you need Minicom, a terminal emulator software.

Installation:

  • Debian/Ubuntu based distros: sudo apt-get install minicom
  • Red Hat/Fedora based distros: sudo yum install minicom

Steps:

  1. Check whether your serial port is detected by the kernel: dmesg | grep ttyS

    [ 0.485378] serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
    [ 0.485739] 00:07: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
  2. Run Minicom: sudo minicom
  3. Press Ctrl+A Z to enter Minicom’s menu.
  4. Press O to enter configuration submenu.
  5. Enter the serial port setup.
  6. Set the serial device (/dev/ttyS0 in this example).
  7. Press E to set the “Bps/Par/Bits”.
  8. Press C (9600 bps) and Q (8-N-1).
  9. Set software flow control to NO.
  10. Save the configuration as “cisco” (for example)
  11. Press Q to quit Minicom
  12. Run Minicom with the new configuration: sudo minicom cisco

Tip: if you need to send a “Break” through Minicom (on a password recovery operation, for example), use Ctrl+A F .

Advertisements

22/12/2010

How to force a file system check on the next reboot on GNU/Linux

Filed under: Linux, SysAdmin — acidborg @ 14:52

Description: sometimes you need to force a file system check after you reboot your computer. This can be done in two ways:

If you are going to reboot right now:

  • Execute this command (the -F argument forces a file system check): sudo shutdown -Fr now

If you aren’t going to reboot right now:

  • Execute this command: sudo touch /forcecheck
  • Next time you reboot or start your computer, a file system check will be performed.

Alternatively, if you want to avoid a file system check, use this command to reboot your machine: sudo shutdown -fr now

19/12/2010

I passed my CCNA exam!

Filed under: Studies, SysAdmin — acidborg @ 18:19

Last Friday, I passed my CCNA exam.

CCNA certification

I would like to thank GNS3‘s developers and community for their great work.

14/10/2010

How to bind a process to a specific CPU(s) on GNU/Linux

Filed under: Linux, SysAdmin — acidborg @ 13:07

Disclaimer: This recipe is focused on SMP computers only.

Description: CPU affinity is a scheduler property that binds a process to a given set of CPUs on the system, so that the system scheduler won’t run this process on any other CPUs. By default, the scheduler tries to keep processes on the same CPU as long as it makes sense for performance reasons, so forcing CPU affinity is useful only in some cases (per processor licensing, testing, broken hardware, etc).

CPU affinity is represented as a bitmask (given in hexadecimal), with the lowest order bit corresponding to the first logical CPU and the highest order bit corresponding to the last logical CPU. Examples:

  • CPU #0: 0x00000001
  • CPU #1: 0x00000002
  • CPU #2: 0x00000004
  • CPU #3: 0x00000008
  • CPU #0 and CPU #1: 0x00000003
  • CPU #2 and CPU #3: 0x0000000C
  • All CPUs: 0xFFFFFFFF

Taskset is a command used to set or retrieve the CPU affinity of a running process given its PID or to launch a new command with a given CPU affinity.

Installation:

  • Debian/Ubuntu systems: sudo apt-get install util-linux
  • Red Hat/ Fedora systems: sudo yum install util-linux

Usage:

  • Retrieve the CPU affinity of a running process: taskset -p PID
    Example:
    taskset -p 1276
    pid 1276's current affinity mask: 3
  • Set the CPU affinity of a running process: taskset -p MASK PID
    Example:
    taskset -p 0x00000001 9030
    pid 9030's current affinity mask: 3
    pid 9030's new affinity mask: 1
  • Run a new command with a given CPU affinity: taskset MASK COMMAND

You can check if taskset is working using top and pressing “1” to show all CPUs.

13/10/2010

How to configure mod_deflate for Apache on Ubuntu 10.10

Filed under: SysAdmin, Ubuntu — acidborg @ 12:51

Description: mod_deflate is an Apache module which “provides the DEFLATE output filter that allows output from your server to be compressed before being sent to the client over the network.” (from its web). This means that you save some bandwidth in exchange for some CPU cycles compressing the data your Apache server sends.

Installation: If you have Apache installed, you don’t need additional packages, because this module belongs to the package “apache2.2-common“.

Configuration:

  1. Enable the mod_deflate module: sudo a2enmod deflate
  2. Edit /etc/apache2/mods-enabled/deflate.conf with the following content:
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/x-javascript application/javascript application/ecmascript application/rss+xml text/x-js
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
  3. Restart Apache: sudo /etc/init.d/apache2 restart

NOTE: There are some old versions of some browsers which don’t support this kind of compression, although it’s included in RFC 2616 (HTTP/1.1). http-compression.com has more info about it.

08/10/2010

How to install and configure Ganglia on Red Hat Enterprise Linux 5

Filed under: Linux, SysAdmin — acidborg @ 13:34

Description: Although Gangliais a scalable distributed monitoring system for high-performance computing systems such as clusters and Grids” (from its web), I’m going to explain how to set up Ganglia as a monitoring system for a group of computers which are neither part of a cluster nor a grid. Ganglia has very low per-node overheads and high concurrency, which makes it perfect to monitor a huge group of servers. I’m going to use one server to collect all data from the nodes. The collector server will run the web front-end for simplicity reasons, although you can install the web front-end on any other server if you need it.

Installation:

  1. Add the EPEL repositories to your systems.
  2. Install the data collector (gmetad), the monitoring daemon (gmond) and the web front-end on the collector server: yum install ganglia ganglia-gmetad ganglia-web ganglia-gmond
  3. install gmond on each node you want to monitor: yum install ganglia ganglia-gmond

Configuration on the collector server (for example: collector.mycompany.com):

  1. Edit /etc/gmetad.conf and modify the line which begins with “data_source“. Example:
    data_source "my servers" 60 localhost

    This will collect data from the groups of machines tagged as “my servers” every 60 seconds. It will use localhost as the source of the info.

  2. Edit /etc/gmond.conf and modify the following part:
    cluster {
    name = "my servers"
    owner = "unspecified"
    latlong = "unspecified"
    url = "unspecified"
    }
    udp_send_channel {
    host = collector.mycompany.com
    port = 8649
    }
    udp_recv_channel {
    port = 8649
    }
    tcp_accept_channel {
    port = 8649
    }

    This allows collector.mycompany.com to receive monitoring data from every node on port 8649(UDP).

  3. Restart the collector daemon (gmetad): service gmetad restart
  4. Restart the node daemon (gmond): service gmond restart

Configuration on each node you want to monitor (except collector.mycompany.com):

  1. Edit /etc/gmond.conf and modify the following part:
    cluster {
    name = "my servers"
    owner = "unspecified"
    latlong = "unspecified"
    url = "unspecified"
    }
    udp_send_channel {
    host = collector.mycompany.com
    port = 8649
    }
    /*udp_recv_channel {
    }
    tcp_accept_channel {
    }*/

    This tells gmond to send the info to collector.mycompany.com on port 8649(UDP).

  2. Restart gmond: service gmond restart

After a few minutes, you will have your monitoring data available through: collector.mycompany.com/ganglia .

17/09/2010

How to automatically start KVM virtual machines on boot

Filed under: Linux, SysAdmin, Virtualization — acidborg @ 13:18

Description: when you have a host machine running KVM and it runs several guests (virtual machines), it’s very useful to make them start on boot so that you don’t have to start them manually.

Steps:
Just execute the following command for each guest you want to autostart on boot: virsh autostart guest_name .

02/09/2010

How to synchonize your Ubuntu 10.04 desktop with a NTP server

Filed under: SysAdmin, Ubuntu — acidborg @ 12:21

Description: On my previous post, I explained how to install and configure a NTP server on your local network. Now I’m going to explain how to synchronize an Ubuntu 10.04 computer with your local NTP server.

Installation: apt-get install ntpdate

Configuration:

  1. Create the file /etc/cron.d/ntpdate.cron with the following content (modifying “your-ntp-server” with the name or IP address of your NTP server):
    15 */1 * * * root /usr/sbin/ntpdate your-ntp-server &> /dev/null
  2. This will synchronize your computer’s clock with the NTP server every hour. If you want to increase the synchronization period, increase the “/1”. For example: Use 15 */6 * * * root /usr/sbin/ntpdate your-ntp-server &> /dev/null to synchronize your computer’s clock every 6 hours.
  3. Set the proper owner and permissions for the created file: chmod 600 /etc/cron.d/ntpdate.cron && chown root:root /etc/cron.d/ntpdate.cron

31/08/2010

How to install and configure a NTP server for your network on Ubuntu Server 10.04

Filed under: SysAdmin, Ubuntu — acidborg @ 13:29

Description: The Network Time Protocol (NTP) is a protocol for synchronizing the clocks of computer systems over a network. It is very useful if you want all the computers on your network to share the same time because file accesses, logs, tasks, etc will be synchronized. I’m going to explain how to install a NTP server on your network so that the rest of computers can synchronize with it.

Installation: apt-get install ntp

Configuration:

  1. Go to www.pool.ntp.org, select your continent on the Active servers list and your country (or the nearest one) on the next list.
  2. You will be given a list of public NTP servers to synchronize your server with. For example, if you live in Spain, you will be given the following list of NTP servers: server 2.es.pool.ntp.org , server 0.europe.pool.ntp.org , server 2.europe.pool.ntp.org .
  3. Edit your /etc/ntp.conf file using the list of servers you were given:
    server 1.es.pool.ntp.org
    server 0.europe.pool.ntp.org
    server 2.europe.pool.ntp.org
    restrict -4 default kod notrap nomodify nopeer noquery
    restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap noquery
    restrict 127.0.0.1
    driftfile /var/lib/ntp/ntp.drift
  4. Change the line “restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap noquery” with your subnet IP and netmask.
  5. Restart your NTP server: /etc/init.d/ntp restart

Some seconds later, your NTP server will begin to synchronize with the external time servers. It may take a couple of minutes to get your computer’s clock synchronized, so please be patient. You can check your NTP server’s stats and status with the following command: ntpq -p .

NOTE: your NTP server must be reachable on port 123 (UDP) from the remote time servers, so make sure your firewall allows it.

On my next post, I will explain how to synchronize your GNU/Linux computers with the NTP server you have just installed.

24/06/2010

How to install and configure Apt-Cacher NG on Ubuntu Server 10.04

Filed under: Linux, SysAdmin, Ubuntu — acidborg @ 13:34

Description: Apt-Cacher NG is a caching proxy specialized for package files from GNU/Linux distributors, primarily for Debian and Debian based distributions (like Ubuntu). This means that if you have many Debian/Ubuntu machines on your network, you just have to download the deb packages (new software, updates, distro upgrades, etc) from the internet once and the rest of the Debian/Ubuntu machines get them from Apt-Cacher NG cache, saving time and internet bandwidth. To install it, follow these simple steps:

Steps:

  1. Installation: apt-get install apt-cacher-ng
  2. Configuration: Edit /etc/apt-cacher-ng/acng.conf with the following content:
    CacheDir: /var/cache/apt-cacher-ng
    LogDir: /var/log/apt-cacher-ng
    Port:3142
    BindAddress: 0.0.0.0
    Remap-debrep: file:deb_mirror*.gz /debian ; file:backends_debian
    Remap-uburep: file:ubuntu_mirrors /ubuntu ; file:backends_ubuntu
    PidFile: /var/run/apt-cacher-ng/pid
    ExTreshold: 4
  3. Restart Apt-Cacher NG: /etc/init.d/apt-cacher-ng restart
  4. Create on the rest of the Debian/Ubuntu machines on the network the file /etc/apt/apt.conf.d/02proxy with the following content:
    Acquire::http { Proxy "http://your-apt-cacher-ng-server:3142"; };

Next time any of your machines needs a deb package, it will ask Apt-Cacher NG for it. If this package was asked previously by any of the other machines, Apt-Cacher will have a copy and will deliver it. Otherwise, it will fetch it from the internet repositories, keep a local copy and deliver it.

Older Posts »

Create a free website or blog at WordPress.com.