MySQL error: Field doesn’t have a default value – ClipBucket – Clip-bucket

Download PDF

Clip-bucket Field ‘action_link’ doesn’t have a default value

or

MySQL error: Field doesn’t have a default value

When inserting a new record with varchar or text field that is required and has no default value. This error will display for example:error : Field ‘description’ doesn’t have a default value

The possible reason is that sql-mode in my.ini is set to STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION.

Change the value to
sql-mode = “”

Update 2011/4/25:
Add Default value “” if possible to avoid changing mysql setting.

iSCSI Naming and Addressing

Download PDF

In an iSCSI network, each iSCSI element that uses the network has a unique and permanent iSCSI name and is assigned an address for access.
iSCSI Name
Identifies a particular iSCSI element, regardless of its physical location. The iSCSI name can use IQN or EUI format.

IQN (iSCSI qualified name)

. Can be up to 255 characters long and has the following format:
iqn.yyyy-mm.naming-authority:unique name

yyyy-mm
The year and month when the naming authority was established.

naming-authority
Usually reverse syntax of the Internet domain name of the naming authority. For example, the iscsi.vmware.com naming authority could have the iSCSI qualified name form of iqn.1998-01.com.vmware.iscsi. The name indicates that the vmware.com domain name was registered in January of 1998, and iscsi is a subdomain, maintained by vmware.com.

unique name
Any name you want to use, for example, the name of your host. The naming authority must make sure that any names assigned following the colon are unique. For example, iqn.1998-01.com.vmware.iscsi:name1.

EUI (extended unique identifier)

. Includes the eui. prefix, followed by the 16-character name. The name includes 24 bits for the company name assigned by the IEEE and 40 bits for a unique ID, such as a serial number.
For example,
eui.0123456789ABCDEF

iSCSI Alias
A more manageable, easy-to-remember name to use instead of the iSCSI name. iSCSI aliases are not unique, and are intended to be just a friendly name to associate with the node.

IP Address
An address associated with each iSCSI element so that routing and switching equipment on the network can establish the connection between different elements, such as the host and storage. This is just like the IP address you assign to a computer to get access to your company’s network or the Internet.

Synology Failed to establish IEEE 802.3ad connection Cisco

Download PDF

Cisco_logo_2006       logo-Synology-300x300

 

 

Failed to establish IEEE 802.3ad connection

Failed to establish IEEE 802.3ad connection

Configuring Synology Link Aggregation

I am using Synology RS814+ and Cisco Catalyst 3750G. RS814+ has 4 gigabit ports. In my case I have only used first 2 ports to create an aggregation link.

If you wish to create 2 and 2 links, then make sure to create interface Port-channel2 for second link and use channel-group2 mode active on switch interfaces.

This configuration works 100%, please let me know if any problems.

interface Port-channel1
switchport
switchport access vlan 100
switchport mode access

interface GigabitEthernet1/0/1
description “Synology NIC1”
switchport access vlan 100
switchport mode access
channel-protocol lacp
channel-group 1 mode active
!
interface GigabitEthernet1/0/2
description “Synology NIC2”
switchport access vlan 100
switchport mode access
channel-protocol lacp
channel-group 1 mode active

Stable FastCGI configuration on a cPanel server

Download PDF

A default installation of FastCGI on cPanel server is dangerously simple. It’s dangerous because one cPanel account (or one vhost) is capable of crashing down a whole server if, say, traffic were to spike up. It’s also simple because it won’t allow complex scripts to run cleanly. In brief, it’s absolutely not ready for production as-is. In this post, I’ll go over what it takes to configure FastCGI on a cPanel node properly.

Before you continue reading, be sure to have FastCGI up and running as the PHP handler on your cPanel server. The installation of FastCGI is covered in the online cPanel documentation. From here on now, I’ll assume you’re ready to add the settings for FastCGI.

The following is a list of settings that you need to add to /etc/httpd/conf/php.conf upon switching to FastCGI:

MaxRequestsPerProcess 1000
FcgidMaxProcesses 200
FcgidProcessLifeTime 7200
MaxProcessCount 500
FcgidIOTimeout 400
FcgidIdleTimeout 600
FcgidIdleScanInterval 90
FcgidBusyTimeout 300
FcgidBusyScanInterval 80
ErrorScanInterval 3
ZombieScanInterval 3
DefaultMinClassProcessCount 0
DefaultMaxClassProcessCount 3
MaxRequestLen 20468982

You’re more likely to adjust the settings in bold above. DefaultMinClassProcessCount 0 instructs FastCGI to keep zero PHP processes running for user when traffic is idle (cPanel account user) . On the other hand, DefaultMaxClassProcessCount 3 tells FastCGI to never allow more than 3 PHP processes running at a time. This settings prevents one users from crashing the server were they to receive a lot of traffic.

So go ahead and copy/paste the above into your httpd.conf and restart Apache (service httpd restart). You’re good to go now!

Please note this configuration will be removed once EasyApache is run next, make sure you have a backup.


How to change the primary IP addres of a WHM/cPanel server

Download PDF

How to change the primary IP addres of a WHM/cPanel server

This is for CentOS/RHEL based servers.
Steps in WHM:

  • Log into WHM and go to Basic cPanel & WHM Setup
  • Change the Primary IP here with the option that says “The IP address (only one address) that will be used for setting up shared IP virtual hosts

Log in to SSH, and do the following:

  1. Edit /etc/sysconfig/network-scripts/ifcfg-eth0
    • Change the IPADDR and GATEWAY lines to match the new IP and Gateway for the new ip
  2. Edit /etc/sysconfig/network
    • Change the GATEWAY line here if it does not exist in the ifcfg-* file.
  3. Edit /etc/ips
    • Remove the new primary IP from this file if it is present
    • Add the old primary IP to this file with the format <IP address>:<Net Mask>:<Gateway>
  4. Edit /var/cpanel/mainip
    • Replace the old primary IP with the new primary IP
  5. Edit /etc/hosts
    • Replace the old primary IP with the new one if needed. The hostname’s dnswill need to be updated too
  6. Restart the network service to make the new IP the primary
    • service network restart
    • Note: You’re probably going to be disconnected at this point, and have to log in to ssh using the new primary ip.
  7. Restart the ipaliases script to bring up the additional IPs
    • service ipaliases restart
  8. Run ifconfig and make sure all IPs show up correctly
  9. Update the cpanel license to the new primary IP
  10. Verify you can still log in to WHM and there is no license warning

How to change SSH port on cPanel Linux server

Download PDF

1. Login to the server through SSH (port 22 by default)

2. Type this command vi /etc/ssh/sshd_config

3. Press “i” on the key to enable editing mode.

4. Where it says #Port 22 change to Port 123 (for example)

5. Now pres “esc” button on the keyboard and type :wq! to save the file and press enter.

6. Now restart the SSHd service by typing service sshd restart

6. Done

PLEASE NOT: IF YOU HAVE A FIREWALL, OPEN THE CUSTOM PORT FIRST BEFORE EDITING, IT MAY LOCK YOU OUT

cPanel how to move mysql data folder location

Download PDF

mysql_logo

09-cpanel_company_logo

1. Make a full mysqldump file:

Code:
mysqldump --all-databases | gzip > /home/alldatabases.sql.gz

2. Uncheck monitor in WHM > Service Manager for Mysql and save the area

3. Stop MySQL

Code:
/etc/init.d/mysql stop

4. Make the directory for MySQL in /home, move it and symlink it:

Code:
mkdir /home/var_mysql
mv /var/lib/mysql /home/var_mysql
chown -R mysql:mysql /home/var_mysql/mysql
ln -s /home/var_mysql/mysql /var/lib/mysql
/etc/init.d/mysql start

5. Re-check monitor in WHM > Service Manager for MySQL and save the area

If anything goes wrong, you have the full mysqldump backup, and can use these steps to restore from it:

First, you’ll need the MySQL root password:

Code:
cat /root/.my.cnf

Once you have the password, then you can use this command to restore from that file:

Code:
gunzip < /home/alldatabases.sql.gz | mysql -u root -p

You’ll be asked for the password here, so simply enter the one noted in /root/.my.cnf location.

How to upgrade GoDaddy VPS to CentOS 6.5

Download PDF

CentOS 6.5 has been released and brings many new features and security fixes.

In my case, I needed to upgrade from CentOS 6.4 to CentOS 6.5 because I needed php-5.4.24 (provided by remi repository), which required openssl-1.0.1 , introduced in CentOS 6.5 and unavailable in CentOS 6.4.

This HowTO explains how to upgrade to CentOS 6.5 on GoDaddy VPS (virtual private server, also called virtual dedicated server).

WARNING1: GoDaddy support discourage in doing this kind of update (and they even don’t know how to do it), because they want you to use their repositories. It is not clear if further updates will break things up. So follow this guide at your own risk.

WARNING2BACKUP EVERYTHING, a system update like this one could overwrite important configuration files (e.g: php.ini, my.cnf, httpd.conf, etc) or could even completely break your system. I updated 5 GoDaddy servers without any problem, but I don’t know what will happen with yours.

WARNING3MAKE A FULL COPY OF YOUR SERVER, because if something goes wrong, system could become unbootable. If you miss one or more steps, YOUR SERVER WON’T BOOT. If you have a custom server configuration, YOUR SERVER MAY NOT BOOT AFTER THE UPGRADE and you will HAVE TO reprovision your server, which means losing ALL DATA on server disk.

Why do I need to update to CentOS 6.5?

As soon as php-5.4.24 package (by remi) has been released, yum update started to raise weird errors.

These are the errors when I issued “yum update”, trying to update from php-5.4.23 to php-5.4.24 on CentOS 6.4.

# yum update

–> Running transaction check
—> Package php.x86_64 0:5.4.23-1.el6.remi will be updated
—> Package php.x86_64 0:5.4.24-1.el6.remi will be an update
–> Processing Dependency: libssl.so.10(libssl.so.10)(64bit) for package: php-5.4.24-1.el6.remi.x86_64
–> Processing Dependency: libcrypto.so.10(libcrypto.so.10)(64bit) for package: php-5.4.24-1.el6.remi.x86_64
–> Processing Dependency: libcrypto.so.10(OPENSSL_1.0.1)(64bit) for package: php-5.4.24-1.el6.remi.x86_64
—> Package php-bcmath.x86_64 0:5.4.23-1.el6.remi will be updated
—> Package php-bcmath.x86_64 0:5.4.24-1.el6.remi will be an update
—> Package php-cli.x86_64 0:5.4.23-1.el6.remi will be updated
—> Package php-cli.x86_64 0:5.4.24-1.el6.remi will be an update
–> Processing Dependency: libssl.so.10(libssl.so.10)(64bit) for package: php-cli-5.4.24-1.el6.remi.x86_64
–> Processing Dependency: libcrypto.so.10(libcrypto.so.10)(64bit) for package: php-cli-5.4.24-1.el6.remi.x86_64
–> Processing Dependency: libcrypto.so.10(OPENSSL_1.0.1)(64bit) for package: php-cli-5.4.24-1.el6.remi.x86_64
—> Package php-common.x86_64 0:5.4.23-1.el6.remi will be updated
—> Package php-common.x86_64 0:5.4.24-1.el6.remi will be an update
—> Package php-devel.x86_64 0:5.4.23-1.el6.remi will be updated
—> Package php-devel.x86_64 0:5.4.24-1.el6.remi will be an update
–> Processing Dependency: libssl.so.10(libssl.so.10)(64bit) for package: php-devel-5.4.24-1.el6.remi.x86_64
–> Processing Dependency: libcrypto.so.10(libcrypto.so.10)(64bit) for package: php-devel-5.4.24-1.el6.remi.x86_64
–> Processing Dependency: libcrypto.so.10(OPENSSL_1.0.1)(64bit) for package: php-devel-5.4.24-1.el6.remi.x86_64
–> Finished Dependency Resolution
Error: Package: php-5.4.24-1.el6.remi.x86_64 (remi)
Requires: libcrypto.so.10(libcrypto.so.10)(64bit)
Error: Package: php-cli-5.4.24-1.el6.remi.x86_64 (remi)
Requires: libcrypto.so.10(libcrypto.so.10)(64bit)
Error: Package: php-cli-5.4.24-1.el6.remi.x86_64 (remi)
Requires: libssl.so.10(libssl.so.10)(64bit)
Error: Package: php-5.4.24-1.el6.remi.x86_64 (remi)
Requires: libcrypto.so.10(OPENSSL_1.0.1)(64bit)
Error: Package: php-devel-5.4.24-1.el6.remi.x86_64 (remi)
Requires: libcrypto.so.10(libcrypto.so.10)(64bit)
Error: Package: php-devel-5.4.24-1.el6.remi.x86_64 (remi)
Requires: libssl.so.10(libssl.so.10)(64bit)
Error: Package: php-cli-5.4.24-1.el6.remi.x86_64 (remi)
Requires: libcrypto.so.10(OPENSSL_1.0.1)(64bit)
Error: Package: php-5.4.24-1.el6.remi.x86_64 (remi)
Requires: libssl.so.10(libssl.so.10)(64bit)
Error: Package: php-devel-5.4.24-1.el6.remi.x86_64 (remi)
Requires: libcrypto.so.10(OPENSSL_1.0.1)(64bit)
You could try using –skip-broken to work around the problem
You could try running: rpm -Va –nofiles –nodigest

It is clear that php-5.4.24 requires openssl-1.0.1, and it’s impossible to update from openssl-1.0.1 to openssl-1.0.1 on CentOS 6.4 because it’s a system package.

HowTo: Updating to CentOS 6.5 on Godaddy Virtual Private/Dedicated Server (VPS)

On GoDaddy VPS, issuing the command “yum update” doesn’t update to CentOS 6.5, because GoDaddy uses its own repositories, very outdated, slow and often unreachable.

1. Edit CentOS Base Repository

You must tweak some configuration files:

# vim /etc/yum.repos.d/CentOS-Base.repo

You need to change GoDaddy mirrorlist to default CentOS one and you’ll get the default repo file.

This is my CentOS-Base.repo after the changes:

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever – Base
#mirrorlist=http://n1plmirror01.shr.prod.ams1.secureserver.net/vph/2/download/mirrors/cos-$releasever-os.$basearch
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
#released updates

[updates]
name=CentOS-$releasever – Updates
#mirrorlist=http://n1plmirror01.shr.prod.ams1.secureserver.net/vph/2/download/mirrors/cos-$releasever-updates.$basearch
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
#additional packages that may be useful

[extras]
name=CentOS-$releasever – Extras
#mirrorlist=http://n1plmirror01.shr.prod.ams1.secureserver.net/vph/2/download/mirrors/cos-$releasever-extras.$basearch
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
#additional packages that extend functionality of existing packages

[centosplus]
name=CentOS-$releasever – Plus
#mirrorlist=http://n1plmirror01.shr.prod.ams1.secureserver.net/vph/2/download/mirrors/cos-$releasever-centosplus.$basearch
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
#contrib – packages by Centos Users

[contrib]
name=CentOS-$releasever – Contrib
#mirrorlist=http://n1plmirror01.shr.prod.ams1.secureserver.net/vph/2/download/mirrors/cos-$releasever-contrib.$basearch
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
#baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

WARNING: DO NOT ISSUE “yum update” right now, or your system won’t boot anymore!

 2. Edit yum.conf to exclude some packages from update

I found that updating iproute causes system freeze on boot. You need to tell yum not to update iproute so edit /etc/yum.conf

# vim /etc/yum.conf

If you don’t have any line starting with “exclude=“, add a line at the end of the file:

exclude=iproute*

If you already have an exclude, add iproute* to it like this:

exclude=package1* package2* iproute*

This is my yum.conf file:

[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=5
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=16&ref=http://bugs.centos.org/bug_report_page.php?category=yum
distroverpkg=centos-release
exclude=iproute*

3. Update all the required packages

WARNING: in one of my servers, I had some problems using the command “yum update”, I was able to upgrade ONLY upgrading some packages separately.

First, check your current system:

# cat /etc/redhat-release 
CentOS release 6.4 (Final)

Second, check if yum is finding all the updates:

# yum clean all

# yum list updates

You should see lot of updates, including these ones:

 centos-release                                x86_64                   6-5.el6.centos.11.2                                   updates                    20 k
 glib2                                         x86_64                   2.26.1-3.el6                                          base                      1.6 M
 openssl                                       x86_64                   1.0.1e-16.el6_5.4                                     updates                   1.5 M
 openssl-devel                                 x86_64                   1.0.1e-16.el6_5.4                                     updates                   1.2 M

VERY IMPORTANT: make sure you don’t see any reference to iproute package, like this one:

 iproute                                       x86_64                   2.6.32-31.el6                                         base                      365 k

If you see it, and you update your system, your server won’t boot anymore and you’ll need to reprovision your server, losing everything on disk!!

3.a Update to CentOS 6.5 the safe way

In one of my servers, issuing the standard “yum update” made the system really unstable, so my advice is:

First: update glibcyumrpm and python.

Second: update all of the other packages.

# yum clean all
yum update glibc* yum* rpm* python*
yum update

If everything is ok, you can now reboot:

reboot

3.b Update to CentOS 6.5 with some risks

Use the default update procedure, then reboot:

yum update

reboot

4. Verify a correct upgrade to CentOS 6.5

Just check everything works like expected (you may need to restore some configuration files overwritten during updates) and check CentOS Release:

# cat /etc/redhat-release 
CentOS release 6.5 (Final)

5. Optional (untested): update to php-5.4.24 + mysql 5.5.35 (Ver 14.14)

WARNING: I did not test php+mysql update AFTER system upgrade (I was already using remi repo on CentOS 6.4), so I don’t know if it will raise any error.

If you need latest php 5.4.*, you need to install epel and remi repository, enable them, update php+mysql:

5.a: install remi and epel repositories:

# wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
# rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm

5.b: enable remi repository

# vim /etc/yum.repos.d/remi.repo

Change enabled=0 to enabled=1 inside the [base] section.

5.c: update php and mysql

# yum update php mysql

6. FINISH

I hope everything went fine and now you have an up-to-date GoDaddy VPS with CentOS 6.5!!

How to compact Linux VM vhd size in Microsoft Hyper-V

Download PDF

Linux

In time Windows and Linux virtual machines running on Hyper-V virtualisation platform will grow in size even if the large part has been freed up within the virtual machine itself. This is because Hyper-V is not smart enough to auto compact the vhd (virtual hard disk) on the fly – to recognise real space usage within the VM. With Windows VM’s this is done very easy by using Edit>Compact options within the VM settings. However, with Linux VM this is not as straight forward.

 In this case I have used CentOS 6.5 running cPanel on a dynamically expanding .VHD (total size 1.5TB)

1.

The first thing you need to do is to zero out the free space within your linux VM. That means, the rest of the free space will be filled with zeros. Type the following command in your linux box (via ssh or hyper-v console)

cat /dev/zero > zero.dat ; sync ; sleep 1 ; sync ; rm -f zero.dat

This command will create a zero.dat file as big as the available free space and then delete it. It may take a while to finish depending on the size assigned.

After the command has finished it will show no more disk space message.

***README************************************************************

– .VHD file on the host will not grow in size to it’s maximum if you execute this command, it only grows to the maximum within the virtual machine. (in case you have no space for it to grow on Hyper-V host)

– make sure you run this command on a Linux partition that contains the biggest amount of disk space assigned, see my example:

/tmp /var/tmp 4% (140,592 of 4,128,448)
/dev/sda1 /boot 20% (93,976 of 495,844)
/dev/mapper/vg_centos65cp-lv_home /home 5% (76,409,648 of 1,529,194,928)
/dev/mapper/vg_centos65cp-lv_root / 30% (14,663,896 of 51,606,140)
/usr/tmpDSK /tmp 4% (140,592 of 4,128,448)

So in this case you would first switch to home partition because it is the biggest one:

centos>cd /home

centos>cat /dev/zero > zero.dat ; sync ; sleep 1 ; sync ; rm -f zero.dat

If you do it in root partition it will only fill up to it’s maximum which in my case is only 50GB.

*********************************************************************************

2.

Open Hyper-V Manager and shut down the VM first. Then open settings of the VM, select the VHD disk and then edit.

Select the compact option > Next > Finish.

hyper-v_vm_settings

 

hyper-v_vm_compact

Depending on the VHD file current size, it could take several hours. After it has finished, your VHD file should be smaller.

My VHD file was 460GB, after compacting it, 115GB. 

Any questions feel free to ask!

How to fix: Hotmail & Gmail mark me as SPAM – Be careful! This sender failed our fraud detection checks.

Download PDF

If your emails keep going to people’s “Junk” or “Spam” folders on either GMAIL or HOTMAIL this is how to fix it:

GMAIL, HOTMAIL and many other public email systems use Sender Policy Framework (SPF) to recognize legit senders.

If you do not have a valid SPF Record in place, your emails won’t pass the security check and will me marked as SPAM.

 

1. You need to access your Hosting Control Panel, where the domain in question is hosted. In our case we use cPanel.

cpanel

2. Find DNS Zone Editor icon (either Simple or Advanced)

dns_editor

3. Chose the domain you want to add the records to and add the following details

add_txt_record

 

v=spf1 ip4:ipaddress/24 -all

v=spf1 a mx include:serverhostname.com ~all

v=spf1 +a +mx +ip4:ipaddress ?all

 

First option is to use the public ip address /24 in that subnet

Second option uses the server FQDN no matter what the IP is

Third option uses the public ip address regardles of subnets

 

Second option us usually the most correct option since it uses a FQDN regardles of it’s public IP address..

 

Hope this helps 🙂

If any questions feel free to comment or private message me.

 

 UPDATE 04.10.2013.

SPF Record Generator

By Microsoft, works great.