Photos
Reviews
4.8
8 Reviews
Tell people what you think
Posts

How to Install and Configure Ansible on CentOS 7

Introduction

Configuration management systems are designed to make controlling large numbers of servers easy for administrators and operations teams. They allow you to control many different systems in an automated way from one central location. While there are many popular configuration management systems available for Linux systems, such as Chef and Puppet, these are often more complex than many people want or need. Ansible ...

Continue Reading

Linux Interview Questions Answers

This article presents a basic collection of Linux interview questions with answers.
What is Kerberos used for?

...Continue Reading

RHEL 6 vs RHEL 7 Difference Between Previous and Newer Version

by ARK · Published January 20, 2017 · Updated January 25, 2017

Red Hat Enterprise Linux 7 is an major / drastic change to enterprise. To serve / meet today’s business critical application performance RHEL 7 is the best Operating system to use, very light weight and container based. In this article we are going to see RHEL 6 vs RHEL 7 Difference Between Previous and Newer Version. RHEL 7 vs RHEL 6....

Continue Reading

How To Set Up Master Slave Replication in MySQL

About MySQL replication

MySQL replication is a process that allows you to easily maintain multiple copies of a MySQL data by having them copied automatically from a master to a slave database. This can helpful for many reasons including facilating a backup for the data,a way to analyze it without using the main database, or simply as a means to scale out.

...Continue Reading

How To Set Up MySQL Master-Master Replication
PostedApril 26, 2013 532.2k views MySQL Scaling Backups
Intro

This second installment of "Scaling Web Applications..." will list out the steps necessary for scaling a mysql deployment over two VPS.

The first article in this series laid out the steps needed to load-balance nginx over two VPS, and it is recommended that you read that article first.

MySQL replication is the process by which a single data set, stored in a MySQL database, will be live-copied to a second server. This configuration, called "master-slave" replication, is a typical setup. Our setup will be better than that, because master-master replication allows data to be copied from either server to the other one. This subtle but important difference allows us to perform mysql read or writes from either server. This configuration adds redundancy and increases efficiency when dealing with accessing the data.

The examples in this article will be based on two VPS, named Server C and Server D.

Server C: 3.3.3.3

Server D: 4.4.4.4
Step 1 - Install and Configure MySQL on Server C

The first thing we need to do is to install the mysql-server and mysql-client packages on our server. We can do that by typing the following:

sudo apt-get install mysql-server mysql-client

By default, the mysql process will only accept connections on localhost (127.0.0.1). To change this default behavior and change a few other settings necessary for replication to work properly, we need to edit /etc/mysql/my.cnf on Server C. There are four lines that we need to change, which are currently set to the following:

#server-id = 1
#log_bin = /var/log/mysql/mysql-bin.log
#binlog_do_db = include_database_name
bind-address = 127.0.0.1

The first of those lines is to uniquely identify our particular server, in our replication configuration. We need to uncomment that line, by removing the "#" before it. The second line indicates the file in which changes to any mysql database or table will be logged.

The third line indicates which databases we want to replicate between our servers. You can add as many databases to this line as you'd like. The article will use a single database named "example" for the purposes of simplicity. And the last line tells our server to accept connections from the internet (by not listening on 127.0.0.1).

server-id = 1
log_bin = /var/log/mysql/mysql-bin.log
binlog_do_db = example
# bind-address = 127.0.0.1

Now we need to restart mysql:

sudo service mysql restart

We next need to change some command-line settings within our mysql instance. Back at our shell, we can get to our root mysql user by typing the following:

mysql -u root -p

Please note that the password this command will prompt you for is that of the root mysql user, not the root user on our droplet. To confirm that you are logged in to the mysql shell, the prompt should look like the following.

mysql>

Once we are logged in, we need to run a few commands.

We need to create a pseudo-user that will be used for replicating data between our two VPS. The examples in this article will assume that you name this user "replicator". Replace "password" with the password you wish to use for replication.

create user 'replicator'@'%' identified by 'password';

Next, we need to give this user permissions to replicate our mysql data:

grant replication slave on *.* to 'replicator'@'%';

Permissions for replication cannot, unfortunately, be given on a per-database basis. Our user will only replicate the database(s) that we instruct it to in our config file.

For the final step of the initial Server C configuration, we need to get some information about the current MySQL instance which we will later provide to Server D.

The following command will output a few pieces of important information, which we will need to make note of:

show master status;

The output will looking similiar to the following, and will have two pieces of critical information:

+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000001 | 107 | example | |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)

We need to make a note of the file and position which will be used in the next step.
Step 2 - Install and Configure MySQL on Server D

We need to repeat the same steps that we followed on Server C. First we need to install it, which we can do with the following command:

sudo apt-get install mysql-server mysql-client

Once the two packages are properly installed, we need to configure it in much the same way as we configured Server C. We will start by editing the /etc/mysql/my.cnf file.

sudo nano /etc/mysql/my.cnf

We need to change the same four lines in the configuration file as we changed earlier.

The defaults are listed below, followed by the changes we need to make.

#server-id = 1
#log_bin = /var/log/mysql/mysql-bin.log
#binlog_do_db = include_database_name
bind-address = 127.0.0.1

We need to change these four lines to match the lines below. Please note, that unlike Server C, the server-id for Server D cannot be set to 1.

server-id = 2
log_bin = /var/log/mysql/mysql-bin.log
binlog_do_db = example
# bind-address = 127.0.0.1

After you save and quit that file, you need to restart mysql:

sudo service mysql restart

It is time to go into the mysql shell and set some more configuration options.

mysql -u root -p

First, just as on Server C, we are going to create the pseudo-user which will be responsible for the replication. Replace "password" with the password you wish to use.

create user 'replicator'@'%' identified by 'password';

Next, we need to create the database that we are going to replicate across our VPS.

create database example;

And we need to give our newly created 'replication' user permissions to replicate it.

grant replication slave on *.* to 'replicator'@'%';

The next step involves taking the information that we took a note of earlier and applying it to our mysql instance. This will allow replication to begin. The following should be typed at the mysql shell:

slave stop;
CHANGE MASTER TO MASTER_HOST = '3.3.3.3', MASTER_USER = 'replicator', MASTER_PASSWORD = 'password', MASTER_LOG_FILE = 'mysql-bin.000001', MASTER_LOG_POS = 107;
slave start;

You need to replace 'password' with the password that you have chosen for replication. Your values for MASTER_LOG_FILE and MASTER_LOG_POS may differ than those above. You should copy the values that "SHOW MASTER STATUS" returns on Server C.

The last thing we have to do before we complete the mysql master-master replication is to make note of the master log file and position to use to replicate in the other direction (from Server D to Server C).

We can do that by typing the following:

SHOW MASTER STATUS;

The output will look similiar to the following:

+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000004 | 107 | example | |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)

Take note of the file and position, as we will have to enter those on server C, to complete the two-way replication.

The next step will explain how to do that.
Step 3 - Completing Replication on Server C

Back on Server C, we need to finish configuring replication on the command line. Running this command will replicate all data from Server D.


slave stop;
CHANGE MASTER TO MASTER_HOST = '4.4.4.4', MASTER_USER = 'replicator', MASTER_PASSWORD = 'password', MASTER_LOG_FILE = 'mysql-bin.000004', MASTER_LOG_POS = 107;
slave start;

Keep in mind that your values may differ from those above. Please also replace the value of MASTER_PASSWORD with the password you created when setting up the replication user.

The output will look similiar to the following:

Query OK, 0 rows affected (0.01 sec)

The last thing to do is to test that replication is working on both VPS. The last step will explain an easy way to test this configuration.
Step 4 - Testing Master-Master Replication

Now that have all the configuration set up, we are going to test it now. To do this, we are going to create a table in our example database on Server C and check on Server D to see if it shows up. Then, we are going to delete it from Server D and make sure it's no longer showing up on Server C.

We now need to create the database that will be replicated between the servers. We can do that by typing the following at the mysql shell:

create database example;

Once that's done, let's create a dummy table on Server C:

create table example.dummy (`id` varchar(10));

We now are going to check Server D to see if our table exists.


show tables in example;

We should see output similiar to the following:

+-------------------+
| Tables_in_example |
+-------------------+
| dummy |
+-------------------+
1 row in set (0.00 sec)

The last test to do is to delete our dummy table from Server D. It should also be deleted from Server C.

We can do this by entering the following on Server D:

DROP TABLE dummy;

To confirm this, running the "show tables" command on Server C will show no tables:

Empty set (0.00 sec)

And there you have it! Working mysql master-master replication. As always, any feedback is more than welcome.

See More
3.3.3.3

How To Set Up MySQL Master-Master Replication
PostedApril 26, 2013 532.2k views MySQL Scaling Backups
Intro

This second installment of "Scaling Web Applications" will list out the steps necessary for scaling a mysql deployment over two VPS.

...Continue Reading
3.3.3.3

PHP memcache and memcached extensions

Because PHP has no native support for memcache, you must install an extension for PHP to use it. There are two PHP extensi...ons available and it’s important to decode which to use:

memcache (no d), an older but very popular extension that is not maintained regularly. The memcache extension currently does not with PHP 7.

PHP documentation for memcache

The exact name is php5-memcache for Ubuntu and php-pecl-memcache for CentOS

memcached (with a d), a newer and maintained extension that should be compatible with PHP 7.

PHP documentation for memcached

The exact name is php5-memcached for Ubuntu and php-pecl-memcached for CentOS

Install and configure memcached on CentOS

This section provides instructions to install memcached on CentOS and Ubuntu. For additional information, consult the memcached wiki.

We recommend using the latest stable memcache or memcached version (currently, 3.0.8 for memcache and 2.2.0 for memcached).

To install memcached on CentOS, perform the following tasks as a user with root privileges:

Install memcached and its dependencies:

yum -y update
yum install -y libevent libevent-devel
yum install -y memcached
yum install -y php-pecl-memcache

The syntax of the preceding commands might depend on what package repositories you use. For example, if you use webtatic and PHP 5.6, enter yum install -y php56w-pecl-memcache. Use yum search memcache|grep php to find the appropriate package name.

Change the memcached configuration setting for CACHESIZE and OPTIONS:
Open /etc/sysconfig/memcached in a text editor.

Locate the value for CACHESIZE and change it to at least 1GB.

For example,

CACHESIZE="1GB"

Locate the value for OPTIONS and change it to localhost or 127.0.0.1

For more information about configuring memcached, see the memcached wiki.
Save your changes to memcached and exit the text editor.

Restart memcached.

service memcached restart

Restart your web server.

For Apache, service httpd restart
Continue with the next section.

Verify memcached works before installing Magento

We recommend testing memcached to make sure it works before you install Magento. Doing so takes only a few minutes and can simplify troubleshooting later.
Verify memcached is recognized by the web server

To verify memcached is recognized by the web server:

Create a phpinfo.php file in the web server’s docroot:

<?php

// Show all information, defaults to INFO_ALL
phpinfo();

Go to that page in your web browser.

For example, http://192.0.2.1/phpinfo.php

Make sure memcache displays as follows:

Confirm memcache is recognized by the web server

Verify you’re using memcached version 3.0.5 or later.

If memcache does not display, restart the web server and refresh the browser page. If it still does not display, verify you installed the php-pecl-memcache extension.

Create a memcache test consisting of a MySQL database and PHP script

The test uses a MySQL database, table, and data to verify you can retrieve the database data and store it in memcache. A PHP script first searches the cache. If the result does not exist, the script queries database. After the query has been fulfilled by the original database, the script stores the result in memcache, using the set command.

More details about this test

Create the MySQL database:

mysql -u root -p

At the mysql prompt, enter the following commands:

create database memcache_test;
GRANT ALL ON memcache_test.* TO memcache_test@localhost IDENTIFIED BY 'memcache_test';
use memcache_test;
create table example (id int, name varchar(30));
insert into example values (1, "new_data");
exit

Create cache-test.php in your web server’s docroot:

if (class_exists('Memcache')) {
$meminstance = new Memcache();
} else {
$meminstance = new Memcached();
}

$meminstance->addServer('<memcache host name or ip>', <memcache port>);

$query = "select id from example where name = 'new_data'";
$querykey = "KEY" . md5($query);

$result = $meminstance->get($querykey);

if (!$result) {
try {
$dbh = new PDO('mysql:host=localhost;dbname=memcache_test','memcache_test','memcache_test');
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$result = $dbh->query("select id from example where name = 'new_data'")->fetch();
$meminstance->set($querykey, $result, 0, 600);
print "got result from mysql\n";
return 0;
} catch (PDOException $e) {
die($e->getMessage());
}
}
print "got result from memcached\n";
return 0;

where <memcache host name or ip> is either localhost, 127.0.0.1, or the memcache host name or IP address. <memcache port> is its listen port; by default, 11211.

Run the script from the command line.

cd <web server docroot>
php cache-test.php

The first result is got result from mysql. This means that the key didn’t exist in memcache but it was retrieved from MySQL.

The second result is got result from memcached, which verifies that the value is stored successfully in memcache.

Finally, you can view the memcache keys using Telnet:

telnet localhost <memcache port>

At the prompt, enter

stats items

The result is similar to the following:

STAT items:3:number 1
STAT items:3:age 1075
STAT items:3:evicted 0
STAT items:3:evicted_nonzero 0
STAT items:3:evicted_time 0
STAT items:3:outofmemory 0
STAT items:3:tailrepairs 0

Flush the memcache storage and quit Telnet:

flush_all
quit

See More
127.0.0.1

PHP memcache and memcached extensions

Because PHP has no native support for memcache, you must install an extension for PHP to use it. There are two PHP extensions available and it’s important to decode which to use:

memcache (no d), an older but very popular extension that is not maintained regularly. The memcache extension currently does not with PHP 7.

...Continue Reading
127.0.0.1

APC, Varnish, Memcache, and Caching Beyond Drupal Core
By: MOHD TAUHEED
on December 12, 2016

Drupal is a powerful web application framework and Content Management System. It is capable of serving high volume websites at incredible speeds. But a poorly configured cache setting can grind your web site to a halt, leaving impatient visitors waiting for pages. Excessive page load times will even drive some visitors away with the impression that your site has gone down. The most co...

Continue Reading
Varnish Cache 4.1.4 has been released and is ready for download. This is a maintenance release with bug fixes and performance enhancements.
varnish-cache.org

How To Use the Linux Auditing System on CentOS 7
Posted Jul 16, 2015 42.6k views Logging Security CentOS
Introduction

The Linux Auditing System helps system administrators create an audit trail, a log for every action on the server. We can track security-relevant events, record the events in a log file, and detect misuse or unauthorized activities by inspecting the audit log files. We can choose which actions on the server to monitor and to what extent. Audit does not provide...

Continue Reading
Linux and Network Engineers updated their cover photo.
September 17, 2016
No automatic alt text available.

How To Set Up Master Slave Replication in MySQL

About MySQL replication

MySQL replication is a process that allows you to easily maintain multiple copies of a MySQL data by having them copied automatically from a master to a slave database. This can helpful for many reasons including facilating a backup for the data,a way to analyze it without using the main database, or simply as a means to scale out.

...Continue Reading

SSL Certificates
Table of Contents

Certificate Types
Manage SSL certificates

...

SSL (Secure Sockets Layer) is a security protocol designed to secure the communication between a server and a client, for example a web server and a browser. An SSL certificate is required to enable SSL on your site and use the HTTPS protocol.

We offer different types of domain-validated SSL certificates, signed by globally recognized certificate authorities.
Getting started with SSL certificates

Are you buying an SSL certificate for the first time? We assembled a getting started with SSL Certificates article that will guide you through the entire process.
Certificate Types

There are several types of SSL Certificates. They are generally classified by validation type or secured domains. If you are not familiar with the differences, take a look at the SSL certificate types article.

DNSimple currently provides the following domain-validated certificates:

Single-name SSL certificates (issued by Comodo)
Wildcard SSL certificates (issued by Comodo)

We currently don’t provide organization-validated or extended-validation certificates.
Single-name SSL certificates

The single-name certificate is a domain-validated certificate. It costs $20 per year and covers one host and the root domain in case of the www hostname.

The certificate is issued by Comodo, the name of the product is Comodo EssentialSSL certificate.
Wildcard SSL certificates

The wildcard certificate is a domain-validated certificate. It costs $100 per year and covers all single-level subdomains as well as the root domain.

The certificate is issued by Comodo, the name of the product is Comodo EssentialSSL Wildcard certificate.
Manage SSL certificates

You can purchase and manage SSL certificates from the your domain page. Go to the domain page and scroll down until you find the SSL certificate section.

SSL Certificate section

If the domain is not in your DNSimple account because you just joined DNSimple or because it is registered elsewhere, it’s not a problem: just add the domain to your account and follow the same procedure.
To go to the SSL certificate section

Log into your DNSimple account.
On the top-nav menu click the Domains tab, locate the relevant domain and click on the name to access the domain page.
Scroll down the page until you see the SSL certificates section.

See More

Differences between the A, CNAME, ALIAS and URL records

A, CNAME, ALIAS and URL records are all possible solutions to point a host name (name hereafter) to your site. However, they have some small differences that affect how the client will reach your site.

Before going further into the details, it’s important to know that A and CNAME records are standard DNS records, whilst ALIAS and URL records are custom DNS records provided by DNSimple’s DNS hosting. Both of them are tran...slated internally into A records to ensure compatibility with the DNS protocol.
Understanding the differences

Here’s the main differences:

The A record maps a name to one or more IP addresses, when the IP are known and stable.
The CNAME record maps a name to another name. It should only be used when there are no other records on that name.
The ALIAS record maps a name to another name, but in turns it can coexist with other records on that name.
The URL record redirects the name to the target name using the HTTP 301 status code.

Some important rules to keep in mind:

The A, CNAME, ALIAS records causes a name to resolve to an IP. Vice-versa, the URL record redirects the name to a destination. The URL record is simple and effective way to apply a redirect for a name to another name, for example to redirect www.example.com to example.com.
The A name must resolve to an IP, the CNAME and ALIAS record must point to a name.

Which one to use

Understanding the difference between the A name and the CNAME records will help you to decide.

The general rule is:

use an A record if you manage what IP addresses are assigned to a particular machine or if the IP are fixed (this is the most common case)
use a CNAME record if you want to alias a name to another name, and you don’t need other records (such as MX records for emails) for the same name
use an ALIAS record if you are trying to alias the root domain (apex zone) or if you need other records for the same name
use the URL record if you want the name to redirect (change address) instead of resolving to a destination.

You should never use a CNAME record for your root domain name (i.e. example.com)

See More
This domain is established to be used for illustrative examples in documents. You may use this domain in examples without prior coordination or asking for permission.
example.com