Showing posts with label Debian. Show all posts
Showing posts with label Debian. Show all posts

12/17/2010

where is my free disk space :)

To list files larger than 10M:
find / -type f -size +10000k -exec ls -lh {} \; | awk '{ print $8 ": " $5 }'

To list files larger than 100M:
find / -type f -size +100000k -exec ls -lh {} \; | awk '{ print $8 ": " $5 }'

9/10/2010

Mysql master-master replication

Today I’m going to write a short manual how to create failover mysql cluster.
What we need:

Server1 = master 1/slave2
Server2 = master2/slave2
Internal or external IPs (in this example I will use server1 _ip and server2_ip)
Replication user = replicau


Step-by-step how to:
Step 1.
On server 1 in my.cnf we need to add following lines

[mysqld]
#master config
Server-id =1
Log-bin = mysql-bin
binlog-do-db = test_db
… #we can add as many DB as we need to replicate
#slave config
replicate-do-db = test_db
… #we can add as many DB as we need to replicate
master-host = server2_ip
master-user= replicau
master-password =password_of_user_replicau
master-port = 3306


same lines we should add in my.cnf on server2, the only thing we should change is master-host parameter to use server1_ip instead of server2_ip and change server-id parameter
Step 2
Restart mysql servers
Step 3
On each server we need to create replication user:
Server1

mysql>GRANT REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'replicau'@'server2_ip' IDENTIFIED BY 'password';
server2

mysql> GRANT REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'replicau'@'server1_ip' IDENTIFIED BY 'password';

Step 4
Add server2 as slave to server1
- we need to set read_only parameter as ON on server1 (master 1)

mysql> SET GLOBAL read_only = ON;
mysql> show master status;
mysql> show master status;
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000006 | 7984 | | |
+------------------+----------+--------------+------------------+
1 row in set (0,00 sec)
on server2

mysql>slave stop;
mysql> CHANGE MASTER TO MASTER_HOST = "server2_ip", MASTER_USER = "replicau", MASTER_PASSWORD = "password_of_user_replication", MASTER_LOG_FILE = "mysql-bin.000006", MASTER_LOG_POS = 7984;
mysql> slave start;


on server1

mysql> SET GLOBAL read_only = OFF;

on server2 check connection status

mysql> show slave status;

if we do not receive any errors, everything is perfect 

Step 5
Do Step 4 for connecting server 1 as slave to server2.

Step 6
Check if everything is fine, if no try from step 1 

Step 7
It’s time to have a cup of coffee/tea of a bottle of beer

7/12/2010

Installing Lighttpd With PHP5 And MySQL Support On Debian Etch

best manual I ever found is there

5/01/2010

installation fcgi with ruby

This is a small how to install  fcgi to work with ruby and rails.

first of all you should have ruby and rails installed on your server. In my case I installed ruby and rails using standard Debian command

 

apt-get install ruby gem rails

 

to make sure that you use the latest version of rails I recommend to check installation with gem:

 

gem install rails

 

after that I was ready to install fcgi on my server:

 

cd /temp
wget http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gz
tar -zxvf fcgi-2.4.0.tar.gz
cd fcgi-2.4.0
./configure --prefix=/usr/local/fcgi --exec-prefix=/usr/local/fcgi
make
make install

 

Now you can install the fcgi gem (this is a long command which your browser may line-wrap here -- beware that the command is all on the same line):

 

gem install fcgi -r -- --with-fcgi-lib=/usr/local/fcgi/lib --with-fcgi-include=/usr/local/fcgi/include

 

You also need to install the FastCGI module for Apache. Make sure you have Perl installed on your shared host, you need it to run apxs!

cd /temp
wget http://www.fastcgi.com/dist/mod_fastcgi-2.4.2.tar.gz
tar -zxvf mod_fastcgi-2.4.2.tar.gz
cd mod_fastcgi-2.4.2
/usr/sbin/apxs -o mod_fastcgi.so -c *.c
/usr/sbin/apxs -i -a -n fastcgi mod_fastcgi.so
You may need to add the following block to "/etc/apache2/apache2.conf":
<IfModule mod_fastcgi.c>
FastCgiIpcDir /tmp/fcgi_ipc/
AddHandler fastcgi-script .fcgi
</IfModule>
And finally, you need to configure your Rails project to use FastCGI. Edit the file "(your_rails_app)/public/.htaccess", changing the line:
RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
to:
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]

You'll need to restart Apache before the changes will take effect:

 

/etc/init.d/apache2 restart

4/24/2010

mysql tuning

for high load mysql servers you most probably will need suggestion what parameter you should change to improve performance

First of all I recommend to run mysqltuner script
usage:

wget http://mysqltuner.com/mysqltuner.pl
chmod +x mysqltuner.pl
./mysqltuner.pl

You will be prompted to enter valid mysql credentials and after that you will see recommendation what should you tune on your mysql server

mysql optimize tables

and there I found nice perl script which can be run on your server and you can optimize tables in DB
you can download it from there

1/26/2010

Online Radio as 1,2,3…..

Захотілось мені створити своє радіо так щоб зміг наприклад на роботі увімкнути собі радейко і послухати музику яка є у мене дома на компі. Після довгого гугління я знайшов іформацію що це можна зробити за допомогою SHOUTcast. Отже зараз буде невеличкий мануал як створити собі своє власне онлайн радіо.

Отже створювати радіо ми будемо з допомогою SHOUTcast і Debian 5.x… У моєму випадку це була чиста інсталяція ОС

1. Інсталюємо Debian без Х зі стандартним набором програм, настроюємо ssh. І ломимось на нього з якоїсь нормальної ОС з Х (вінда чи лінух все рівно)
2. Дописуємо наступні рядки у /etc/apt/source.list
deb
http://ftp.de.debian.org/debian sid main non-free
## Christian Marillat's Mult-Media Repository for Unstabledeb
http://www.debian-multimedia.org sid main
## Christian Marillat's Mult-Media Repository for Unstable - Experimental Stagingdeb
http://www.debian-multimedia.org experimental main
apt-get --allow-unauthenticated  install debian-multimedia-keyring
apt-get update
apt-get upgrade

3. Інсталюємо потрібний софт:

apt-get install lame
wget
http://yp.shoutcast.com/downloads/sc1-9-8/sc_serv_1.9.8_Linux.tar.gz SHOUTcast DNAS
wget
http://yp.shoutcast.com/downloads/sc_trans_posix_040.tgz SHOUTcast Radio DSP for Unix/Linux/MAC OSX
4. Настроюємо SHOUTcast DNAS

tar xzvf sc_serv_1.9.8_Linux.tar.gz 
ls -al 
mkdir sc 
mv ./sc_serv ./sc 
mv ./sc_serv.conf ./sc 
mv ./README.TXT ./sc
В цьому файлі дописуємо конфіг сервера  vi ./sc/sc_serv.conf
Я змінив наступні параметри:

MaxUser=10 було 32
Password=********* потрібно настроїти без нього радіо працювати не буде
SrcIP=127.0.0.1 потрібно поставити цей праметер щоб ніхто не пробував броудкаститись через вас

5. Настроювання SHOUTcast Radio DSP

у моєму випадку музичні файли знаходяться на фізичній машині на якій крутиться віндовс, а радіо настроєне на віртуалці тому прийшлось настроїти автомонтування віндової шари, як це робиться можна прочитати тут: http://www.debian-administration.org/articles/165
mv ./sc_trans_posix_040.tgz ./sct
cd ./sct/
tar xzvf sc_trans_posix_040.tgz
готуємо плейліст у мене це получилось наступним чином:

find /mnt/win/muz/Rock/ -type f -name *.mp3 >> rock.txt
редагуємо конфіг файл SHOUTcast Radio DSP

sc_trans.conf
PlaylistFile=/root/rock.txt
ServerIP=127.0.0.1 # саме так повинно виглядати це поле так само як у sc_serv.conf
Password=******** такий самий як у sc_serv.conf
Називаємо своє радіо:
StreamTitle=Rock
StreamURL=http:/
Genre=Rock
Виставляємо бітрейт
Bitrate=128000
SampleRate=44100
Channels=2
Quality=6

Далі я підготував файл для того щоб запускати радіо з однієї консолі

 cat sstart
#!/bin/sh
/root/sc/sc_serv /root/sc/sc_serv.conf  | /root/sct/sc_trans_040/sc_trans_linux /root/sct/sc_trans_040/sc_trans.conf

Тепер до станції можна доступитись з броузера: http://your_ip:8000

FIN

1/13/2010

Debian Lenny

Added by Ewan Mellor http://community.citrix.com/display/xs/Debian+Lenny

Comment: Update link point release 3 version of jigdo.

Introduction

From version 5.5 onwards XenServer supports Debian GNU/Linux 5 AKA "Lenny" as a guest Virtual Machine. This includes installation of Lenny from a standard Debian network mirror as well as installation from CD/DVD image.

Note that XenServer 5.5 only supports 32 bit installations of Lenny.

Installation From DVD/CD

Unfortunately at the time of release the Official Debian installation CD and DVD ISO images did not contain a XenServer-compatible kernel and therefore cannot be used with XenServer. To remedy this Citrix has made available a custom built Unofficial DVD image containing a XenServer-compatible kernel.

Downloading A XenServer-compatible installation ISO

Citrix has made the DVD image available using the Jigdo(Jigsaw Download) utility. Jigdo allows ISO images to be downloaded quickly and efficiently by retrieving the majority of the data from a nearby mirror only obtaining a minimal template from the centralised download site.

If you have an existing Debian installation the obtaining jigdo is as simple as running

# aptitude install jigdo-file


If you do not have an existing Debian installation then jigdo can be download from its website. Jigdo is available for both Linux and Windows machines.



Once you have installed jigdo you should select a mirror from the Debian Mirror List. Choose a mirror which is geographically near to your location and which includes the i386 architecture. e.g ftp://ftp.XX.debian.org/debian/



After you have installed jigdo and selected a mirror you are ready to begin downloading the ISO from Citrix. Drop to a shell prompt or command line console. On Windows you will need to change to the directory where you unpacked jigdo.



Note: You must download the image from the URL given. The images available on Debian mirrors are not compatible with XenServer.



# jigdo-lite http://ca.downloads.xensource.com/debian/lenny/debian-503-i386-source-xen-DVD-1.jigdo


Jigdo will automatically download the template file (around 40M in size) and then will prompt you for a location to scan for existing packages. This can be useful if you have already downloaded Official Lenny images since you can reuse many of the packages on Official CDs. To do this simply mount or insert the Official CD/DVD and enter the path to it.

Next jigdo will prompt for a mirror to use, enter the mirror you selected above.



Jigdo will then begin downloading packages. If it complains about missing packages you should select another mirror and try again, this will not redownload any packages which were successfully retrieved.



When jigdo has completed it will leave debian-50-i386-source-xen-DVD-1.iso in the current directory.



Adding Additional CD/DVD Images



The custom XenServer-compatible DVD image contains a subset of the Debian software repository.



In order to access the remainder after installation you can either make use of a Debian network mirror in the normal way or you can add additional CD/DVD images using the Official images. To do this simply insert a CD/DVD into the virtual machine's CD drive and on the guest console run



# apt-cdrom add


Repeat this for as many CD/DVD images as you are interested in.

8/20/2009

Встановлення Xen на Debian Etch 4.0

Основна стаття http://mediakey.dk/~cc/installing-xen-on-debian-etch-40/
Переклад Михайло "veselujm" Веселовський

Протягом довгого часу я випробуав багато технологій віртуалізації: Xen, VMWare, і Xen LogoMicrosoft VM. Я з впевненістю можу сказати що всі вони придатні для використання, але VMWare і Microsoft’s VM є більш вялими ніж Xen. Цих вихідних я розгорнув свій перший сервер на базі Debian Etch 4.0 і Xen. І все запрацювало з "коробки"

Тут я опишу кроки які я зробив щоб поставити Xen на Debian Etch:

sudo apt-get install xen-linux-system-2.6.18-4-xen-686 libc6-xen bridge-utils


Грузимось в нове ядро з встановленим Xen

sudo reboot


Потім настроюємо настройки мережі в
/etc/xen/xend-config.sxp. Вмикаємо network bridge:

(network-script network-bridge)


Встановлюю
xen-tools:

apt-get install xen-tools


Xen tools це пакет який включає в себе різноманітні утиліти для Xen, утиліта для створення віртуальних машин тощо.

Редагуємо настройки ядра і initrd в /etc/xen-tools/xen-tools.conf, так щоб вони були подібними до ваших системних.

Взнаємо як ядро і initrd називаються у вашій системі:

ls /boot/vmlinuz*
/boot/vmlinuz-2.6.18-4-686 /boot/vmlinuz-2.6.18-4-xen-686

і

ls /boot/initrd*
/boot/initrd.img-2.6.18-4-686 /boot/initrd.img-2.6.18-4-686.bak /boot/initrd.img-2.6.18-4-xen-686


Змінюємо рядки:


#
# Default kernel and ramdisk to use for the virtual servers
#
kernel = /boot/vmlinuz-2.6.18-4-xen-686
initrd = /boot/initrd.img-2.6.18-4-xen-686


В наступному кроці змінюємо наступні рядки в xen-tools.conf


dir = /home/xen
debootstrap = 1
size = 4Gb # Розмір диску
memory = 128Mb # Память
swap = 128Mb # Своп
fs = ext3 # використовувати файлову систему EXT3 для створення дисків
dist = etch # Стандартиний дистрибутив для встановлення
image = sparse # Визначаємо тип диску повний чи частинами

Створюємо домівки для наших віртуальних машин:

mkdir /home/xen
mkdir /home/xen/domains


Тепер ми готові до створення віртуальної машини

xen-create-image -hostname=mailserver -ip=10.0.0.21 -netmask=255.255.255.0 -gateway=10.0.0.1 -passwd


Після чого новостворену віртуалку можна запустити:

xm create mailserver.cfg


У випадку появи наступної помилки:

Error: Device 0 (vif) could not be connected. Backend device not found.


Потрібно перевірити чи ви увімкнена підтримка
network bridge, “(network-script network-bridge)”, в /etc/xen/xend-config.sxp після додавання потрібно пергрузити демон xen /etc/init.d/xend restart. Здопомогою команд “xm list” чи “xentop” можна подивитись яка віртуалка зараз крутиться:
debian5:# sudo xm list
Name ID Mem(MiB) VCPUs State Time(s)
Domain-0 0 874 1 r----- 657.9
mailserver 3 128 1 -b---- 8.0


Базуючись на моєму досвіді використання і впровадження технолоїй віртуалізації , а думаю що Xen це саме те для впровадження Linux і Linux-based технологій і це показує що вони готові до використання вже тепер. Технології віртуалізації вже тепер готові до впровадження в великих компаніях і дата центрах, і вони допомагають спростити настроювання, впровадження і встановлення працівникам, І я думаю що найближчі роки технології віртуалізації будуть грати важливу роль на серверному ринку.

12/17/2007

apt-get update errors

Вже двічі я стикнувся з проблемою в apt-get, постійно при спробі оновити ОС викидувало якісь дурацькі помилки. Так як ця проблема є доволі відома, то я не буду перекладати її на українську мову, а подам її мовою оригіналу.

apt-get update

Now we are ready to apt-get update. This will add the new repositories to apt's list.

E: Dynamic MMap ran out of room

You may find that you receive an error like the following:

E: Dynamic MMap ran out of room
E: Error occured while processing sqlrelay-sqlite (NewPackage)
E: Problem with MergeList /var/lib/apt/lists/ftp.us.debian.org_debian_dists_woody_contrib_binary-i386_Packages
E: The package lists or status file could not be parsed or opened.

This is caused because apt's cache is too small to handle all of the packages that are included with stable, testing, and unstable. This is also very easy to fix. Add the following line to /etc/apt/apt.conf

APT::Cache-Limit "8388608";


з числом ви зможете творити все що вам заманеться до того часу поки ви небудете задоволені результатом.

12/14/2007

Істаляція та настроювання Nagios (Part 1)

Інсталяція системи моніторингу Nagios у Debian і Ubuntu.

Для створення повноцінної системи моніторингу нам потрібно
  • встановлений дистрибутив одного з лінуксів(Debian і Ubuntu)
  • настроєний веб сервер Apache
  • інтернет канал))
Якщо це все внас вже підготовлене, приступаємо до істаляції пакетів(інсталяцію потрібно проводити з правами суперкористувача)
apt-get install nagios-text 
базова система nagios заінсталиться на вашу систему, але для повноцінного використання ми ще повинні доставити плагіни
apt-get install nagios-plugins

Преходимо до настроювання моніторингу
Нам потрібно
  • знайти cgi.cfg і перенсти його в /etc/nagios
  • перенести інфу з apache.conf в /etc/apeche2/sites-enabled/nagios

Як бачимо файлів конфігурації є доволі багато.
Але якщо трішки по працювати над файлами можна частини з них позбутись і оптимізувати.
Спочатку конфігуруємо файл в якому містяться дані про користувачів яким буде відсилатись інформація про ваші сервіси contacts.cfg

define contact{
contact_name admin
alias Mega Admin
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands notify-by-email,notify-by-pager
host_notification_commands host-notify-by-email,host-notify-by-epager
email admin@yourdomain.com
pager 5555555@pager.yourdomain.com
}
Згідно цих даних наш адмін буде отримувати повідомлення по імейлу і на телефон/пейджер

Далі настроюємо файл contactsgroups.cfg

для прикладу я розкоментував дані стрічки

define contactgroup{
contactgroup_name linux_admin
alias Linux Administrators
members admin
}

Прийшла черга настроїти хости які ми будемо моніторити
/etc/nagios/hosts.cfg

define host{
use generic-host
host_name gw1.yourdomain.com
alias Gateway Router
address 10.0.0.1
check_command check-host-alive
max_check_attempts 20
notification_interval 240
notification_period 24x7
notification_options d,u,r
}

define host{
use generic-host
host_name mail.yourdomain.com
alias Mail Server
address 10.0.0.100
check_command check-host-alive
max_check_attempts 20
notification_interval 240
notification_period 24x7
notification_options d,u,r
}
Настроюємо групи хостів. У файлі /etc/nagios/hostgroups.cfg я розкоментував

# 'linux-boxes' host group definition
define hostgroup
{
hostgroup_name linux-boxes
alias Linux Servers
contact_groups linux-admins
members gw1.yourdomain.com,mail.yourdomain.com
}

Настроюємо сервіси які ми будемо перевіряти /etc/nagios/services.cfg
define service{
use generic-service
host_name mail.yourdomain.com
service_description SMTP
is_volatile 0
check_period 24x7
max_check_attempts 3
normal_check_interval 5
retry_check_interval 1
contact_groups server_admin
notification_interval 240
notification_period 24x7
notification_options w,u,c,r
check_command check_smtp
}

define service{
use generic-service
host_name gw1.yourdomain.com
service_description PING
is_volatile 0
check_period 24x7
max_check_attempts 3
normal_check_interval 5
retry_check_interval 1
contact_groups router_admin
notification_interval 240
notification_period 24x7
notification_options w,u,c,r
check_command check_ping!100.0,20%!500.0,60%
}

Ось так має виглядати вікно Service Status у вікні бровзера

А тепер про проблеми з якими я стикнувся
при виконанні команди перевірки DNS в автоматичному режимі від бувалась помилка, а з командного рядка все нормально працювало....
пофіксалось все просто: в файлі /etc/nagios-plugins/config/dns.cfg
check_dns -H www.google.com -s $HOSTADDRESS$ замінив на check_dns -H $ARG1$ -s $HOSTADDRESS$

Для перевірки ваших настройок виконуємо наступну команду

nagios -v /etc/nagios/nagios.cfg 
Стартуємо наш сервер монітрингу з новими параметрами
/etc/init.d/nagios restart

У наступному випуску я опишу як настроїти Nagios не використовуючи автоматичне інсталення