Deprecated: Hook custom_css_loaded is deprecated since version jetpack-13.5! Use WordPress Custom CSS instead. Jetpack no longer supports Custom CSS. Read the WordPress.org documentation to learn how to apply custom styles to your site: https://wordpress.org/documentation/article/styles-overview/#applying-custom-css in /srv/www/srvfail.com/public_html/wp-includes/functions.php on line 6078
Linux Archives ⋆ Page 8 of 8 ⋆ SysAdminStuff

YUM fails in clean CentOS 7 install, Exiting on user cancel

If you are installing CentOS 7, you might get an issue with yum update exiting, when it starts downloading packages with the message  Exiting on user cancel even though you haven’t pressed any key, or did anything else that might have cancelled the process.

This seems to be a known bug on Red Hat Enterprise Linux / CentOS 7.1, but it happened on version 7.0.1406 for me.

https://bugzilla.redhat.com/show_bug.cgi?id=1091740

[root@CentOS70x86-001 ~]# cat /etc/redhat-release
CentOS Linux release 7.0.1406 (Core)

After running yum update it would connect to repository any resolve all the dependencies, and list all the packages that need to be updated, but once you would confirm the download, it would initiate download of packages, and then failed with the message indicating that the process was interrupted from keyboard.

Transaction Summary
=================================================================================================================================
Install    8 Packages (+6 Dependent packages)
Upgrade  202 Packages

Total size: 203 M
Total download size: 194 M
Is this ok [y/d/N]: y
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
Traceback (most recent call last):
  File "/usr/libexec/urlgrabber-ext-down", line 75, in 
    main()
  File "/usr/libexec/urlgrabber-ext-down", line 61, in main
    fo = PyCurlFileObject(opts.url, opts.filename, opts)
  File "/usr/lib/python2.7/site-packages/urlgrabber/grabber.py", line 1258, in __init__
    self._do_open()
  File "/usr/lib/python2.7/site-packages/urlgrabber/grabber.py", line 1589, in _do_open
    self._do_grab()
  File "/usr/lib/python2.7/site-packages/urlgrabber/grabber.py", line 1723, in _do_grab
    self._do_perform()
  File "/usr/lib/python2.7/site-packages/urlgrabber/grabber.py", line 1517, in _do_perform
    raise KeyboardInterrupt
KeyboardInterrupt


Exiting on user cancel

After running bash -c 'yum clean metadata && yum upgrade' as suggested on CentOS forums, yum has downloaded all the packages, and upgraded to latest CentOS version

https://www.centos.org/forums/viewtopic.php?t=47372

[root@CentOS70x86-001 ~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)

Alternate solution

Another possible solution, to this might be to edit /usr/lib/python2.7/site-packages/urlgrabber/grabber.py file, and change the line number 1510 as below:

Change “elif errcode in (42, 55, 56):” to “elif errcode == 42:”

https://infologs.wordpress.com/2015/01/25/url-grabber-error-on-yum-updateinstall-on-centos7/

How to install MySQL through YaST

This is a repost of a post from an old blog, made on January 9, 2012, that used to be on:

http://adminramble.com/install-mysql-yast/

Original post:

I was looking into Novell Service Desk as solution for our Help-desk department today, so i decided to test it by installing it on a single machine together with a MySQL server to act as its database. It’s been a few years since the last time I installed MySQL, last few years I’m mostly working with Informix and MS SQL.

I just wanted it installed as soon as possible so I decided to install the it through YaST thinking it would be faster, but neglected the fact that YaST scatters the installation through several directories so I spend some time locating the files. So this are the short instructions for those who decided to do it with YaST. I was installing on SUSE Linux Enterprise Server 11 SP1

HOW TO INSTALL MYSQL THROUGH YAST ON SLES 11
  1. Open YaST(just type yast in terminal)>Software>Software management(use Tab button to move between sections), or go straight to Install Software on main menu if you’re working through GUI
  2. In the search filed type mysql and press Enter or Search
  3. Select mysql package, mysql-client will be selected also automatically also, and press Accept to install them.
    (mysql user and mysql group will be created automatically, so you don’t need to do that)If you want to find out where did YaST installed all the files, you can do that either through the terminal with rpm -qal mysql command, or if you’re working through the GUI by opening YaST, typing mysql i search box and selecting mysql package. On the File List tab you can see where all the files are installed.

  4. Edit the /etc/my.cnf file, by adding user=mysql after the [mysqld]
    your file should look something like this:

    [mysqld]
     user = mysql
  5. Crate a mysql database with the following command:
    /usr/bin/mysql_install_db –user=mysql
  6. Start your server with:
    /usr/bin/mysqld_safe –user=mysql &
  7. Check if the server is running with:
    /usr/bin/mysqladmin version
    You should get information about the software version.
  8. Connect to your MySQL server with:
    /usr/bin/mysql -u root
    You should get the mysql> prompt if everything is okay.

 

There are other ways to install MySQL besides YaST, if you would like to install MySQL from source you can check this blog

cPanel a lot of accounts quota or bandwidth exceeded.

WHM/cPanel all packages get reapplied, and Upgrade/Downgrade notification is sent for all accounts.

lvemanager-1.0-9.9 has been released in production by CloudLinux yesterday, and it has caused issues on WHM/cPanel servers, by reapplying packages to all accounts.

https://cloudlinux.com/blog/clnews/lve-manager-1099-and-lveutils-1523-released-to-production.php

All accounts that had their quotas and limits modified, without modifying the related packages, have been reassigned to values that are specified in the package, they are assigned to. This will cause  quota or bandwidth being exceeded on a lot of accounts on the server, if you haven’t been modifying them properly.

If you have received a following type of mail for all accounts on your server,  that account Upgrade/Downgrade was made, then it is due to lvemanager update to lvemanager-1.0-9.9.

Upgrade/Downgrade: %account" from <root@%hostname> for email@domain.tld

If you check your yum update logs, you will see lvemanager-1.0-9.9 has been installed on the server overnight, which is the cause of the issues with the packages being reapplied.

# grep lve /var/log/yum.log | tail -2
Dec 17 05:09:12 Updated: lve-utils-1.5-2.3.el6.cloudlinux.i686
Dec 17 05:09:27 Updated: lvemanager-1.0-9.9.el6.cloudlinux.noarch
#

According to the comments on CloudLinux blog

“You can find their last allocated settings from your last backup –
less /cpb/incremental/accounts/domainname/cp/domainname”

https://cloudlinux.com/blog/clnews/lve-manager-1099-and-lveutils-1523-released-to-production.php#comments

Update by CloudLinux:

CloudLinux has in the meantime issued a statement regarding LVE Manager 1.0-9.9 issues, with some details on how to revert the values to one prior the upgrade.

http://cloudlinux.com/blog/clnews/lve-manager-1099-issues.php

Excerpt from their blog:

If you have cPanel backups enabled, you can get previous limits from backups. Here is an example how to do it:

cd /backup/cpbackup/daily
tar -zxvf username.tar.gz username/cp
tar -zxvf username.tar.gz username/quota

cat username/quota
cat username/cp/username | egrep "MAX|BWLIMIT"

Then set limits manually with WHM –> Modify account.

UPDATED: Dec 18, 07:16 AM UTC

Here are some commands that should help you returning quotas back, if you have cpanel backups enabled.

Get list of users over quota:

cd /backup/cpbackup/daily/
repquota -a | grep "+" | awk '{ print $1 }' > users_overquota

Extract only quota files for them:

for i in `cat users_overquota` ; do echo "tar -zxvf "$i".tar.gz "$i"/quota" ; done | sh

Echo username and quota limit, the output value means Mb:

for i in `cat users_overquota` ; do echo "echo -e '\n'; echo "$i"; cat "$i"/quota " ; done | sh

Now use cpanel’s script to set quotas, based on above output add ‘M’ key for it. Copy-paste username and %value% and run command for each:

/scripts/editquota username %value%M

Another update:

CloudLinux has made another updated about the issue, and have provided a script that could be used to restore those limits if cPanel backups were enabled.

http://cloudlinux.com/blog/clnews/autorestore-package-limits-script-after-lvemanager1099-update.php

Excerpt from their blog:

Due to number of servers affected with custom package limits reset to package defaults we prepared a script that could be used to restore those limits if cPanel backups were enabled. It restores all limits if:

  • package was not changed since backup time;
  • limits are the same as package limits;
  • all package limits in backup are the same as current package limits.

Required files: %backup_location%/files/_etc_quota.conf.gz and %backup_location%/dirs/_var_cpanel.tar.gz . Please, restore them from a day/week before LVE Manager update (before December 16). Better to place them in the same /root/ directory.

Download the following script and make it executable:

wget http://kb.cloudlinux.com/scripts/autorestore.py
chmod 755 autorestore.py

Run it the following way:

./autorestore.py /root/_var_cpanel.tar.gz /root/_etc_quota.conf.gz
The script will back up current user limits to /var/cpanel/users.%timestamp% before changing limits.

Install ClamAV on RHEL/CentOS 7, and configure clamd

ClamAV on RedHat Enterprise Linux (RHEL) and CentOS 7 can be installed from Extra Packages for Enterprise Linux (EPEL) repository.

One liner to install EPEL repo, ClamAV packages, and correct configuration files.

yum -y install epel-release; yum -y install clamav-server clamav-data clamav-update clamav-filesystem clamav clamav-scanner-systemd clamav-devel clamav-lib clamav-server-systemd; sed -i '/^Example$/d' /etc/freshclam.conf; sed -i '/^Example$/d' /etc/clamd.d/scan.conf; sed -i -e 's/#LocalSocket \/var\/run\/clamd.scan\/clamd.sock/LocalSocket \/var\/run\/clamd.scan\/clamd.sock/g' /etc/clamd.d/scan.conf; sed -i '/REMOVE ME/d' /etc/sysconfig/freshclam; systemctl enable clamd@scan; freshclam; systemctl start clamd@scan; systemctl status clamd@scan;

If everything is OK, output should end something like this.

Downloading daily.cvd [100%]
daily.cvd updated (version: 20882, sigs: 1566229, f-level: 63, builder: neo)
Downloading bytecode.cvd [100%]
bytecode.cvd updated (version: 268, sigs: 47, f-level: 63, builder: anvilleg)
Database updated (3990501 signatures) from database.clamav.net (IP: 104.131.196.175)
clamd@scan.service - Generic clamav scanner daemon
   Loaded: loaded (/usr/lib/systemd/system/clamd@scan.service; enabled)
   Active: active (running) since Sun 2015-09-06 09:24:37 EDT; 16ms ago
 Main PID: 707 (clamd)
   CGroup: /system.slice/system-clamd.slice/clamd@scan.service
           └─707 /usr/sbin/clamd -c /etc/clamd.d/scan.conf --nofork=yes

Sep 06 09:24:37 test.demo.local systemd[1]: Started Generic clamav scanner daemon.
Sep 06 09:24:37 test.demo.local clamd[707]: clamd daemon 0.98.7 (OS: linux-gnu, ARCH: x86_64, CPU: x86_64)
Sep 06 09:24:37 test.demo.local clamd[707]: Running as user clamscan (UID 998, GID 997)
Sep 06 09:24:37 test.demo.local clamd[707]: Log file size limited to 1048576 bytes.
Sep 06 09:24:37 test.demo.local clamd[707]: Reading databases from /var/lib/clamav
Sep 06 09:24:37 test.demo.local clamd[707]: Not loading PUA signatures.
Sep 06 09:24:37 test.demo.local clamd[707]: Bytecode: Security mode set to "TrustSigned".
[root@test ~]#

ClamAV Installation details:

Install EPEL repo:

EPEL can be installed from CentOS Extras repository, which is enabled by default, with the following command.

yum -y install epel-release

In case epel-release package is not available for any reason, it can be installed from Webtatic or Fedora servers, with following commands.

rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm

or

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
Install ClamAV packages:

Once EPEL is installed ClamAV packages can be installed with the following command.

yum -y install clamav-server clamav-data clamav-update clamav-filesystem clamav clamav-scanner-systemd clamav-devel clamav-lib clamav-server-systemd

Once all necessary packages have been installed, freshclam.conf file needs to be edited, for ClamAV update to work.

Correct freshclam.conf file:

Default installation will return the following error when “freshclam” command is run, due to file being marked as example config file.

# freshclam
ERROR: Please edit the example config file /etc/freshclam.conf
ERROR: Can't open/parse the config file /etc/freshclam.conf

Error is caused by the following section in the freshclam.conf configuration file.

## Example config file for freshclam
## Please read the freshclam.conf(5) manual before editing this file.
##

# Comment or remove the line below.
Example

As specified in the file, last line in this snippet, needs to be removed, or commented out, in order for “freshclam” command to work.
Line can be removed with the following command.

sed -i '/^Example$/d' /etc/freshclam.conf
Enable automatic Updates:

By default freshclam cronjob is disabled, and last line needs to be removed or commented out from /etc/sysconfig/freshclam in order for automatic updates to run.

[root@test ~]# cat /etc/sysconfig/freshclam
## When changing the periodicity of freshclam runs in the crontab,
## this value must be adjusted also. Its value is the timespan between
## two subsequent freshclam runs in minutes. E.g. for the default
##
## | 0 */3 * * *  ...
##
## crontab line, the value is 180 (minutes).
# FRESHCLAM_MOD=

## A predefined value for the delay in seconds. By default, the value is
## calculated by the 'hostid' program. This predefined value guarantees
## constant timespans of 3 hours between two subsequent freshclam runs.
##
## This option accepts two special values:
## 'disabled-warn'  ...  disables the automatic freshclam update and
##                         gives out a warning
## 'disabled'       ...  disables the automatic freshclam silently
# FRESHCLAM_DELAY=


### !!!!! REMOVE ME !!!!!!
### REMOVE ME: By default, the freshclam update is disabled to avoid
### REMOVE ME: network access without prior activation
FRESHCLAM_DELAY=disabled-warn   # REMOVE ME
[root@test ~]#

Lines can be removed with following command.

sed -i '/REMOVE ME/d' /etc/sysconfig/freshclam
Correct scan.conf file:

Same needs to be done for scan.conf file

##
## Example config file for the Clam AV daemon
## Please read the clamd.conf(5) manual before editing this file.
##


# Comment or remove the line below.
Example

Following command removes the line from scan.conf file.

sed -i '/^Example$/d' /etc/clamd.d/scan.conf

We also need to define the socket file.
If we try to run clamd, following error is returned.

[root@test ~]# clamd -c /etc/clamd.d/scan.conf
ERROR: Please define server type (local and/or TCP).
[root@test ~]#

Checking the scan.conf file, we see socket file is commented out.

# Path to a local socket file the daemon will listen on.
# Default: disabled (must be specified by a user)
#LocalSocket /var/run/clamd.scan/clamd.sock

Comment can be removed with following command.

sed -i -e 's/#LocalSocket \/var\/run\/clamd.scan\/clamd.sock/LocalSocket \/var\/run\/clamd.scan\/clamd.sock/g' /etc/clamd.d/scan.conf

 

MySQLTuner Couldn’t find mysqladmin in your $PATH

If you try to run MySQLTuner on a default RHEL/CentOS 7 minimal install, you will receive an error due to “which” command not being found.

In order to resolve the error you need to add “which” to your CentOS/RHEL installation, or use the “–mysqladmin” switch to point to mysqladmin executable when running mysqltuner.pl.

When you try to execute MySQLTuner, you will receive a message like this:

# perl mysqltuner.pl
Can't exec "which": No such file or directory at mysqltuner.pl line 905 (#1)
(W exec) A system(), exec(), or piped open call could not execute the
named program for the indicated reason. Typical reasons include: the
permissions were wrong on the file, the file wasn't found in
$ENV{PATH}, the executable in question was compiled for another
architecture, or the #! line in a script points to an interpreter that
can't be run for similar reasons. (Or maybe your system doesn't support
#! at all.)

Use of uninitialized value $mysqladmincmd in scalar chomp at mysqltuner.pl line
907 (#1)
(W uninitialized) An undefined value was used as if it were already
defined. It was interpreted as a "" or a 0, but maybe it was a mistake.
To suppress this warning assign a defined value to your variables.

To help you figure out what was undefined, perl will try to tell you
the name of the variable (if any) that was undefined. In some cases
it cannot do this, so it also tells you what operation you used the
undefined value in. Note, however, that perl optimizes your program
anid the operation displayed in the warning may not necessarily appear
literally in your program. For example, "that $foo" is usually
optimized into "that " . $foo, and the warning will refer to the
concatenation (.) operator, even though there is no . in
your program.

Use of uninitialized value $mysqladmincmd in -e at mysqltuner.pl line 908 (#1)
Use of uninitialized value $mysqladmincmd in -e at mysqltuner.pl line 913 (#1)
[!!] Couldn't find mysqladmin in your $PATH. Is MySQL installed?

If you check the reported lines in mysqltuner.pl file, you will see that reported variable mysqladmincmd is found by looking for path of mysqladmin with “which mysqladmin” command.

# sed -n '905p;908p;913p' mysqltuner.pl
        $mysqladmincmd = `which mysqladmin`;
    if ( !-e $mysqladmincmd && $opt{mysqladmin} ) {
    elsif ( !-e $mysqladmincmd ) {

You can install “which” with following command.

yum -y install which

After installing the rpm, you will be able to execute mysqltuner.pl file.

Alternative to installing “which” is to run MySQLTuner with “–mysqladmin” switch and define the path to mysqladmin executable.

# perl mysqltuner.pl --help
   MySQLTuner 1.6.0 - MySQL High Performance Tuning Script
   Bug reports, feature requests, and downloads at http://mysqltuner.com/
   Maintained by Major Hayden (major@mhtx.net) - Licensed under GPL

   Important Usage Guidelines:
      To run the script with the default options, run the script without arguments
      Allow MySQL server to run for at least 24-48 hours before trusting suggestions
      Some routines may require root level privileges (script will provide warnings)
      You must provide the remote server's total memory when connecting to other servers

   Connection and Authentication
      --host     Connect to a remote host to perform tests (default: localhost)
      --socket     Use a different socket for a local connection
      --port         Port to use for connection (default: 3306)
      --user     Username to use for authentication
      --pass     Password to use for authentication
      --mysqladmin   Path to a custom mysqladmin executable
      --mysqlcmd     Path to a custom mysql executable

      --noask              Dont ask password if needed

   Performance and Reporting Options
      --skipsize           Don't enumerate tables and their types/sizes (default: on)
                           (Recommended for servers with many tables)
      --skippassword       Don't perform checks on user passwords(default: off)
      --checkversion       Check for updates to MySQLTuner (default: don't check)
      --forcemem     Amount of RAM installed in megabytes
      --forceswap    Amount of swap memory configured in megabytes
      --passwordfile Path to a password file list(one password by line)
   Output Options:
      --silent             Don't output anything on screen
      --nogood             Remove OK responses
      --nobad              Remove negative/suggestion responses
      --noinfo             Remove informational responses
      --debug              Print debug information
      --dbstat             Print database information
      --idxstat            Print index information
      --nocolor            Don't print output in color
      --buffers            Print global and per-thread buffer values
      --outputfile   Path to a output txt file

      --reportfile   Path to a report txt file

      --template     Path to a template file

On CentOS 7 path to mysqladmin executable is “/usr/bin/mysqladmin”.

This is an example of a command which runs MySQL tuner, by manually specifying MySQL user and password, and path to mysqladmin executable.

perl mysqltuner.pl --user root --pass yourpassword --mysqladmin /usr/bin/mysqladmin