khanhnnvn

Redis – Environment

 Hệ thống  Comments Off on Redis – Environment
Sep 042015
 

Install Redis on Ubuntu

To install the Redis on Ubuntu, go to terminal and type the following commands:

$sudo apt-get update
$sudo apt-get install redis-server

This will install redis on your machine.
Start Redis

$redis-server

Check if redis is working?

$redis-cli

This will open a redis prompt, as shown below:

redis 127.0.0.1:6379>

In the above prompt 127.0.0.1 is your machine’s IP address and 6379 is port on which redis server is running. Now type the PING command as shown below.

redis 127.0.0.1:6379> ping
PONG

This shows that you have successfully installed redis on your machine.

Install Redis Desktop Manager on Ubuntu

To install redis dessktop manager on ubuntu, just download the package fromhttp://redisdesktop.com/downloadOpen the downloaded package and install it.
Redis desktop manager will give you UI to manage your redis keys and data.

OPTIMIZE APACHE FOR WORDPRESS – HIGH TRAFFIC WEBSITES

 Hệ thống  Comments Off on OPTIMIZE APACHE FOR WORDPRESS – HIGH TRAFFIC WEBSITES
Sep 042015
 

OPTIMIZE APACHE FOR WORDPRESS – HIGH TRAFFIC WEBSITES

This article will help you to tweak your apache server and can aceept high traffic, but let’s talk about the insides and possibilities first. Optimizing apache matters the server hardware so if you checking the solution for Shared Hosting then this article won’t help you, should check my other articles for the low traffic website optimization.

Practically it’s seen that many people finding solution for optimizing wordpress but didn’t check the requirement to do so. If you have traffic more than 1M/Month and VPS has Memory of 2GB with 2 Cores CPU and running WHM then it’s complicated to switch to more traffic, since WHM is not made to accept high traffic due to buffer delay between CPU Cores, Memory, Mysql Database & HTTP Server. Usually stat shows how much traffic your WHM can manage with specific hardware requirement and how much you can tweak to accept more traffic. The stat is based on overall monthly traffic (Including all Hosted sites on your WHM)

Traffic Memory (GB) CPU Cores Tweak Possible Traffic
25K to 50K 2 2 75K
1M to 2M 4 4 3M
3M to 5M 8 8 6M
7M to 10M 12 12 11.5M
12M to 15M 16 16 17M

* Database Size matters, with above figure Database Size not calculated.

* More than 17M – You should better switch to Dedicated

 

To tweak for more traffic find this line in your apache, the following config is default with WHM you can edit the nos according to your CPU Cores & Memory. I assume that you might have 2GB Memory and 2 CPU Cores and the apache httpd.conf may have following values.

You could find the file at the following destination /usr/local/apache/conf/httpd.conf

Note: You might found blank entries between <IfModule prefork.c></IfModule> and you can add following lines between tag and change as per your requirement.

<IfModule prefork.c>

StartServers 3 (Change it as per your CPU Cores)

MinSpareServers 3 (Change it as per your CPU Cores)

MaxSpareServers 10 (Do not change)

ServerLimit 50  (Control the maximum value for MaxClients)

MaxClients 50  (Limit on the number of simultaneous requests)

MaxRequestsPerChild 2000 (Number of requests a child server OR each Domain will handle)

</IfModule>

Also Find Following & Change OR if not mentioned in your httpd.cof then add them

KeepAlive Off

(KeepAlive allows your visitors to use multiple requests over the same TCP connection, this helps improve latency because your visitors can request your webpage, images, and javascripts all over one connection. You can safely reduce this value. If your site has lots of images, java scripts and bigger database then you should keep this on)

 

KeepAliveTimeout 15

(If you leave KeepAlive turned on you should change the default KeepAliveTimeout value. This prevents unused connections from staying open for excessive amounts of time.)

 

MaxKeepAliveRequests 100

(If you leave KeepAlive on you should increase MaxKeepAliveRequests. Setting this higher allows more requests per connection and increases the performance and stability)

Once changes done. Restart the HTTP Server (Recommended Restart Server), to changes take affect.

If you have any queries, questions feel free to ask about Optimize Apache For WordPress – High Traffic Websites

Description

Practically it’s seen that many people finding solution for optimizing wordpress but didn’t check the requirement to do so. If you have traffic more than 1M/Month and VPS has Memory of 2GB with 2 Cores CPU and running WHM then it’s complicated to switch to more traffic, since WHM is not made to accept high traffic due to buffer delay between CPU Cores, Memory, Mysql Database & HTTP

25 Apache Performance Tuning Tips

 Hệ thống  Comments Off on 25 Apache Performance Tuning Tips
Sep 042015
 

We all know and love Apache.  Its great, it allows us to run websites on the Internet with minimal configuration and administration.
However, this same ease of flexibility and lack of tuning, is typically what leads Apache to becoming a memory hog.  Utilizing these easy to understand tips, you can gain a significant performance boost from Apache.

Apache Specifics

1. Remove unused modules – save memory by not loading modules that you do not need, including but not limited to mod_php, mod_ruby, mod_perl, etc.

2. Use mod_disk_cache NOT mod_mem_cache – mod_mem_cache will not share its cache amongst different apache processes, which results in high memory usage with little performance gain since on an active server, mod_mem_cache will rarely serve the same page twice in the same apache process.
3. Configure mod_disk_cache with a flat hierarchy – ensure that you are using CacheDirLength=2 and CacheDirLevels=1 to ensure htcacheclean will not take forever when cleaning up your cache directory.
4. Setup appropriate Expires, Etag, and Cache-Control Headers – to utilize your cache, you must tell it when a file expires, otherwise your client will not experience the caching benefits.
5. Put Cache on separate disk – place your cache on a separate physical disk for fastest access without slowing down other processes.
6. Use Piped Logging instead of direct logging – directly logging to a file has issues when you want to rotate the log file.  It must restart apache to use the next log file.  This will cause significant slowness for your users during the restart.  Particularly if you are using Passenger or some other app loader.
7. Log to a different disk than disk serving pages – put your logs on physically different disks than the files you are serving.
8. Utilize mod_gzip/mod_deflate – gzip your content before sending it off and then the client will ungzip upon receipt, this will minimize the size of file transfers, it generally will help all user experience.
9. Turn HostnameLookups Off – stop doing expensive DNS lookups.  You will rarely ever need them and when you do, you can look them up after the fact.
10. Avoid using hostname in configs – if you have HostnameLookups off, this will prevent you from having to wait for the DNS resolve of the hostnames in your configs, use IP addresses instead.
11. Use Persistent Connections – Set KeepAlive On and then set KeepAliveTimeout and KeepAliveRequests.  KeepAliveTimeout is how long apache will wait for the next request, and KeepAliveRequests is the max number of requests for a client prior to resetting the connection.  This will prevent the client from having to reconnect between each request.
12. Do Not set KeepAliveTimeout too high – if you have more requests than apache children, this setting can starve your pool of available clients.
13. Disable .htaccess – i.e. AllowOverride None  This will prevent apache from having to check for a .htaccess file on each request.
14. Allow symlinks – i.e. Options +FollowSymLinks -SymLinksIfOwnerMatch.  Otherwise, apache will make a separate call on each filename to ensure it is not a symlink.
15. Set ExtendedStatus Off – Although very useful, the ExtendedStatus will produce several system calls for each request to gather statistics.  Better to utilize for a set time period in order to benchmark, then turn back off.
16. Avoid Wildcards in DirectoryIndex – use a specific DirectoryIndex, i.e. index.html orindex.php, not index

OS Specifics

17. Increase Swappiness – particularly on single site hosts this will increase performance.  On linux systems increase /proc/sys/vm/swappiness to at least 60 if not greater.  This will try to load as many files as possible into the memory cache for faster access.

18. Increase Write Buffer Size – increase your write buffer size for tcp/ip buffers.  On linux systems increase /proc/sys/net/core/wmem_max and /proc/sys/net/core/wmem_default. If your pages fit within this buffer, apache will complete a process in one call to the tcp/ip buffer.
19. Increase Max Open Files – if you are handling high loads increase the number of allowed open files.  On linux, increase /proc/sys/fs/file-max and run ulimit -H -n 4096.

Application Specifics

 

20. Setup Frontend proxy for images and stylesheets – allow your main web servers to process the application while images and stylesheets are served from frontend webservers
21. Use mod_passenger for rails – mod_passenger is able to share memory and resources amongst several processes, allowing for faster spawning of new application instances.  It will also monitor these processes and remove them when they are unnecessary.
22. Turn off safe_mode for php – it will utilize about 50-70% of your script time checking against these safe directives.  Instead configure open_base_dir properly and utilize plugins such as mod_itk.
23. Don’t use threaded mpm with mod_php – look at using mod_itk, mod_php tends to segfault with threaded mpm.
24. Flush buffers early for pre-render – it takes a relatively long time to create a web page on the backend, flush your buffer prior to page completion to send a partial page to the client, so it can start rendering.  A good place to do this is right after the HEAD section – so that the browser can start fetching other objects.
25. Use a Cache for frequently accessed data – memcached is a great for frequently used data and sessions.  It will speed up your apache render time as databases are slow.

And one more tip.  Your Apache performance is only as good as your benchmarks measuring it.  If you can’t get numbers or a graph to show that your performance has increased or load decreased, then you don’t know if your tuning has done you any good.  A great way to ensure that you are performing better than before is to use these techniques to hook up apache monitoring to Monitis hosted monitoring.
Do you know more tips? Disagree with some of the tips? Please share your comments bellow.

25 Apache Performance Tuning Tips

 Optimization  Comments Off on 25 Apache Performance Tuning Tips
Jan 132015
 

We all know and love Apache.  Its great, it allows us to run websites on the Internet with minimal configuration and administration.
However, this same ease of flexibility and lack of tuning, is typically what leads Apache to becoming a memory hog.  Utilizing these easy to understand tips, you can gain a significant performance boost from Apache.

Apache Specifics

1. Remove unused modules – save memory by not loading modules that you do not need, including but not limited to mod_php, mod_ruby, mod_perl, etc.
2. Use mod_disk_cache NOT mod_mem_cache – mod_mem_cache will not share its cache amongst different apache processes, which results in high memory usage with little performance gain since on an active server, mod_mem_cache will rarely serve the same page twice in the same apache process.
3. Configure mod_disk_cache with a flat hierarchy – ensure that you are using CacheDirLength=2 and CacheDirLevels=1 to ensure htcacheclean will not take forever when cleaning up your cache directory.
4. Setup appropriate Expires, Etag, and Cache-Control Headers – to utilize your cache, you must tell it when a file expires, otherwise your client will not experience the caching benefits.
5. Put Cache on separate disk – place your cache on a separate physical disk for fastest access without slowing down other processes.
6. Use Piped Logging instead of direct logging – directly logging to a file has issues when you want to rotate the log file.  It must restart apache to use the next log file.  This will cause significant slowness for your users during the restart.  Particularly if you are using Passenger or some other app loader.
7. Log to a different disk than disk serving pages – put your logs on physically different disks than the files you are serving.
8. Utilize mod_gzip/mod_deflate – gzip your content before sending it off and then the client will ungzip upon receipt, this will minimize the size of file transfers, it generally will help all user experience.
9. Turn HostnameLookups Off – stop doing expensive DNS lookups.  You will rarely ever need them and when you do, you can look them up after the fact.
10. Avoid using hostname in configs – if you have HostnameLookups off, this will prevent you from having to wait for the DNS resolve of the hostnames in your configs, use IP addresses instead.
11. Use Persistent Connections – Set KeepAlive On and then set KeepAliveTimeout and KeepAliveRequests.  KeepAliveTimeout is how long apache will wait for the next request, and KeepAliveRequests is the max number of requests for a client prior to resetting the connection.  This will prevent the client from having to reconnect between each request.
12. Do Not set KeepAliveTimeout too high – if you have more requests than apache children, this setting can starve your pool of available clients.
13. Disable .htaccess – i.e. AllowOverride None  This will prevent apache from having to check for a .htaccess file on each request.
14. Allow symlinks – i.e. Options +FollowSymLinks -SymLinksIfOwnerMatch.  Otherwise, apache will make a separate call on each filename to ensure it is not a symlink.
15. Set ExtendedStatus Off – Although very useful, the ExtendedStatus will produce several system calls for each request to gather statistics.  Better to utilize for a set time period in order to benchmark, then turn back off.
16. Avoid Wildcards in DirectoryIndex – use a specific DirectoryIndex, i.e. index.html or index.php, not index

OS Specifics

17. Increase Swappiness – particularly on single site hosts this will increase performance.  On linux systems increase /proc/sys/vm/swappiness to at least 60 if not greater.  This will try to load as many files as possible into the memory cache for faster access.
18. Increase Write Buffer Size – increase your write buffer size for tcp/ip buffers.  On linux systems increase /proc/sys/net/core/wmem_max and /proc/sys/net/core/wmem_default. If your pages fit within this buffer, apache will complete a process in one call to the tcp/ip buffer.
19. Increase Max Open Files – if you are handling high loads increase the number of allowed open files.  On linux, increase /proc/sys/fs/file-max and run ulimit -H -n 4096.

Application Specifics

20. Setup Frontend proxy for images and stylesheets – allow your main web servers to process the application while images and stylesheets are served from frontend webservers
21. Use mod_passenger for rails – mod_passenger is able to share memory and resources amongst several processes, allowing for faster spawning of new application instances.  It will also monitor these processes and remove them when they are unnecessary.
22. Turn off safe_mode for php – it will utilize about 50-70% of your script time checking against these safe directives.  Instead configure open_base_dir properly and utilize plugins such as mod_itk.
23. Don’t use threaded mpm with mod_php – look at using mod_itk, mod_php tends to segfault with threaded mpm.
24. Flush buffers early for pre-render – it takes a relatively long time to create a web page on the backend, flush your buffer prior to page completion to send a partial page to the client, so it can start rendering.  A good place to do this is right after the HEAD section – so that the browser can start fetching other objects.
25. Use a Cache for frequently accessed data – memcached is a great for frequently used data and sessions.  It will speed up your apache render time as databases are slow.

And one more tip.  Your Apache performance is only as good as your benchmarks measuring it.  If you can’t get numbers or a graph to show that your performance has increased or load decreased, then you don’t know if your tuning has done you any good.  A great way to ensure that you are performing better than before is to use these techniques to hook up apache monitoring to Monitis hosted monitoring.
Do you know more tips? Disagree with some of the tips? Please share your comments bellow.

Apache Optimization 2

 Optimization  Comments Off on Apache Optimization 2
Jan 132015
 

All the important configuration options are stored by Apache in a config file called httpd.conf that is located at /usr/local/apache/conf/httpd.conf. We will start by opening this file in your favorite text editor. For example:

  • vi /usr/local/apache/conf/httpd.conf

MaxClients
Total number of concurrent connections.
Locate it in the configuration file. This should be set to a reasonable value. I suggest using this formula to determine the right value for your server.

  • MaxClients = 150 x RAM (GB)

So for example if you have 2 GB or RAM set this value to 300.
There is no reason for you to set it any higher unless you have a specific problem with this value. A high value can lead to a complete server hang in case of a DOS attack. A value too low can create timeout problems for your clients if the limit is reached.
ServerLimit
This value should be same as MaxClients

  • ServerLimit = 150 x RAM (GB)

MinSpareServers and MaxSpareServers
MaxSpareServers and MinSpareServers control how many spare (unused) child-processes Apache will keep alive while waiting for more requests to put them to use. Each child-process consumes resources, so having MaxSpareServers set too high can cause resource problems. On the other hand, if the number of unused servers drops below MinSpareServers, Apache will fork (an expensive operation) new child-processes until MinSpareServers is satisfied.
Leave those values to:

  • MinSpareServers 5
  • MaxSpareServers 10

If you have more them 2 GB of RAM and you run a resource intensive website consider increasing MaxSpareServers.
MaxRequestsPerChild
Controls the number of request the a child serves before the child is killed. This should not be set too low as it will put an unnecessary load on the apache server to recreate the child. I suggest setting it to:

  • MaxRequestsPerChild 1000 for 1 GB RAM

10,000 for 2 GB and 0 for more than 2 GB RAM
KeepAlive and MaxKeepAliveRequests
KeepAlive provides long-lived HTTP sessions which allow multiple requests to be sent over the same TCP connection. In some cases this has been shown to result in an almost 50% speedup in latency times for HTML documents with many images, but having keepalive on is also a resource intensive setting.
Here comes the big question: To KeepAlive or not to KeepAlive?
Well the opinions are mixed here, some say to KeepAlive some say not to.

  • KeepAlive off

If you want to hear my option I would say NOT to KeepAlive if you are running a shared hosting business or if you want to get the most out of your hardware. You should KeepAlive only if the loading time of your pages is the most important factor in your business and you have the money to invest in a more powerful hardware. If you decide to KeepAlive I suggest you set MaxKeepAliveRequest low to something like 2 seconds.
StartServers
Sets the number of child server processes created on startup. This setting depends greatly on the type of webserver you run. If you run low traffic websites on that server set it low to something like 5. If you have resource intensive websites on that server you should set it close to MaxClients.

  • StartServers 5

Timeout
The amount of time Apache will wait for three things: the total amount of time it takes to receive a GET request, The amount of time between receipt of TCP packets on a POST or PUT request, the amount of time between ACKs on transmissions of TCP packets in responses.
The default value is 300. You should set time to something a bit lower. A setting of 150 is probably ok. This will also help in case of small DOS attacks like to ones targeting some phpBB forums. Do NOT set it any lower then 10 as your users will start having timeout problems.

  • Timeout 150

After you have done all the necessary changes you can go ahead and restart Apache.
There is an extra step that you have to do so that the changes that you done to httpd.conf aren’t lost when a recompile is done.
To also save the changes in the database you will have to run:
/usr/local/cpanel/bin/apache_conf_distiller –update
You can check to see if the changes were accepted and will not be discarded at the next apache recompile by running
/usr/local/cpanel/bin/build_apache_conf
Sample values:
MinSpareServers 5
MaxSpareServers 10
ServerLimit 600
MaxClients 600
MaxRequestsPerChild 0
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 3
Timeout 30

Apache Optimization

 Optimization  Comments Off on Apache Optimization
Jan 132015
 

The default Apache settings that cPanel sets upon install are definitely something that can be improved on. With a few small tweaks, the efficiency with which Apache runs with can be greatly improved.
Please noted: This article assumes that you are using a Linux server running Apache and cPanel or Plesk, and that you are familiar with editing files from the command line.

To start, open the Apache configuration file and finding the directives section. On a cPanel server, it will be located in /usr/local/apache/conf/. On a Plesk server, it will be in /etc/httpd/conf/. If you are using vi or vim: once you open the file, you can find the directives by scrolling through the file, or by typing forward-slash ‘/’ and typing the exact string that you are looking for (search is case specific).
[root@host /] vim /usr/local/apache/conf/httpd.conf
or
[root@host /] vim /etc/httpd/conf/httpd.conf
This list is a composite of the settings we will be reviewing from fresh install on a cPanel server:

Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 15
MinSpareServers 5
MaxSpareServers 10
StartServers 5
MaxClients 150
MaxRequestsPerChild 0

Please note, the settings that we will review in this article are by no means a complete list of tweakable options in the Apache configuration file. The settings we will be focusing on are the ones that control how Apache handles webpage requests.
Timeout

Timeout 300

Usually this value doesn’t require editing and a default of 300 is sufficient. Lowering the ‘Timeout’ value will cause a long running script to terminate earlier than expected.
On virtualized servers like VPS servers, lowering this value to 100 can help improve performance.

KeepAlive

KeepAlive On

This setting should be “On” unless the server is getting requests from hundreds of IPs at once.
High volume and/or load balanced servers should have this setting disabled (Off) to increase connection throughput.

MaxKeepAliveRequests

MaxKeepAliveRequests 100

This setting limits the number of requests allowed per persistent connection when KeepAlive is on. If it is set to 0, unlimited requests will be allowed.
It is recommended to keep this value at 100 for virtualized accounts like VPS accounts. On dedicated servers it is recommended that this value be modified to 150.

KeepAliveTimeout

KeepAliveTimeout 15

The number of seconds Apache will wait for another request before closing the connection. Setting this to a high value may cause performance problems in heavily loaded servers. The higher the timeout, the more server processes will be kept occupied waiting on connections with idle clients.
It is recommended that this value be lowered to 5 on all servers.

MinSpareServers

MinSpareServers 5

This directive sets the desired minimum number of idle child server processes. An idle process is one which is not handling a request. If there are fewer spareservers idle then specified by this value, then the parent process creates new children at a maximum rate of 1 per second. Setting this parameter to a large number is almost always a bad idea.
Liquidweb recommends adjusting the value for this setting to the following:
Virtualized server, ie VPS 5
Dedicated server with 1-2GB RAM 10
Dedicated server with 2-4GB RAM 20
Dedicated server with 4+ GB RAM 25
MaxSpareServers

MaxSpareServers 10

The MaxSpareServers directive sets the desired maximum number of idle child server processes. An idle process is one which is not handling a request. If there are more than MaxSpareServers idle, then the parent process will kill off the excess processes.
The MaxSpareServers value should be set as double the value that is set in MinSpareServers.

StartServers

StartServers 5

This directivesets the number of child server processes created on startup. This value should mirror what is set in MinSpareServers.

MaxClients

MaxClients 150

This directive sets the limit on the number of simultaneous requests that will be served. Any connection attempts over the specified limit will be queued. Once a process is freed at the end of a different request, the queued connection will then be served.
For virtualized servers such as VPS accounts, it is recommended to keep this value at 150. For all dedicated servers the recommended value for this setting is 250.
MaxRequestsPerChild

MaxRequestsPerChild 0

This directive sets the limit on the number of requests that an individual child server process will handle. After the number of requests reaches the value specified, the child process will die. When this value is set at 0, then the process will never expire.
Liquidweb recommends adjusting the value for this setting to the following:
Virtualized server, ie VPS 300
Dedicated server with 1-4GB RAM 500
Dedicated server with 4+GB RAM 1000

How to install vnc on centos 6

 Linux, Monitoring  Comments Off on How to install vnc on centos 6
Nov 242014
 

VNC server

VNC is used to display X windows sessions on remote computers.In this tutorial, we can learn how to setup VNC server on centos 6. Desktop environment is required in order to enable VNC server on centos.

Install VNC on Centos 6

Before installing VNC server, make sure you have installed any Desktop environment.
Step 1 » Issue the below command to install gnome desktop environment.
[root@krizna ~]# yum groupinstall Desktop
Step 2 » After installing gnome packages .Issue the below command to install VNC package along with dependencies.
[root@krizna ~]# yum -y install tigervnc-server pixman pixman-devel libXfont
Step 3 » Create user name and password.
[root@krizna ~]# adduser user1
[root@krizna ~]# adduser user2
[root@krizna ~]# passwd user1
[root@krizna ~]# passwd user2

Step 4 » Create VNC passwords for the Users created.
[root@krizna ~]# su - user1
[user1@krizna ~]$ vncpasswd
Password:
Verify:
[user1@krizna ~]$ logout
[root@krizna ~]# su - user2
[user2@krizna ~]$ vncpasswd
Password:
Verify:
[user2@krizna ~]$ logout

Step 5 » Now open /etc/sysconfig/vncservers file and add the following lines at the end of the file( Edit as per your usernames ).
VNCSERVERS="1:user1 2:user2"
VNCSERVERARGS[1]="-geometry 640x480"
VNCSERVERARGS[2]="-geometry 800x600"

Here we have configured session 1 with 640×480 resolution for the user “user1″ and session 2 with 800×600 resolution for the user “user2″.
Step 6 » Start vnc service
[root@krizna ~]# service vncserver start
and issue this command to start vnc service automatically during startup.
[root@krizna ~]# chkconfig --levels 235 vncsever on
Step 7 » Now in remote machine, start vncviewer type the IP and session as below to view their respective sessions.
192.168.1.10:1 for user1
192.168.1.10:2 for user2

install vnc on centos 6
Users sessions.
install vnc server centos 6

Troubleshooting

» Check the iptables in the server, if you are not able to connect the sessions.
Issue the below command to stop iptables service.
[root@krizna ~]# service iptables stop
try again.
» you might receive the below error while starting the vnc service.
/usr/bin/Xvnc: symbol lookup error: /usr/bin/Xvnc: undefined symbol: pixman_composite_trapezoids
/usr/bin/Xvnc: symbol lookup error: /usr/bin/Xvnc: undefined symbol: pixman_composite_trapezoids
[FAILED]
Issue the below command to install pixman,pixman-devel and libXfont packages.
[root@krizna ~]# yum -y pixman pixman-devel libXfont
[or]
This command will update everything .
[root@krizna ~]# yum update
and restart the VNC service and try again.

Install ntopng on Centos 7

 Monitoring  Comments Off on Install ntopng on Centos 7
Oct 312014
 
This is how to compile ntopng in a fresh centos 7 x64 installation
  • For the impatient:
    • # yum install -y subversion autoconf automake make gcc 
      libpcap-devel libxml2-devel sqlite-devel libtool glib2-devel
       gcc-c++
      $ svn co https://svn.ntop.org/svn/ntop/trunk/ntopng
      $ ./autogen.sh
      $ ./configure
      $ make
      $ ./ntopng --help
      ntopng x86_64 v.1.1.4 (r7865) - (C) 1998-14 ntop.org
      <snip>
  • Step by step description
    • Pull the source code from the ntop svn repository. To do this, you need first to install subversion using yum as follows
      $ sudo yum -y install subversion
    • Now change your directory to the one you want ntopng in and run
      $ svn co https://svn.ntop.org/svn/ntop/trunk/ntopng
    • Once the repository is downloaded, you should run the autogen.sh script
      $ ./autogen.sh
    • It will fail due to the lack of a autoconf packages. To step over this run
      $ sudo yum install -y autoconf automake
    • and re-run autogen.sh
      $ ./autogen.sh
      ......
    • Now autogen.sh completes successfully, then run ./configure, but it will fail due to the missing compiler
      $ ./configure
      .....
      configure: error: no acceptable C compiler found in $PATH
    • Install it using
      $ sudo yum install -y gcc
      Next step is the missing libpcap development package
      $ ./configure
      ......
    • Please install libpcap(-dev) (http://tcpdump.org)
      $ sudo yum install -y libpcap-devel
    • Next mandatory package is libxml2-devel required by rrd compilation
      $ ./configure
      .....
    • Please install libxml2(-devel) package (RRD prerequisite)
      $ sudo yum install -y libxml2-devel
      and glib2-devel
      $ ./configure
      .....
    • Please install libglib-2.0 (glib2-devel/libglib2.0-dev) package (RRD prerequisite)
      $ sudo yum install -y glib2-devel
    • now configure require another package
      $ ./configure
      SQLite 3.x missing (libsqlite3-dev): please install it and try again
    • Installable runn
      ing

      $ sudo yum install -y sqlite-devel
    • Now configure works
      $ ./configure
    • You are now ready to compile typing /usr/bin/gmake
      But make will fail due the the missing c++ compiler
      $ make
      configure: error: Unable to find a working C++ compiler
      $ sudo yum install gcc-c++
    • After the last installed package, build will fail on json-c compilation with the following error
      $ make
      make: *** [third-party/json-c/.libs/libjson-c.a] Error 2
    • To solve this, install libtool package using
      $ sudo yum -y install libtool
    • Then rerun make
      $ make
    • and you should have everything compiled successfully.
      Test is running:
      $ ./ntopng --help
      ntopng x86_64 v.1.1.4 (r7865) - (C) 1998-14 ntop.org
Enjoy!

Other

IMPORTANT

This directory contains nightly builds (SVN code) of 64 bit binary packages for RedHat/CentOS (latest OS version). Please use rpm-stable.ntop.org for stable builds.

In order to use the repository you need to create a file named /etc/yum.repos.d/ntop.repo containing
# cat /etc/yum.repos.d/ntop.repo
[ntop]
name=ntop packages
baseurl=http://www.nmon.net/centos/$releasever/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://www.nmon.net/centos/RPM-GPG-KEY-deri
[ntop-noarch]
name=ntop packages
baseurl=http://www.nmon.net/centos/$releasever/noarch/
enabled=1
gpgcheck=1
gpgkey=http://www.nmon.net/centos/RPM-GPG-KEY-deri

and also install the /etc/yum.repos.d/epel.repo extra repositories

# cat /etc/yum.repos.d/epel.repo 
[epel]
name=Extra Packages for Enterprise Linux X - $basearch
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-X&arch=$basearch
failovermethod=priority
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-X

Note: replace X with 6 (for CentOS 6) or 7 (for CentOS 7) then do:

  • yum clean all
  • yum update
  • yum install pfring n2disk nprobe ntopng ntopng-data nbox

PF_RING is now packaged without ZC/DNA drivers. You can choose what family you want to install

  • ZC: yum install pfring-drivers-zc-dkms
  • DNA: yum install pfring-drivers-dna-dkms
Most software works without licenses. However some components do need a license. They include:
  • PF_RING DNA and libzero user-space libraries
  • nProbe (NetFlow/IPFIX probe)
  • n2disk (packet to disk application)
You can find more info on the ntop site, or acquire licenses on the ntop e-shop.
We remind you that all ntop products are available at no cost to universities and research.
NOTE
  • we periodically update the kernel package in order to build against a recent kernel. If you encounter issues while installing packages make sure you have first updated the linux kernel package.


Install Redis on CentOS 6.5

 Database  Comments Off on Install Redis on CentOS 6.5
Oct 312014
 

Perform an update to ensure you’ve got the latest of everything in the base package.

yum update

Install wget so you can download a few things.

yum install wget

Allow yum to locate/install redis, per this page here.

wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm"

Now, install all the prerequisites

yum install tar make automake gcc gcc-c++ git net-tools libcurl-devel libxml2-devel libffi-devel libxslt-devel tcl redis ImageMagick npm mysql-server mysql-devel nginx libyaml libyaml-devel patch readline-devel libtool bison

Enable and start MySQL

chkconfig --level 3 mysqld on
service mysqld start

Secure your MySQL installation by setting a password. replace ‘new-password’ with your secure password.

mysqladmin -u root password 'new-password'
mysqladmin -u root -h YourHost.YourDomain.com password 'new-password'

Open up the necessary firewall ports

vi /etc/sysconfig/iptables
copy this line.
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
and add two more with port 80 & 443 as well
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT

Restart the firewall

service iptables restart

How to set a default gateway on CentOS

 Linux  Comments Off on How to set a default gateway on CentOS
Oct 102014
 

A default gateway is a remote host or router that your Linux host forwards traffic to when the destination IP address of outgoing traffic does not match any route in your local routing table. Configuring a default gateway on CentOS is quite straightforward.
If you wish to change a default gateway temporarily at run time, you can use ip command.
First things first. To check what default gateway you are using currently:
$ ip route show
192.168.91.0/24 dev eth0  proto kernel  scope link  src 192.168.91.128 
169.254.0.0/16 dev eth0 scope link metric 1002
default via 192.168.91.2 dev eth0
According to the local routing table shown above, a default gateway is 192.168.91.2, and traffic is forwarded to the gateway via eth0.
In order to change a default gateway to another IP address:
$ sudo ip route replace default via 192.168.91.10 dev eth0
Obviously, a default gateway’s IP address should come from the subnet associated with the interface connected to the default gateway, in this example, 192.168.91.0/24. Otherwise, the command will fail with the following error.
RTNETLINK answers: No such process
Also, keep in mind that the default route change made by ip command will be lost after rebooting.
In order to set a default gateway permanently on CentOS, you will need to update /etc/sysconfig/network accordingly.
$ sudo vi /etc/sysconfig/network
GATEWAY=192.168.91.10
Again, be aware that the IP addressed specified here should match with the subnet (192.168.91.0/24) associated with a default route interface.
Another option to set a default gateway persistently on CentOS is to edit /etc/sysconfig/network-scripts/ifcfg-<default_interface_name>, and add “GATEWAY=<gateway_ip>” there. If the default interface is “eth0”, you will need to edit /etc/sysconfig/network-scripts/ifcfg-eth0. If you choose to use this method, you need to refer to this post to get familiar with this option.
Whether you edit /etc/sysconfig/network or /etc/sysconfig/network-scripts/ifcfg-ethX, don’t forget to restart networkservice as follows, or reboot your CentOS for the change to take effect.