Archive for the 'AdminTutorials' Category
Cpanel mysql5 and php5 how to
I updated today to mysql5 and php5 .. and I ran into one problem…. the sql server would not start
after installing I was getting:
Starting MySQLCouldn't find MySQL manager or server [FAILED]
1st! how to install mysql5 and php5 with cpanel (with out having cpanel downgrade you automatically)
(read below)
* login to the WHM interface, and from “Server Configuration / Tweak Settings” choose in the “MySQL” section the 5.0 radio button. (This will actually run the script: /scripts/mysqlup that will download and install the latest MySQL5 rpms available at that time.)
* After completion as instructed you should rebuild your perl mysql libraries and rebuild apache (to have php build against the newly installed mysql library).
/scripts/perlinstaller --force Bundle::DBD::mysql
* On the WHM interface and from “Software” choose “Apache Update” and make sure you select the version of php that you want (in this case 5.21, I also select CURL) and rebuild (this will take some time) (if you have php5 already installed you can just run from your commandline:
/scripts/easyapache
and you are done….
But in my case … when I tried to run mysql I had a problem…
/etc/init.d/mysql start
Starting MySQLCouldn't find MySQL manager or server [FAILED]
to fix this I had to edit /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
[mysql.server]
user=mysql
#basedir=/var/lib <--- COMMENT OUT THIS LINE
old-passwords = 1
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
the line basedir=/var/lib was causing the error and in case you are having the same problem commenting out that line will solve the problem and MySQL will start properly.
thanks for carlos’s blog
No commentsFinding/locating files with find command
UNIX/Linux system administrator can use nifty find utility to gain lots of useful information. This will help to monitor and enhance the security of system.
(A) Finding all set user id files
# find / -perm +u=s
OR
# find / -perm +4000
See also, shell script to find all programs and scripts with setuid set on.
(B) Finding all set group id files
# find / -perm +g=s
OR
# find / -perm +2000
See also, shell script to find all programs and scripts with setgid bit set on.
(C)Finding all large directories – For example find all directories taking 40k (kilobytes) blocks of space. This is useful to find out which directories on system taking lot of space.
# find / -type d -size +40k
/var/lib/dpkg/info
/var/log/ksymoops
/usr/share/doc/HOWTO/en-html
/usr/share/man/man3
(D) Finding all large files on a Linux
# find / -type f -size +10000k
/var/log/kern.log
/sys/devices/pci0000:00/0000:00:02.0/resource0
/sys/devices/pci0000:00/0000:00:00.0/resource0
/opt/03Jun05/firefox-1.0.4-source.tar.bz2
However my favorite hack to above command is as follows:
find / -type f -size +10000k -exec ls -lh {} \; | awk ‘{ print $8 “: ” $5 }’
/var/log/kern.log: 22M
/sys/devices/pci0000:00/0000:00:02.0/resource0: 128M
Above command will find all files block size greater than 10000k and print filename followed by file size. Now this is more informative than the normal output .
No commentsOptimizing host.conf and sysctl.conf
#!/bin/sh
cp /etc/host.conf /etc/host.back
echo “# Lookup names via DNS first then fall back to /etc/hosts.” > /etc/host.conf
echo “order bind,hosts” >> /etc/host.conf
echo “# We have machines with multiple IP addresses.” >> /etc/host.conf
echo “multi on” >> /etc/host.conf
echo “# Check for IP address spoofing.” >> /etc/host.conf
echo “nospoof on” >> /etc/host.conf
cp /etc/sysctl.conf /etc/sysctl.conf.old
echo “# Max File Handlers” >> /etc/sysctl.conf
echo “fs.file-max = 8192″ >> /etc/sysctl.conf
echo “# Disable CTR+ALT+DEL Restart Keys” >> /etc/sysctl.conf
echo “kernel.ctrl-alt-del = 1″ >> /etc/sysctl.conf
echo “# Enable TCP SYN cookie protection” >> /etc/sysctl.conf
echo “net.ipv4.tcp_syncookies = 1″ >> /etc/sysctl.conf
echo “# Disable ICMP Redirect Acceptance” >> /etc/sysctl.conf
echo “net.ipv4.conf.all.accept_redirects = 0″ >> /etc/sysctl.conf
echo “# Enable bad error message protection” >> /etc/sysctl.conf
echo “net.ipv4.icmp_ignore_bogus_error_responses = 1″ >> /etc/sysctl.conf
echo “# Decrease time between keepalives” >> /etc/sysctl.conf
echo “net.ipv4.tcp_keepalive_time = 1200″ >> /etc/sysctl.conf
echo “# Turn off timestamps” >> /etc/sysctl.conf
echo “net.ipv4.tcp_timestamps = 0″ >> /etc/sysctl.conf
echo “# Ignore icmp broadcast request” >> /etc/sysctl.conf
echo “net.ipv4.icmp_echo_ignore_broadcasts = 1″ >> /etc/sysctl.conf
echo “# Decrease the time default value for tcp_fin_timeout connection” >> /etc/sysctl.conf
echo “net.ipv4.tcp_fin_timeout = 25″ >> /etc/sysctl.conf
echo “# Turn off the tcp_window_scaling” >> /etc/sysctl.conf
echo “net.ipv4.tcp_window_scaling = 0″ >> /etc/sysctl.conf
echo “# Turn off the tcp_sack” >> /etc/sysctl.conf
echo “net.ipv4.tcp_sack = 0″ >> /etc/sysctl.conf
echo “# Allow more SYN backlog” >> /etc/sysctl.conf
echo “net.ipv4.tcp_max_syn_backlog = 1048″ >> /etc/sysctl.conf
echo “# Lower retry rates” >> /etc/sysctl.conf
echo “net.ipv4.tcp_synack_retries = 2″ >> /etc/sysctl.conf
echo “net.ipv4.tcp_syn_retries = 3″ >> /etc/sysctl.conf
cp /etc/syslog.conf /etc/syslog.conf.old
echo “# Log all kernel messages to the new file /var/log/kernel” >> /etc/syslog.conf
echo “kern.* /var/log/kernel” >> /etc/syslog.conf
echo “# Log all logins to /var/log/login_log” >> /etc/syslog.conf
echo “auth.*;user.*;daemon.none /var/log/login_log” >> /etc/syslog.conf
when you look through the script, you can generally see what it is doing. But for a basic overveiw, the script is setting up the configs most people forget about, or maybe never even knew about. The script also makes a back-up of itself incase something might go wrong.
Enjoy.
How to install PRM (Process Resource Monitor)
How to install PRM (Process Resource Monitor)
PRM (Process Resource Monitor)
Introduction
PRM monitors the process table on a given system and matches process id’s with set resource limits in the config file or per-process based rules. Process id’s that match or exceed the set limits are logged and killed; includes e-mail alerts, kernel logging routine and more…
How it works?
PRM works on the basis that once a process id is found matching resource limits; there is a corresponding trigger and wait value. The trigger value increments upwards from zero (0) to the defined value, pausing the duration of seconds defined as wait value. There after the status of the flagged pid is checked again, if still above or equal to resource limits the trigger/wait cycle begins again till the max trigger value is reached. When this trigger value is reached the given process is logged/killed.
This all together has the effect that applications with short burst resource spikes (e.g: apache, mysql etc..) are not killed; but rather on applications with prolonged resource consumption. Using the rule system, you can define different wait/trigger/resource values for any application.
Installation
First we must fetch the package:
wget http://www.rfxnetworks.com/downloads/prm-current.tar.gz
And extract it:
tar xvfz prm-current.tar.gz
The current version of prm as of this writing is 0.3, so lets cd to the 0.3 extracted path:
cd prm-0.3/
And finally run the enclosed install.sh script:
./install.sh
Configuration
The prm installation is located at ‘/usr/local/prm’, and the configuration file is labeled ‘conf.prm’.
Open the ‘/usr/local/prm/conf.prm’ file with your preferred editor. There is an array of options in this file but we will only be focusing on the main variables.
Lets skip down to the user e-mail alert’s section and set the USR_ALERT value to ‘1′; enabling alerts.
# enable user e-mail alerts [0=disabled,1=enabled] USR_ALERT=”1″
And configure our e-mail addresses for alerts:
# e-mail address for alerts USR_ADDR=”root, you@domain.com”
Check the 5,10, or 15 minute load average; relative to the later option below for min. load level.
# check 5,10,15 minute load average. [1,2,3 respective of 5,10,15] LC=”1″
PRM optionally has a required load average for running. If the load is not equal to or greater than this value; PRM will not run. Setting this value to zero will force the script to always run but this should not be needed.
# min load level required to run (decimal values unsupported) MIN_LOAD=”1″
This is the introduction described wait value, used for pauses between trigger increments. The value of wait multiplied by the value of kill_trig equal the duration of time before a process is killed (10×3=30seconds).
# seconds to wait before rechecking a flagged pid (pid’s noted resource # intensive but not yet killed). WAIT=”10″
The trigger limit before processes are killed, described in detail in the above ‘wait’ description and introduction.
# counter limit that a process must reach prior to kill. The counter value # increases for a process flagged resource intensive on rechecks. KILL_TRIG=”3″
The max percentage of CPU a process should be allowed to use before PRM flags it for killing.
# Max CPU usage readout for a process - % of all cpu resources (decimal values unsupported) MAXCPU=”35″
The max percentage of MEM a process should be allowed to use before PRM flags it for killing.
# Max MEM usage readout for a process - % of system total memory (decimal values unsupported) MAXMEM=”15″
That is it; you should tweak the MAXCPU/MAXMEM limits to your desired needs but the defaults should be fine for most.
Usage
The executable program resides in ‘/usr/local/prm/prm’ and ‘/usr/local/sbin/prm’. The prm executable can receive one of two arguments:
-s Standard run
-q Quiet run
The log path for prm is ‘/usr/local/prm/prm_log’, as well pid specific logs are stored in ‘/usr/local/prm/killed/’.
A default cronjob for PRM is installed to ‘/etc/cron.d/prm’, and is configured to run once every 5 minutes.
There is a provided ignore file, to ignore processes based on string rules. The ignore file is located at ‘/usr/local/prm/ignore’. This file supports line separated ignore strings. As a default the strings ‘root, named and postgre’ are ignored by PRM; this script was not intended to monitor root processes but rather user land tasks. It could easily watch root processes by removing the given line in the ignore file but this is strongly discouraged.
No comments
Getting started with SSH Tutorial
Getting started with SSH Tutorial
Getting started with SSH Tutorial - Connecting to your server with SSH
Secure Shell (SSH), sometimes known as Secure Socket Shell, is a UNIX-based command interface and protocol for securely getting access to a remote computer. It is widely used by network administrators to control Web and other kinds of servers remotely. SSH is actually a suite of three utilities - slogin, ssh, and scp - that are secure versions of the earlier UNIX utilities, rlogin, rsh, and rcp. SSH commands are encrypted and secure in several ways. Both ends of the client/server connection are authenticated using a digital certificate, and passwords are protected by being encrypted. SSH uses RSA public key cryptography for both connection and authentication. Encryption algorithms include Blowfish, DES, and IDEA. IDEA is the default.
The server you are connecting to must be running SSH, and you must be running a secure shell client on your own machine as well, more details on getting a secure shell client are below.
Step 1) Download the SSH client on your local machine, we are assuming you’re using Windows. If not then see other PuTTY download options here: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
Windows PuTTY Download
http://the.earth.li/~sgtatham/putty/latest/x86/putty.exe
Step 2) Save the file to your desktop and double click it.
Step 3) You should see a something that looks like this, asking you what server you want to connect to.
Click for larger screenshot
Step 4) Enter your servers IP and click on Open.
Step 5) Enter your account’s username to connect then enter your password.
Click for larger screenshot
Step 6) Change to the root user, type: su –
That’s it! You have now logged into your server using SSH.
Now get comfortable with it and learn some shell/SSH commands in the article listed below.