Puppet CentOS 6 install

Source:
http://www.how2centos.com/centos-6-puppet-install/

Install the Puppet Repository


# rpm -ivh http://yum.puppetlabs.com/el/6/products/i386/puppetlabs-release-6-7.noarch.rpm

Install the EPEL x86_64 YUM Repository


# rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

Install the Puppet Master packages


# yum install puppet-server

Install the Puppet Client packages


# yum install puppet

See more – HERE

See Puppet install

http://docs.puppetlabs.com/guides/install_puppet/install_el.html

Find reason for linux server crash

Check the logs

/var/log/messages, which stores logs from many native CentOS services, such as the kernel logger, the network manager, and many other services that don’t have their own log files. This log file tells you if there are kernel problems (kernel panic messages) or kernel limits violations, such as the number of currently open files, which can cause system problems. You can fix kernel misconfigurations by editing the file /etc/sysctl.conf and changing the value for the corresponding error.

/var/log/dmesg, which contains information about hardware found by the kernel drivers. It can help you troubleshoot hardware problems and missing drivers. You can also use the command /bin/dmesg for similar purposes. /bin/dmesg provides more detailed information in real time, while the log file keeps less information for historical purposes.

/var/log/audit/audit.log, which is the file in which the Linux Auditing System (auditd) writes its logs, including all SELinux information. If auditd is disabled, SELinux sends its logs to /var/log/messages. SELinux is a common suspect for any strange behavior and problems in CentOS. It is enabled by default in CentOS 6 and should not be frivolously disabled, as it is important for security. You can check its status with the command sestatus. A Wazi article about Linux server hardening covers the basics of SELinux, including how to adjust its policies in order to avoid problems.

Service- and application-specific logs – Many applications create logs in other places, and have options that control where and what to log. By default in CentOS the Apache web server logs in the directory /var/log/httpd/, mail servers log in /var/log/maillog, and MySQL logs in /var/log/mysqld.log. However, not all logs are located in the logs directory. Some applications, such as user-space programs, may not have privileges to write there. Others prefer to log inside their own root directory. You may need to consult an application’s manual to learn where it writes its logs.

If it’s gone down without logging anything, it might be power related so it’s not had the chance to log anything.

Suspend / Unsuspend domain via command line Plesk

 

Suspend a domain via command line Plesk

 /usr/local/psa/bin/domain -u yourdomain.com -status disabled

Domains are not listing and showing following error on Plesk Panel:

[stextbox id=”alert”]The webspace was suspended. All sites hosted with the webspace are not available.[/stextbox]

Unsuspend domain via command line Plesk

/usr/local/psa/bin/domain -u yourdomain.com -status enabled

Who is Logged-In on Your Linux System

w command is used to show logged-in user names and what they are doing. The information will be read from /var/run/utmp file. The output of the w command contains the following columns:

Name of the user
User’s machine number or tty number
Remote machine address
User’s Login time
Idle time (not usable time)
Time used by all processes attached to the tty (JCPU time)
Time used by the current process (PCPU time)
Command currently getting executed by the users

Following options can be used for the w command:

-h Ignore the header information
-u Display the load average (uptime output)
-s Remove the JCPU, PCPU, and login time.


[root@austin ~]# w
 15:46:21 up 23 days, 1 min,  1 user,  load average: 0.00, 0.00, 0.00
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
root     pts/0    66.226.xx.x    15:46    0.00s  0.06s  0.00s w


[root@austin ~]# w -h
root     pts/0    66.226.79.7      15:46    0.00s  0.06s  0.00s w -h


[root@austin ~]# w -u
 15:47:05 up 23 days, 2 min,  1 user,  load average: 0.00, 0.00, 0.00
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
root     pts/0    66.226.79.7      15:46    0.00s  0.06s  0.00s w -u

[root@austin ~]# w -s
 15:47:23 up 23 days, 2 min,  1 user,  load average: 0.00, 0.00, 0.00
USER     TTY      FROM               IDLE WHAT
root     pts/0    66.226.79.7       0.00s w -s

2. Get the user name and process of logged in user using who and users command

who command is used to get the list of the usernames who are currently logged in. Output of the who command contains the following columns: user name, tty number, date and time, machine address.


[root@austin ~]# who
root     pts/0        2014-07-11 15:46 (66.226.79.7)

To get a list of all usernames that are currently logged in, use the following:


[root@austin ~]# who | cut -d' ' -f1 | sort | uniq
root

Users Command

users command is used to print the user name who are all currently logged in the current host. It is one of the command don’t have any option other than help and version. If the user using, ‘n’ number of terminals, the user name will shown in ‘n’ number of time in the output.


[root@austin ~]# users
root

3. Get the username you are currently logged in using whoami. whoami command is used to print the loggedin user name.


[root@austin ~]# whoami
root

whoami command gives the same output as id -un as shown below:


[root@austin ~]# id -un
root

who am i command will display the logged-in user name and current tty details. The output of this command contains the following columns: logged-in user name, tty name, current time with date and ip-address from where this users initiated the connection.


[root@austin ~]# who am i
root     pts/0        2014-07-11 15:46 (66.226.79.7)


[root@austin ~]# who mom likes
root     pts/0        2014-07-11 15:46 (66.226.79.7)

Warning: Don’t try “who mom hates” command.

Also, if you do su to some other user, this command will give the information about the logged in user name details.

4. Get the user login history at any time

last command will give login history for a specific username. If we don’t give any argument for this command, it will list login history for all users. By default this information will read from /var/log/wtmp file. The output of this command contains the following columns:

User name
Tty device number
Login date and time
Logout time
Total working time

[root@austin ~]# last
root     pts/0        10.1.xx.x    Sat Aug  3 06:49 - down   (00:01)

Partitioning and Creating and Ext3 or Ext4 filesystem CentOS

We will install a new serial ATA hard drive into our system, and it’s hooked to the second SATA port, thus making our drive “sdb.” Enter the following as root:

# fdisk /dev/sdb

This brings up how many cylinders are on your hard disk, and of course opens up the fdisk program that will allow us to partition our new hard disk.

The next step is to simply enter a “p” to show the partition table. This is useful to see what partitions are already setup on the disk.

Command (m for help): p

Disk /dev/sdb: 50.0 GB, 50019202560 bytes
255 heads, 63 sectors/track, 6081 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot    Start       End    Blocks   Id  System

Command (m for help):

There are no partitions on it. If any partitions are present we’ll just go ahead and delete them by pressing “d.”

Next we’ll need to partition our drive. We’ll keep it simple and mount this drive with a large, single primary partition, just like a backup drive. To do that enter “n” at the command line to create a new partition.

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-6081, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-6081, default 6081): 6081

Command (m for help):

As you can see, I hit “n” and it asked if I’d like to create a primary (P) or an extended partition (E) I hit P for a primary partition, entered “1″ for it being my first partition on the drive. Your first cylinder will be “1″ and the last one in our case will be “6081.” Most times you will be able to hit enter and use the default cylinder counts.

Verify that we’ve done everything correctly up until this point. At the command prompt enter “p” to check the partition table again:

Command (m for help): p

Disk /dev/sdb: 50.0 GB, 50019202560 bytes
255 heads, 63 sectors/track, 6081 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/sdb1             1      6081  48845601   83  Linux

Command (m for help):

Now you can see that we’ve added a partition to the drive, but we’re not done yet. No changes have been written to the disk yet, everything is just in memory. If everything looks right, go ahead and enter the “w” command which will write the changes to the disk.

Creating an ext3 file system

Now that our disk is partitioned to sdb1 we’ll need to format it. You can format your drive to any filesystem you want, but for our purposes here I’m going to format it with ext3, the most common today. To format your drive:

root@laxmi [~]# mkfs -t ext3 /dev/sdb1
mke2fs 1.41.12 (17-May-2010)
Discarding device blocks: done                            
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
7331840 inodes, 29304560 blocks
1465228 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
895 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
	4096000, 7962624, 11239424, 20480000, 23887872

Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 20 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.


Using the mk2fs (make file system) command, we specified the type (using the -t) ext3 using the device and partition name (/dev/sdb1). You have successfully partitioned and formatted your new drive. We need to mount this partition to make it usable, and add an entry in the file “/etc/fstab”

We’re going to add this entry in the fstab file because on reboot, our drive that we just mounted will need to be remounted. By adding a simple entry in the fstab file our drive will be mounted every time on startup. To do this we’re going to add the following code on the last line of the file “/etc/fstab”

/dev/sdb1               /backup                  ext3    defaults        1 2

Once you’ve added that to the last line in the file, save it and issue this final command as root:

# mount /dev/sdb1

The mount command mounts the drive for immediate use, and the /dev/sdb1 is our drives partition name.

Creating an ext4 file system

The easiest way to create a file system on a partition is to use the mkfs.ext4 utility which takes as arguments the label and the partition device:

YOU MAY GET THIS IS YOU DO NOT SPECIFY THE NUMBER…

# mkfs.ext4 -L /backup /dev/sdd
mke2fs 1.41.12 (17-May-2010)
/dev/sdd is entire device, not just one partition!

# /sbin/mkfs.ext4 -L /backup /dev/sdb1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=/backup
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
2097152 inodes, 8388352 blocks
419417 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
256 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 36 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

Mounting a File System

Now that we have created a new file system on the Linux partition of our new disk drive we need to mount it so that it is accessible. In order to do this we need to create a mount point. A mount point is simply a directory or folder into which the file system will be mounted. For the purposes of this example we will create a /backup directory to match our file system label (although it is not necessary that these values match):

# mkdir /backup

The file system may then be manually mounted using the mount command:

# mount /dev/sdb1 /backup

Configuring CentOS 6 to Automatically Mount a Ext4 File System

In order to set up the system so that the new file system is automatically mounted at boot time an entry needs to be added to the /etc/fstab file.

For ext 4 find the UUIS:

# blkid /dev/sdd1
/dev/sdb1: LABEL="/backup" UUID="6043e3e8-f0a3-405b-9905-9a6087fd02fe" TYPE="ext4"

Add to fstab

UUID=6043e3e8-f0a3-405b-9905-9a6087fd02fe /backup     ext4    1       1

The following example shows an fstab file configured to automount our /backup partition:

/dev/mapper/vg_centos6-lv_root /            ext4    defaults        1 1
UUID=0d06ebad-ea73-48ad-a50a-1b3b8ef24491 /boot  ext4    defaults        1 2
/dev/mapper/vg_centos6-lv_swap swap         swap    defaults        0 0
tmpfs                   /dev/shm            tmpfs   defaults        0 0
devpts                  /dev/pts            devpts  gid=5,mode=620  0 0
sysfs                   /sys                sysfs   defaults        0 0
proc                    /proc               proc    defaults        0 0
LABEL=/backup /backup      ext4    defaults        1 2

cPanel comes with a built in handy utility that will automatically detect, format, and partition your new drive with just a few clicks.

To install your new hard drive through cPanel you’ll need to login to WHM as root, and find the button on the left called “Format/Mount a new hard drive” under the drives tab about 3/4 the way down. Click on that. The next page will show you the newly detected drives and have a button next to the drive to select it. Once you select your new drive follow the onscreen instructions, and hit enter.

ftp Proftpd error

Error when ftp to a domain

DS28220.domain.com proftpd[16643]: error: no valid servers configured
DS28220.domain.com proftpd[16643]: Fatal: error processing configuration file ‘/etc/proftpd.conf’

Edit the /etc hosts file and put the IP and the name in it:


Nano /etc/hosts
DS28220.domain.com 129.33.44.55

Restart xinetd

service xinetd restart

Email Deferred/Greylisting error

Getting email logs that show the following?

mail qmail-queue-handlers[8672]: Handlers Filter before-queue for qmail started …Jul 7 14:17:18 mail qmail-queue-handlers[8672]: from=domain@domain.comJul 7 14:17:18 mail qmail-queue-handlers[8672]: to=domain@domain.comJul 7 14:17:18 mail greylisting filter[8673]: Starting greylisting filter…Jul 7 14:17:18 mail qmail-queue-handlers[8672]: handlers_stderr: DEFERJul 7 14:17:18 mail qmail-queue-handlers[8672]: DEFER during call ‘grey’ handlerJul 7 14:17:26 mail pop3d: Connection, ip=[::ffff:203.197.xx.xx]Jul 7 14:17:26 mail pop3d: LOGOUT, ip=[::ffff:203.197.xx.xx]

In this case its referring to greylisting which you can choose to disable if you wish, http://kb.parallels.com/en/6359 is an article that refers to it.

Or run:

/usr/local/psa/bin/grey_listing --update-server -status off

What is uplink port speed on a dedicated server?

What is uplink port speed on a dedicated server with 100MBPS port?

Put another way, there are 8 bits to a byte, 1024 bytes to a kilobyte and 1024 kilobytes to a megabyte. 100 Mbits = 100/8 MBytes = 12.4 MBytes/sec; 10 Mb = 1.24 MB/sec.

1Gbps uplink (would max out at around 125MB/sec).

In terms of dedicated servers, the uplink port speed is most likely the speed of the connection between the server and the router to the backbone. If the host company’s connection to the ‘net in general is faster than your uplink speed (most likely the case), then the uplink port speed will be a bottleneck.

Measure of file size: KBps
File size i.e. how big the file or how much space a file occupies in the hard disk measured in terms of KiloBytes (KB upper case “K” and upper case “B”). In computing terms the upper case “K” stands for 1024. 1024 is computed from 210. (2 power 10). 2 denote the number of characters in the binary system which is used to store data in the disc (ones and zeroes).
Other abbreviations like mega, giga and terra also use the base as 1024,

1KB (KiloByte) = 1024 Bytes (approximately 1000 Bytes)
1MB (MegaByte) = 1024 KB (approximately 1000 KiloBytes or 1 million Bytes)
1GB (GigaByte) = 1024 MB (approximately 1000 MegaBytes or 1 billion Bytes)
1TB (TerraByte) = 1024 GB (approximately 1000 GigaBytes or 1 trillion Bytes)

Measure of data transfer speeds: kbps
Data transfer speed over the networks (including the internet) is calculated in terms of bits per second: kilobits (kb small case “k” and small case “b”). The higher the kbps i.e. more the bits transferred per second, more the speed, faster the network/connection. Here k stands for 1000 (103 )

1 kbps (kilo bits per second) = 1000 bits per second
1 Mbps (mega bits per second) = 1000 kilo bits per second.
1 Gbps (giga bits per second) = 1,000 mega bits per second.

ISP bandwidth and download speeds
The most common confusion caused by the similarity of KBps and kbps is when it comes to internet bandwidth and download speeds. People often complain that their ISP promised 512kbps connectivity but they are seldom able to download any file at 512 KBps. They fail to notice the difference in cases of the units and hence think their ISP is cheating them or offering them poor quality service. As mentioned earlier data transfer speeds are always calculated in terms of kilo bits per second (kbps) so an ISP connectivity of 512 kbps promises of transfer of at the max 512 kilo bits per second.

On the other hand, file size measure is always in Kilo Bytes and thus download speeds are always calculated based on how many Bytes per second are downloaded and hence Kilo Bytes per second (KBps). KBps and kbps are not interchangeable.

So an internet connectivity of say 512kbps can never achieve a download speed of 512 KBps. To calculate the maximum download speed of a “X kbps” connection, we need to use a simple formula as below.

Download KBPS speed = (Kbps value*1000) /8)) / 1024.

I.e. For a connectivity of 512 kbps

kbps value * 1000 = 512 * 1000 = 512000

512000 / 8 = 64000

64000 / 1024 = 62.5 KBps

Therefore theoretically an internet connection of 512kbps bandwidth can download at a speed of 62.5 KBps

If you don’t want to go through all the hassles of the above formula, just multiply the kbps value with 0.1220703125 to get the KBps value.

512 kbps * 0.1220703125 = 62.5 KBps. Simple!

Internet connectivity Download speed (approx)
256 kbps 31.3 KBps
384 kbps 46.9 KBps
512 kbps 62.5 KBps
768 kbps 93.8 KBps
1 mbps ~ 1000kbps 122.1 KBps

FTP error – ECONNREFUSED – Connection refused by server-Proftp

When connecting to the server via ftp and you are sure about the credentials and the firewall rules and iptables. Check DNS and the proftpd.conf file:

# dig domain.com
domain.com.       21599   IN      A       216.xx.xx.xx


# nano /etc/proftpd.conf
Port                            21
MasqueradeAddress       216.xx.xx.xx
PassivePorts                    60000 65000

Check the MasqueradeAddress feature and see if matched your IP for the domain you are connecting to.

Also – if behind a firewall…

Create a VirtualHost for 216.xx.xx.xx with the following configuration:


<VirtualHost 192.168.0.5>
ServerName "ProFTPD"
MasqueradeAddress 216.xx.xx.xx
PassivePorts 60000 65000
</VirtualHost>

Move Data from Slaved Drive – Plesk

First you will want to set up subscriptions for the domains in the plesk panel. Once they are created you can run the commands below:

Here are a few commands that should help.

1.) rsync example. This will move the data from one drive to the other.


rsync -avz /mnt/slave/var/www/vhosts/"domain name"/httpdocs /var/www/vhosts/"domain name"/httpdocs

You will want to change the “domain name” to the one you are working on at the time.

2.) Changing ownership:


chown -R "ftpusername":psacln /var/www/vhosts/"domain name"/httpdocs/*

You will want to change the “ftpusername” to what you set up for each domain when creating the subscription.

If the sites are simple, these are the only 3 steps you should need to take for each domain.

Update:

I would use the rsync command rather than cp. Rsync will keep permissions the same. The command would look something like:


rsync -aPSv /mnt/olddrive/var/www/vhosts/domain.com/httpdocs/somedirectory/ /var/www/vhosts/domain.com/httpdocs/restoredirectory/

You can also preview what will be synced by adding –dry-run to the command. This doesn’t actually copy anything, just shows you what’s going to happen e.g.


rsync -aPSv /mnt/olddrive/var/www/vhosts/domain.com/httpdocs/somedirectory/ /var/www/vhosts/domain.com/httpdocs/restoredirectory/ --dry-run

The databases are in /mnt/olddrive/var/lib/mysql

One thing you might try is to stop mysql, change datadir in /etc/my.cnf to /mnt/olddrive/var/lib/mysql, then restart mysql and dump your databases. Then stop mysql, revert datadir back and restart mysql again.

When MySQL is running using the slaved drive as the datadir, you can use this to log in to MySQL:


mysql -uadmin -p`cat /mnt/olddrive/etc/psa/.psa.shadow

alternately you can set skip-grant-tables in the /etc/my.cnf file until you have things running again.

You can either dump your databases as one file or as separate files for each DB – http://www.commandlinefu.com/commands/view/2916/backup-all-mysql-databases-to-individual-files