The system cannot open the database eximstats_db.sqlite3

Example error

—————

Cpanel::Exception::Database::DatabaseCreationInProgress/(XID 2dkj7a) The system cannot open the database “/var/cpanel/eximstats_db.sqlite3” because another process has created it but has not yet completed its initialization.
at /usr/local/cpanel/Cpanel/Exception/CORE.pm line 336.
Cpanel::Exception::create(“Database::DatabaseCreationInProgress”, ARRAY(0xf3ce90)) called at /usr/local/cpanel/Cpanel/SQLite/AutoRebuildSchemaBase.pm line 222
Cpanel::SQLite::AutoRebuildSchemaBase::__ANON__(Cpanel::Exception::Database::Error=HASH(0x1de9e58)) called at /usr/local/cpanel/3rdparty/perl/524/lib64/perl5/cpanel_lib/Try/Tiny.pm line 120
Try::Tiny::try(CODE(0x1debac0), Try::Tiny::Catch=REF(0x1de7a50)) called at /usr/local/cpanel/Cpanel/SQLite/AutoRebuildSchemaBase.pm line 223
Cpanel::SQLite::AutoRebuildSchemaBase::_get_schema_version(Cpanel::EximStats::DB::Sqlite=HASH(0x1debb20)) called at /usr/local/cpanel/Cpanel/EximStats/DB/Sqlite.pm line 142
Cpanel::EximStats::DB::Sqlite::_schema_check(Cpanel::EximStats::DB::Sqlite=HASH(0x1debb20)) called at /usr/local/cpanel/Cpanel/SQLite/AutoRebuildBase.pm line 179
Cpanel::SQLite::AutoRebuildBase::new_without_rebuild(“Cpanel::EximStats::DB::Sqlite”) called at /usr/local/cpanel/Cpanel/EximStats/DB/Sqlite.pm line 86
Cpanel::EximStats::DB::Sqlite::__ANON__() called at /usr/local/cpanel/3rdparty/perl/524/lib64/perl5/cpanel_lib/Try/Tiny.pm line 99
eval {…} called at /usr/local/cpanel/3rdparty/perl/524/lib64/perl5/cpanel_lib/Try/Tiny.pm line 90
Try::Tiny::try(CODE(0x1dec210), Try::Tiny::Catch=REF(0x1dec240)) called at /usr/local/cpanel/Cpanel/EximStats/DB/Sqlite.pm line 114
Cpanel::EximStats::DB::Sqlite::get_status() called at whostmgr/bin/whostmgr11.pl line 621
main::__ANON__() called at /usr/local/cpanel/3rdparty/perl/524/lib64/perl5/cpanel_lib/Try/Tiny.pm line 99
eval {…} called at /usr/local/cpanel/3rdparty/perl/524/lib64/perl5/cpanel_lib/Try/Tiny.pm line 90
Try::Tiny::try(CODE(0x1ddc5f8), Try::Tiny::Catch=REF(0xf5aba8)) called at whostmgr/bin/whostmgr11.pl line 630
main::_db_status_vars() called at whostmgr/bin/whostmgr11.pl line 568
main::_emailstats_summary(ARRAY(0x10081e8)) called at whostmgr/bin/whostmgr11.pl line 597
main::emailstats_faildefer_summary() called at whostmgr/bin/whostmgr11.pl line 155

===================

 

To resolve this issue follow below steps

 

mv /var/cpanel/eximstats_db.sqlite3 /var/cpanel/eximstats_db.sqlite3-12-26
/scripts/restartsrv_tailwatchd
/scripts/import_exim_data /var/log/exim_mainlog

 

If the error still persists make sure that your server’s IOWait is not high and perform the import step once again after the IOWait is reduced.

Install MagickWand on CPanel

Before installing MagickWand you have to install ImageMagick

Go to WHM Home » Software » Module Installers » PHP Pecl

Select respective PHP version from the drop-down box

Click “Apply”

Search for “imagick” and install it.

 

After installing, go to command line and perform below steps

 

cd /usr/local/src/

wget http://www.magickwand.org/download/php/releases/MagickWandForPHP-1.0.9.tar.gz

tar -zxvf MagickWandForPHP-1.0.9.tar.gz

cd MagickWandForPHP-1.0.9

/opt/cpanel/ea-php56/root/usr/bin/phpize

./configure –with-php-config=/opt/cpanel/ea-php56/root/usr/bin/php-config

make

make install

 

After that update the “magickwand.so” from the MultiPHP INI Editor

Go to Home »Software »MultiPHP INI Editor

Select respective PHP version on “Editor mode” and add below line

extension=”magickwand.so”

How to format disk using parted command

Partition using parted command


The fdisk command won’t create partitions larger than 2 TB so you cannot use fdisk to create partition. In this case, you can use parted command to format the disk.

NOTE: You can use fdisk command for 2TB drive, here I’m using 2TB for testing purpose.


Check the available free disk using “lsblk” , “df -h” commands and make sure that the drive is not mounted anywhere.

# lsblk

#df -h

free disk is /dev/sdb

 

Use parted command and disk name to create partition

#parted /dev/sdb

(parted) print
Model: Seagate Expansion (scsi)
Disk /dev/sdb: 2.00TB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name Flags

 

In below step, all the datas will be erased so make sure there is no important datas on the disk.

(parted) mklabel gpt
Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? yes

 

Mention units in TB

(parted) unit TB

 

Mention start and end size of the partition

(parted) mkpart primary 0.00TB 2.00TB

 

Print command to display created partitions

(parted) print
Model: Seagate Expansion (scsi)
Disk /dev/sdb: 2.00TB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name Flags
1 0.00TB 2.00TB 2.00TB primary

 

Enter quit to save and exit

(parted) quit
Information: You may need to update /etc/fstab.


 

In case of any mistake you can remove the existing partitions with “rm” command and re-create it as mentioned above.

(parted) print
Model: Seagate Expansion (scsi)
Disk /dev/sdb: 2.00TB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name Flags
1 0.00TB 2.00TB 2.00TB primary

(parted) rm 1


 

Thank you

Fix CPanel account permission and ownership

Fix CPanel account permission and ownership issue with below script, save below code as fixperms.sh and run it as mentioned below. You can run the script from any location of the server (Like /root /home /usr/local/src), it will only fix the CPanel account permission issues.

for i in `ls -A /var/cpanel/users` ; do ./fixperms.sh $i ; done

./fixperms.sh username

=======================================

#!/bin/bash
# Script to fix permissions of accounts
# Written by: Vanessa Vasile 5/13/10
# http://thecpaneladmin.com

if [ “$#” -lt “1” ];then
echo “Must specify user”
exit;
fi

USER=$@

for user in $USER
do

HOMEDIR=$(egrep “^${user}:” /etc/passwd | cut -d: -f6)

if [ ! -f /var/cpanel/users/$user ]; then
echo “$user user file missing, likely an invalid user”

elif [ “$HOMEDIR” == “” ];then
echo “Couldn’t determine home directory for $user”

 

else

echo “Setting ownership for user $user”

chown -R $user:$user $HOMEDIR
chmod 711 $HOMEDIR
chown $user:nobody $HOMEDIR/public_html $HOMEDIR/.htpasswds
chown $user:mail $HOMEDIR/etc $HOMEDIR/etc/*/shadow $HOMEDIR/etc/*/passwd

echo “Setting permissions for user $USER”

find $HOMEDIR -type f -exec chmod 644 {} \; -print
find $HOMEDIR -type d -exec chmod 755 {} \; -print
find $HOMEDIR -type d -name cgi-bin -exec chmod 755 {} \; -print
find $HOMEDIR -type f \( -name “*.pl” -o -name “*.perl” \) -exec chmod 755 {} \; -print

chmod 750 $HOMEDIR/public_html

if [ -d “$HOMEDIR/.cagefs” ]; then
chmod 775 $HOMEDIR/.cagefs
chmod 700 $HOMEDIR/.cagefs/tmp
chmod 700 $HOMEDIR/.cagefs/var
chmod 777 $HOMEDIR/.cagefs/cache
chmod 777 $HOMEDIR/.cagefs/run
fi
fi
done

==========================================

Thanks for the wonderful script

Credits: Vanessa Vasile

Source: http://thecpaneladmin.com/fix-account-permissions/

 

Disclaimer: This script is not owned or created by me and it’s shared for knowledge purpose. The credits goes to actual creator and thecpaneladmin.com

Extend Logical Volume (LVM)

Current volume group name is “vg_home” and the logical volume name is “lv_home” we are going to increase the size of “lv_home” from addition disk “/dev/sdb” which is 100GB

Check current VG name

# vgs

VG #PV #LV #SN Attr VSize VFree

vg_home 1 3 0 wz–n- 79.51g 0

 

Check available logical volumes

# lvs

LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert

lv_home vg_m4 -wi-ao—- 25.57g

lv_root vg_m4 -wi-ao—- 50.00g

lv_swap vg_m4 -wi-ao—- 3.94g

 

Check addition added (free space) disk name (/dev/sdb)

# lsblk

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT

sdb 8:16 0 100G 0 disk  ———–> new disk with 100GB space

sda 8:0 0 80G 0 disk

├─sda1 8:1 0 500M 0 part /boot

└─sda2 8:2 0 79.5G 0 part

├─vg_home-lv_root (dm-0) 253:0 0 50G 0 lvm /

├─vg_home-lv_swap (dm-1) 253:1 0 4G 0 lvm [SWAP]

└─vg_home-lv_home (dm-2) 253:2 0 25.6G 0 lvm /home

 

Create partition on new disk /dev/sdb

#fdisk -c /dev/sdb

Command (m for help): n

Command action

e extended

p primary partition (1-4) p

Partition number (1-4):

Value out of range.

Partition number (1-4): 1

First cylinder (1-13054, default 1): (ENTER)

Using default value 1

Last cylinder, +cylinders or +size{K,M,G} (1-13054, default 13054): (ENTER)

Using default value 13054

Command (m for help): t

Selected partition 1

Hex code (type L to list codes): 8e

Changed system type of partition 1 to 8e (Linux LVM)

Command (m for help): p

Disk /dev/sdb: 107.4 GB, 107374182400 bytes

255 heads, 63 sectors/track, 13054 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0xf8587692

Device Boot Start End Blocks Id System

/dev/sdb1 1 13054 104855231 8e Linux LVM

Command (m for help): w

The partition table has been altered!

Check newly created partition “/dev/sdb1”

 

# lsblk

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT

sdb 8:16 0 100G 0 disk

└─sdb1 8:17 0 100G 0 part

sda 8:0 0 80G 0 disk

├─sda1 8:1 0 500M 0 part /boot

└─sda2 8:2 0 79.5G 0 part

├─vg_home-lv_root (dm-0) 253:0 0 50G 0 lvm /

├─vg_home-lv_swap (dm-1) 253:1 0 4G 0 lvm [SWAP]

└─vg_home-lv_home (dm-2) 253:2 0 25.6G 0 lvm /home

 

Create Physical volume on new disk (/dev/sdb1)

# pvcreate /dev/sdb

Physical volume “/dev/sdb1” successfully created

 

Display available physical volumes

# pvs

PV VG Fmt Attr PSize PFree

/dev/sda2 vg_home lvm2 a–u 79.51g 0

/dev/sdb1 lvm2 —- 100.00g 100.00g   ————–> newly  added physical volume

 

Extend the existing volume group with the new partition “/dev/sdb1”

# vgextend vg_home /dev/sdb1

Volume group “vg_home” successfully extended

 

# vgs

VG #PV #LV #SN Attr VSize VFree

vg_home 2 3 0 wz–n- 179.50g 100.00g   —————> 100GB free space available now

 

Extend lv_home of all the free space of new disk

#lvextend -l +100%FREE /dev/vg_home/lv_home

Size of logical volume vg_home/lv_home changed from 25.57 GiB (6546 extents) to 125.57 GiB (32145 extents).

Logical volume lv_home successfully resized.

 

Resize the logical volume to update changes

# resize2fs /dev/vg_home/lv_home

Filesystem at /dev/vg_home/lv_home is mounted on /home; on-line resizing required

old desc_blocks = 2, new_desc_blocks = 8

Performing an on-line resize of /dev/vg_home/lv_home to 32916480 (4k) blocks.

The filesystem on /dev/vg_home/lv_home is now 32916480 blocks long.

Check disk usage and you could see the 100GB added into /home partition.

 

#df -h

Filesystem Size Used Avail Use% Mounted on

/dev/mapper/vg_home-lv_root 50G 18G 30G 38% /

tmpfs 1.9G 0 1.9G 0% /dev/shm

/dev/sda1 477M 124M 328M 28% /boot

/dev/mapper/vg_home-lv_home 124G 24G 94G 20% /home

/usr/tmpDSK 2.0G 38M 1.9G 2% /tmp

Cpanel Backup in Rescue mode

NOTE:  

In this guide, the server is in rescue mode with Debian OS and the actual server was in Centos 6.8. There are two scenarios, 1.Rescue mode (debian os) 2.Chroot (centos 6.8 under /mnt)

In this scenario the “/ ” and all other partitions (like /home) are under same drive, you have to mount the drives according to your server partition 

This method will not work on Centos 7 and later versions because the systemctl command will not work in chroot environment.

Rescue mode

  • Login to the rescue server using ssh or putty (ssh root@ip.add.re.ss)
  • Check  the (attached) old disk  with lsblk command and mount it on /mnt

#lsblk

-For example, f the disk name is /dev/sdb1
#mount /dev/sdb1 /mnt

  • Now the old disk has been mounted on /mnt
  • Check /mnt/dev /mnt/sys /mnt/proc directories under /mnt, it should be empty (the “/mnt/dev” will have null file)
  • Bind the directories from rescue server to /mnt environment as follows
# mount --bind /proc /mnt/proc
# mount --rbind /dev /mnt/dev
# mount --bind /sys /mnt/sys 

Chroot environment

  • Create screen with screen command

#screen -S chroot

  • From the screen chroot into “/mnt” with following command
#chroot /mnt

 

  • Now, you are connected with the old disk, you could see the actual server’s disk or list the files with ls -al command to verify the disk.
#cat /etc/redhat-release
CentOS release 6.8

 

  • Start the services like cpanel and mysql
#service cpanel start
#service mysql start

 

  • After starting the services, you can take backup with “/scripts/pkgacct” or “/usr/local/cpanel/bin/backup” or “/scripts/cpbackup”
  • Take the list of Cpanel users which you want to take backup and initiate with below script. The Cpanel usernames will be in “/etc/userdomains” file so, now we are going to get the list.
#cat /etc/userdomains | cut -d":" -f2 | sort -n | uniq >> users.txt

 

  • Open the file “users.txt” check if there is any blank spaces and use below command to remove blank spaces
#sed "s/ //g" users.txt

 

#for i in `cat users.txt`; do /scripts/pkgacct $i; done

 

  • The backup should be in progress
  • Detach the screen with Ctrl + ad

Compile PHP module on secondary PHP

If you have multiple PHP versions installed on your server, you have to specify for which installation you’d like to build by using respective binary locations and configuration paths.

#cd /usr/local/src/
 
Download the same version of secondary PHP from php.net
 
 
#tar -zxvf php-7.0.20.tar.gz
 
Here we are going to add PDO module for PHP7.0
 
#cd php-7.0.20/ext/pdo
 
Use phpize from the binary location of secondary PHP otherwise, it will use default PHP version’s binary. Here the PHP7.0 is installed under /opt/php70
 
#/opt/php70/bin/phpize
 
After building an environment configure the module with “php-config” binary of PHP7.0
 
Example: ./configure –with-php-config=[Insert path to proper php-config here]
 
#./configure –with-php-config=/opt/php70/bin/php-config
 
Now the PHP module is configured with PHP7.0, use below command to install.
 
#make
#make install
 
You will get following output with installed location of the PHP module.
———————————————————————————————-
Installing shared extensions:     /opt/php70/lib/php/extensions/no-debug-non-zts-20151012/
Installing header files:          /opt/php70/include/php/
Installing PDO headers:           /opt/php70/include/php/ext/pdo/
———————————————————————————————-
 
Go to /opt/php70/lib/php/extensions/no-debug-non-zts-20151012/ and verify the extension. Copy the “shared extensions” path into your respective php.ini.
You can use phpinfo (); to find the php.ini location.
 
#echo ‘extension=/opt/php70/lib/php/extensions/no-debug-non-zts-20151012/pdo.so’ >> /etc/opt/rh/rh-php70/php.ini
 
Check the phpinfo page and the PDO module will be listed there.

Find symlinks in Linux

Find symlinks, using below command. This command will search for symlink file type in all subdirectories from the current location.

find . -type l -exec ls -lad {} \;

You can also redirect the result to text file with ‘> result.txt’ in last

find . -type l -exec ls -lad {} \; > result.txt

Change the location (/home/*/public_html) as per your requirement.

find /home/*/public_html -type l -exec ls -lad {} \; > /usr/local/src/result.txt

After finding the symlink files you can unlink with below command.

find . -type l -exec unlink {} \;

The ‘ . ‘ represents your current location. make sure the correct location before unlinking the files.

Do not execute it from “/” partition. :p

Thank you