“drush” is a command line shell and scripting interface for Drupal, a veritable Swiss Army knife designed to make life easier for those of us who spend some of our working hours hacking away at the command prompt. In general
• drush is a command line shell and scripting interface for Drupal.
• drush is not a module
• It is valid to use the latest '7.x' (or master) no matter what your version of Drupal is. Drush is independent of Drupal version
Installation:
1. Untar the tarball into a folder outside of your web site (/path/to/drush)
2. Make the 'drush' command executable:
$ chmod u+x /path/to/drush/drush
3. (Optional, but recommended:) To ease the use of drush,
- create a link to drush in a directory that is in your PATH, e.g.:
$ ln -s /path/to/drush/drush /usr/local/bin/drush
NOTE ON PHP.INI FILES
Usually, php is configured to use separate php.ini files for the web server and the command line. To see which php.ini file drush is using, run:
$ drush status
Compare the php.ini that drush is using with the php.ini that the webserver is using. Make sure that drush's php.ini is given as much memory to work with asthe web server is; otherwise, Drupal might run out of memory when drush bootstraps it.
Drush requires a fairly unrestricted php environment to run in. In particular, you should insure that safe_mode, open_basedir, disable_functions and disable_classes are empty.
If drush is using the same php.ini file as the web server, you can create a php.ini file exclusively for drush by copying your web server's php.ini file to the folder $HOME/.drush or the folder /etc/drush. Then you may edit this file and change the settings described above without affecting the php enviornment of your web server.
4. Start using drush by running "drush" from your Drupal root directory.
Drush Commands:
You can find the drush commands from the url: http://drush.ws/
November 22, 2011
September 12, 2011
Puppet script for installing Apache, Mysql & PHP (LAMP) for all Linux operating systems.
Click here for the link to have a generalized puppet script for installing Apache, Mysql and PHP on any Linux Operating Systems.
For git hub url click here or git@github.com:geopcgeo/LAMP.git
For git hub url click here or git@github.com:geopcgeo/LAMP.git
August 25, 2011
Optimizing Mysql
Optimizing MySQL
mysql_fix_privilege_tables
mysqlcheck -o –all-databases
Open /etc/my.cnf
[mysqld]
max_connections=500
safe-show-database
query_cache_limit=1M
query_cache_size=32M
query_cache_type=1
key_buffer_size=256M
table_cache=150
thread_cache_size=200
datadir = /var/lib/mysql
socket = /var/lib/mysql/mysql.sock
[mysql.server]
user = mysql
basedir = /var/lib
[safe_mysqld]
err-log = /var/log/mysqld.log
pid-file = /var/run/mysqld/mysqld.pid
Below are notes on some of the important variables, I took down while tuning the config file.
1. QUERY CACHE
query_cache_size:
* MySQL 4 provides one feature that can prove very handy - a query cache. In a situation where the database has
to repeatedly run the same queries on the same data set, returning the same results each time, MySQL can cache the result
set, avoiding the overhead of running through the data over and over and is extremely helpful on busy servers.
query_cache_limit : a total size of memory that server utilizes for caching results of queries
query_cache_type : 0 - Off
1 - Cache all query results except for those that begin with SELECT SQL_NO_CACHE
2 - Cache results only for queries that begin with SELECT SQL_CACHE.
2. key_buffer_size:
* The value of key_buffer_size is the size of the buffer used with indexes. The larger the buffer, the faster
the SQL command will finish and a result will be returned. Ideally, it will be large enough to contain
all the indexes (the total size of all .MYI files on the server).
Using a value that is 25% of total memory on a machine that mainly runs MySQL is quite common.
The Key_reads/Key_read_requests ratio < 0.01
The Key_writes/Key_write_requests ratio ~ 1
SHOW STATUS;
3. LOG
log : Whether logging of all statements to the general query log is enabled. See Section 5.3.2, “The General Query Log”.
log_error : The location of the error log. This variable was added in MySQL 4.0.10.
log_slow_queries : Whether slow queries should be logged. “Slow” is determined by the value of the long_query_time
variable.
4. table_cache:
* The default is 64. Each time MySQL accesses a table, it places it in the cache. If the system accesses many
tables, it is faster to have these in the cache. MySQL, being multi-threaded, may be running many queries on the table at
one time, and each of these will open a table. Examine the value of open_tables at peak times. If you find it stays at the
same value as your table_cache value, and then the number of opened_tables starts rapidly increasing, you should increase
the table_cache if you have enough memory.
check for Open_tables
SHOW STATUS;
5. sort_buffer_size: Each thread that needs to do a sort allocates a buffer of this size. Increase this value for faster
ORDER BY or GROUP BY operations.
6. read_rnd_buffer_size:
* The read_rnd_buffer_size is used after a sort, when reading rows in sorted order. If you use many queries with
ORDER BY, upping this can improve performance. Remember that, unlike key_buffer_size and table_cache, this buffer is
allocated for each thread. This variable was renamed from record_rnd_buffer in MySQL 4.0.3. It defaults to the same size as
the read_buffer_size. A rule-of-thumb is to allocate 1KB for each 1MB of memory on the server, for example 1MB on a machine
with 1GB memory.
7. thread_cache_size:
* If you have a busy server that’s getting a lot of quick connections, set your thread cache high enough that the
Threads_created value in SHOW STATUS stops increasing. This should take some of the load off of the CPU.
8. tmp_table_size:
* “Created_tmp_disk_tables” are the number of implicit temporary tables on disk created while executing statements
and “created_tmp_tables” are memory-based. Obviously it is bad if you have to go to disk instead of memory all the time.
Increase the value of tmp_table_size if you do many advanced GROUP BY queries and you have lots of memory.
This variable does not apply to user-created MEMORY tables.
9. innodb_buffer_pool_size
While the key_buffer_size is the variable to target for MyISAM tables, for InnoDB tables, it is innodb_buffer_pool_size.
Again, you want this as high as possible to minimize slow disk usage. On a dedicated MySQL server running InnoDB tables,
you can set this up to 80% of the total available memory.
10. innodb_additional_mem_pool_size
This variable stores the internal data structure. Make sure it is big enough to store data about all your InnoDB tables
(you will see warnings in the error log if the server is using OS memory instead).
11. max_connections
12. wait_timeout=500
This variable determines the timeout in seconds before mysql will dump a connection. If set to low
you will likely receive mySQL server has gone away errors in your log, which in vBulletins case is quite common.
13. max_allowed_packet
The maximum size of one packet or any generated/intermediate string.
Again if set to low (the default is 8M) users will likely experience errors. 16M has always
worked fine for my production environments.
You can grab a mySQL performance script from the guys at hackmysql.com( http://hackmysql.com/mysqlreport ). I use it to
tell me how the database is performing under load. You can run this from any shell when you are loaded with traffic.
Nothing fancy but should give you an idea.
==================================
http://dev.mysql.com/doc/refman/4.1/en/server-system-variables.html
http://dev.mysql.com/doc/refman/4.1/en/server-status-variables.html
mysql_fix_privilege_tables
mysqlcheck -o –all-databases
Open /etc/my.cnf
[mysqld]
max_connections=500
safe-show-database
query_cache_limit=1M
query_cache_size=32M
query_cache_type=1
key_buffer_size=256M
table_cache=150
thread_cache_size=200
datadir = /var/lib/mysql
socket = /var/lib/mysql/mysql.sock
[mysql.server]
user = mysql
basedir = /var/lib
[safe_mysqld]
err-log = /var/log/mysqld.log
pid-file = /var/run/mysqld/mysqld.pid
Below are notes on some of the important variables, I took down while tuning the config file.
1. QUERY CACHE
query_cache_size:
* MySQL 4 provides one feature that can prove very handy - a query cache. In a situation where the database has
to repeatedly run the same queries on the same data set, returning the same results each time, MySQL can cache the result
set, avoiding the overhead of running through the data over and over and is extremely helpful on busy servers.
query_cache_limit : a total size of memory that server utilizes for caching results of queries
query_cache_type : 0 - Off
1 - Cache all query results except for those that begin with SELECT SQL_NO_CACHE
2 - Cache results only for queries that begin with SELECT SQL_CACHE.
2. key_buffer_size:
* The value of key_buffer_size is the size of the buffer used with indexes. The larger the buffer, the faster
the SQL command will finish and a result will be returned. Ideally, it will be large enough to contain
all the indexes (the total size of all .MYI files on the server).
Using a value that is 25% of total memory on a machine that mainly runs MySQL is quite common.
The Key_reads/Key_read_requests ratio < 0.01
The Key_writes/Key_write_requests ratio ~ 1
SHOW STATUS;
3. LOG
log : Whether logging of all statements to the general query log is enabled. See Section 5.3.2, “The General Query Log”.
log_error : The location of the error log. This variable was added in MySQL 4.0.10.
log_slow_queries : Whether slow queries should be logged. “Slow” is determined by the value of the long_query_time
variable.
4. table_cache:
* The default is 64. Each time MySQL accesses a table, it places it in the cache. If the system accesses many
tables, it is faster to have these in the cache. MySQL, being multi-threaded, may be running many queries on the table at
one time, and each of these will open a table. Examine the value of open_tables at peak times. If you find it stays at the
same value as your table_cache value, and then the number of opened_tables starts rapidly increasing, you should increase
the table_cache if you have enough memory.
check for Open_tables
SHOW STATUS;
5. sort_buffer_size: Each thread that needs to do a sort allocates a buffer of this size. Increase this value for faster
ORDER BY or GROUP BY operations.
6. read_rnd_buffer_size:
* The read_rnd_buffer_size is used after a sort, when reading rows in sorted order. If you use many queries with
ORDER BY, upping this can improve performance. Remember that, unlike key_buffer_size and table_cache, this buffer is
allocated for each thread. This variable was renamed from record_rnd_buffer in MySQL 4.0.3. It defaults to the same size as
the read_buffer_size. A rule-of-thumb is to allocate 1KB for each 1MB of memory on the server, for example 1MB on a machine
with 1GB memory.
7. thread_cache_size:
* If you have a busy server that’s getting a lot of quick connections, set your thread cache high enough that the
Threads_created value in SHOW STATUS stops increasing. This should take some of the load off of the CPU.
8. tmp_table_size:
* “Created_tmp_disk_tables” are the number of implicit temporary tables on disk created while executing statements
and “created_tmp_tables” are memory-based. Obviously it is bad if you have to go to disk instead of memory all the time.
Increase the value of tmp_table_size if you do many advanced GROUP BY queries and you have lots of memory.
This variable does not apply to user-created MEMORY tables.
9. innodb_buffer_pool_size
While the key_buffer_size is the variable to target for MyISAM tables, for InnoDB tables, it is innodb_buffer_pool_size.
Again, you want this as high as possible to minimize slow disk usage. On a dedicated MySQL server running InnoDB tables,
you can set this up to 80% of the total available memory.
10. innodb_additional_mem_pool_size
This variable stores the internal data structure. Make sure it is big enough to store data about all your InnoDB tables
(you will see warnings in the error log if the server is using OS memory instead).
11. max_connections
12. wait_timeout=500
This variable determines the timeout in seconds before mysql will dump a connection. If set to low
you will likely receive mySQL server has gone away errors in your log, which in vBulletins case is quite common.
13. max_allowed_packet
The maximum size of one packet or any generated/intermediate string.
Again if set to low (the default is 8M) users will likely experience errors. 16M has always
worked fine for my production environments.
You can grab a mySQL performance script from the guys at hackmysql.com( http://hackmysql.com/mysqlreport ). I use it to
tell me how the database is performing under load. You can run this from any shell when you are loaded with traffic.
Nothing fancy but should give you an idea.
==================================
http://dev.mysql.com/doc/refman/4.1/en/server-system-variables.html
http://dev.mysql.com/doc/refman/4.1/en/server-status-variables.html
August 23, 2011
Installing Puppet
Installing Facter From Source
The facter library is a prerequisite for Puppet. Like Puppet, there are packages available for most platforms, though you may want to use the tarball if you would like to try a newer version or are using a platform without an OS package:
Get the latest tarball:
$ wget http://puppetlabs.com/downloads/facter/facter-1.6.0.tar.gz
Untar and install facter:
$ gzip -d -c facter-latest.tgz | tar xf -
$ cd facter-*
$ sudo ruby install.rb # or become root and run install.rb
Installing Puppet From Source
Using the same mechanism as Facter, install the puppet libraries and executables:
# get the latest tarball
$ wget http://puppetlabs.com/downloads/puppet/puppet-latest.tgz
# untar and install it
$ gzip -d -c puppet-latest.tgz | tar xf -
$ cd puppet-*
$ sudo ruby install.rb # or become root and run install.rb
You can also check the source out from the git repo:
$ mkdir -p ~/git && cd ~/git
$ git clone git://github.com/puppetlabs/puppet
$ cd puppet
$ sudo ruby ./install.rb
To install into a different location you can use:
$ sudo ruby install.rb --bindir=/usr/bin --sbindir=/usr/sbin
Alternative Install Method: Using Ruby Gems
You can also install Facter and Puppet via gems:
$ wget http://puppetlabs.com/downloads/gems/facter-1.5.7.gem
$ sudo gem install facter-1.5.7.gem
$ wget http://puppetlabs.com/downloads/gems/puppet-0.25.1.gem
$ sudo gem install puppet-0.25.1.gem
The facter library is a prerequisite for Puppet. Like Puppet, there are packages available for most platforms, though you may want to use the tarball if you would like to try a newer version or are using a platform without an OS package:
Get the latest tarball:
$ wget http://puppetlabs.com/downloads/facter/facter-1.6.0.tar.gz
Untar and install facter:
$ gzip -d -c facter-latest.tgz | tar xf -
$ cd facter-*
$ sudo ruby install.rb # or become root and run install.rb
Installing Puppet From Source
Using the same mechanism as Facter, install the puppet libraries and executables:
# get the latest tarball
$ wget http://puppetlabs.com/downloads/puppet/puppet-latest.tgz
# untar and install it
$ gzip -d -c puppet-latest.tgz | tar xf -
$ cd puppet-*
$ sudo ruby install.rb # or become root and run install.rb
You can also check the source out from the git repo:
$ mkdir -p ~/git && cd ~/git
$ git clone git://github.com/puppetlabs/puppet
$ cd puppet
$ sudo ruby ./install.rb
To install into a different location you can use:
$ sudo ruby install.rb --bindir=/usr/bin --sbindir=/usr/sbin
Alternative Install Method: Using Ruby Gems
You can also install Facter and Puppet via gems:
$ wget http://puppetlabs.com/downloads/gems/facter-1.5.7.gem
$ sudo gem install facter-1.5.7.gem
$ wget http://puppetlabs.com/downloads/gems/puppet-0.25.1.gem
$ sudo gem install puppet-0.25.1.gem
August 22, 2011
Puppet
Why Puppet.
As system administrators acquire more and more systems to manage, automation of mundane tasks is increasingly important. Rather than develop in-house scripts, it is desirable to share a system that everyone can use, and invest in tools that can be used regardless of one’s employer. Certainly doing things manually doesn’t scale.
Puppet has been developed to help the sysadmin community move to building and sharing mature tools that avoid the duplication of everyone solving the same problem. It does so in two ways:
It provides a powerful framework to simplify the majority of the technical tasks that sysadmins need to perform
The sysadmin work is written as code in Puppet’s custom language which is shareable just like any other code.
Below are few links for Studying Puppet:
http://bitfieldconsulting.com/puppet-tutorial
http://bitfieldconsulting.com/puppet-tutorial-2
http://projects.puppetlabs.com/projects/1/wiki/Using_Stored_Configuration
http://www.agileweboperations.com/configuration-management-introduction-to-puppet
http://bitfieldconsulting.com/puppet-and-mysql-create-databases-and-users
http://www.how2centos.com/installing-puppet-dashboard-on-centos-5-5/
http://docs.puppetlabs.com/
http://docs.puppetlabs.com/guides/installation.html
http://docs.puppetlabs.com/guides/configuring.html
http://docs.puppetlabs.com/guides/language_guide.html
http://docs.puppetlabs.com/guides/tools.html
As system administrators acquire more and more systems to manage, automation of mundane tasks is increasingly important. Rather than develop in-house scripts, it is desirable to share a system that everyone can use, and invest in tools that can be used regardless of one’s employer. Certainly doing things manually doesn’t scale.
Puppet has been developed to help the sysadmin community move to building and sharing mature tools that avoid the duplication of everyone solving the same problem. It does so in two ways:
It provides a powerful framework to simplify the majority of the technical tasks that sysadmins need to perform
The sysadmin work is written as code in Puppet’s custom language which is shareable just like any other code.
Below are few links for Studying Puppet:
http://bitfieldconsulting.com/puppet-tutorial
http://bitfieldconsulting.com/puppet-tutorial-2
http://projects.puppetlabs.com/projects/1/wiki/Using_Stored_Configuration
http://www.agileweboperations.com/configuration-management-introduction-to-puppet
http://bitfieldconsulting.com/puppet-and-mysql-create-databases-and-users
http://www.how2centos.com/installing-puppet-dashboard-on-centos-5-5/
http://docs.puppetlabs.com/
http://docs.puppetlabs.com/guides/installation.html
http://docs.puppetlabs.com/guides/configuring.html
http://docs.puppetlabs.com/guides/language_guide.html
http://docs.puppetlabs.com/guides/tools.html
August 9, 2011
Linux using my RAM
Q. How do I find out what process are eating up all my memory. Is it possible to find out how long that memory has been allocated to particular process? How do I kill that process to free up memory?
A. You need to use the top command which provides a dynamic real-time view of a running system. It can display system summary information as well as a list of tasks currently being managed by the Linux kernel.
Simply type top command:
# top
top command will tell you the percentage of physical memory a particular process is using at any given time. As far as I know, there is no easy way that can tell how long that memory has been allocated.
You can also use ps command to get more information about process.
# ps aux | less
To kill process uses kill command
'free' and /proc
The 'free' command shows the memory on a machine, in certain categories.
[need explanation of categories here...'man free' doesn't explain the numbers]
$ free
total used free shared buffers cached
Mem: 507564 481560 26004 0 68888 185220
-/+ buffers/cache: 227452 280112
Swap: 2136604 105168 2031436
This information is obtained from /proc/meminfo, which has additional details not shown by the 'free' command.
The following is on my machine with 512 Mb RAM, running Linux 2.6.3:
$ cat /proc/meminfo
MemTotal: 507564 kB
MemFree: 26004 kB
Buffers: 68888 kB
Cached: 185220 kB
SwapCached: 29348 kB
Active: 342488 kB
Inactive: 32092 kB
HighTotal: 0 kB
HighFree: 0 kB
LowTotal: 507564 kB
LowFree: 26004 kB
SwapTotal: 2136604 kB
SwapFree: 2031436 kB
Dirty: 88 kB
Writeback: 0 kB
Mapped: 165648 kB
Slab: 73212 kB
Committed_AS: 343172 kB
PageTables: 2644 kB
VmallocTotal: 524212 kB
VmallocUsed: 7692 kB
VmallocChunk: 516328 kB
meminfo:
Provides information about distribution and utilization of memory. This
varies by architecture and compile options. The following is from a
16GB PIII, which has highmem enabled. You may not have all of these fields.
> cat /proc/meminfo
MemTotal: 16344972 kB
MemFree: 13634064 kB
Buffers: 3656 kB
Cached: 1195708 kB
SwapCached: 0 kB
Active: 891636 kB
Inactive: 1077224 kB
HighTotal: 15597528 kB
HighFree: 13629632 kB
LowTotal: 747444 kB
LowFree: 4432 kB
SwapTotal: 0 kB
SwapFree: 0 kB
Dirty: 968 kB
Writeback: 0 kB
Mapped: 280372 kB
Slab: 684068 kB
Committed_AS: 1576424 kB
PageTables: 24448 kB
ReverseMaps: 1080904
VmallocTotal: 112216 kB
VmallocUsed: 428 kB
VmallocChunk: 111088 kB
MemTotal: Total usable ram (i.e. physical ram minus a few reserved
bits and the kernel binary code)
MemFree: The sum of LowFree+HighFree
Buffers: Relatively temporary storage for raw disk blocks
shouldn't get tremendously large (20MB or so)
Cached: in-memory cache for files read from the disk (the
pagecache). Doesn't include SwapCached
SwapCached: Memory that once was swapped out, is swapped back in but
still also is in the swapfile (if memory is needed it
doesn't need to be swapped out AGAIN because it is already
in the swapfile. This saves I/O)
Active: Memory that has been used more recently and usually not
reclaimed unless absolutely necessary.
Inactive: Memory which has been less recently used. It is more
eligible to be reclaimed for other purposes
HighTotal:
HighFree: Highmem is all memory above ~860MB of physical memory
Highmem areas are for use by userspace programs, or
for the pagecache. The kernel must use tricks to access
this memory, making it slower to access than lowmem.
LowTotal:
LowFree: Lowmem is memory which can be used for everything that
highmem can be used for, but it is also availble for the
kernel's use for its own data structures. Among many
other things, it is where everything from the Slab is
allocated. Bad things happen when you're out of lowmem.
SwapTotal: total amount of swap space available
SwapFree: Memory which has been evicted from RAM, and is temporarily
on the disk
Dirty: Memory which is waiting to get written back to the disk
Writeback: Memory which is actively being written back to the disk
Mapped: files which have been mmaped, such as libraries
Slab: in-kernel data structures cache
Committed_AS: An estimate of how much RAM you would need to make a
99.99% guarantee that there never is OOM (out of memory)
for this workload. Normally the kernel will overcommit
memory. That means, say you do a 1GB malloc, nothing
happens, really. Only when you start USING that malloc
memory you will get real memory on demand, and just as
much as you use. So you sort of take a mortgage and hope
the bank doesn't go bust. Other cases might include when
you mmap a file that's shared only when you write to it
and you get a private copy of that data. While it normally
is shared between processes. The Committed_AS is a
guesstimate of how much RAM/swap you would need
worst-case.
PageTables: amount of memory dedicated to the lowest level of page
tables.
ReverseMaps: number of reverse mappings performed
VmallocTotal: total size of vmalloc memory area
VmallocUsed: amount of vmalloc area which is used
VmallocChunk: largest contigious block of vmalloc area which is free
This command will list all of your processes sorted by memory usage:
ps -eo pmem,pcpu,rss,vsize,args | sort -k 1 -r | more
The first column shows the percentage of memory used by the process. You can use this information to find out which process is using the most.
ps -A --sort -rss -o comm,pmem | head -n 11
ps -A --sort -rss -o pid,comm,pmem,rss
This will give you the 10 processes using the most ram
lsb_release -a && free -m
From this command you get information of version of linux , ram,and memory status information.
Use a tool called pmap. It reports the memory map of a process or processes.
pmap examples
To display process mappings, type
$ pmap pid
$ pmap 3724
Output:
3724: /usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf
0000000000400000 164K r-x-- /usr/sbin/lighttpd
0000000000629000 12K rw--- /usr/sbin/lighttpd
000000000bb6b000 4240K rw--- [ anon ]
00000035ee600000 104K r-x-- /lib64/ld-2.5.so
00000035ee819000 4K r---- /lib64/ld-2.5.so
00000035ee81a000 4K rw--- /lib64/ld-2.5.so
00000035eea00000 1304K r-x-- /lib64/libc-2.5.so
00000035eeb46000 2048K ----- /lib64/libc-2.5.so
00000035eed46000 16K r---- /lib64/libc-2.5.so
00000035eed4a000 4K rw--- /lib64/libc-2.5.so
00000035eed4b000 20K rw--- [ anon ]
00000035eee00000 8K r-x-- /lib64/libdl-2.5.so
00000035eee02000 2048K ----- /lib64/libdl-2.5.so
.....
....
00002aaaac51e000 4K r---- /lib64/libnss_files-2.5.so
00002aaaac51f000 4K rw--- /lib64/libnss_files-2.5.so
00007fff7143b000 84K rw--- [ stack ]
ffffffffff600000 8192K ----- [ anon ]
total 75180K
The -x option can be used to provide information about the memory allocation and mapping types per mapping. The amount of resident, non-shared anonymous, and locked memory is shown for each mapping:
pmap -x 3526
Clearing the disk cache
For experimentation, it's very convenient to be able to drop the disk cache. For this, we can use the special file /proc/sys/vm/drop_caches. By writing 3 to it, we can clear most of the disk cache:
$ free -m
total used free shared buffers cached
Mem: 1504 1471 33 0 36 801
-/+ buffers/cache: 633 871
Swap: 2047 6 2041
$ echo 3 | sudo tee /proc/sys/vm/drop_caches
3
$ free -m
total used free shared buffers cached
Mem: 1504 763 741 0 0 134
-/+ buffers/cache: 629 875
Swap: 2047 6 2041
Notice how "buffers" and "cached" went down, free mem went up, and free+buffers/cache stayed the same.
You can refer this link for additional information.
A. You need to use the top command which provides a dynamic real-time view of a running system. It can display system summary information as well as a list of tasks currently being managed by the Linux kernel.
Simply type top command:
# top
top command will tell you the percentage of physical memory a particular process is using at any given time. As far as I know, there is no easy way that can tell how long that memory has been allocated.
You can also use ps command to get more information about process.
# ps aux | less
To kill process uses kill command
'free' and /proc
The 'free' command shows the memory on a machine, in certain categories.
[need explanation of categories here...'man free' doesn't explain the numbers]
$ free
total used free shared buffers cached
Mem: 507564 481560 26004 0 68888 185220
-/+ buffers/cache: 227452 280112
Swap: 2136604 105168 2031436
This information is obtained from /proc/meminfo, which has additional details not shown by the 'free' command.
The following is on my machine with 512 Mb RAM, running Linux 2.6.3:
$ cat /proc/meminfo
MemTotal: 507564 kB
MemFree: 26004 kB
Buffers: 68888 kB
Cached: 185220 kB
SwapCached: 29348 kB
Active: 342488 kB
Inactive: 32092 kB
HighTotal: 0 kB
HighFree: 0 kB
LowTotal: 507564 kB
LowFree: 26004 kB
SwapTotal: 2136604 kB
SwapFree: 2031436 kB
Dirty: 88 kB
Writeback: 0 kB
Mapped: 165648 kB
Slab: 73212 kB
Committed_AS: 343172 kB
PageTables: 2644 kB
VmallocTotal: 524212 kB
VmallocUsed: 7692 kB
VmallocChunk: 516328 kB
meminfo:
Provides information about distribution and utilization of memory. This
varies by architecture and compile options. The following is from a
16GB PIII, which has highmem enabled. You may not have all of these fields.
> cat /proc/meminfo
MemTotal: 16344972 kB
MemFree: 13634064 kB
Buffers: 3656 kB
Cached: 1195708 kB
SwapCached: 0 kB
Active: 891636 kB
Inactive: 1077224 kB
HighTotal: 15597528 kB
HighFree: 13629632 kB
LowTotal: 747444 kB
LowFree: 4432 kB
SwapTotal: 0 kB
SwapFree: 0 kB
Dirty: 968 kB
Writeback: 0 kB
Mapped: 280372 kB
Slab: 684068 kB
Committed_AS: 1576424 kB
PageTables: 24448 kB
ReverseMaps: 1080904
VmallocTotal: 112216 kB
VmallocUsed: 428 kB
VmallocChunk: 111088 kB
MemTotal: Total usable ram (i.e. physical ram minus a few reserved
bits and the kernel binary code)
MemFree: The sum of LowFree+HighFree
Buffers: Relatively temporary storage for raw disk blocks
shouldn't get tremendously large (20MB or so)
Cached: in-memory cache for files read from the disk (the
pagecache). Doesn't include SwapCached
SwapCached: Memory that once was swapped out, is swapped back in but
still also is in the swapfile (if memory is needed it
doesn't need to be swapped out AGAIN because it is already
in the swapfile. This saves I/O)
Active: Memory that has been used more recently and usually not
reclaimed unless absolutely necessary.
Inactive: Memory which has been less recently used. It is more
eligible to be reclaimed for other purposes
HighTotal:
HighFree: Highmem is all memory above ~860MB of physical memory
Highmem areas are for use by userspace programs, or
for the pagecache. The kernel must use tricks to access
this memory, making it slower to access than lowmem.
LowTotal:
LowFree: Lowmem is memory which can be used for everything that
highmem can be used for, but it is also availble for the
kernel's use for its own data structures. Among many
other things, it is where everything from the Slab is
allocated. Bad things happen when you're out of lowmem.
SwapTotal: total amount of swap space available
SwapFree: Memory which has been evicted from RAM, and is temporarily
on the disk
Dirty: Memory which is waiting to get written back to the disk
Writeback: Memory which is actively being written back to the disk
Mapped: files which have been mmaped, such as libraries
Slab: in-kernel data structures cache
Committed_AS: An estimate of how much RAM you would need to make a
99.99% guarantee that there never is OOM (out of memory)
for this workload. Normally the kernel will overcommit
memory. That means, say you do a 1GB malloc, nothing
happens, really. Only when you start USING that malloc
memory you will get real memory on demand, and just as
much as you use. So you sort of take a mortgage and hope
the bank doesn't go bust. Other cases might include when
you mmap a file that's shared only when you write to it
and you get a private copy of that data. While it normally
is shared between processes. The Committed_AS is a
guesstimate of how much RAM/swap you would need
worst-case.
PageTables: amount of memory dedicated to the lowest level of page
tables.
ReverseMaps: number of reverse mappings performed
VmallocTotal: total size of vmalloc memory area
VmallocUsed: amount of vmalloc area which is used
VmallocChunk: largest contigious block of vmalloc area which is free
This command will list all of your processes sorted by memory usage:
ps -eo pmem,pcpu,rss,vsize,args | sort -k 1 -r | more
The first column shows the percentage of memory used by the process. You can use this information to find out which process is using the most.
ps -A --sort -rss -o comm,pmem | head -n 11
ps -A --sort -rss -o pid,comm,pmem,rss
This will give you the 10 processes using the most ram
lsb_release -a && free -m
From this command you get information of version of linux , ram,and memory status information.
Use a tool called pmap. It reports the memory map of a process or processes.
pmap examples
To display process mappings, type
$ pmap pid
$ pmap 3724
Output:
3724: /usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf
0000000000400000 164K r-x-- /usr/sbin/lighttpd
0000000000629000 12K rw--- /usr/sbin/lighttpd
000000000bb6b000 4240K rw--- [ anon ]
00000035ee600000 104K r-x-- /lib64/ld-2.5.so
00000035ee819000 4K r---- /lib64/ld-2.5.so
00000035ee81a000 4K rw--- /lib64/ld-2.5.so
00000035eea00000 1304K r-x-- /lib64/libc-2.5.so
00000035eeb46000 2048K ----- /lib64/libc-2.5.so
00000035eed46000 16K r---- /lib64/libc-2.5.so
00000035eed4a000 4K rw--- /lib64/libc-2.5.so
00000035eed4b000 20K rw--- [ anon ]
00000035eee00000 8K r-x-- /lib64/libdl-2.5.so
00000035eee02000 2048K ----- /lib64/libdl-2.5.so
.....
....
00002aaaac51e000 4K r---- /lib64/libnss_files-2.5.so
00002aaaac51f000 4K rw--- /lib64/libnss_files-2.5.so
00007fff7143b000 84K rw--- [ stack ]
ffffffffff600000 8192K ----- [ anon ]
total 75180K
The -x option can be used to provide information about the memory allocation and mapping types per mapping. The amount of resident, non-shared anonymous, and locked memory is shown for each mapping:
pmap -x 3526
Clearing the disk cache
For experimentation, it's very convenient to be able to drop the disk cache. For this, we can use the special file /proc/sys/vm/drop_caches. By writing 3 to it, we can clear most of the disk cache:
$ free -m
total used free shared buffers cached
Mem: 1504 1471 33 0 36 801
-/+ buffers/cache: 633 871
Swap: 2047 6 2041
$ echo 3 | sudo tee /proc/sys/vm/drop_caches
3
$ free -m
total used free shared buffers cached
Mem: 1504 763 741 0 0 134
-/+ buffers/cache: 629 875
Swap: 2047 6 2041
Notice how "buffers" and "cached" went down, free mem went up, and free+buffers/cache stayed the same.
You can refer this link for additional information.
July 8, 2011
disable initial configuration tasks and server manager pop up when an admin logs
Launch MMC.exe and select File -> Add/Remove Snap-in, choose Group Policy and local computer and click ok.
Or gpedit.msc
From the Group policy snap-in, navigate to
Computer Configuration -> Administrative Templates -> System -> Server Manager.
There you will find 3 settings for Server Manager, one of it is the auto launch of Server Manager. Enable the setting. The auto launch of ICT is also available here as well.
For further click here
Or gpedit.msc
From the Group policy snap-in, navigate to
Computer Configuration -> Administrative Templates -> System -> Server Manager.
There you will find 3 settings for Server Manager, one of it is the auto launch of Server Manager. Enable the setting. The auto launch of ICT is also available here as well.
For further click here
Subscribe to:
Posts (Atom)