Archive for the 'Linux Support' Category

Force fsck on next boot on Red Hat Enterprise Linux

If you only want to run fsck on the next boot, execute the following as the root user:

# cd /
# touch forcefsck

The file “forcefsck” will be deleted automatically after fsck is finished.

This will only run the file system check on the next reboot. By touching the file “forcefsck” in the / directory, it will force the system to perform a full file system check.

You can force an automatic full check by changing the check interval using tune2fs (-c and/or -i). For example:

The below command would tell the init scripts to run fsck on hda2 at every boot.

# tune2fs -c 1 /dev/hda2

*tune2fs - adjust tunable filesystem parameters on ext2/ext3 filesystems

-c max-mount-counts

Adjust the number of mounts after which the filesystem will be checked by e2fsck(8). If max-mount-counts is 0 or -1, the number of times the filesystem is mounted will be disregarded by e2fsck(8) and the kernel.

-C mount-count

Set the number of times the filesystem has been mounted. If set to a greater value than the max-mount-counts parameter set by the -c option, e2fsck(8) will check the filesystem at the next reboot.

-i interval-between-checks[d|m|w]

Adjust the maximal time between two filesystem checks. No post fix or d result in days, m in months, and w in weeks. A value of zero will disable the time-dependent checking.

It is strongly recommended that either -c (mount-count-dependent) or -i (time-dependent) checking be enabled to force periodic full e2fsck(8) checking of the filesystem.

Resources available for OpenVZ containers.

Resources that can be set, include disk space usage, memory usage, CPU usage, and more.

Restricting and setting hard limits of what is permitted in a container ensures that no tasks within the container can get greedy and steal resources from other containers or the host system itself.

First, look at the vzlist tool. This will provide information on any installed containers which makes managing them simpler vzlist tool

This will provide information on any installed containers which makes managing them simpler:

# vzlist -a

How to increase the available disk space from 1GB to something more useful like 10GB.

Check disk space.

# vzctl exec 101 df -hT

The above increases the default 1GB drive space available to a barrier of 10GB and a maximum limit of 11GB.

# vzctl set 101 –diskspace 10G:11G –save
# vzctl exec 101 df -hT

There are two ways to change settings for containers. The first is using vzctl as above (remember to use the -save option to make the changes persistent). The second is to edit the configuration file for the container. For a container with a CTID of 101, the file would be /etc/sysconfig/vz-scripts/101.conf.

SBDavid

Working with mysql databases

Creating mysql user and then setting password for user.

mysql> create user @localhost;
mysql> SET PASSWORD FOR r@localhost=PASSWORD(”);

How to set up password for mysql root user.

mysql> SET PASSWORD FOR root@localhost=PASSWORD(’);

In the below eaxmple, database and user is the same - serverbuddies

mysql> create database serverbuddies;


How to give permission to user - serverbuddies.

mysql> grant INSERT,SELECT on root.* to serverbuddies@localhost;
mysql> grant CREATE,INSERT,SELECT,DELETE,UPDATE on serverbuddies.* to serverbuddies@localhost;
mysql> grant CREATE,INSERT,SELECT,DELETE,UPDATE on serverbuddies.* to serverbuddies;

The next example has user as admin and databses as ubuntu.

mysql> create database ubuntu;

Setting permission to user admin for the database ubuntu.

mysql> grant CREATE,INSERT,SELECT,DELETE,UPDATE on ubuntu.* to admin@localhost;
mysql> grant CREATE,INSERT,SELECT,DELETE,UPDATE on ubuntu.* to archive;
mysql> exit


How to take mysql remote and local backup.

Doing Remote Mysql databse Backup:

`which mysqldump` -h -uusername -ppassword –opt database > /filename.sql


Local Host mysql Backup:

`which mysqldump` -uroot -ppassword –opt database > /filename.sql
SBDavid

Upgrading Your Redhat Server

Upgrading Your Redhat Server.

Check your kernel release before upgrade.

uname -r

If run without any packages, update will update every currently installed package.

yum update

After the upgrade check the kernel release.

uname -r

yum update

If run without any packages, update will update every currently installed package.
If one or more packages are specified,Yum will only update the listed packages. While updating packages, yum will ensure that all dependencies are satisfied.

If no package matches the given package name(s), they are assumed to be a shell glob and any matches are then installed. If the –obsoletes flag is present yum will include package obsoletes in its calculations - this makes it better for distro-version changes, for example: upgrading from somelinux 8.0 to somelinux 9.

yum upgrade : Is the same as the update command with the –obsoletes flag set.

yum is an interactive, automated update program which can be used for maintaining systems.

Yum Options:

* install package1 [package2] [...]
* update [package1] [package2] [...]
* check-update
* upgrade [package1] [package2] [...]
* remove | erase package1 [package2] [...]
* list [...]
* info [...]
* provides | whatprovides feature1 [feature2] [...]
* clean [ packages | headers | metadata | cache | dbcache | all ]
* makecache
* groupinstall group1 [group2] [...]
* groupupdate group1 [group2] [...]
* grouplist [hidden]
* groupremove group1 [group2] [...]
* groupinfo group1 [...]
* search string1 [string2] [...]
* shell [filename]
* resolvedep dep1 [dep2] [...]
* localinstall rpmfile1 [rpmfile2] [...]
* localupdate rpmfile1 [rpmfile2] [...]
* deplist package1 [package2] [...]

FILES

/etc/yum.conf
/etc/yum/repos.d/
/etc/yum/pluginconf.d/
/var/cache/yum/

SEE ALSO

yum.conf (5)
http://linux.duke.edu/yum/
http://wiki.linux.duke.edu/YumFaq

rsync to backup your home directory and mysql databases.

Run the below rsync command using “nohup”, nohup runs a command immune to hangups, with output to a non-tty.

Rsync your home directory’s to your backup server.

Replace $IP with the IP address for your production server.

Run the below commands from your backup server.

#rsync -vrplogDtH –exclude=virtfs/ –progress -e ssh root@$IP:/home/ /home/

rsync all mysql databases.

#rsync -vrplogDtH –progress -e ssh root@$IP:/var/lib/mysql/ /var/lib/mysql/

Backup DB server_support

rsync -vrplogDtH –progress -e ssh root@$IP:/var/lib/mysql/server_support /var/lib/mysql/

« Prev - Next »