Monday, October 25, 2010

Change location on Cent OS / RedHat /Fedora

[root@convirt kitbag]# tzselect
Please identify a location so that time zone rules can be set correctly.
Please select a continent or ocean.
 1) Africa
 2) Americas
 3) Antarctica
 4) Arctic Ocean
 5) Asia
 6) Atlantic Ocean
 7) Australia
 8) Europe
 9) Indian Ocean
10) Pacific Ocean
11) none - I want to specify the time zone using the Posix TZ format.
#? 5
Please select a country.
 1) Afghanistan          18) Israel            35) Palestine
 2) Armenia          19) Japan            36) Philippines
 3) Azerbaijan          20) Jordan            37) Qatar
 4) Bahrain          21) Kazakhstan        38) Russia
 5) Bangladesh          22) Korea (North)        39) Saudi Arabia
 6) Bhutan          23) Korea (South)        40) Singapore
 7) Brunei          24) Kuwait            41) Sri Lanka
 8) Cambodia          25) Kyrgyzstan        42) Syria
 9) China          26) Laos            43) Taiwan
10) Cyprus          27) Lebanon            44) Tajikistan
11) East Timor          28) Macau            45) Thailand
12) Georgia          29) Malaysia            46) Turkmenistan
13) Hong Kong          30) Mongolia            47) United Arab Emirates
14) India          31) Myanmar (Burma)        48) Uzbekistan
15) Indonesia          32) Nepal            49) Vietnam
16) Iran          33) Oman            50) Yemen
17) Iraq          34) Pakistan
#? 14

The following information has been given:

    India

Therefore TZ='Asia/Kolkata' will be used.
Local time is now:    Mon Oct 25 14:52:34 IST 2010.
Universal Time is now:    Mon Oct 25 09:22:34 UTC 2010.
Is the above information OK?
1) Yes
2) No
#? 1

You can make this change permanent for yourself by appending the line
    TZ='Asia/Kolkata'; export TZ
to the file '.profile' in your home directory; then log out and log in again.

Here is that TZ value again, this time on standard output so that you
can use the /usr/bin/tzselect command in shell scripts:
Asia/Kolkata

Installing Postfix Admin on Cent OS / RedHat / Fedora

1. Install the Postfix Admin requirements using the command below.
#yum install mysql-server php-mysql php-imap httpd postfix dovecot
 
2. Download the latest stable version of Postfix Admin in .tar.gz format. 
Assuming you got the file postfixadmin-2.3.2.tar.gz and it is located on your Desktop,
 type in the commands below to extract and to put it into its proper directory.
 
#tar xvfz postfixadmin-2.3.2.tar.gz
#mv postfixadmin-2.3.2 /usr/share/postfixadmin 
#vim /etc/httpd/conf.d/postfixadmin.conf
 
#
#  Web application to manage Postfix email server
#

Directory "/usr/share/postfixadmin"
Order Allow,Deny
Allow from all
Directory

Alias /postfixadmin /usr/share/postfixadmin
Alias /PostFixAdmin /usr/share/postfixadmin
Alias /PostfixAdmin /usr/share/postfixadmin

3. Edit the file /usr/share/postfixadmin/config.inc.php and update the following lines below.
$CONF['configured'] = true;
$CONF['postfix_admin_url'] = '/postfixadmin';
$CONF['database_type'] = 'mysqli';
$CONF['database_host'] = 'localhost';
$CONF['database_user'] = 'postfix';
$CONF['database_password'] = 'your_password';
$CONF['database_name'] = 'postfix';
$CONF['domain_path'] = 'YES';
$CONF['domain_in_mailbox'] = 'NO';
$CONF['encrypt'] = 'cleartext';
$CONF['emailcheck_resolve_domain] = 'NO';

#service mysqld start

4.Launch the MySQL command line tool using the command below.
mysql -u root -p

The default root password of MySQL is a blank password. Next, create a 
new MySQL database for Postfix Admin using the commands below.
mysql> CREATE DATABASE postfix;
mysql> CREATE USER postfix@localhost IDENTIFIED BY 'your_password';
mysql> GRANT ALL PRIVILEGES ON postfix.* TO postfix;

#service httpd start
 
5.Go to the Postfix Admin setup page at http://localhost/postfixadmin/setup.php and fill in the setup password. Next, click the Generate password hash.
6.Get the generated setup password hash and put it into the file /usr/share/postfixadmin/config.inc.php. Next, fill in the Setup password, Admin and Password and Password (again). Finally, click Add Admin to create a new admin account.
7. Go to the Postfix Admin login page at http://localhost/postfixadmin/ and login using your newly created admin account.
 
:)

Fedora / Redhat / CentOS Install Memcached Caching System


How do I install memcached a high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load under CentOS / RHEL / Fedora / Redhat Linux?

Memcached is very fast caching system for MySQL. It uses libevent or epoll (Linux runtime) to scale to any number of open connections and uses non-blocking network I/O.

Required Packages

  1. memcached : High Performance, Distributed Memory Object Cache.
  2. memcached-selinux : SELinux policy module supporting memcached.
  3. perl-Cache-Memcached : Perl client for memcached.
  4. php-pecl-memcache : Php client / extension to work with the Memcached caching daemon.
  5. python-memcached : A Python memcached client library.

Step # 1: Turn on EPEL Repo

Type the following command to enable EPEL repo which carries required memcache packages.
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm.

Step # 2: Install memcached

Type the following command to install memcached with php extension:
# yum install memcached php-pecl-memcache


Step # 3: Configure memcached Edit /etc/sysconfig/memcached, enter:
# vi /etc/sysconfig/memcached
Update it as follows:
PORT="11211"
USER="memcached"
# max connection 2048
MAXCONN="2048"
# set ram size to 2048 - 2GiB
CACHESIZE="4096"
# listen to loopback ip 127.0.0.1, for network connection use real ip e.g., 10.0.0.4
OPTIONS="-l 127.0.0.1"
The above will starts memcached up as a daemon, using 4GB of memory, and listening on IP 127.0.0.1, port 11211. Save and close the file.

Step # 4: Run memcached

Type the following command to start memcached, enter:
# chkconfig memcached on
# service memcached start

To stop / restart use the following commands:
# service memcached stop
# service memcached restart

How Do I See Memory Memcached Slabs?

Type the following command:
# memcached-tool IP_ADDRESS:Port
# memcached-tool IP_ADDRESS:Port display
# memcached-tool 127.0.0.1:11211



  #  Item_Size   Max_age  1MB_pages Count   Full?
  1     104 B     5134 s       1      10      no
  2     136 B     5135 s       1      40      no
  3     176 B        0 s       1       0      no
  4     224 B     2648 s       1       7      no
  8     552 B     1810 s       1      12      no
  9     696 B     1810 s       1       6      no
 10     872 B     2935 s       1       8      no
 11     1.1 kB    4262 s       1      18      no
 12     1.3 kB    2990 s       1      23      no
 13     1.7 kB    2434 s       1      22      no
 14     2.1 kB    3489 s       1      11      no
 15     2.6 kB    2964 s       1      16      no
 16     3.3 kB    2861 s       1      14      no
 17     4.1 kB    2076 s       1       5      no
 18     5.2 kB    2981 s       1       5      no
 20     8.1 kB      64 s       1       1      no
 21    10.1 kB    1865 s       1       3      no
 29    60.2 kB    1550 s       1       2      no

How Do I See Memory Memcached Stats?

Type the following command:
# memcached-tool IP_Address:Port stats
# memcached-tool 127.0.0.1:11211 stats



#127.0.0.1:11211   Field       Value
         accepting_conns           1
                   bytes      399395
              bytes_read      504797
           bytes_written    17313658
               cmd_flush           0
                 cmd_get        1141
                 cmd_set         248
   connection_structures           9
        curr_connections           5
              curr_items         205
               evictions           0
                get_hits         898
              get_misses         243
          limit_maxbytes  1073741824
     listen_disabled_num           0
                     pid       40159
            pointer_size          64
           rusage_system    0.227965
             rusage_user    0.034994
                 threads           5
                    time  1255803547
       total_connections         344
             total_items         259
                  uptime        5829
                 version       1.2.8

Sunday, October 24, 2010

Find out non-system users

alias lsusers='getent passwd | tr ":" " " | awk "\$3 >= $(grep UID_MIN /etc/login.defs | cut -d " " -f 2) { print \$1 }" | sort'
 
Above command to list non-system users. It should be portable though won't work on systems without the getent command.