Here is how to do it with the help of 'information_schema' of MySQL:
select concat('repair table ', table_name, ';') from information_schema.tables where table_schema='my-db-schema-name';
Saturday, June 23, 2012
Thursday, June 07, 2012
Linux: Show all files modified in the last X days
> find -mtime -2 -print
# where 2 is the number of days back
Labels:
files,
filesystem,
linux,
modification time,
modified files
Wednesday, May 16, 2012
Adding swap space on CentOS
# login as root with
su -
# not '-' sign - important!
#allocate file: 20 GB = 20 * 1024 * 1024
dd if=/dev/zero of=/swapfile bs=1024 count=20971520
mkswap /swapfile
#set permissions:
chown root:root /swapfile
chmod 0600 /swapfile
#add immediately to OS
swapon /swapfile
# edit fstab for persistence:
vi /etc/fstab
# edit fstab by adding the following line at the end of the file:
/swapfile /swap swap defaults 0 0
# check if the swap is allocated
free -m
su -
# not '-' sign - important!
#allocate file: 20 GB = 20 * 1024 * 1024
dd if=/dev/zero of=/swapfile bs=1024 count=20971520
mkswap /swapfile
#set permissions:
chown root:root /swapfile
chmod 0600 /swapfile
#add immediately to OS
swapon /swapfile
# edit fstab for persistence:
vi /etc/fstab
# edit fstab by adding the following line at the end of the file:
/swapfile /swap swap defaults 0 0
# check if the swap is allocated
free -m
Wednesday, May 02, 2012
Increase number of open files per user
http://prefetch.net/blog/index.php/2009/07/31/increasing-the-number-of-available-file-descriptors-on-centos-and-fedora-linux-servers
$ ulimit -n
1024
$ cat /proc/sys/fs/file-max
366207
$ echo 512000 > /proc/sys/fs/file-max
$ cat /proc/sys/fs/file-max
512000
$ vi /etc/security/limits.conf
Now add a line after @student (the last user listed)
@username - nofile 70000
$ ulimit -n
8192
$ ulimit -n
1024
$ cat /proc/sys/fs/file-max
366207
$ echo 512000 > /proc/sys/fs/file-max
$ cat /proc/sys/fs/file-max
512000
$ vi /etc/security/limits.conf
Now add a line after @student (the last user listed)
@username - nofile 70000
$ ulimit -n
8192
Wednesday, April 11, 2012
sudo: Sorry, you must have a tty to run sudo (SOLVED)
I found that running a cron job on CentOS I am getting an error:
sudo: Sorry, you must have a tty to run sudo
the script, running not as a root user was using a sudo command.
Some googling showed that this is what I need (run sudo visudo to edit the config file):
Defaults requiretty
Defaults:root !requiretty
Defaults:myusername !requiretty
Thus the default remains "requiretty" for everyone but for the named users.
sudo: Sorry, you must have a tty to run sudo
the script, running not as a root user was using a sudo command.
Some googling showed that this is what I need (run sudo visudo to edit the config file):
Defaults requiretty
Defaults:root !requiretty
Defaults:myusername !requiretty
Thus the default remains "requiretty" for everyone but for the named users.
Sunday, March 25, 2012
Installing RabbitMQ on CentOS, Fedora and RHEL
# Login as root. Note "-" in su command, it is important to get proper shell definitions including the PATH
su -
....enter password
#verify OS version
cat /etc/*release*
# Download and enable EPEL
# for CentOS 5:
# rpm -Uvh http://download.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
# for CentOS 6:
rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-7.noarch.rpm
#Get & install Erlang
wget -O /etc/yum.repos.d/epel-erlang.repo http://repos.fedorapeople.org/repos/peter
/erlang/epel-erlang.repo
yum install erlang
# Get RabbitMQ signing key
rpm --import http://www.rabbitmq.com/rabbitmq-signing-key-public.asc
# check for the latest version at RabbitMQ web site: http://www.rabbitmq.com/install-rpm.html
rpm -Uvh http://www.rabbitmq.com/releases/rabbitmq-server/v2.8.4/rabbitmq-server-2.8.4-1.noarch.rpm
yum install rabbitmq-server-2.8.4-1.noarch.rpm
# Add RabbitMQ to list of services to be started on reboot
chkconfig rabbitmq-server on
# Add RabbitMQ management plugin:
/usr/sbin/rabbitmq-plugins enable rabbitmq_management sudo
# start RabbitMQ server
service rabbitmq-server start
# point your browser to http://[your-rabbitmq-server]:55672
# enter user name / pwd: the defaults are guest / guest
su -
....enter password
#verify OS version
cat /etc/*release*
# Download and enable EPEL
# for CentOS 5:
# rpm -Uvh http://download.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
# for CentOS 6:
rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-7.noarch.rpm
#Get & install Erlang
wget -O /etc/yum.repos.d/epel-erlang.repo http://repos.fedorapeople.org/repos/peter
/erlang/epel-erlang.repo
yum install erlang
# Get RabbitMQ signing key
rpm --import http://www.rabbitmq.com/rabbitmq-signing-key-public.asc
# check for the latest version at RabbitMQ web site: http://www.rabbitmq.com/install-rpm.html
rpm -Uvh http://www.rabbitmq.com/releases/rabbitmq-server/v2.8.4/rabbitmq-server-2.8.4-1.noarch.rpm
yum install rabbitmq-server-2.8.4-1.noarch.rpm
# if this command did not work take a look what you got in online repositories:
# http://repos.fedorapeople.org/repos/peter/erlang/
# probably your RPM does not exists there
# in this case you can try using older RPM
# if you decided to do that, do teh following:
vi /etc/yum.repos.d/epel-erlang.repo
#comment line
baseurl=http://repos.fedorapeople.org/repos/peter/erlang/epel-$releasever/$basearch/
# and replace it with
baseurl=http://repos.fedorapeople.org/repos/peter/erlang/epel-5/$basearch/
# next, comment line
baseurl=http://repos.fedorapeople.org/repos/peter/erlang/epel-$releasever/SRPMS
# and replace it with
baseurl=http://repos.fedorapeople.org/repos/peter/erlang/epel-5/SRPMS
# exit vi and try again running
# yum install rabbitmq-server-2.8.4-1.noarch.rpm
# Add RabbitMQ to list of services to be started on reboot
chkconfig rabbitmq-server on
# Add RabbitMQ management plugin:
/usr/sbin/rabbitmq-plugins enable rabbitmq_management sudo
# start RabbitMQ server
service rabbitmq-server start
# point your browser to http://[your-rabbitmq-server]
Wednesday, March 14, 2012
Installing InfoBright Enterprise Edition (trial) on CentOS 5.7
# create license file on InfoBright web
# download the latest Infobright RPM
> rpm -i ib-installation-file.rpm
#copy license file to IB installation
> cp iblicense-yan123_yan123-89359130-IEE.lic /usr/local/infobright
# run the DB
/etc/init.d/mysqld-ib start
# make IB service running after reboot
> chkconfig --add /etc/init.d/mysqld-ib
> chkconfig mysqld-ib on
# change IB / MySQL root pwd
/usr/local/infobright-4.0.6-x86_64/bin/mysqladmin -u root password 'new-password'
# run mysql client and grant all privileges to a user
# from another host who comes with a certain password
mysql-ib -u root -p
[enter root password on prompt]
> GRANT ALL ON *.* TO 'myuser' IDENTIFIED BY 'some-user-password';
#add remote access and other permissions for 'root' too
> GRANT ALL ON *.* TO 'root' IDENTIFIED BY 'some-root-password';
# download the latest Infobright RPM
> rpm -i ib-installation-file.rpm
#copy license file to IB installation
> cp iblicense-yan123_yan123-89359130-IEE.lic /usr/local/infobright
# run the DB
/etc/init.d/mysqld-ib start
# make IB service running after reboot
> chkconfig --add /etc/init.d/mysqld-ib
> chkconfig mysqld-ib on
# change IB / MySQL root pwd
/usr/local/infobright-4.0.6-x86_64/bin/mysqladmin -u root password 'new-password'
# run mysql client and grant all privileges to a user
# from another host who comes with a certain password
mysql-ib -u root -p
[enter root password on prompt]
> GRANT ALL ON *.* TO 'myuser' IDENTIFIED BY 'some-user-password';
#add remote access and other permissions for 'root' too
> GRANT ALL ON *.* TO 'root' IDENTIFIED BY 'some-root-password';
Subscribe to:
Posts (Atom)