debian etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
debian etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

9 Eylül 2020 Çarşamba

PostgreSQL High Memory Utilization var mı nasıl kontrol edilir?

 PostgreSQL memory kullanımı fazla ise neler kontrol edilmesi gerekir?

Memoryden okumak her zaman diskten okumadan daha ölçülebilirdir, yani bütün database teknolojileri için kullanabildiğiniz kadar memory kullanmak isteyebilirsiniz.

Yaptığınız ayarlardan emin değil veya bir hatanız varsa, bu high memory utilization veya out-of-memory bile oluşturur.


Burada, nasıl PostgreSQL memory kullanımını kontrol edebileceğimize ve hangi parametreleri dikkate almanız gerektiğine bakacağız.

PostgreSQL mimarisi ile başlayalım.


PostgreSQL mimarisi

PostgreSQL mimarisi 3 temel parça üzerine kurulmuştur.

Processler, Memory ve Disk.


Memory iki sınıfa kategori edilebilir:


Local Memory: Her arka plan process’i tarafından kendi querileri işlemek için yüklenir ve alt alanlara ayrılmıştır.


*Work mem: Work mem ORDER BY ve DISTINCT işlemlerine göre tuple’ları sıralamak ve tabloları birleştirmek için kullanılır.


*Maintenance work mem: Bu alan bazı bakım işlemlerinde kullanılır.Örneğin, VACUUM, eğer "autovacuum_work_mem" belirtilmemişse.


*Temp buffers: Geçici tabloları depolamak için kullanılır.


Shared Memory: PostgreSQL server başlatıldığında PostgreSQL tarafından ayrılır ve onun işlemlerinde kullanılır. Alt alanlara ayrılmıştır.


*Shared buffer pool: PostgreSQL direkt memoryden çalışmak ve diske erişimi azaltmak için sayfalarla tabloları ve indexleri diskten yükler.


*WAL buffer:  The WAL data databasedeki işlem günlüğüdür ve değişiklikleri içerir. WAL buffer WAL data nın diske verilerini yazmadan önce verileri geçici olarak tuttuğu alandır.

Bu, kontrol noktası adı verilen önceden tanımlanmış bazı zamanlarda yapılır. Bir sunucu arızası durumunda bilgi kaybını önlemek için bu çok önemlidir.


* Commit log: Eşzamanlılık için bütün işlemleri kaydeder.


Ne olduğunu nasıl anlarsınız?

Eğer yüksek miktarda memory kullanımı varsa önce bu tüketimi yapan processin hangisi olduğunu belirleyiniz.

"Top" linux komutunu kullanın.


Muhtemelen buradaki en iyi seçenek "top" komutu ("htop" komutu da aynı işlevi görmektedir.)

Top komutu ile memory tüketen her bir processi ve processleri görebilirsiniz.

Yüksek miktarda memory kullanımından PostgreSQL sorumlu olduğundan emin olduktan sonra neden olduğunu kontrol edelim.


PostgreSQL Log'u kullanmak

Loglara baktığımızda aşağıdaki gibi bir mesaj ile karşılaşabiliriz:

"Resource temporarily unavailable

 

Out of memory: Kill process 1161 (postgres) score 366 or sacrifice child"


Eğer yeterli memory yoksa veya birden fazla hata varsa bunun gibi:

"FATAL:  password authentication failed for user "username"

 

ERROR:  duplicate key value violates unique constraint "sbtest21_pkey"

 

ERROR:  deadlock detected"


Beklenmedik davranışlar ile karşılaştığınızda database tarafında bu yüzden loglar kullanışlıdır bir sorunu belirlemede ve daha fazlasında.

Aslında bu logları parse edip alarmlar da oluşturabilirsiniz (“FATAL”, “ERROR” veya “Kill”).


Pg_top Kullanımı


Eğer bir PostgreSQL process’in yüksek memory kullandığını biliyor, ama bunu log dosyaları size yardımcı olmuyorsa, pg_top size yardımcı olacak kullanışlı bir araçtır.

Bu araç Linux Top ile benzerdir, ama özellikle PostgreSQL içindir. Yani, onu kullandığınızda database’niz üzerinde daha detaylı bilgi sahibi olursunuz, ve querileri kill edebilir, veya çalışan bir job’ın üzerinde yanlış bir şey var ise bunları tespit edebilirsiniz.


Ama database üzerinde bir error tespit edemediniz ve hala yüksek miktarda memory tüketiyorsa. O zaman muhtemelen database’inizin konfigürasyonuna bakmanız gerekecek.


Hangi konfigürasyon parametrelerini dikkate almak gerekir

Eğer herşey iyi gözüküyor ama hala yüksek memory kullanımı sorunu varsa,

konfigürasyonu kontrol etmeli ve doğru olduğundan emin olmalısınız.

Yani aşağıdaki parametreleri dikkate almalısınız.


Shared_buffers

Bu database sunucusunun kullandığı shared memory de kullandığı memory miktarıdır. Eğer bu çok az olursa, database daha fazla diski kullanır ve daha fazla yavaş olmasına sebep olur. Ama çok fazla olursa yüksek memory kullanımı oluşur.Dökümana göre, eğer database sunucusuna 1GB veya üzerinde RAM atanırsa, başlangıç olarak shared_buffer sistemdeki memory’nin %25’ni kullanır.


work_mem

Diskteki geçici dosyaya yazmadan önce ORDER BY, DISTINCT ve JOIN özel olarak kullandığı memory miktarıdır. Shared_buffers da olduğu gibi, bu parametreyi çok düşük miktarda verilirse, bir çok işlemimiz disk’e gider, ama fazlası memory kullanımı için tehlikeli olabilir. Varsayılan değeri 4 MB'dır.


max_connections

work_mem ayrıca  max_connecitons değeriyle el ele gider, çünkü her bağlantıda bu işlemleri aynı anda yürütür ve her işlemin geçici dosyalara veri yazmadan önce bu değerle belirtilen kadar memory kullanmasına izin verilecektir.

Bu parametre database bağlanan max eş zamanlı bağlantı sayısını belirler, eğer bağlantı sayısını yüksek ayarlarsak bu bize kaynak yetersizliği sorunları oluşturacaktır. Varsayılan değeri 100’dür.


temp_buffers

temp_buffers her oturumda geçici tabloları tutmak için kullanılır.

Bu parametre bu iş için en fazla memory alanını ayarlar. Varsayılan değeri 8 MB’dir.


maintenance_work_mem

Bu bir işlemin Vacuuming, adding indexes veya foreign keys tüketebileceği en fazla memory miktarıdır. İyi tarafı bu tip bir işlem bir oturum içinde bir işlem olarak çalışır ve çok yaygın bir şey değildir bir oturum içinde birden fazla işlem çalıştırması.Varsayılan değeri 64 MB’dır.

autovacuum_work_mem

Vacuum maintenance_work_mem’i kullanırım varsayılan olarak, ama onu bu parametre yardımıyla ayırabiliriz.  Her bir autovacuum worker için max memory kullanımını belirleyebiliriz.


wal_buffers

Diske henüz yazılmamış WAL data için kullanılan shared memory miktarıdır.

Varsayılan olarak shared_buffers’ın %3’dür, ama 64kb az olamaz ve WAL bölümünden de çok olamaz, tipik olarak 16 MB’dır.



Sonuç

Birden fazla sebebi olabilir yüksek memory kullanımının.
Biz burada sorunu bulmak için bakmanız gereken noktaları işaret etmeye çalıştık.

2 Mayıs 2018 Çarşamba

GraphPing Installation on Debian 9

GraphPing Installation

You can reach the following link of the Source code of graphping; 
https://github.com/jaxxstorm/graphping

System upgrade
$sudo apt-get -y upgrade
$sudo apt-get -y install git curl

Nodejs Installation
$curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
$sudo apt-get update
$sudo apt-get install -y build-essential libssl-dev nodejs
$sudo npm install nodeunit

Graphping clone
$git clone https://github.com/jaxxstorm/graphping.git

Go installation
$wget https://dl.google.com/go/go1.10.1.linux-amd64.tar.gz
$sudo tar -xvfz go1.10.1.linux-amd64.tar.gz
$sudo mv go /usr/local
$export GOROOT=/usr/local/go
$export GOPATH=$HOME/graphping
$export PATH=$GOPATH/bin:$GOPATH/bin:$PATH

Check the Go version and env
$go version
$go env

Glide installation
$mkdir -p graphping/bin
$mkdir -p graphping/src
$cd graphping
$curl https://glide.sh/get | sh

Build and installing the graphping
$cd graphping
$go build main
If you get to any packet missing error you can get download like following commands
$go get github.com/Sirupsen/logrus
$go get github.com/cactus/go-statsd-client/statsd
$go get github.com/jaxxstorm/graphping/config
$go get github.com/jaxxstorm/graphping/ping
$go get gopkg.in/urfave/cli.v1
$sudo ln -s /home/arm/graphping/main /usr/local/bin/graphping
$graphping -h

$sudo nano /etc/systemd/system/graphping.service
[Unit]
After = network.target
[Service]
ExecStart = /usr/local/bin/graphping -c /home/arm/graphping/examples/example.json -s 127.0.0.1:8125
[Install]
WantedBy = multi-user.target
$sudo systemctl enable graphping.service


Statsd Installation
$sudo adduser statsd
$sudo git clone https://github.com/etsy/statsd.git
$sudo mkdir -p /etc/statsd
$sudo cp statsd/exampleConfig.js /etc/statsd/config.js
$sudo nano /etc/systemd/statsd.service
[Service]
ExecStart=/usr/bin/node /opt/statsd/stats.js /etc/statsd/config.js
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=statsd
User=statsd
Group=statsd
Environment=NODE_ENV=production</code>
[Install]
WantedBy=multi-user.target


$sudo nano /etc/statsd/config.js
{
influxdb: {
version: 0.9, // !!! we installed 0.9
host: '127.0.0.1', // InfluxDB host. (default 127.0.0.1)
port: 8086, // InfluxDB port. (default 8086)
database: 'graphping', // InfluxDB database instance. (required)
username: 'demo', // InfluxDB database username. (required)
password: 'demo', // InfluxDB database password. (required)
flush: {
enable: true // Enable regular flush strategy. (default true)
},
//proxy: {
//enable: false, // Enable the proxy strategy. (default false)
//suffix: 'raw', // Metric name suffix. (default 'raw')
//flushInterval: 1000 // Flush interval for the internal buffer.
// (default 1000)
//} packets should be "repeated" (duplicated to)..d process starts ['up' or 'down', default: 'up']
},
port: 8125, // StatsD port.
backends: ['./backends/console', 'statsd-influxdb-backend'],
debug: false,
legacyNamespace: false
}

$sudo systemctl enable statsd.service
$sudo systemctl start statsd.service
$sudo systemctl status statsd.service
$sudo journcalctl -f -u statsd
$ npm install statsd-influxdb-backend -d


Influxdb Installation
By the way statsd is only support version of 0.9 yet
$wget https://s3.amazonaws.com/influxdb/influxdb_0.9.5.1_amd64.deb
$sudo dpkg -i influxdb_0.9.5.1_amd64.deb
$sudo systemctl start influxdb.service
You have to create a database and user for connect to influxdb via statsd
You can reach via http://ip-of-the-influxdb::8083
Test the graphping following command
$sudo graphping -c graphping/examples/example.json -s 127.0.0.1:8125

Check the measurements via web ui of influxdb.
It has to be like the image.


Start the graphping
$sudo systemctl start graphping.service

Grafana Installation
$sudo nano /etc/apt/sources.list
deb https://packagecloud.io/grafana/stable/debian/ stretch main
$curl https://packagecloud.io/gpg.key | sudo apt-key add -
$sudo apt-get update
$sudo apt-get install grafana
$sudo systemctl enable grafana-server
$sudo systemctl start grafana-server
You can reach via http://ip-of-the-grafana:3000

10 Nisan 2018 Salı

Linux System check


Linux System check in 60 seconds 

$uptime
The current time, how long the system has been running, how many users are currently logged on, and the system load averages for the past 1, 5, and 15 minutes.

$dmesg | tail
dmesg is used to examine or control the kernel ring buffer.
The default action is to display all messages from the kernel ring buffer.

$vmstat 1
 vmstat reports information about processes, memory, paging, block IO, traps, disks and cpu activity.

$mpstat -P ALL 1
The mpstat command writes to standard output activities for each available processor, processor 0 being the first one.  Global average activities among all processors are also reported.  The mpstat com‐
       mand can be used both on SMP and UP machines, but in the latter, only global average activities will be printed. If no activity has been selected, then the default report is the CPU utilization report.

$pidstat 1
 The pidstat command is used for monitoring individual tasks currently being managed by the Linux kernel.  It writes to standard output activities for every task selected with option -p or for every task
       managed  by  the  Linux kernel if option -p ALL has been used. Not selecting any tasks is equivalent to specifying -p ALL but only active tasks (tasks with non-zero statistics values) will appear in the
       report.

$iostat -xz 1
 The iostat command is used for monitoring system input/output device loading by observing the time the devices are active in relation to their  average  transfer  rates.  The  iostat  command  generates
       reports that can be used to change system configuration to better balance the input/output load between physical disks.

$free -m
free  displays  the  total amount of free and used physical and swap memory in the system, as well as the buffers and caches used by the kernel. The information is gathered by parsing /proc/meminfo.

$sar -n DEV 1
$sar -n TCP,ETCP 1
The  sar command writes to standard output the contents of selected cumulative activity counters in the operating system. The accounting system, based on the values in the count and interval parameters,
       writes information the specified number of times spaced at the specified intervals in seconds.  If the interval parameter is set to zero, the sar command displays the average  statistics  for  the  time
       since  the system was started. If the interval parameter is specified without the count parameter, then reports are generated continuously.  The collected data can also be saved in the file specified by
       the -o filename flag, in addition to being displayed onto the screen. If filename is omitted, sar uses the standard system activity daily data file (see below).  By default all the data  available  from
       the kernel are saved in the data file.

21 Aralık 2017 Perşembe

ActiveMQ Artemis Installation on Debian 9

This is a base installation of ActiveMQ Artemis.
I am checking cluster and fail over configuration of Artemis. When it is ready I will share on my blog.

OpenJDK of Zulu For JAVA:

$sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0x219BD9C9
$sudo apt-add-repository 'deb http://repos.azulsystems.com/debian stable main'
$sudo apt-get update
$sudo apt-get install zulu-8

More about Zulu;
https://www.azul.com/

Artemis Installation :
$wget http://ftp.itu.edu.tr/Mirror/Apache/activemq/activemq-artemis/2.4.0/apache-artemis-2.4.0-bin.tar.gz
$ sudo tar -zxvf apache-artemis-2.4.0-bin.tar.gz -C /opt/
$cd /opt

The most commonly used artemis commands are:
    address     Address tools group (create|delete|update|show) (example ./artemis address create)
    browser     It will browse messages on an instance
    consumer    It will consume messages from an instance
    create      creates a new broker instance
    data        data tools group (print) (example ./artemis data print)
    help        Display help information
    mask        mask a password and print it out
    migrate1x   Migrates the configuration of a 1.x Artemis Broker
    producer    It will send messages to an instance
    queue       Queue tools group (create|delete|update|stat) (example ./artemis queue create)

sudo ./bin/artemis create /opt/broker-name
You can now start the broker by executing:

   "/opt/broker-name/bin/artemis" run

Or you can run the broker in the background using:

   "/opt/broker-name/bin/artemis-service" start

Base Configuration of Artemis:
If you want access the web-ui from any where ,you have to change as below of the "web bind" in the <broker>/etc/bootstrap.xml.

<web bind="http://0.0.0.0:8161" path="web">
       <app url="activemq-branding" war="activemq-branding.war"/>
       <app url="artemis-plugin" war="artemis-plugin.war"/>
       <app url="console" war="console.war"/>
   </web>
If you do not set the jolokia, you can not reach the stats of artemis.
Below configuration that is enough for your access..
Jolokia settings:
<broker>/etc/jolokia-access.xml

<allow-origin>*://<ipaddressorfqdnofartemis>*</allow-origin>

Create a Systemd File for Artemis:
$sudo nano /etc/systemd/system/artemis.service

#############################################
[Unit]
Description=Apache ActiveMQ Artemis
After=network-online.target

[Service]
Type=forking
WorkingDirectory=/opt/broker-name/bin
ExecStart=/opt/broker-name/bin/artemis-service start
ExecStop=/opt/broker-name/bin/artemis-service stop
Restart=on-abort
User=root
Group=root

[Install]
WantedBy=multi-user.target
################################################

$sudo systemctl daemon-reload

Now you can start via systemd as a be service of Artemis.
$sudo systemctl start artemis.service

You can reach the web admin panel:
http://ipaddressorfqdnofartemis:8161

8 Ocak 2016 Cuma

How to install mikoomi plugin of mongodb on the zabbix server

Mongodb mikoomi plugin installation

I used template of mikoomi server side ;
I tested of mongo db 3.0.7 and it works .

https://code.google.com/p/mikoomi/wiki/03

Setup and Configuration

The MongoDB plugin uses the MongoDB PHP driver which needs to be installed on the Zabbix server. For this, install and setup the following packages:
  • php5-dev (or php5-devel) = Files for PHP5 module development
  • php5-pear = PEAR - PHP Extension and Application Repository
  • gcc = GNU C Compiler
  • make = make utility
To install the above on a Zabbix appliance, login into the appliance as root (default password = zabbix) and run the following commands:
  • yast -i php5-devel
  • yast -i gcc
  • yast -i php5-pear
  • yast -i make
Now install the php MongoDB driver using the instructions at http://us2.php.net/manual/en/mongo.installation.php
In the case of the Zabbix appliance, run the the following pecl command:
  • pecl install mongo
After successful installation of the MongoDB driver, you need to "enable" it within php5. Edit the two files /etc/php5/cli/php.ini and /etc/php5/apache2/php.ini and add a line to the "Dynamic Extensions" sections as shown below.
;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;

extension=mongo.so
Ensure that the php MongoDB driver is setup and configured properly by testing out one of the sample php programs for MongoDB driver (http://us2.php.net/manual/en/mongo.tutorial.php).
Dowload template and script files;
http://mikoomi.googlecode.com/svn/plugins/MongoDB%20Plugin/
[root@zabbix ~]# grep ExternalScripts /etc/zabbix/zabbix_server.conf
You have to Change to mikoomi of shell script file of about the externalscirpt .
And all of scripts are download at the externalscirpt directory.
And delete the word of "shift" . If you don't delete, your script doesn't work.
Next open up a browser and download the MongoDB Zabbix template. Now login to the Zabbix frontend (user = admin, password = zabbix).
Navigate as follows:
  • Configuration >> Templates
  • Click on the "Import Template" button on the top right-hand corner
  • In the "Import file" dialog box, browse/search/enter the filename of the Zabbix template that was downloaded
  • Upload the template
Now you are ready to start monitoring your MongoDB servers !
If you have any question please leave comments.

3 Aralık 2015 Perşembe

Dtrace installation on Debian 7

When I install the dtrace via systemtap I had an error like this "could not load module build-3.2.0-4-amd64/driver/dtracedrv.ko: No such file or directory"

How I solved the problem;
$sudo apt-get install linux-headers-$(uname -r)

Dtrace installation;

$git clone "https://github.com/dtrace4linux/linux.git" dtrace
$sudo apt-get install linux-headers-$(uname -r)
$cd dtrace
$tools/get-deps.pl
$sudo make all 
$sudo make install
$sudo make load
$sudo dtrace -l

9 Aralık 2014 Salı

Nginx, Django, Gunicorn & Mysql Installation and Configuration on Debian 7

Nginx, Django, Gunicorn & Mysql Installation and Configuration

Step One;
Update packages
#apt-get update
#apt-get upgrade

Step Two;
Install and create virtualenv
#apt-get install python-virtualenv python-dev
#source virtualenv /opt/myenv
Notice that a new directory "myenv" was created in the "/opt" directory. This is where our virtualenv will live. Make sure to replace "/opt/myenv" with the path to where you want your virtualenv installed. I typically put my env's in /opt, but this is strictly preference. Some people create a directory named "webapps" at the root of the VPS. Choose whatever method makes the most sense to you.

Step Three ;
Install Django
#source /opt/myenv/bin/activate
You should now see that "(myenv)" has been appended to the beginning of your terminal prompt. This will help you to know when your virtualenv is active and which virtualenv is active should you have multiple virtualenv's on the VPS.
With your virtualenv active, we can now install Django. To do this, we will use pip, a Python package manager much like easy_install. Here is the command you will run:
(myenv)root@Django:/opt/myenv/bin#pip install django
You now have Django installed in your virtualenv! Now let's get our database server going.

Step Four ;
Install Mysql Server
Since we don't need our virtualenv active for this part, run the following command to deactivate:
(myenv)root@Django:/opt/myenv/bin#deactivate
This will always deactivate whatever virtualenv is active currently. Now we need to install dependencies for Mysql to work with Django with this command:
#apt-get install python-mysqldb libmysqlclient-dev mysql-server


Step Five;
Install Nginx
#apt-get install nginx

Step Six;
Install Gunicorn
Gunicorn is a very powerful Python WSGI HTTP Server. Since it is a Python package we need to first activate our virtualenv to install it. Here is how we do that:
#source /opt/myenv/bin/activate
Make sure you see the added "myenv" at the beginning of your terminal prompt. With your virtualenv now active, run this command:
(myenv)root@Django:/opt/myenv/bin# pip install gunicorn
Gunicorn is now installed within your virtualenv.
If all you wanted was to get everything installed, feel free to stop here. Otherwise, please continue for instructions on how to configure everything to work together and make your app accessible to others on the web.
(myenv)root@Django:/opt/myenv/bin#deactivate

Step Seven;
Configure Mysql
#mysql -u root -p 
>CREATE DATABASE djangodb;
>CREATE USER 'django'@'localhost' IDENTIFIED BY 'passwd';
>GRANT ALL PRIVILEGES ON djangodb . * TO 'django'@'localhost';
>FLUSH PRIVILEGES;

Step Eight;
Create a Django project
In order to go any further we need a Django project to test with. This will allow us to see if what we are doing is working or not. Change directories into the directory of your virtualenv (in my case /opt/myenv) like so:
#cd /opt/myenv
Now make sure your virtualenv is active. If you're unsure then just run the following command to ensure you're activated:
#source /opt/myenv/bin/activate
With your virtualenv now active, run the following command to start a new Django project:
(myenv)root@Django:/opt/myenv/bin#django-admin.py startproject myproject
You should see a new directory called "myproject" inside your virtualenv directory. This is where our new Django project files live.
In order for Django to be able to talk to our database we need to install a backend for Mysql. Make sure your virtualenv is active and run the following command in order to do this:
(myenv)root@Django:/opt/myenv/bin# pip install mysql-python
Change directories into the new "myproject" directory and then into it's subdirectory which is also called "myproject" like this:
(myenv)root@Django:/opt/myenv/bin#cd /opt/myenv/myproject/myproject
Edit the settings.py file with your editor of choice:
(myenv)root@Django:/opt/myenv/myproject/myproject#nano settings.py
Find the database settings and edit them to look like this:
DATABASES = {
        'default': {
'ENGINE': 'django.db.backends.mysql', 
'NAME': 'djangodb',
'USER': 'django',
'PASSWORD': 'passwd',
'HOST': 'localhost',   # Or an IP Address that your DB is hosted on
'PORT': '3306',
  }
}
Save and exit the file. Now move up one directory so your in your main Django project directory 
#cd /opt/myenv/myproject
Activate your virtualenv if you haven't already with the following command:
#source /opt/myenv/bin/activate
With your virtualenv active, run the following command so that Django can add it's initial configuration and other tables to your database:
(myenv)root@Django:/opt/myenv/myproject/#python manage.py syncdb
You should see some output describing what tables were installed, followed by a prompt asking if you want to create a superuser. This is optional and depends on if you will be using Django's auth system or the Django admin.

Step Nine;
Configure Gunicorn
First lets just go over running Gunicorn with default settings. Here is the command to just run default 
#gunicorn_django --bind yourdomainorip.com:8001
Be sure to replace "yourdomainorip.com" with your domain, or the IP address of your VPS if you prefer. Now go to your web browser and visit yourdomainorip.com:8001 and see what you get. You should get the Django welcome screen.
If you look closely at the output from the above command however, you will notice only one Gunicorn worker booted. What if you are launching a large-scale application on a large VPS? Have no fear! All we need to do is modify the command a bit like so:
#gunicorn_django --workers=3 --bind yourdomainorip.com:8001
Now you will notice that 3 workers were booted instead of just 1 worker. You can change this number to whatever suits your needs.
Since we ran the command to start Gunicorn as root, Gunicorn is now running as root. What if you don't want that? Again, we can alter the command above slightly to accomodate:
#gunicorn_django --workers=3 --user=nobody --bind yourdomainorip.com:8001
If you want to set more options for Gunicorn, then it is best to set up a config file that you can call when running Gunicorn. This will result in a much shorter and easier to read/configure Gunicorn command.
You can place the configuration file for gunicorn anywhere you would like. For simplicity, we will place it in our virtualenv directory. Navigate to the directory of your virtualenv like so:
#cd /opt/myenv
Now open your config file with your preferred editor (nano is used in the example below):
#nano gunicorn_config.py
Add the following contents to the file:
command = '/opt/myenv/bin/gunicorn'
pythonpath = '/opt/myenv/myproject'
bind = '127.0.0.1:8001'
workers = 3
user = 'nobody'
Save and exit the file. What these options do is to set the path to the gunicorn binary, add your project directory to your Python path, set the domain and port to bind Gunicorn to, set the number of gunicorn workers and set the user Gunicorn will run as.
In order to run the server, this time we need a bit longer command. Enter the following command into your prompt:
#/opt/myenv/bin/gunicorn -c /opt/myenv/gunicorn_config.py myproject.wsg
You will notice that in the above command we pass the "-c" flag. This tells gunicorn that we have a config file we want to use, which we pass in just after the "-c" flag. Lastly, we pass in a Python dotted notation reference to our WSGI file so that Gunicorn knows where our WSGI file is.
Running Gunicorn this way requires that you either run Gunicorn in its own screen session (if you're familiar with using screen), or that you background the process by hitting "ctrl + z" and then typing "bg" and "enter" all right after running the Gunicorn command. This will background the process so it continues running even after your current session is closed. This also poses the problem of needing to manually start or restart Gunicorn should your VPS gets rebooted or were it to crash for some reason. To solve this problem, most people use supervisord to manage Gunicorn and start/restart it as needed. Installing and configuring supervisord has been covered in another article which can be found here.
Lastly, this is by no means an exhaustive list of configuration options for Gunicorn. Please read the Gunicorn documentation found at gunicorn.org for more on this topic.

Step Ten;
Configure Nginx
#service nginx restart
Since we are only setting NGINX to handle static files we need to first decide where our static files will be stored. Open your settings.py file for your Django project and edit the STATIC_ROOT line to look like this:
STATIC_ROOT = "/opt/myenv/static/" 
Add to /opt/myenv/myproject/myproject/settings.py
#nano /etc/nginx/sites-available/myproject
server {
        server_name yourdomainorip.com;

        access_log off;

        location /static/ {
            alias /opt/myenv/static/;
        }

        location / {
                proxy_pass http://127.0.0.1:8001;
                proxy_set_header X-Forwarded-Host $server_name;
                proxy_set_header X-Real-IP $remote_addr;
                add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"';
        }
    }
#cd /etc/nginx/sites-enabled
#ln -s ../sites-available/myproject
#rm default
#service nginx restart
And that's it! You now have Django installed and working with Mysql and your app is web accessible with NGINX serving static content and Gunicorn serving as your app server. If you have any questions or further advice, be sure to leave it in the comments section.