Kategori: Kategorisiz Yazilar
Hic bir kategoriye girmeyen yazilarimi buraya yazacagim..
a sunucusundan b sunucusuna dosyalari en hizli nasil transfer ederiz?
a sunucusundan b sunucusuna dosyalari en hizli nasil transfer ederiz?
cevap rsync tabiiki..
daha oncede yazmistim. Biraz gelistirmek zorunda kaldim.
soyle ki: su linkdeki adresde bu konuyu yazmisim.
ancak rsync malum paralel calismiyor. tek thread isi bozuyor.
o zaman 1 den cok thread calistiralim
parallel kullanarak.
yum install parallel veyahut apt-get install moreutils
sonrasinda komutumuz bu:
ls . | parallel -v -j8 rsync -raz --progress {} root@sun.ucu.ip.adres:/home/blabla/domains/hoptirirom.com.tr/public_html/{}
8 baglanti acip rsync yapacak bu.
ssh-keygen -t rsa
ve
ssh-copy-id user@123.45.56.78
yapmayi unutma bastan 🙂
biraz daha aciklama yazayim kendim icin
rsync icin -raz
-recursive
-archive
-zikistir
demek oluyor.
-j8 8 paralel demek
daha once
rsync icin -ave gibi bisi kullanmistim
-archive
-verbose
-e -e, –rsh=COMMAND specify the remote shell to use
demekmis
-e neden kullanmadim ben burada acaba?
cunku daha once sunu kullanmistim
rsync -ave 'ssh -p 22' 1.2.3.4:/home/ /home/
simdi kullanmadim. ssh yap demedim. centosdan centosa benzer zaten sheller. kendisi halletti galiba.
NOT: http://moo.nac.uci.edu/~hjm/parsync/
buda perl wrapper ayni isi yapan. bakmadim henuz buna lazim olursa bakarim. eminim daha kolaydir.
hpacucli –
hpacucli ctrl slot=1 show config
Smart Array P410 in Slot 1 (sn: PACCRID11510NCV)
array A (SAS, Unused Space: 0 MB)
logicaldrive 1 (838.3 GB, RAID 1+0, Recovering, 13% complete)
physicaldrive 1I:1:1 (port 1I:box 1:bay 1, SAS, 450 GB, OK)
physicaldrive 1I:1:2 (port 1I:box 1:bay 2, SAS, 450 GB, OK)
physicaldrive 1I:1:3 (port 1I:box 1:bay 3, SAS, 450 GB, Rebuilding)
physicaldrive 1I:1:4 (port 1I:box 1:bay 4, SAS, 450 GB, OK)
SEP (Vendor ID PMCSIERA, Model SRC 8x6G) 250 (WWID: 500143801887352F)
3.2. hpacucli
This tool is a proprietary one created by HP. It can do both reporting and management.
3.2.1. Quickstart guide
List all controllers:
server:~# hpacucli controller all show
Smart Array 6i in Slot 0 ()
List arrays on controller in slot 0:
server:~# hpacucli ctrl slot=0 logicaldrive all show status
logicaldrive 1 (33.9 GB, RAID RAID 1+0): OK
logicaldrive 2 (136.7 GB, RAID RAID 1+0): OK
I don’t know why it reports RAID 1+0. This is regular RAID1 arrays.
List physical drives on controller in slot 0:
server:~# hpacucli ctrl slot=0 pd all show status
physicaldrive 1:0 (port 1:id 0, 36.4 GB): OK
physicaldrive 1:1 (port 1:id 1, 36.4 GB): OK
physicaldrive 1:2 (port 1:id 2, 146.8 GB): OK
physicaldrive 1:3 (port 1:id 3, 146.8 GB): OK
Summarized status:
server:~# hpacucli ctrl slot=0 show config
Smart Array 6i in Slot 0 ()
array A (Parallel SCSI, Unused Space: 0 MB)
logicaldrive 1 (33.9 GB, RAID 1+0, OK)
physicaldrive 2:0 (port 2:id 0 , Parallel SCSI, 36.4 GB, OK)
physicaldrive 2:1 (port 2:id 1 , Parallel SCSI, 36.4 GB, OK)
array B (Parallel SCSI, Unused Space: 0 MB)
logicaldrive 2 (136.7 GB, RAID 1+0, OK)
physicaldrive 2:2 (port 2:id 2 , Parallel SCSI, 146.8 GB, OK)
physicaldrive 2:3 (port 2:id 3 , Parallel SCSI, 146.8 GB, OK)
Controller policies (write cache, disk cache, battery), only interesting lines kept:
root@server:~# hpacucli ctrl slot=0 show
Smart Array P420i in Slot 0 (Embedded)
Serial Number: *SERIAL*
Controller Status: OK
Firmware Version: 3.54
Cache Board Present: True
Cache Status: OK
Cache Ratio: 25% Read / 75% Write
Drive Write Cache: Disabled
Total Cache Size: 512 MB
No-Battery Write Cache: Disabled
Cache Backup Power Source: Capacitors
Battery/Capacitor Count: 1
Battery/Capacitor Status: OK
Cache is ok, Battery is too. Write cache disabled if battery back isn’t enabled, that’s ok.
Check and enable cache for all arrays:
Check current state:
root@server:~# hpacucli ctrl slot=0 ld all show detail
Smart Array P420i in Slot 0 (Embedded)
array A
Logical Drive: 1
Size: 136.7 GB
Fault Tolerance: RAID 1
Status: OK
Caching: Disabled
Enable caching:
root@server:~# hpacucli ctrl slot=0 ld all modify arrayaccelerator=enable
Enable disks’ write cache:
root@server:~# hpacucli ctrl slot=0 modify dwc=enable
Warning: Without the proper safety precautions, use of write cache on physical
drives could cause data loss in the event of power failure. To ensure
data is properly protected, use redundant power supplies and
Uninterruptible Power Supplies. Also, if you have multiple storage
enclosures, all data should be mirrored across them. Use of this
feature is not recommended unless these precautions are followed.
Continue? (y/n) y
Warning is self-explaining I guess. Disks’s cache aren’t protected by controller’s battery. It’s up to you but I wouldn’t enable such features if your power supply isn’t protected.
Modify cache ratio between read and write:
root@server:~# hpacucli ctrl slot=0 modify cacheratio=50/50
MySQL viewleri dump etmece?
MySQL de views diye bir sey varmis.
ilgili bir zamanda belli bir query nin cevabini virtual olarak tutmasina yariyormus MySQL in.
MySQL ci olmayinca neyin ne oldugunu detaylica bilmiyorum.
bu view denen boklari dump etmiyor default mysqldump
1 kac kez sorun yasadim, programcilar tiri viri yapiyor
su sekilde dump edilebilir ozel durumlarda:
1. mysql.view.dump.sh diye bir text dosyasi icine yaz
#!/bin/bash -e mysql --skip-column-names --batch -e \ "select table_name from information_schema.views \ where table_schema = database()" $* | xargs --max-args 1 mysqldump $*
2- su sekilde calistir
sh mysql.view.dump.sh -u user -ppassword databasename > dumpfile.sql
imagick
yum install php-devel ImageMagick ImageMagick-devel
pecl install Imagick
*locate pecl*
don’t forget to add this to php.ini
extension=imagick.so
and then
service httpd restart
basit nginx config ornegi
Basitce sunucuda bulunan bir dizini nginix ile paylasmam gerekti.
ancak guzelde olsun istedim.
cokbasit nginix configi
# Default server configuration
#
server {
listen 80 default_server;
listen [::]:80 default_server;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name besdokuz.ee.pe;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
location /TOPGEAR {
autoindex on;
fancyindex on;
fancyindex_exact_size off;
alias /home/shukko/Downloads/TOPGEAR;
}
What is RAID? and What it had to do with servers?
quagga girdi hayatima.-kendim kasindim!-
https://wiki.quagga.net/wiki/index.php/TipsNTricks
cat /etc/quagga/bgpd.conf password blablabla router bgp 203555 network 37.24.11.0/24 bgp router-id 103.38.19.185 neighbor 169.254.169.254 remote-as 64515 neighbor 169.254.169.254 password rdjh&hjgsbjd3 neighbor 169.254.169.254 ebgp-multihop 2 neighbor 169.254.169.254 soft-reconfiguration inbound !
bu asagidaki openbgpd.conf – freebsd uzerinde , hatta yetmedi pfsense uzerinde..
neden diye sorma… routing bilmiyoz diye kimseye caktirmiyoz. denedik yanildik
o denemelerin hatirasi icin
# This file was created by the package manager. Do not edit!
AS 203555
fib-update yes
listen on 104.238.191.198
router-id 104.238.191.198
network 37.27.18.0/24
group "vultr" {
remote-as 64515
neighbor 169.254.169.254 {
descr "vultr"
tcp md5sig password rdfdf3efdf9C
announce all
multihop 2
softreconfig in yes
local-address 104.238.191.198
}
}
deny from any
deny to any
allow from 169.254.169.254
allow to 169.254.169.254
How to convert a non-sparse image to a sparse image
orjinal link: https://blog.laimbock.com/2013/10/31/how-to-convert-a-non-sparse-image-to-sparse/
Below are the steps how to convert a raw or qcow2 non-sparse image to a sparse image. Basically there are two ways to do the conversion:
1) use virt-sparsify
2) use dd and cp –sparse
Convert a non-sparse image to a sparse image with virt-sparsify
IMPORTANT: make sure the VM is not running/live! It must be shut down or else you will destroy the data in your image.
Make sure virt-sparsify is installed:
|
1
|
$ sudo yum install libguestfs–tools
|
Check current image:
|
1
2
|
$ sudo ls –lsk test.img
10737418240 –rw———–. 1 qemu qemu 10737418240 Oct 31 16:00 test.img
|
The first 10737418240 value is the allocated size and the second 10737418240 value is the file size. Since they are both the same value it means that this image is non-sparse (or 100% full in which case the sparse attempt is irrelevant).
Check again using qemu-img info:
|
1
2
3
4
5
|
$ sudo qemu–img info test.img
image: test.img
file format: raw
virtual size: 10G (10737418240 bytes)
disk size: 10G
|
Both the virtual size and the disk size are 10G so this image is not a sparse image.
Now convert the non-sparse image to a sparse image using virt-sparsify:
|
1
2
|
$ sudo virt–sparsify test.img sparse–test.img
$ sync
|
Check the new image:
|
1
2
|
$ sudo ls –lsk sparse–test.img
1425852 –rw———–. 1 qemu qemu 10737418240 Oct 31 16:01 sparse–test.img
|
The allocated size of 1425852 is much smaller than the file size of 10737418240 which means this is now a sparse image.
Check again using qemu-img info:
|
1
2
3
4
5
|
$ sudo qemu–img info sparse–test.img
image: sparse–test.img
file format: raw
virtual size: 10G (10737418240 bytes)
disk size: 1.4G
|
The disk size is much smaller than the virtual disk size so the image has indeed been successfully converted to a sparse image.
Convert a non-sparse image to a sparse image with dd and cp
Start the VM/image which you want to make sparse and login to it. Next fill the free space in the VM with zeros using the following command and then shut it down again:
|
1
2
3
4
|
$ sudo dd if=/dev/zero of=/tmp/zeroallspace bs=1M
$ sync
$ sudo rm –v /tmp/zeroallspace
$ sudo /sbin/shutdown –h now
|
Now convert the non-sparse image to a sparse image using cp:
|
1
|
$ sudo cp —sparse=always test.img sparse–test.img
|
Check the new image:
|
1
2
|
$ sudo ls –lsk sparse–test.img
1425852 –rw———–. 1 qemu qemu 10737418240 Oct 31 16:01 sparse–test.img
|
The allocated size of 1425852 is much smaller than the file/image size of 10737418240 which means this is now a sparse image.
Check again using qemu-img info:
|
1
2
3
4
5
|
$ sudo qemu–img info sparse–test.img
image: sparse–test.img
file format: raw
virtual size: 10G (10737418240 bytes)
disk size: 1.4G
|
Again this shows that the image is now a sparse image.
Which method to use?
Both methods work equally well. In terms of options the virt-sparsify method may be preferred as it can for example also convert the image from raw to qcow2 and it needs less steps. See man virt-sparsify for more information. If you just want to make the image sparse than choose the method which you like best.
Tip
If you use rsync to make backups of your images then do not forget to use the –sparse option and realize that –sparse conflicts with –inplace (see man rsync).
MySQL INNODB CRaSh Toplu yazisi.
MySQL INNODB Crash etti. Napicaz?
1- nano /etc/my.cnf
innodb_force_recovery = 2
2den basla 6ya kadar yolu var
GUNCELLEME: Agustos 2018
Be sure to check your MySQL logs, and if it loops with something like:
InnoDB: Waiting for the background threads to start
You should also add innodb_purge_threads=0 to your my.cnf.
So all together to bring back database, I had to add these 3 parameters in my.cnf:
port = 8881 innodb_force_recovery=3 innodb_purge_threads=0
2- killall -9 mysqld
calisan bir mysql processi kalmasin
3- innodb recovery ile calistiktan sonra read only olarak.
herseyi dump et tek buyuk bir dosyaya
cat /usr/local/directadmin/conf/mysql.conf mysqldump -u da_admin -p --opt --all-databases > alldb.sql
4- /var/lib/mysql altindaki
ibdata1
ib_logfile0
ib_logfile1
sil, veya sen en iyisi tum /mysql dizinini yedekle sonra sil
5- herseyi restore et buyuk dosya yedeginden.
mysql -u da_admin -p < alldb.sql
server.err logu tail le duruma bak
gule gule kullan.
NOT: 2021 mart::
Use the --force (-f) flag on your mysql import. Rather than stopping on the offending statement, MySQL will continue and just log the errors to the console.
For example:
mysql -u userName -p -f -D dbName < script.sql
ek:
aynisi oldu 1 serverda db leri dump ederken 1 table hata veriyordu.
inatla hangi table hangi db icinde onuda bulamadim crash diyip duruyodu
ne yaptim
updatedb
locate crashedentable.frm
frm ler cikinca tek tek hepsini (1den cok vardi ) 12 tane toplam
el ile fix ettim. aslinda otomatik auto-repair calismasi gerekirdi.
calismadi pust nedense ..
mysqlcheck -u da_admin -p --auto-repair --optimize --all-databases bu yukairdaki otomatik olan hepsini fixleyen. neden calismadiki acep. bilinmez.. ben naptim: mysqlcheck -u da_admin -p --auto-repair --databases esila_shop eticaret2_shop bu ise yaradi. bilgim olsun :) artik kod modundanda cikalim..
evet/./

