Saturday, November 29, 2014

Others

To verify your entire system and see what files are missing, issue the following command as root:
rpm -Va

If some files are missing or appear corrupted, consider reinstalling relevant packages.
To determine which package owns a file, enter:
rpm -qf file

To verify the package that owns a particular file, enter as root:
rpm -Vf file

To locate documentation files that are a part of a package to which a file belongs, enter:
rpm -qdf file

To find information about a (non-installed) package file, use the following command:
rpm -qip package.rpm

To list files contained in a package, use:

rpm -qlp package.rpm

<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1829997584334758"
     crossorigin="anonymous"></script>

AIX monitoring

Data gathering tools

Zsnap
The zsnap utility delivers all the benefits of the standard snap command and captures additional debugging data in an easily understood format. IBM's world-class AIX support centers have teamed up to deliver a more fully integrated tool for data gathering, one that has already been proven to reduce the time needed to resolve customer problems. IBM recommends that you install zsnap before you call IBM technical support.

Devscan
The devscan tool facilitates the debugging of storage problems by rapidly gathering a great deal of information about the SAN. It then displays the information in an easy-to-understand manner. You can run devscan from any AIX host, including VIO clients, or from a VIOS.

perfmpr
The perfpmr tool is used extensively by the AIX technical support centers. This package contains a set of tools and instructions for collecting the data needed to analyze performance problems. IBM may ask you to download and use this tool.

pdump
The pdump script extracts information from the running process using kdb command and other AIX tools.

snap
The snap command is included with the operating system. Snap captures system configuration information for AIX and PowerHA. Product technical support centers regularly request snap output to identify and resolve problems. Snap output can be delivered to IBM in portable archive exchange format (pax).

General AIX Performance Tools by Resource
The following AIX performance tools provide general information and metrics related to performance.

Resource
Command
CPU Monitoring
vmstat, iostat, topas, sar, time/timex
Memory Monitoring
vmstat, topas, ps, lsps, ipcs
I/O Subsystem
vmstat, topas, iostat, lvmstat, lsps, lsatt/lsdev, lspv/lsvg/lslv
Network
netstat, topas, atmstat, entstat, tokstat, fddistat, nfsstat, ifconfig
Processes & Threads
ps, pstat, topas
In Depth Tools
The following AIX performance tools provide in-depth information and metrics related to performance.

Resource
Command
CPU Monitoring
netpmon
Memory Monitoring
svmon, netpmon, and filemon
I/O Subsystem
filemon, fileplace
Network
netpmon, tcpdump
Processes & Threads
svmon, truss,kdb, dbx, gprof, fuser, prof
NEW AIX Performance Commands for Micro Partitions
Name
Comments
mpstat
Collects and displays performance statistics for all logical CPUs in the system
lparstat
Reports logical partition (LPAR) related information and statistics
Free performance monitoring and capacity planning for IBM Power platform. Link to Open Source website which is not part of MyDeveloperWorks.

Commercially Available Performance Monitoring Tools

Name
Comments
SaaS-based performance analysis and consolidation tool with centralized web GUI for AIX and Linux. Link to ISV Website which is not part of MyDeveloperWorks.

Apache

same on Solaris/Linux/Win32

yum -y install httpd w3m  (-y to accept any prompt)

cd /etc/httpd/conf
2 files -> httpd.conf magic

-- service httpd start

sudo service httpd start

sudo yum install mysql-server

root@rhel-gpfs # sudo yum install mysql-server
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: centos.hostingxtreme.com
 * extras: centos.eecs.wsu.edu
 * updates: repos.lax.quadranet.com
Resolving Dependencies
--> Running transaction check
---> Package mysql-server.x86_64 0:5.1.73-3.el6_5 will be installed
--> Processing Dependency: mysql = 5.1.73-3.el6_5 for package: mysql-server-5.1.73-3.el6_5.x86_64
--> Processing Dependency: perl-DBD-MySQL for package: mysql-server-5.1.73-3.el6_5.x86_64
--> Running transaction check
---> Package mysql.x86_64 0:5.1.73-3.el6_5 will be installed
---> Package perl-DBD-MySQL.x86_64 0:4.013-3.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved

===================================================
 Package               Arch          Version                  Repository   Size
===================================================
Installing:
 mysql-server          x86_64        5.1.73-3.el6_5           base        8.6 M
Installing for dependencies:
 mysql                 x86_64        5.1.73-3.el6_5           base        894 k
 perl-DBD-MySQL        x86_64        4.013-3.el6              base        134 k

Transaction Summary
===================================================
Install       3 Package(s)

Total download size: 9.6 M
Installed size: 27 M
Is this ok [y/N]: y
Is this ok [y/N]: y
Downloading Packages:
(1/3): mysql-5.1.73-3.el6_5.x86_64.rpm                   | 894 kB     00:03    
(2/3): mysql-server-5.1.73-3.el6_5.x86_64.rpm            | 8.6 MB     00:17    
(3/3): perl-DBD-MySQL-4.013-3.el6.x86_64.rpm             | 134 kB     00:00    
---------------------------------------------------
Total                                           455 kB/s | 9.6 MB     00:21    
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : mysql-5.1.73-3.el6_5.x86_64                                  1/3
  Installing : perl-DBD-MySQL-4.013-3.el6.x86_64                            2/3
  Installing : mysql-server-5.1.73-3.el6_5.x86_64                           3/3
  Verifying  : perl-DBD-MySQL-4.013-3.el6.x86_64                            1/3
  Verifying  : mysql-server-5.1.73-3.el6_5.x86_64                           2/3
  Verifying  : mysql-5.1.73-3.el6_5.x86_64                                  3/3

Installed:
  mysql-server.x86_64 0:5.1.73-3.el6_5                                         

Dependency Installed:
  mysql.x86_64 0:5.1.73-3.el6_5       perl-DBD-MySQL.x86_64 0:4.013-3.el6     

Complete!
root@rhel-gpfs # sudo /usr/bin/mysql_secure_installation


root@rhel-gpfs # chkconfig --levels 235 httpd on
root@rhel-gpfs # vi /etc/httpd/conf/httpd.conf
Uncomment this line -> NameVirtualHost *:80
root@rhel-gpfs # service httpd restart

Go to firefox to verify and open localhost
  
####################################################################

web server binaries
/usr/sbin/httpd
/usr/sbin/httpd_monitor
config files
/etc/httpd/conf/*
log files
/etc/httpd/logs/*
web server root
(contains cgi, icons/images, and html files)
/home/httpd/*

##########################################################
 All of the files for the sites that you host will be located in directories that exist underneath/srv/www. You can symbolically link these directories into other locations if you need them to exist in other places.

ErrorLog and CustomLog entries are suggested for more fine-grained logging, but are not required. If they are defined (as shown above), the logs directories must be created before you restart Apache.
#################################################
Apache Interview Questions & Answers
Q: – What is location of log files for Apache server ?
Ans- /var/log/httpd
Q: – What are the types of virtual hosts ?
Ans-
a. name-based
b. IP-based.
Name-based virtual host means that multiple names are running on each IP address.
IP-based virtual host means that a different IP address exists for each website served. Most configurations are named-based because it only requires one IP address.
Q: – Command to restart/start Apache web server ?
Ans- service httpd restart/start
Q: – Comamnd to check the version of Apache server ?
Ans- rpm -qa |grep httpd
Q: – What is meaning of “Listen” in httpd.conf file ?
Ans- Port number on which to listen for nonsecure (http) transfers.
Q: – What is Document Root ?
Ans- It is a location of files which are accessible by clients. By default, the Apache HTTP server in RedHat Enterprise Linux is configured to serve files from the /var/www/html/ directory.
Q: – Apache server works on which ports ?
Ans-
http – port 80
https – port 443
Q: – Tell me name of main configuration file of Apache server ?
Ans- httpd.conf
Q: – On which version of apache you have worked ?
Ans- httpd-2.2.3
Q: – What do you mean by a valid ServerName directive?
Ans- The DNS system is used to associate IP addresses with domain names. The value of ServerName is returned when the server generates a URL. If you are using a certain domain name, you must make sure that it is included in your DNS system and will be available to clients visiting your site.
Q: – What is the main difference between and sections?
Ans- Directory sections refer to file system objects; Location sections refer to elements in the address bar of the Web Page.
Q: – What is the difference between a restart and a graceful restart of a web server ?
Ans- During a normal restart, the server is stopped and then started, causing some requests to be lost. A graceful restart allows Apache children to continue to serve their current requests until they can be replaced with children running the new configuration.
Q: – What is the use of mod_perl module ?
Ans- mod_perl scripting module to allow better Perl script performance and easy integration with the web server.
Q: – If you have added “loglevel Debug” in httpd.conf file, than what will happen ?
Ans- It will give you more information in the error log in order to debug a problem.
Q: – Is it possible to record the MAC (hardware) address of clients that access your server ?
Ans- No
Q: – If there is one IP address, than how to host two web sites on server ?
Ans- In this case I will use Name Based Virtual hosting.
ServerName 10.111.203.25
NameVirtualHost *:80

ServerName web1.test.com
DocumentRoot /var/www/html/web1

ServerName web2.test2.com
DocumentRoot /var/www/html/web2
Q: – Can I serve content out of a directory other than the DocumentRoot directory?
Ans- Yes. We can do it by using “Alias” command.
Q: – If you have to more than one URL map to the same directory but you don’t have multiple Alias directives. What you will do ?
Ans- In this case I will use “AliasMatch” directives.
The AliasMatch directive allows you to use regular expressions to match arbitrary patterns in URLs and map anything matching the pattern to the desired URL.
Q: – Can you record all the cookies sent to your server by clients in Web Server logs?
Ans- Yes, add following lines in httpd.conf file.
CustomLog logs/cookies_in.log “%{UNIQUE_ID}e %{Cookie}i” CustomLog logs/cookies2_in.log “%{UNIQUE_ID}e %{Cookie2}i”
Q: – Can we do automatically roll over the Apache logs at specific times without having to shut down and restart the server?
Ans- Yes
Use CustomLog and the rotatelogs programs
Add following line in httpd.conf file. CustomLog “| /path/to/rotatelogs /path/to/logs/access_log.%Y-%m-%d 86400″ combined
Q: – What we should do to find out how people are reaching your site ?
Ans- Add the following effect or to your activity log format. %{Referer}
Q: – How you will put a limit on uploads on your web server ?
Ans- This can be achieved by LimitRequestBody directive.

LimitRequestBody 100000

Here I have put limit of 100000 Bytes
Q: – I want to stop people using my site by Proxy server. Is it possible?
Ans-

Order Allow,Deny
Deny from all
Satisfy All
Q: – What is mod_evasive module?
Ans- mod_evasive is a third-party module that performs one simple task and performs it very well. It detects when your site is receiving a Denial of Service (DoS) attack and it prevents that attack from doing as much damage. mod_evasive detects when a single client is making multiple requests in a short period of time and denies further requests from that client. The period for which the ban is in place can be very short, because it just gets renewed the next time a request is detected from that same host.
Q: – How t to enable PHP scripts on your server?
Ans- If you have mod_php installed, use AddHandler to map .php and .phtml files to the PHP handler. AddHandler application/x-httpd-php .phtml .php
Q: – Which tool you have used for Apache benchmarking?
Ans-
ab (Apache bench)
ab -n 1000 -c 10 http://www.test.com/test.html
Q: – Can we cache files which are viewed frequently?
Ans- Yes we can do it by using mod_file_cache module.
CacheFile /www/htdocs/index.html

1: Briefly explain Apache Web Server.
Answer:
Apache Web Server is one of the most secure, powerful and popular open source HTTP Servers. It can be used to host anything from personal web sites to corporate domains.

2: You see "connection reset by peer" in error log. What could be the reason for this?
Answer:
If the end user terminates the connection when the server response was being formed or was being transferred, we see "connection reset by peer" in the error log.

3: What type of IP is required for Apache Web Server to host our website?
Answer:
If we have a DSL connection with a static IP then we can use the Apache web server to host our website.

5. You are asked to stop Apache Service through its control Script. What will you do?
Answer : The Apache service is controlled using a script called apachectl. In order to stop apache using its control script we need to run.
# apachectl stop                [On Debian based Systems]
# /etc/inid.t/httpd stop        [On Red Hat based Systems]
6. How is ‘apachectl restart’ different from ‘apachect1 graceful’
Answer : The ‘apachect1 restart’ when executed will force Apache to restart immediately, before the task complete whereas ‘apachectl graceful’ will wait for the current task to be finished before restarting the service. Not to mention ‘apachectl graceful’ is more safe to execute but the execution time for ‘apachect1 restart’ is less as compared to ‘apachectl graceful’.

MySQL

Below rpms are required to run mksql on CentOS.
  1. mysql-version.rpm (Required)
  2. mysql-server-version.rpm (Required)
  3. mysqlclient9-version.rpm (Shared object libraries)
  4. mysql-devel-version.rpm (C include files and libraries for developers)
  5. php-mysql-version.rpm (For accessing MySQL database from php)
  
root@centosserver # mysql -h localhost -u root -p<passwd>
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.1.73 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;

Shutdown my SQL DB
[prompt]$ /etc/rc.d/init.d/mysqld stop
OR
[prompt]$ service mysqld stop

 mysql> CREATE USER user_name@'localhost' IDENTIFIED BY 'password';
         
or generate a user by adding them to the user table directly:[prompt]$ mysql -h localhost -u root -p
 mysql> use mysql;
 mysql> INSERT INTO user (Host,User,Password) VALUES('localhost','user_name',PASSWORD('PASSWD'));
####################################################################
Connect to the database

mysql -h localhost -u root -p<passwd>

mysql> create database vihan;
  Query OK, 1 row affected (0.01 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| try                |
| mysql              |
| test               |
| vihan              |
+--------------------+
5 rows in set (0.01 sec)

mysql> drop database test;
Query OK, 0 rows affected (0.02 sec)

mysql> use vihan;
Database changed
mysql>

mysql> show tables;
Empty set (0.00 sec)

mysql> CREATE TABLE pot(id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
    -> name VARCHAR(20),
    -> food VARCHAR(30),
    -> confirmed CHAR(1),
    -> signup_date DATE);
Query OK, 0 rows affected (0.01 sec)

mysql> DESCRIBE pot;
+-------------+-------------+------+-----+---------+----------------+
| Field       | Type        | Null | Key | Default | Extra          |
+-------------+-------------+------+-----+---------+----------------+
| id          | int(11)     | NO   | PRI | NULL    | auto_increment |
| name        | varchar(20) | YES  |     | NULL    |                |
| food        | varchar(30) | YES  |     | NULL    |                |
| confirmed   | char(1)     | YES  |     | NULL    |                |
| signup_date | date        | YES  |     | NULL    |                |
+-------------+-------------+------+-----+---------+----------------+
5 rows in set (0.00 sec)

mysql> INSERT INTO `pot` (`id`,`name`,`food`,`confirmed`,`signup_date`) VALUES (NULL, "John", "Casserole","Y", '2012-04-11');
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO `pot` (`id`,`name`,`food`,`confirmed`,`signup_date`) VALUES (NULL, "Tina", "Salad","Y", '2012-04-10');
Query OK, 1 row affected (0.00 sec)

mysql> SELECT * FROM pot;
+----+-------+----------------+-----------+-------------+
| id | name  | food           | confirmed | signup_date |
+----+-------+----------------+-----------+-------------+
|  1 | John  | Casserole      | Y         | 2012-04-11  |
|  2 | Sandy | Key Lime Tarts | N         | 2012-04-14  |
|  3 | Tom   | BBQ            | Y         | 2012-04-18  |
|  4 | Tina  | Salad          | Y         | 2012-04-10  |
+----+-------+----------------+-----------+-------------+
4 rows in set (0.00 sec)

mysql> UPDATE `pot`
    -> SET
    -> `confirmed` = 'Y'
    -> WHERE `pot`.`name` ='Sandy';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> ALTER TABLE pot ADD email VARCHAR(40);

DELETE from [table name] where [column name]=[field text];

mysql> DELETE from pot where name='Sandy';