FreeBSD update ports

As referred here: https://www.freebsd.org/doc/handbook/ports-using.html

The Ports Collection is a set of Makefiles, patches, and description files stored in /usr/ports. This set of files is used to compile and install applications on FreeBSD. Before an application can be compiled using a port, the Ports Collection must first be installed. If it was not installed during the installation of FreeBSD, use one of the following methods to install it:

# portsnap fetch
# portsnap extract
# portsnap fetch update

So I think a
# portsnap fetch update
is enough for allready Ports Collection installed freebsd systems.

digitalocean vps

I recently changed my web hosting provider and decided to host my blog at a vps to digitalocean.com in order to check the service provided by this company. From now on, this website is hosted in a vps @ digitalocean.com . I am totally satisfied and I became a fan of digitalocean.com! My low end vps 512Mb ram with 1 vcpu and 20gb ssd is extremely fast! This was an excellent choice with only 5$ per month! Try it yourself to believe it!

digitalocean

MySQL repair myisam table fails

I play the role of the “MySQL administrator” in some cases without having the appropriate expertise or knowledge, and in some cases, I find myself against some first time seeing situations. One situation like this I had never faced before was to fail the repair table command when a myIsam table is corrupted. For everyone there is a first time. Let’s see what the problem was:

I got connected through mysql client as root to the database server, I selected my database through use command and tried to execute the repair:


mysql -h localhost -u root -p
use database_name;
repair table table_name;

The output was:

Found link that points at 5427775770519881079 outside data file) at 788525176
Found block with too small length at 872968268; Skipped
Found link that points at 5131911463743613025 (outside data file) at 886920912
Found link that points at 5131911463743613025 (outside data file) at 888429508
Found block with too small length at 892989976; Skipped
Found block with too small length at 893943488; Skipped
Found block with too small length at 896942348; Skipped
Not enough memory for blob at 919756416 (need 1416319567)
Operation failed

This error probably means that your variable sort_buffer_size is not high enough to repair the table.
Everytime I tried to repair a table it was a success story! And now what? Don’t get anxious! There is another way to repair your corrupted myIsam table. There is a command line tool, myisamchk that you can use. Now take some care because this tool needs to be the only process that uses the corrupted table. You can choose to shutdown the database server, or there are lot of critical applications running on this database server, you have to stop the services that use the database which has the corrupted table. For example the database in which I had the corrupted table was used by two applications, webmail and sympa mailing list server. The corrupted table was inside the database sympa uses. I took the sympa service offline and then I was sure that this database was not accessed by anything else.

Thus, after reassuring that noone access the table you want to repair, you have to do the following steps:
1. cd to the data dir of the database where table_name.MYI file exists. Lets say mine was at :/var/data/mysql/data/sympa/
cd /var/data/mysql/data/sympa/
2. Check what’s your available free memory using something like top, leave a little memory ballon and decice the value of sort_buffer_size. Let’s use an example, if top gives about 3Gb of total ram free and cached then use sort_buffer_time=2G as soon in the example below:
myisamchk -o -f table_name.MYI -sort_buffer_size=2G
3. If this is successfull you are done! Just check the table status:

mysql -h localhost -u root -p
use database_name;
check table table_name;

else if the operation failed, maybe it’s a good idea to shutdown the mysql server, to free more ram and try again with higher value of sort_buffer_size.

It’s good to see this MySQL article too:

http://dev.mysql.com/doc/refman/5.7/en/myisam-repair.html

My first class on Coursera

It was three months ago since I decided to have a new experience with coursera. It was my first time on e-learning. I am a post-graduate student on Computer Engineering and Informatics Department of University of Patras (Greece). So I thought that an introduction class to a programming language wouldn’t be so tough. I have learned the basics of dozen programming languages. I was interested in learning python, and that was the chance for me. I choose the class: An Introduction to Interactive Programming in Python, more for python and less for the Interactive part. That was my fault, because it was my first experience in Interactive Programming and it was so cool!!! Python was just the starting tool. I completed successfully the class with a grade of 99.4%. Event driven programming combined with object driven and test driven programming was a very nice experience. Now I am going to have more classes, in order to widen my area of interests in Computer Science. Below is a screenshot of my Statement of Accomplishment. I recommend to any of you whatever level of your expertise to attend a class on coursera.
Coursera interactivepython 2013

mount ISO file in linux

In this article we will describe the procedure to mount an ISO image file as a physical device

1) You must login as a root user, if not root user then switch to root user using following command:

$ su -

2) Create the directory i.e. mount point:

# mkdir -p /mnt/disk

3) Use mount command as follows to mount iso file called disk1.iso:

# mount -o loop disk1.iso /mnt/disk

4) Change directory to list files stored inside an ISO image:


# cd /mnt/disk
# ls -l

I hope you enjoy!

Centos – change hostname

To permanent change your hostname you have to edit the /etc/sysconfig/network file and set the variable HOSTNAME to your needs.

vi /etc/sysconfig/network

give the value you want to HOSTNAME variable like the following example:

HOSTNAME=myhost1.example.com

now this change will take effect after a reboot. There is a way to avoid reboot. You have to run the following command:

echo "myhost1.example.com" > /proc/sys/kernel/hostname

and that’s all!!!

Managing network on FreeBSD

FreeBSD administration is a little bit different from linux. At the moment I had only experience as a hobbyist. Now I have to prepare my self for more enterprise experience on this Operating System.

That was an a little introduction about why I am going to post some freebsd relative articles.

Lets get into the issue of the article.

In order to restart network you have to run the following command:

service netif restart

This is not going to change routing tables produced before.
If you want to reproduce the routing tables you have to the following command:

service routing restart

And now if you want to do it in a simple command:

service netif restart && service routing restart

That was about services!

Now let’s see how you can manage interfaces.

the old time classic method to see the status of all interfaces:

ifconfig -a

to list the down network interfaces:

ifconfig -d

to list the up network interfaces:

ifconfig -u

to stop a network interface:

ifconfig network-interface down

to start a network interface:

ifconfig network-interface up

Now let’s see how to view the routing table:

netstat -rn

One of my future posts will be about disabling ipv6 networking.

set locale terminal settings on Mac OS X

One of my first experiences with Mac OS, was the locale errors and warnings when using ssh connections. Then I understood, that this was a problem occurred by mac os terminal. Locale settings by default are accepted from ssh client.

Then I run:

$locale

and the output was:

LANG=
LC_COLLATE="C"
LC_CTYPE="C"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=

I then edited /etc/profile and added these two lines:

export LC_ALL=en_US.UTF-8  
export LANG=en_US.UTF-8

Then I opened a new terminal session and run:

$locale

and the output was:

LANG="en_US.UTF-8"  
LC_COLLATE="en_US.UTF-8"  
LC_CTYPE="en_US.UTF-8"  
LC_MESSAGES="en_US.UTF-8"  
LC_MONETARY="en_US.UTF-8"  
LC_NUMERIC="en_US.UTF-8"  
LC_TIME="en_US.UTF-8"  
LC_ALL="en_US.UTF-8"

After these committing these changes, I transfer my locale settings to my ssh connections and all problems solved.

How to disable ipv6 networking – CentOS

There are some simple steps to follow, in order to disable ipv6 networking on CentOS. This simple guide is about CentOS 6.4, but I think that it will work on both a little older or next versions of this Operating System.

Step 1: add this rule in /etc/sysctl.conf : net.ipv6.conf.all.disable_ipv6 = 1

Step 2: add this rule in /etc/sysconfig/network: NETWORKING_IPV6=no

Step 3: add this setting for each nic X (X is the corresponding number for each nic) in /etc/sysconfig/network-scripts/ifcfg-ethX: IPV6INIT=”no”

Step 4: disable the ip6tables service : chkconfig ip6tables off

Step 5: reboot

freeBSD – make install clean accept default config or configure all at start

I am new to the freeBSD world. I am trying to figure out how to do things like install some packages. I was not familiar with ports at all. All my experience is around linux repositories.

So firstly, i tried to figure out how to find available packages to install, and thus I discovered whereis command:

whereis apache*

and the output is:

# whereis apache*
apache-forrest: /usr/ports/www/apache-forrest
apache-mode.el: /usr/ports/www/apache-mode.el
apache22: /usr/ports/www/apache22
apache22-event-mpm: /usr/ports/www/apache22-event-mpm
apache22-itk-mpm: /usr/ports/www/apache22-itk-mpm
apache22-peruser-mpm: /usr/ports/www/apache22-peruser-mpm
apache22-worker-mpm: /usr/ports/www/apache22-worker-mpm
apache24: /usr/ports/www/apache24

after choosing the package I want to install, I go to it’s port directory. For example to install apache2.4 I have to go to :

cd /usr/ports/www/apache24

and then I have to compile and install this package by executing:

make install clean

Now the problem sometimes is that most of the packages have configuration options in which, I have to manually choose the options. So if I install packageA with a lot of dependencies, those dependencies may have each a configuration option in which I have to make selections. There are a lot of interruptions, in the installing procedure. I need to be over the terminal and waiting for an interruption. This is time consuming and not productive at all.

So my first thought was to find a way to install packages with the default configuration options. I found this one:

make -DBATCH install clean

 

Then as a System Administrator, I thought that’s not my case, it’s a common usage case, but I need to know and configure some things. So I found how to make all the configurations needed recursively and then install the package:

make config-recursive
make install clean

You have to run make config-recursive as many times as needed to configure all dependencies. You have to do this, until all dependent ports options have been defined, and ports options dialog(1) screens no longer appear, to be certain all ports options have been configured as intended.

 

In order you want to reconfigure the package(s) you want to compile, then you have to run:

make rmconfig-recursive

I hope you find this post helpfull. As I go deeper with freeBSD, I like it more.

Source: http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/ports-using.html