Posts Tagged ‘host’

How to backup and restore your MySQL database or table structure to in Linux

Whenever there is a database involved, an important task that should never be neglected is backing it up. In the case of MySQL on a Linux machine, backing up consists of executing a single command.
Backing up a MySQL database can be done with one simple command:

mysqldump -h <host> -u <user> -p<password> <db_name> > backup.sql

For example if you want to backup a local database called db1 using the user user1 with password pass1 you should write:

mysqldump -h localhost -u user1 -ppass1 db1 > backup.sql

The backup.sql file contains an SQL query for creating the exact same database. Restoring such a dump-file is just a matter of one command too:

mysql -h <host> -u <user> -p<password> <db_name> < backup.sql

Following the naming from our previous example will result in the following command to restore the database:

mysql -h localhost -u user1 -ppass1 db1 < backup.sql

In the perfect environment the backup should be created by a cronjob or anacronjob.
Another useful thing that one may want to backup is the table structure. For tables whose structure is relatively often changed this can prove to be very helpful. It is done by using one simple modification of the command for backing up an entire database:

mysqldump -d -h <host> -u <user> -p<password> <db_name> > backup.sql

Did you notice the difference? It is the -d option, which specifies that data should not be dumped. Using our previous examples this will be transform to:

mysqldump -d -h localhost -u user1 -ppass1 db1 > backup.sql
VN:F [1.9.18_1163]
Rating: 6.3/10 (3 votes cast)

Creating host-specific PuTTY shortcuts

When using PuTTY with multiple hosts and/or with multiple sessions, there is always the problem of entering the same information many, many times. Now, you can always go for the key-based SSH login with PuTTY, which is a secure way of doing this, but here, we will present you an easier and simpler way of auto-login using PuTTY shortcuts.

First, you must obtain a copy of the PuTTY client (available here). Now, after downloading it, open PuTTY:

In the Host Name field enter the name of the host, set the port in Port and enter a name for the session in the Saved Sessions text field:

Click Save to save your profile. Now when you double-click on the entry in the Saved Sessions or click on it, click Load and click Open your PuTTY client will automatically connect to it. You can save every host you like in the Saved Sessions:

Now here is the really nice part. Create a shortcut to PuTTY and open its Properties:

Now after the current Target (after the if any, and don’t forget a space), you can add a few arguments to automatically log into a saved session. The possible arguments are:

-load “<session_name>” – for automatically loading a session. Note: <session_name> is a saved session name and not a hostname.

-l <username> – for automatically entering a username on the host.

-pw <password> – for automatically entering a password.

Note: Using the -pw option is not secure in any way. If you use it you are storing your password in plain-text. If you have any doubts about how secure your machine is, please refer to the key-based SSH login.

It is also possible to only use some of those arguments, so for example if you want to load a session and a username you can only use the -load and -l options. Or if you use the same credentials for more than one host (which is bad, bad, bad…), you can omit the -load option. So, an automatic login on the host specified in the session ABlog with username root and password badandtrivial will be:

“D:\<path_to_putty>\putty.exe” -load “ABlog” -l root -pw badandtrivial

Note: This method is not in any way secure. It is merely a method to speed up your work, but stores passwords in plain-text.

So after editing a shortcut’s properties you only click OK to save. You can easily have multiple shortcuts:

Still, secure or not, it can be used for any non critical information. It is not, in any way, more dangerous than storing passwords in browsers…

VN:F [1.9.18_1163]
Rating: 3.3/10 (3 votes cast)

How to setup Apache HTTP and HTTPS virtual hosts

Virtual hosting is a way of hosting several servers on a single machine. This technique is widely used in shared web hosting, because it greatly reduces hosting costs, since multiple customers use one server.

There are three types of virtual hosting:

  • Name-based – when the virtual hosts is determined by its domain. A problem with this approach is that it is completely dependent on the DNS.
  • IP-based – when each site is differentiated via his IP. A natural complication is that this requires a different IP for each site.
  • Port-based – when each site is described with the same domain, but different port. Naturally, the problem that users don’t generally use ports arises. Additionally, some firewalls block uncommon ports.

Using Apache, we will setup two name-based virtual hosts – an HTTP one and an HTTPS one. Both will work on the standard ports 80 for HTTP and 443 for HTTPS. Naturally we will see how to set port-based hosts.

Note: This tutorial assumes standard file places and settings for Apache on CentOS.

Note: The goal of this tutorial is not to provide extensive knowledge on configuring virtual hosts, but to provide a general-purpose working configuration. For more find-tuned configurations refer to the Apache documentation on virtual hosts.

We assume that <domain> is the domain for our virtual host. In the httpd/conf.d directory (usually /etc/httpd/conf.d) create a file called <domain>.conf

Note: It is not necessary to call your file <domain>.conf, but it’s a sort of a convention and makes editing hosts easier. The file for the HTTP virtual host should contain:

# <domain> HTTP Virtual Host
<VirtualHost *:80>
    # General
    ServerAdmin <administrator_e_mail>
    DocumentRoot /var/www/html/<domain>
    ServerName www.<domain>
    ServerAlias <domain>
 
    # Logging
    ErrorLog logs/<domain>-error_log
    CustomLog logs/<domain>-access_log common
</VirtualHost>

<administrator_e_mail> is the e-mail of the site administrator. After you set this file restart the HTTP Server daemon:

service httpd restart

To setup an HTTPS virtual host, again create the <domain>.conf file in the /httpd/conf.d. Again we assume <domain> is the domain-name:

# <domain> HTTPS Virtual Host
<VirtualHost *:443>
    # General
    ServerAdmin <administrator_e_mail>
    DocumentRoot /var/www/html/<domain>
    ServerName www.<domain>
    ServerAlias <domain>
 
    # Logging
    ErrorLog logs/<domain>-ssl_error_log
    TransferLog logs/<domain>-ssl_access_log
    CustomLog logs/<domain>-ssl_request_log "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
    LogLevel warn
 
    # SSL Engine
    SSLEngine on
 
    # SSL Protocol
    SSLProtocol all –SSLv2
 
    # SSL Cipher Suite
    SSLCipherSuite LL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW
 
    # Server Certificate
    SSLCertificateFile <path_to_certificate>
 
    # Server Private Key
    SSLCertificateKeyFile <path_to_private_key>
 
    # SSL Engine Options
    <Files ~ "\.(cgi|shtml|phtml|php3?)$">
        SSLOptions +StdEnvVars
    </Files>
    <Directory "/var/www/cgi-bin">
        SSLOptions +StdEnvVars
    </Directory>
 
    # SSL Protocol Adjusments
    SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown owngrade-1.0 force-response-1.0
</VirtualHost>

Of course, after setting this, restart the HTTP daemon:

service httpd restart

It is easily noticeable, that you can setup port-based virtual hosts quite easy, by using the same domain, but different ports in the .conf file.

Naturally this tutorial is not exhaustive, as such tutorial will be pretty much equal to documentation (which you can find here).

VN:F [1.9.18_1163]
Rating: 7.0/10 (2 votes cast)

Creating Persistent Aliases in PowerShell

In this tutorial, you will learn how to create persistent aliases.

I’m sure creating temporary aliases has been fun and all, but let’s get more usefulness out of them by making them permanently available! In this tutorial, you will learn how to create persistent aliases.

Setup
If you have not already done so, click open Windows PowerShell ISE.

The Concept…
There really is no point in making something temporary unless it was meant to be temporary. Making a permanent alias is helpful and far more efficient. The best part about it is that all of this can be done by defining aliases in your profile script. Since the profile is executed every time you open a new PSH window, it’s the perfect location to define your aliases of choice so they’re immediately available to you the moment you open up PSH.

There are two commands that PSH has that will assist in making the aliases persistent. They are called Export-Alias (exports the alias information to a file) and Import-Alias. You can define the aliases on one system, export the alias definition and then distribute it to all the other systems.

Yes, it is possible to find a good web host. Sometimes it takes a while to find one you are comfortable with. After trying several, we went with Server Intellect and have been very happy thus far. They are by far the most professional, customer service friendly and technically knowledgeable host we’ve found so far.

Step one.
To export and import your aliases, run the following command sequence:
Export-Alias c:thealiases.txtImport-Alias c:thealiases.txt

Now, as a side note, by default the Export-Alias command overwrites the contents of a file it automatically created. If you wish to not overwrite, you can implement the noclobber parameter so the command returns an error if the file already exists.

The command is implemented as follows:
Code Block

Ask a Question

PSH Command

Export-Alias c:thealiases.txt –noclobber Also, there is the option to append to an existing alias file. This feature is great if you have aliases defined in various locations and are trying to consolidate them into a single file. Read the rest of this entry »

VN:F [1.9.18_1163]
Rating: 0.9/10 (11 votes cast)

How to clear the ARP cache in Windows 7

The Address Resolution Protocol (ARP) is a computer networking protocol that is used to determine a host’s MAC address using its IP. The ARP cache contains the latest IP to MAC mappings and is used to minimize ARP requests. However, sometimes the ARP cache may be responsible for slow connections and sometimes (although extremely rare) for timeouts. So, let’s learn how to flush the ARP cache. Read the rest of this entry »

VN:F [1.9.18_1163]
Rating: 0.0/10 (0 votes cast)

Top 10 basic networking command in unix

These are most useful command in my list while working on Linux server , this enables you to quickly troubleshoot connection issues e..g whether other system is connected or not , whether other host is responding or not etc.

This commands are very handy for troubleshooting day by day networking issues, having this networking commands its not just save time but also improves productivity.

I work as a Java , FIX developer for trading application . Since working with FIX involves lots of networking activity I used these commands every day and it saves quite a lot of time while identifying FIX connection issues. Read the rest of this entry »

VN:F [1.9.18_1163]
Rating: 0.0/10 (0 votes cast)

config multiple servers in phpmyadmin

In this tutorial we will give you an example configuration for PhpMyAdmin from which we can manage more than one mysql server.

PhpMyAdminis very powerful and flexible web based database administration tool. For this feature, that the tools is web based he is platform independent and can work under Windows, Linux, Unix, Apple etc. platfroms.

In our first tutorial we have given you complete list of instructions for How to Configure PhpMyAdmin for one server.

As you already know the main configuration file for phpmyadmin is called config.inc.php
In there you have a section that looks like this.

Note that the comments were slightly modified by me ;). Read the rest of this entry »

VN:F [1.9.18_1163]
Rating: 7.6/10 (7 votes cast)

Install and configure heartbeat

The Heartbeat program is one of the core components of the Linux-HA (High-Availability Linux) project

The installation is pretty simple and straight forward process. For the purposes of this tutorial we have used RedHat Enterprise Linux 4.

Dependency package is: libnet-1.0.2-2.2.el4.rf.i386.rpm

It can easily be installed with the following command
rpm -Uvh libnet-1.0.2-2.2.el4.rf.i386.rpm

Now we ready to continue with the installation of heatbeat itself

mkdir /usr/local/src/packs
cd /usr/local/src/packs/
wget http://linux-ha.org/download/heartbeat-2.0.8.tar.gz
tar –zxvf heartbeat-2.0.8.tar.gz
cd heartbeat-2.0.8
./ConfigureMe configure
make
make install

Copy or create two main configuration files – ha.cf and haresources in /etc/ha.d/
Below follows a config example of a high availability system with 2 identical nodes which will share an IP address.

Here is an example configuration for /etc/ha.d/ha.cf is on the first host :
Read the rest of this entry »

VN:F [1.9.18_1163]
Rating: 0.0/10 (10 votes cast)

How to Use or Get Dynamic IP Address for Host

If you are using Internet connection to your Internet service provider by a dialup, adsl or cable modem or you don”t have a static IP address, every time when you connect you probably get different (dynamic) IP address. If you want to play online games directly with your friend or want to use some network service like web server, mail server, ftp server or just need to connect to your PC outside through Remote Desktop this will be problem for you, because every time the network service will be with different IP Address.

If you in this situation, there is one solution for you – DynDNS.com. There is a free service, which give you a fixed sub domain name from DynDNS region and assign to this address your host, no matter what is current IP adress at each moment. Read the rest of this entry »

VN:F [1.9.18_1163]
Rating: 0.2/10 (10 votes cast)

Strip SSL with Apache mod_proxy part two

Greetings, reader.

This tutorial is the second part of the setup instructions how to Strip SSL part of a request with Apache mod_proxy. Lets remind you what the situation was. We have server A which has SSL support and can handle the initial request. Then we have server B which is supposed actually to handle the request but doesn”t support SSL. The goal is to relay the request which landed on Server A and to pass it to Server B

You can read the first part of the tutorial here Strip SSL with Apache mod_proxy part one

So the first part ended up with configuring a virtual host to handle HTTP request on Server A.

Now we need to configure a virtual host to handle HTTPS requests. Open /usr/local/apache2/conf/extra/httpd-ssl.conf with your favorite editor.

Read the rest of this entry »

VN:F [1.9.18_1163]
Rating: 5.5/10 (2 votes cast)