LINUX – Nginx – exited on signal 11 error

After compiling NGINX 1.7.7 I started getting this error:

2014/11/27 22:10:27 [alert] 8326#0: worker process 8730 exited on signal 11
2014/11/27 22:10:27 [alert] 8326#0: worker process 8731 exited on signal 11
2014/11/27 22:10:28 [alert] 8326#0: worker process 8728 exited on signal 11
2014/11/27 22:10:28 [alert] 8326#0: worker process 8732 exited on signal 11
2014/11/27 22:10:28 [alert] 8326#0: worker process 8733 exited on signal 11
2014/11/27 22:10:29 [alert] 8326#0: worker process 8735 exited on signal 11

quick web search pointed me to: http://trac.nginx.org/nginx/ticket/235

The solution is quick, edit:

/etc/nginx/nginx.conf

and add the following line:

ssl_session_cache    shared:SSL:10m;

then restart nginx service

Debian – compiling NGINX from source

Install software pre-requisites:

apt-get install libpcre3 libpcre3-dev libpcrecpp0 libssl-dev zlib1g-dev make gcc libgeoip-dev

Get latest nginx from: http://nginx.org/en/download.html

First stop nginx if it already installed then download and unpack the software:

cd /opt
wget http://nginx.org/download/nginx-1.9.11.tar.gz
tar -zxvf nginx-1.9.11.tar.gz
cd ./nginx-1.9.11
mkdir modules
cd modules
git clone https://github.com/FRiCKLE/ngx_cache_purge.git
cd ..

and then there is just one more important step – to customize your server name: http://www.nginxtips.com/customize-nginx-server-name/ but in essence it all boils down to this:

Edit this file right at line #49: src/http/ngx_http_header_filter_module.c

nano -w +49 src/http/ngx_http_header_filter_module.c

Find these lines:

static char ngx_http_server_string[] = "Server: nginx" CRLF;
static char ngx_http_server_full_string[] = "Server:" NGINX_VER CRLF;

Modify those to match these new ones:

static char ngx_http_server_string[] = "Server: YourCustomName" CRLF;
static char ngx_http_server_full_string[] = "Server: YourCustomName" CRLF;

Modify “YourCustomName” as you want. You can place anything there. It could be the name of your website, product, company, etc.

Configure NGINX:

The configuration I have here works on Debian and preserves default directory layouts, provides support for IPv6, SSL, HTTPv2, WebDAV, nginx-cache-purge module and GeoIP:

./configure --sbin-path=/usr/sbin --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log
--pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx.lock --http-log-path=/var/log/nginx/access.log 
--http-client-body-temp-path=/var/lib/nginx/body --http-proxy-temp-path=/var/lib/nginx/proxy 
--http-fastcgi-temp-path=/var/lib/nginx/fastcgi --with-debug --with-http_stub_status_module 
--with-http_flv_module --with-http_ssl_module --with-http_dav_module --with-ipv6 
--with-http_geoip_module --with-http_v2_module --add-module=$(MODULESDIR)/ngx_cache_purge

Compile and install NGINX:

make && make install

when everything is done verify:

nginx -V

and you shoud get something like that:

nginx version: nginx/1.9.11
built by gcc 4.8.2 (Debian 4.8.2-21)
TLS SNI support enabled
configure arguments: --sbin-path=/usr/sbin --conf-path=/etc/nginx/nginx.conf 
--error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx.pid 
--lock-path=/var/lock/nginx.lock --http-log-path=/var/log/nginx/access.log 
--http-client-body-temp-path=/var/lib/nginx/body --http-proxy-temp-path=/var/lib/nginx/proxy 
--http-fastcgi-temp-path=/var/lib/nginx/fastcgi --with-debug --with-http_stub_status_module 
--with-http_flv_module --with-http_ssl_module --with-http_dav_module --with-ipv6 
--with-http_geoip_module --with-http_v2_module

NGINX and Syslog-NG

For the test I use Syslog-NG version 3.3 and Nginx 1.6 as setup in my previous post.

From version 1.7 Nginx has built in support for sysloging but since my version is 1.6 I use this technique found somewhere on the net with my modifications.

Setup is simple just add the following lines to the syslog-ng.conf file:

source nginx_error_var { program("tail -F -n0 /var/log/nginx/error.log" program_override(nginx)); };
log {
 source(nginx_error_var);
 destination(d_mysql);
 };

and restart syslog-ng (service syslog-ng restart)

The only downside is that some lines might be missed but it works great and does what I want it to do.

 

 

 

MySQL replication

I have 2 servers, one of which is a Master (my UDOO box) and the other which is a Slave (Raspberry PI). We tell the Master that it should keep a log of every action performed on it. We tell the slave server that it should look at this log on the Master and whenever something new happens, it should do the same thing.

Step 1. Create sleve_replication_user_account:

 

GRANT REPLICATION SLAVE ON *.* TO 'sleve_replication_user_account'@'%' 
  IDENTIFIED BY 'your_password';
FLUSH PRIVILEGES;

 

Step 2. Setup your Master.

Login to your “master” mysql server phpmyadmin and go to the replication tab, under Master configuration select set the options as your require:mysql1

Then copy the generated by PhpMyAdmin config and paste it to your my.cnf config file and restart your mysql server.

Go back to your phpmyadmin installation to verify that everything is working OK:

mysql2

Step 3. Setup your Slave.

Open Phpmyadmin on your slave go to replication tab and fill in the bits:

mysql3

Don’t forget to add the server-id to the slave my.cnf config.

Then add list of databases you want to replicate:

replicate-do-db=database_name1
replicate-do-db=database_name2
.....

This should match the config on your Master. Save your config and restart the mysql service.

Step 4. Export your DBs on Master to sql file

Run:

FLUSH TABLES WITH READ LOCK;

Then use Phpmyadmin to export one by one all the databases that you want to replicate.

Step 5. Import your DBs on Slave from exported sql files

Transfer exported sql files from Master to Slave.

log into MySQL, and create the databases:

mysql -u root -p
CREATE DATABASE `database_name1`;

then import the data:

mysql -u root -p database_name1  </home/my_home_dir/database_name1.sql

 

Step 6. Get it all running.

Now we are ready to kick things off. We need to find the position the Master is at in the logs. So, log into MySQL on your Master and run the following:

 mysql -u root -p
SHOW MASTER STATUS;

result:

+---------------------+----------+----------------------+------------------+
| File                | Position | Binlog_Do_DB         | Binlog_Ignore_DB |
+---------------------+----------+----------------------+------------------+
| mysql-bin.000076    | 00027442 | database_name1;      |                  |
+---------------------+----------+----------------------+------------------+

make note of this and login to MySql on your Slave:

mysql -u root -p
slave stop;
 CHANGE MASTER TO MASTER_HOST='AA.BB.CC.DD', MASTER_USER='slave_user', 
    MASTER_PASSWORD='slave_password', MASTER_LOG_FILE='mysql-bin.000076', 
    MASTER_LOG_POS=00027442;
slave start;

where AA.BB.CC.DD is your Master IP address

then go back to the Master and run:

unlock tables;

And that is pretty much it.

 

Troubleshooting.

If the servers get out of sync run this on the Slave:

STOP SLAVE;
 CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000049';
 CHANGE MASTER TO MASTER_LOG_POS=98;
 START SLAVE;

Note: MASTER_LOG_FILE must be the last file where it stop from replicating