Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Call of Postgres: Advanced Operations. Part II.
Search
Alexey Lesovsky
July 05, 2017
Education
0
58
Call of Postgres: Advanced Operations. Part II.
Slides from my tutorial at PgDay 2017 St.Petersburg
Alexey Lesovsky
July 05, 2017
Tweet
Share
More Decks by Alexey Lesovsky
See All by Alexey Lesovsky
PostgreSQL Scaling Usecases
lesovsky
0
84
Patroni failure stories, or How to crash yout PostgreSQL cluster
lesovsky
0
390
PostgreSQL High Availability in 2019
lesovsky
0
250
Top developer's mistakes when working with PostgreSQL
lesovsky
1
120
Let's Pull the Plug On the Autovacuum (EN)
lesovsky
0
1.2k
Troubleshooting PostgreSQL for Developers (RU)
lesovsky
2
340
Troubleshooting PostgreSQL Streaming Replication
lesovsky
0
850
Call of Postgres: Advanced Operations. Part I.
lesovsky
0
53
Call of Postgres: Advanced Operations. Part III.
lesovsky
0
47
Other Decks in Education
See All in Education
謙虚なアジャイルコーチ__アダプティブ_ムーブ_による伴走支援.pdf
antmiyabin
0
250
JavaScript - Lecture 6 - Web Technologies (1019888BNR)
signer
PRO
0
2.5k
東工大 traP Kaggle班 機械学習講習会 2024
abap34
1
290
脳卒中になってしまった さあ、どうする
japanstrokeassociation
0
450
HCI and Interaction Design - Lecture 2 - Human-Computer Interaction (1023841ANR)
signer
PRO
0
790
week15@tcue2024
nonxxxizm
0
560
AWS All Certが伝える 新AWS認定試験取得のコツ (Machine Learning Engineer - Associate)
nnydtmg
1
520
PSYC-560 R and R Studio Setup
jdbedics
0
510
HCI Research Methods - Lecture 7 - Human-Computer Interaction (1023841ANR)
signer
PRO
0
670
Introduction - Lecture 1 - Web Technologies (1019888BNR)
signer
PRO
0
4.8k
Qualtricsで相互作用実験する「SMARTRIQS」実践編
kscscr
0
270
Kaggle 班ができるまで
abap34
1
190
Featured
See All Featured
Teambox: Starting and Learning
jrom
132
8.7k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
33k
A designer walks into a library…
pauljervisheath
202
24k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
328
21k
How to train your dragon (web standard)
notwaldorf
88
5.7k
How GitHub (no longer) Works
holman
311
140k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
46
2.1k
Intergalactic Javascript Robots from Outer Space
tanoku
268
27k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
43
6.6k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
320
Gamification - CAS2011
davidbonilla
80
5k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
42
9.2k
Transcript
Call of Postgres: Advanced Operations Alexey Lesovsky
[email protected]
Tuning Linux: практика 02
План 02 dataegret.com Отработка навыков настройки Linux. Отработка навыков troubleshooting
в Linux.
Отработка навыков настройки 02 dataegret.com Настройка RAID контроллера. Настройка переменных
sysctl. Виртуальная память, NUMA, Huge Pages Transparent Huge Pages. Планировщики ввода-вывода. Файловые системы. Энергосбережение.
Настройка RAID контроллера 02 dataegret.com MegaCli (StorCli): • Проверка конфигурации
контроллера, томов, дисков. • Настройка логических томов. • Журнал событий.
Настройка RAID контроллера 02 dataegret.com Проверка конфигурации контроллера, томов, дисков.
# megacli adpallinfo aall # megacli ldinfo lall aall # megacli pdlist aall # megacli adpbbucmd aall
Настройка RAID контроллера 02 dataegret.com Настройка логических томов. # megacli
ldsetprop wt l0 a0 -- set Writethrough # megacli ldsetprop direct l0 a0 -- set Direct # megacli ldsetprop nora l0 a0 -- set No ReadAhead
Настройка RAID контроллера 02 dataegret.com Журнал событий. # megacli adpeventlog
getevents severity -f filename a0 • severity: info, warning, critical, fatal
Sysctl переменные 02 dataegret.com Планировщик процессов: # vi /etc/sysctl.conf kernel.sched_autogroup_enabled
= 0 kernel.sched_migration_cost_ns = 5000000 # sysctl -p
Sysctl переменные 02 dataegret.com Виртуальная память: # vi /etc/sysctl.conf vm.dirty_background_bytes
= 128000000 vm.dirty_bytes = 512000000 # sysctl -p
Sysctl переменные 02 dataegret.com Виртуальная память и Out-of-memory: # vi
/etc/sysctl.conf vm.swappiness = 1 vm.min_free_kbytes = 1000000 vm.overcommit_memory = 0 # sysctl -p
Sysctl переменные 02 dataegret.com Виртуальная память и NUMA: # vi
/etc/sysctl.conf vm.zone_reclaim_mode = 0 kernel.numa_balancing = 0 # sysctl -p
Sysctl переменные 02 dataegret.com Виртуальная память и Huge Pages: #
vi /etc/sysctl.conf vm.nr_hugepages = 32000 # 64GB vm.nr_overcommit_hugepages = 1000 # +2GB # echo 3 > /proc/sys/vm/drop_caches # sysctl -p # grep ^Huge /proc/meminfo
NUMA 02 dataegret.com # numastat # numactl --hardware # numactl
--interleave program # cat /proc/pid/numa_maps
Transparent Huge Pages 02 dataegret.com # uname -a # echo
never > /sys/kernel/mm/transparent_hugepage/enabled # echo never > /sys/kernel/mm/transparent_hugepage/defrag # vi /etc/rc.local
Планировщики ввода-вывода 02 dataegret.com На лету: # echo noop >
/sys/block/<device>/queue/scheduler На постоянно, способ №1: # vi /etc/rc.local На постоянно, способ №2: # vi /etc/default/grub GRUB_CMDLINE_LINUX="… elevator=noop" # update-grub
Механизм BLK-MQ 02 dataegret.com # vi /etc/default/grub GRUB_CMDLINE_LINUX="… scsi_mod.use_blk_mq=1" #
update-grub # reboot # cat /sys/block/sd*/queue/scheduler (none)
Файловые системы 02 dataegret.com На лету: # mount -o remount,nobarrier
/db На постоянно: # vi /etc/fstab LABEL=pgdb /db ext4 nobarrier 0 2 # mount -o remount,nobarrier /db
Энергосбережение 02 dataegret.com Какой режим включен? # lscpu |grep MHz
# cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor Поменять на лету: # for i in $(ls -1 /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor); do echo performance > $i; done На постоянно: # update-rc.d ondemand disable – Ubuntu # cpupower frequency-set -g performance – CentOS
Troubleshooting Linux 02 dataegret.com Постановка задачи: • Определение проблемного ресурса.
План: • Выявление нагрузки на CPU. • Выявление нагрузки на Storage. • Выявление нагрузки на Network.
Troubleshooting Linux 02 dataegret.com # git clone https://github.com/lesovsky/ConferenceStuff # cd
ConferenceStuff/2017.pgday/scripts # ./01-generate-test-data.sh
Troubleshooting Linux 02 dataegret.com # scripts/02-generate-cpu-load.sh # top • Load
average. • CPU Usage: us, sy, ni, id, wa, hi, si, st.
Troubleshooting Linux 02 dataegret.com А какие еще есть тулзы? •
htop, atop, pidstat, tiptop, ... • /proc/stat интерфейс.
Troubleshooting Linux 02 dataegret.com # scripts/03-generate-io-load.sh # top • CPU
Usage: wa. # iostat -m -x 1 • IOPSes, throughput, latencies, utilization. # iotop -Poa • Disk read/write, swap, io%. # cat /proc/diskstats
Troubleshooting Linux 02 dataegret.com # scripts/04-generate-network-load.sh # nicstat -m -x
1 • Throughput, errors, utilization. # netstat -s # ss # cat /proc/net/dev
Troubleshooting Linux 02 dataegret.com Проблемы с памятью? • numastat. •
Intel Memory Latency Checker. • dmesg.
Troubleshooting Linux 02 dataegret.com Аппаратные проблемы: • Chassis? – ipmitool.
• CPU? – mcelog. • Memory? – EDAC модули, mcelog. • Storage? – утилиты RAID-контроллеров, smartmontools, mcelog. • Network? – ethtool.
Troubleshooting Linux 02 dataegret.com Аппаратные проблемы: • Chassis? – ipmitool.
• # ipmitool sel elist • CPU? – mcelog. • Memory? – EDAC модули, mcelog. • Storage? – утилиты RAID-контроллеров, smartmontools, mcelog. • Network? – ethtool.
Troubleshooting Linux 02 dataegret.com Аппаратные проблемы: • Chassis? – ipmitool.
• CPU? – mcelog. • # mcelog --client • Memory? – EDAC модули, mcelog. • Storage? – утилиты RAID-контроллеров, smartmontools, mcelog. • Network? – ethtool.
Troubleshooting Linux 02 dataegret.com Аппаратные проблемы: • Chassis? – ipmitool.
• CPU? – mcelog. • Memory? – EDAC модули, mcelog. • # cat /sys/devices/system/edac/mc/mc*/*_count • Storage? – утилиты RAID-контроллеров, smartmontools, mcelog. • Network? – ethtool.
Troubleshooting Linux 02 dataegret.com Аппаратные проблемы: • Chassis? – ipmitool.
• CPU? – mcelog. • Memory? – EDAC модули, mcelog. • Storage? – утилиты RAID-контроллеров, smartmontools, mcelog. • # megacli, storcli, arcconf, tw_cli, hpacucli, etc... • Network? – ethtool.
Troubleshooting Linux 02 dataegret.com Аппаратные проблемы: • Chassis? – ipmitool.
• CPU? – mcelog. • Memory? – EDAC модули, mcelog. • Storage? – утилиты RAID-контроллеров, smartmontools, mcelog. • Network? – ethtool. • # ethtool -S eth0 |grep err
Troubleshooting Linux 02 dataegret.com
Вопросы? dataegret.com
[email protected]