[dvd]
#mediaid=xxxxxxxxxx.xxxxxx
name=DVD for RHEL6
baseurl=file:///media/dvd/Server
enabled=1
gpgcheck=0
Perşembe, Haziran 19, 2014
Create a yum Repository from the RHEL 6 DVD
Create a dvd.repo text file in /etc/yum.repos.d/ with the following content:
Cuma, Haziran 13, 2014
How to install Redis stable on Centos 6.5
wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
cd redis-stable
make
make install
cd utils
sh install_server.sh
How To Install PostgreSQL 9.3 on CentOS 6.5
Update your system
[root@centos]# yum update
Install tools needed for DB [root@centos]# yum install git wget[root@centos]# yum groupinstall "Development tools"
Then finish PostgreSQL installation[root@centos]# rpm -Uvh http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/pgdg-centos93-9.3-1.noarch.rpm
[root@centos]# yum install postgresql93-server postgresql93-contrib postgresql93-devel
[root@centos]# service postgresql-9.3 initdb
[root@centos]# chkconfig postgresql-9.3 on
Çarşamba, Haziran 04, 2014
elementary os(ubuntu 12.04) üzerine postgresql 9.3 kurulumu
$ echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" > /etc/apt/sources.list.d/pgdg.list
$ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
$ sudo apt-get update
$ sudo apt-get install postgresql-9.3 postgresql-contrib-9.3
eğer bu tarz bi hata alırsanız
The following packages have ummet dependencies:
postgresql-9.3 : Depends: postgresql-client-9.3 but is not going to be installed
Depends: postgresql-common (>=1.4.2)...
...
postgresql-common u güncelleyip tekrar deneyin
$ sudo apt-get install postgresql-common=151.pgdg12.4+1
$ sudo apt-get install postgresql-9.3 postgresql-contrib-9.3
postgresql-common alternatifleri için
sudo apt-cache policy postgresql-common
Perşembe, Şubat 27, 2014
linux find komutu
boyutu 1 byte den küçük olanları sil
find . -size -1b -exec rm -rf {} \;
tarihi bugünden eski planları sil
find . -daystart -type f -mtime 1 -exec rm -f {} \;
Pazartesi, Şubat 24, 2014
Postgresql get running queries and kill a long running query
SELECT datname,procpid,current_query FROM pg_stat_activity;
template1=# SELECT datname,procpid,current_query FROM pg_stat_activity;
datname | procpid | current_query
-----------+---------+-----------------------------------------------------------------------------------
pguser | 22438 |
template1 | 24692 | SELECT datname,procpid,current_query FROM pg_stat_activity;
(2 rows)
SELECT pg_cancel_backend(pid of the postgres process);
deleting all pending tasks in celery
Çarşamba, Şubat 19, 2014
django obj reference for processing in Inline
class RoomInline(admin.TabularInline):
model = Room
def formfield_for_foreignkey(self, db_field, request=None, **kwargs):
field = super(RoomInline, self).formfield_for_foreignkey(db_field, request, **kwargs)
if db_field.name == 'inside_room':
if request._obj_ is not None:
field.queryset = field.queryset.filter(building__exact = request._obj_)
else:
field.queryset = field.queryset.none()
return field
class BuildingAdmin(admin.ModelAdmin):
inlines = (RoomInline,)
def get_form(self, request, obj=None, **kwargs):
# just save obj reference for future processing in Inline
request._obj_ = obj
return super(BuildingAdmin, self).get_form(request, obj, **kwargs)
Salı, Ocak 28, 2014
rename lots of redis keys with regex
önce
error-testtask_2405406e-98d4-45a0-874f-46131843520b
redis-cli keys "error-*" |awk '{print "redis-cli RENAME " $1 " " substr($0,7)}'|sh
sonra
testtask_2405406e-98d4-45a0-874f-46131843520b
Pazar, Ocak 05, 2014
Failover With KeepAlived
Network Scenario:
Keepalived is available in centos base repository. Install it using yum command line tool.
Configure Keepalived on LB1.
Edit Keepalived configuration file on LB1 and add following configuration.
1. Priority value will be higher on Master server, It doesn’t matter what you used in state. Ifyour state is MASTER but your priority is lower than the router with BACKUP, you will lose the MASTER state.
2. virtual_router_id should be same on both LB1 and LB2 servers.
3. By default single vrrp_instance support up to 20 virtual_ipaddress. In order to add more addresses you need to add more vrrp_instance
1. LB1 Server: 192.168.10.111 ( eth1 )Install Keepalived
2. LB2 Server: 192.168.10.112 ( eth1 )
3. Virtual IP: 192.168.10.121
Keepalived is available in centos base repository. Install it using yum command line tool.
# yum install keepalivedKeepalived configuration File: /etc/keepalived/keepalived.conf
Configure Keepalived on LB1.
Edit Keepalived configuration file on LB1 and add following configuration.
vrrp_instance VI_1 {
interface eth1 state MASTER
virtual_router_id 10
priority 101 # 101 on master, 100 on backup
virtual_ipaddress {
192.168.10.121
}
}
Configure Keepalived on LB2.
Edit Keepalived configuration file on LB2 and add following configuration.
Edit Keepalived configuration file on LB2 and add following configuration.
vrrp_instance VI_1 {
interface eth1 state BACKUP
virtual_router_id 10
priority 100 # 101 on master, 100 on backup
virtual_ipaddress {
192.168.10.121
}
}
1. Priority value will be higher on Master server, It doesn’t matter what you used in state. Ifyour state is MASTER but your priority is lower than the router with BACKUP, you will lose the MASTER state.
2. virtual_router_id should be same on both LB1 and LB2 servers.
3. By default single vrrp_instance support up to 20 virtual_ipaddress. In order to add more addresses you need to add more vrrp_instance
Start Keepalived
Start Keepalived service using following command and also configure to auto start on system boot.
Start Keepalived service using following command and also configure to auto start on system boot.
# service keepalived start
# chkconfig keepalived on
Çarşamba, Ocak 01, 2014
PostgreSQL 9.1 Hot standby Kurulumu
kontrol makinesi : 192.168.2.5
master db : 192.168.101
slave db: 192.168.2.102
Bu yöntem ile yapılabilecekler.
Veri klasörünün kopyalanması
öncelikle master veri tabanın da backup işlemini başlatın
pgadmin den veya psql den yazılabilir.
Şimdi master sunucudaki postgresql in veri klasörünü, slave sunucudaki postgresql veri klasörüne kopyalamalısınız.
Son olarak yapmanız gereken slave sunucudaki postgresql servisini yeniden başlatmanız. Bunun için terminale aşağıdaki kodu yazın.
sudo /etc/init.d/postgresql restart
- Orjinal veritabanınızın bir kopyasına sahip olursunuz ve veri kaybınıönlemiş olursunuz.
- Veritabanına gelen yükü dağıtabilirsiniz (Slave server üzerinde sadeceokuma amaçlı sorguları çalışıtrabilirsiniz )
- Rapor amaçlı uzun süren sorguları slaver server üzerinde çalıştırarakperformans artışı sağlanabilir.
Bu yöntem ile neler yapılamaz
Kurulum
- Sadece bir tabloyu, şemayı (schema) yada veritabanını kopyalayamazsınız.
- Slave server orjinalin bire bir kopyası olmak zorundadır.
- Birden fazla Master kopya olamaz.
- PostgreSQL versiyonları farklı olamaz.
Kurulum
sudo apt-get install postgresql"
yazarak postgresql in son sürümünü indirin.
Postgresql için kullanıcı adı ve şifrelerin ayarlanması için gereken terminal komutları
Postgresql için kullanıcı adı ve şifrelerin ayarlanması için gereken terminal komutları
sudo -u postgres psql postgresMaster tarafında ki ayarlamalar
\password postgres
Master tarafında yapılan değişkilklikler. Master sunucu içerisinde ki ayar dosyalarındaki değişiklikleri yapın.
/etc/postgresql/9.1/main/postgresql.conf
listen_address = '*'
wal_level = hot_standby
max_wal_senders = 3
etc/postgresql/9.1/main/pg_hba.conf
host all all 192.168.2.5/32 md5
host replication all 192.168.2.102/32 trust
Veri klasörünün kopyalanması
öncelikle master veri tabanın da backup işlemini başlatın
pgadmin den veya psql den yazılabilir.
select pg_start_backup('backup');
Şimdi master sunucudaki postgresql in veri klasörünü, slave sunucudaki postgresql veri klasörüne kopyalamalısınız.
rsync -av 192.168.2.101:/var/lib/postgresql/9.1/main/ /var/lib/postgresql/9.1/main/
kopyalama işlemini yaptıktan sonra kopyalanan slave sunucudaki "postmaster.pid" dosyasını silin.
rm -rf /var/lib/postgresql/9.1/main/postmaster.pid
veri klasörünün nerde olduğunu bulmak için pgadmin de aşağıdaki sql cümlesini yazıp çalıştırabilirsiniz.
Slave sunucudaki postgresql veri klasörü içine "recovery.conf" adında bir dosya oluşturmalısınız.
show data_directory;Son olarak master sunucudaki backup işlemini durdurmalısınız. Bunun için pgadmin de aşağıdakı sorguyu çalıştırın.
select pg_stop_backup();Slave sunucu tarafında yapılan değişklikler
Slave sunucudaki postgresql veri klasörü içine "recovery.conf" adında bir dosya oluşturmalısınız.
Bu dosyaya aşağıdaki satırları yazın.
vi /var/lib/postgresql/9.1/recovery.conf
vi /var/lib/postgresql/9.1/recovery.conf
standby_mode='on'eğer salave sunucuda sorgu çalıştırmak istiyorsanız slave sunucuda aşağıdaki ayarı da yapın
primary_conninfo='host=192.168.2.101'
/etc/postgresql/9.1/main/postgresql.conf
hot_standby = on
Son olarak yapmanız gereken slave sunucudaki postgresql servisini yeniden başlatmanız. Bunun için terminale aşağıdaki kodu yazın.
sudo /etc/init.d/postgresql restart
Cuma, Aralık 20, 2013
how to find postgresql duplicate records
SELECT * FROM (
SELECT id,
codename,
ROW_NUMBER() OVER(PARTITION BY name, codename ORDER BY id asc) AS count
FROM auth_permission
) dups
WHERE
dups.count > 1
SELECT id,
codename,
ROW_NUMBER() OVER(PARTITION BY name, codename ORDER BY id asc) AS count
FROM auth_permission
) dups
WHERE
dups.count > 1
Cumartesi, Eylül 21, 2013
ubuntu debian basit vnc server kurulmu
$ sudo apt-get install x11vnc vnc-java
kullanıcı şifresi oluşturalım.
$ x11vnc -storepasswdçalıştıralım
Enter VNC password:
Verify password:
Write password to /home/kullanici/.vnc/passwd? [y]/n y
$ x11vnc -forever -usepw -httpdir /usr/share/vnc-java/ -httpport 5800
sunucumuz hazır.
http://sistem_makine_adresi:5800
Cumartesi, Temmuz 20, 2013
Okunası
Almanya’da bir lise müdürü, her eğitim öğretim yılı başında öğretmenlerine şu mektubu gönderirmiş.
“Bir toplama kampından sağ kurtulanlardan biriyim. Gözlerim hiçbir insanın görmemesi gereken şeyleri gördü. İyi eğitilmiş ve yetiştirilmiş mühendislerin inşa ettiği gaz odaları, iyi yetiştirilmiş doktorların zehirlediği çocuklar, işini iyi bilen hemşirelerin vurduğu iğnelerle ölen bebekler, lise ve üniversite mezunlarının vurup yaktığı insanlar.
Eğitimden bu nedenle kuşku duyuyorum. Sizlerden isteğim şudur.Öğrencilerinizin insan olması için çaba harcayın.Çabalarınız bilgili canavarlar ve becerikli psikopatlar üretmesin. Okuma yazma, matematik, çocuklarınızın daha fazla insan olmasına yardımcı olursa ancak o zaman önem taşır.”
Çarşamba, Temmuz 10, 2013
php online kullanıcı sayısı
$folder = dirname(__FILE__)."/activeusers/";
$timeold=30; // seconds
$actualtime=date("U"); // seconds since January 1st, 1970.
$ip = "0.0.0.0";
if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
if(isset($_SERVER['REMOTE_ADDR'])) $ip = $_SERVER['REMOTE_ADDR'];
file_put_contents ($folder."$ip.$actualtime.txt", "0");
$counter=0;
$ipCounter = array();
$dir = dir($folder);
while($temp = $dir->read()){
if ($temp=="." or $temp==".."){continue;}
$filecreatedtime=date("U", filemtime($folder.$temp));
if ($actualtime>($filecreatedtime+$timeold)){
unlink ($folder.$temp); //
}else{
$dataArr = explode('.',$temp);
$dataIp = sprintf('%s', $dataArr[0], $dataArr[0], $dataArr[0], $dataArr[0]);
$ipCounter[$dataIp] += 1;
$counter++;
if($ipCounter[$dataIp]>15) {
echo ":)";
exit(0);
}
}
}
Çarşamba, Mayıs 08, 2013
toplu dosya ismi değiştirme
for i in *.bmp; do convert ${i} ${i%bmp}jpg; done
gelişmiş seçenekler eklenebilir
convert -size 360x85 xc:transparent -font Bookman-DemiItalic -pointsize 72 -draw "text 25,60 'nixCraft'" -channel RGBA -gaussian 0x6 -fill YellowGreen -stroke RosyBrown -draw "text 20,55 'nixCraft'" nixCraft.png
Perşembe, Nisan 25, 2013
How to Compact a VirtualBox Linux Guest’s VDI file
Steps to compact a VDI file:
To zero-fill a linux disk, the most efficient way is to use the dd command, which can write a stream to a file. In this case, we will be writing from the linux pseudo-device /dev/zero to a fill file. Use the following command to zero-fill the disk:
if= specifies the input file, in this case, a stream of zeroes. of= specifies an output file. If you were to specify a drive here, like /dev/sda, it would zero fill the entire drive, so be careful. bs= specifies the block size. In this case, it will write a megabyte of zeroes at a time into fillfile.
Once dd has completed, delete your zero-fill file
This is a minor consideration, done for speed. For future reference, it can be much faster to specify a 512k-1M block size when random filling a drive with dd for data destruction purposes.
Once dd has completed, delete your fill file (which should be taking up all of the free space on the drive at this point) and shut the virtual machine down. Once it’s shut down, run VBoxModify to complete the process. VBoxModify is a very powerful tool, and occupies an entire chapter of the VirtualBox Manual. Compact the VDI using the following command:
When the process is complete, you should have a smaller vdi. If not, something went wrong with the zero-filling process or there was no room to compact your VDI.
- Zero-fill the virtual machine’s disk using the dd command
- Shut down the machine
- Use Oracle’s VBoxManage program to compact the VDI
- Restart the virtual machine
To zero-fill a linux disk, the most efficient way is to use the dd command, which can write a stream to a file. In this case, we will be writing from the linux pseudo-device /dev/zero to a fill file. Use the following command to zero-fill the disk:
$ dd if=/dev/zero of=fillfile bs=1M
if= specifies the input file, in this case, a stream of zeroes. of= specifies an output file. If you were to specify a drive here, like /dev/sda, it would zero fill the entire drive, so be careful. bs= specifies the block size. In this case, it will write a megabyte of zeroes at a time into fillfile.
Once dd has completed, delete your zero-fill file
This is a minor consideration, done for speed. For future reference, it can be much faster to specify a 512k-1M block size when random filling a drive with dd for data destruction purposes.
Once dd has completed, delete your fill file (which should be taking up all of the free space on the drive at this point) and shut the virtual machine down. Once it’s shut down, run VBoxModify to complete the process. VBoxModify is a very powerful tool, and occupies an entire chapter of the VirtualBox Manual. Compact the VDI using the following command:
$ VBoxManage modifyhd /path/to/your.vdi --compact
When the process is complete, you should have a smaller vdi. If not, something went wrong with the zero-filling process or there was no room to compact your VDI.
Cuma, Mart 15, 2013
Javascript URL Parse
javascript ile url pars etme
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
Çarşamba, Mart 13, 2013
OpenERP Ident authentication failed for user "openerp"
OpenERP kurulumunda
Ident authentication failed for user "openerp"hatası alıyorsanız pg_hba.conf dosyasında
local all all ident
satırını
local all all md5
şeklinde deneyin
Kaydol:
Kayıtlar (Atom)