| Home Profile Fun |
#185 Linux 03.08.2009
Linux NotepadHere you find a growing list of various commands tips and tricks which are too short for a whole article. I use this page as a notepad. It will be updated weekly or even daily. Let's start... Flush the file system buffer. In other words physically write everything that shall be written to the disk. sync Do an ext2/ext3 filesystem check. Additionally exclude bad blocks by using a non-destructive read/write test. These bad blocks will then be ignored by the file system and not used any more. Unfortunately the command takes very long (days). e2fsck -ccfv /dev/sdaX If you find these kind of errors in dmesg you may want to disable the usage of Memory Type Range Registers (MTRR) completely. The MTRRs usually affect only graphical environments where you need high performance, like X and 3D for example. mtrr: type mismatch for c8000000,1000000 old: write-back new: write-combining mtrr: no MTRR for c8000000,1000000 foundThere are several ways to turn them off: 1. in grub add "video=nomtrr" to the kernel line 2. in /etc/X11/xorg.conf add "Option "NoMTRR" to the screen section: Section "Screen" ... Option "NoMTRR" EndSection3. or set the default runlevel to 3 if you don't need a desktop environment and run init 3. Print the return value of the last executed shell command/program. This example uses a simple bash script. Create the script: # vi test.sh #!/bin/bash exit 9Make it executable: # chmod +x ./test.shExecute it: # ./test.shPrint the return value: # echo $? 9 Reading emails on the shell from the local mailbox ("You have new mail in /var/mail/..."). mailx Install Puppet on SLES 10. (Ruby is part of the SLES SDK package) wget http://demeter.uni-regensburg.de/SLES10-SDK-x86/suse/i586/ruby-1.8.4-17.2.i586.rpm rpm -i ruby-1.8.4-17.2.i586.rpm wget http://download.opensuse.org/repositories/system:/management/SLE_10/i586/facter-1.5.4-1.1.i586.rpm rpm -i facter-1.5.4-1.1.i586.rpm wget http://download.opensuse.org/repositories/system:/management/SLE_10/i586/puppet-0.24.8-1.1.i586.rpm rpm -i puppet-0.24.8-1.1.i586.rpm wget http://download.opensuse.org/repositories/system:/management/SLE_10/i586/puppet-server-0.24.8-1.1.i586.rpm rpm -i puppet-server-0.24.8-1.1.i586.rpm The rest is according to the official manual for openSUSE. If for any reason the connection to the Puppet master fails check first the firewalls. Then make sure that on the client machine the hostname "puppet" can be resolved to the correct IP address of the Puppet master. Erasing the bash history history -c Some good server monitoring tools which need only very few administration effort and not much know-how.: With Logwatch you can regularly let the server send an email to you with an overview about the system configuration and status. It includes requested URLs which resulted in error 404, ssh logins, available disk space, status of the network interfaces, etc. Logwatch Rootkit Hunter does not only search for root kits but it also scans the system for suspicious files and directories, network interfaces in promiscuous mode, ssh configuration, etc. Rootkit Hunter Syntax check for the Samba configuration file. testparm /etc/smb.conf Open a text file with a certain encoding. # kwrite --encoding iso-8859-1 testiso.txt & # kwrite --encoding utf-8 testutf8.txt &kwrite also offers a lot of encodings for saving a file. In order to display or change data correctly in the MySQL shell it is necessary to start mysql with the appropriate character set. This is the one that has been used for the creation of the table(s). To find it out you can use the command "show create table Tablename". # mysql -uroot -p --default-character-set=UTF8 # mysql -uroot -p --default-character-set=latin1 MySQL replicationCreate a MySQL user on the replication master which will be used later by the replication slave.master: mysql> GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%.mydomain.com' IDENTIFIED BY 'passwordxyz'; Show the current binary log file and the current position of the master. master: mysql> FLUSH TABLES WITH READ LOCK; master: mysql> SHOW MASTER STATUS; (Keep this MySQL session alive until you do the UNLOCK TABLES, see further below, otherwise you lose the lock!) Create an actual dump of the database(s). # mysqldump -uroot -p --lock-all-tables databasename > ./dump.db or # mysqldump -uroot -p --lock-all-tables --all-databases > ./dump.db master: mysql> UNLOCK TABLES; Set up the slave so that it can access the master for replication, use the exact file name and position (according to show master status).
slave: mysql> CHANGE MASTER TO MASTER_HOST='hostnameofmaster', MASTER_USER='repl',
-> MASTER_PASSWORD='passwordxyz', MASTER_LOG_FILE='mysql-bin.000074', MASTER_LOG_POS=14238;
slave: mysql> START SLAVE;
slave: mysql> SHOW SLAVE STATUS \G
The crucial thing is that the following parameters show a Yes, otherwise the replication can not work:Slave_IO_Running: Yes Slave_SQL_Running: Yes The database(s) must exist before the dump can be imported: slave: mysql> CREATE DATABASE databasename; # mysql -uroot -p databasename < ./dbdump.db or # mysql -uroot -p < ./dbdump.db |