Настройки PostgreSQL для работы с 1С:Предприятием. Часть 2
Глава 5. Администрирование
Тестовая виртуальная машина
1. Устанавливаем ubuntu 16.04.5 HWE server без swap файла,
т.е. размечаем вручную весь диск ext4 root.
ubuntu имя компьютера u1604
ubuntu пользователь user пароль 12345
ubuntu пользователь postgres password pass
ubuntu пользователь usr1cv8 password pass
Настройки виртуальной машины - RAM (32GB)
Сеть - сетевой мост.
Проще всего пробросить в виртуальную машину лицензии 1С:Предприятия 8 посредством локального hasp.
Настройки ubuntu пользователь (привязка в скриптах) user пароль 12345, имя компьютера
u1604 сеть DHCP
После установки, Ctrl +Alt + T (окно терминала)
$ sudo apt update -y
$ sudo apt upgrade -y
$ sudo apt install mc ssh samba htop -y
Возможно sudo apt upgrade -y не пройдет из за блокировки, тогда sudo reboot и повторите с начала.
$ lsusb
Bus 001 Device 002: ID 80ee:0021 VirtualBox USB Tablet
Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Пробросить hasp средствами VirtualBox
$ lsusb
Bus 001 Device 004: ID 0529:0001 Aladdin Knowledge Systems HASP copy protection dongle
Bus 001 Device 003: ID 0529:0001 Aladdin Knowledge Systems HASP copy protection dongle
Bus 001 Device 002: ID 80ee:0021 VirtualBox USB Tablet
Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
$ sudo cat /proc/cpuinfo | grep MHz
$ sudo systemctl status ondemand
$ sudo systemctl stop ondemand
$ sudo systemctl disable ondemand
$ sudo poweroff
Образ u16045.ova
2. После перезагрузки по сети можно подключиться MobaXterm
к нашей виртуальной машине (по ip или или имени ) загрузить файлы установки:
$ mkdir /home/user/test
В папку /test положить файлы:
postgresql_10.5_10.1C_amd64_deb.tar.bz2
postgresql_10.5_10.1C_amd64_addon_deb.tar.bz2
Исправим bug
Several regex warnings when installing latest postgres update
sudo nano /usr/sbin/pam_getenv
строка 78 заменить
$val =~ s/(?<!\\)\${([^}]+)}/$ENV{$1}||""/eg;
на
$val =~ s/(?<!\\)\$\{([^}]+)\}/$ENV{$1}||""/eg;
#sudo apt-get install libicu55 -y
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main" >> /etc/apt/sources.list.d/postgresql.list'
sudo apt update -y
sudo apt-get install postgresql-common libtcl8.6 -y
dpkg -l | grep postgres | awk -F' ' '{print $2}' | sudo xargs apt-mark hold
mkdir -p /tmp/post
cp /home/user/test/postgresql_10.5_10.1C_amd64_deb.tar.bz2 /tmp/post/
cp /home/user/test/postgresql_10.5_10.1C_amd64_addon_deb.tar.bz2 /tmp/post/
cd /tmp/post
tar -xvf postgresql_10.5_10.1C_amd64_deb.tar.bz2
cd postgresql-10.5-10.1C_amd64_deb
sudo dpkg -i *.deb
cd /tmp/post/
tar -xvf postgresql_10.5_10.1C_amd64_addon_deb.tar.bz2
cd postgresql-10.5-10.1C_amd64_addon_deb
sudo dpkg -i *.deb
dpkg -l | grep 10.5-10.1C | awk -F' ' '{print $2}' | sudo xargs apt-mark hold
#sudo apt-mark hold postgresql-common postgresql-client-common
sudo -u postgres psql -U postgres -c "alter user postgres with password 'pass';"
sudo cp /etc/postgresql/10/main/postgresql.conf /etc/postgresql/10/main/postgresql.conf.bak
#sudo rm /etc/apt/sources.list.d/postgresql.list
#sudo apt update -y
#Делаем проверки
#sudo systemctl status postgresql.service
#ss -tunpl | grep 5432
# $ ps aux | grep postgres | grep -- -D
postgres 4914 0.0 0.1 320972 28864 ? S 08:37 0:00 /usr/lib/postgresql/10/bin/postgres -D /var/lib/postgresql/10/main -c config_file=/etc/postgresql/10/main/postgresql.conf
#--------------------------------------------------------------------------------
Собственно тюнинг.
#add a swap file to an Ubuntu 16.04
sudo fallocate -l 1G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo cp /etc/fstab /etc/fstab.bak
sudo echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
# отключим ip6
sudo /bin/su -c "echo 'net.ipv6.conf.all.disable_ipv6 = 1' >> /etc/sysctl.conf"
sudo /bin/su -c "echo 'net.ipv6.conf.default.disable_ipv6 = 1' >> /etc/sysctl.conf"
sudo /bin/su -c "echo 'net.ipv6.conf.lo.disable_ipv6 = 1' >> /etc/sysctl.conf"
#sudo /bin/su -c "echo 'net.ipv4.ip_forward = 1' >> /etc/sysctl.conf"
#тюнинг postgresql
sudo /bin/su -c "echo 'vm.swappiness=1' >> /etc/sysctl.conf"
sudo /bin/su -c "echo 'kernel.sched_migration_cost_ns = 5000000' >> /etc/sysctl.conf"
sudo /bin/su -c "echo 'kernel.sched_autogroup_enabled = 0' >> /etc/sysctl.conf"
sudo /bin/su -c "echo 'vm.dirty_background_bytes = 67108864' >> /etc/sysctl.conf"
sudo /bin/su -c "echo 'vm.dirty_bytes = 536870912' >> /etc/sysctl.conf"
sudo /bin/su -c "echo 'vm.zone_reclaim_mode = 0' >> /etc/sysctl.conf"
sudo /bin/su -c "echo 'vm.zone_reclaim_mode = 0' >> /etc/sysctl.conf"
sudo sysctl -p
PGTune
sudo nano /etc/postgresql/10/main/postgresql.conf
Добавить в конец:
# DB Version: 10
# OS Type: linux
# DB Type: oltp
# Total Memory (RAM): 16 GB
# Data Storage: ssd
max_connections = 1000
shared_buffers = 4GB
temp_buffers = 256MB
work_mem = 64MB
effective_cache_size = 12GB
maintenance_work_mem = 1GB
wal_buffers = 16MB
min_wal_size = 2GB
max_wal_size = 4GB
default_statistics_target = 100
effective_io_concurrency = 2
random_page_cost = 1.1
autovacuum = on
autovacuum_max_workers = 4
autovacuum_naptime = 20s
bgwriter_delay = 20ms
bgwriter_lru_multiplier = 4.0
bgwriter_lru_maxpages = 400
synchronous_commit = off
checkpoint_completion_target = 0.9
#min_wal_size = 2GB
#max_wal_size = 4GB
ssl = off
fsync = on
commit_delay = 1000
commit_siblings = 5
row_security = off
max_files_per_process = 1000
standard_conforming_strings = off
escape_string_warning = off
max_locks_per_transaction = 256
#log_min_duration_statement = 0
log_line_prefix = '%t [%p]: [%l-1] user=%u,db=%d,client=%h '
log_checkpoints = on
log_connections = on
log_disconnections = on
log_lock_waits = on
log_temp_files = 0
#log_autovacuum_min_duration = 0
lc_messages='C'
#log_duration = on
#log_statement = all
log_destination = stderr
plantuner.fix_empty_table = 'on'
online_analyze.table_type = 'temporary'
online_analyze.verbose = 'off'
Сохранить.
sudo nano /etc/postgresql/10/main/postgresql.conf
Добавить в конец:
# DB Version: 10
# OS Type: linux
# DB Type: oltp
# Total Memory (RAM): 4 GB
# Data Storage: ssd
max_connections = 1000
shared_buffers = 1GB
temp_buffers = 64MB
work_mem = 16MB
effective_cache_size = 3GB
maintenance_work_mem = 256MB
wal_buffers = 16MB
min_wal_size = 2GB
max_wal_size = 4GB
default_statistics_target = 100
effective_io_concurrency = 2
random_page_cost = 1.1
autovacuum = on
autovacuum_max_workers = 4
autovacuum_naptime = 20s
bgwriter_delay = 20ms
bgwriter_lru_multiplier = 4.0
bgwriter_lru_maxpages = 400
synchronous_commit = off
checkpoint_completion_target = 0.9
#min_wal_size = 2GB
#max_wal_size = 4GB
ssl = off
fsync = on
commit_delay = 1000
commit_siblings = 5
row_security = off
max_files_per_process = 1000
standard_conforming_strings = off
escape_string_warning = off
max_locks_per_transaction = 256
#log_min_duration_statement = 0
log_line_prefix = '%t [%p]: [%l-1] user=%u,db=%d,client=%h '
log_checkpoints = on
log_connections = on
log_disconnections = on
log_lock_waits = on
log_temp_files = 0
#log_autovacuum_min_duration = 0
lc_messages='C'
#log_duration = on
#log_statement = all
log_destination = stderr
plantuner.fix_empty_table = 'on'
online_analyze.table_type = 'temporary'
online_analyze.verbose = 'off'
Сохранить.
sudo nano /etc/postgresql/10/main/postgresql.conf
Добавить в конец:
# DB Version: 10
# OS Type: linux
# DB Type: oltp
# Total Memory (RAM): 8 GB
# Data Storage: ssd
max_connections = 1000
shared_buffers = 2GB
temp_buffers = 128MB
work_mem = 32MB
effective_cache_size = 6GB
maintenance_work_mem = 512MB
wal_buffers = 16MB
min_wal_size = 2GB
max_wal_size = 4GB
default_statistics_target = 100
effective_io_concurrency = 2
random_page_cost = 1.1
autovacuum = on
autovacuum_max_workers = 4
autovacuum_naptime = 20s
bgwriter_delay = 20ms
bgwriter_lru_multiplier = 4.0
bgwriter_lru_maxpages = 400
synchronous_commit = off
checkpoint_completion_target = 0.9
#min_wal_size = 2GB
#max_wal_size = 4GB
ssl = off
fsync = on
commit_delay = 1000
commit_siblings = 5
row_security = off
max_files_per_process = 1000
standard_conforming_strings = off
escape_string_warning = off
max_locks_per_transaction = 256
#log_min_duration_statement = 0
log_line_prefix = '%t [%p]: [%l-1] user=%u,db=%d,client=%h '
log_checkpoints = on
log_connections = on
log_disconnections = on
log_lock_waits = on
log_temp_files = 0
#log_autovacuum_min_duration = 0
lc_messages='C'
#log_duration = on
#log_statement = all
log_destination = stderr
plantuner.fix_empty_table = 'on'
online_analyze.table_type = 'temporary'
online_analyze.verbose = 'off'
Сохранить.
sudo nano /etc/postgresql/10/main/postgresql.conf
Добавить в конец:
# DB Version: 10
# OS Type: linux
# DB Type: oltp
# Total Memory (RAM): 2 GB
# Data Storage: ssd
max_connections = 1000
shared_buffers =512MB
temp_buffers = 32MB
work_mem = 8MB
effective_cache_size =768MB
maintenance_work_mem = 128MB
wal_buffers = 16MB
min_wal_size = 2GB
max_wal_size = 4GB
default_statistics_target = 100
effective_io_concurrency = 2
random_page_cost = 1.1
autovacuum = on
autovacuum_max_workers = 4
autovacuum_naptime = 20s
bgwriter_delay = 20ms
bgwriter_lru_multiplier = 4.0
bgwriter_lru_maxpages = 400
synchronous_commit = off
checkpoint_completion_target = 0.9
#min_wal_size = 2GB
#max_wal_size = 4GB
ssl = off
fsync = on
commit_delay = 1000
commit_siblings = 5
row_security = off
max_files_per_process = 1000
standard_conforming_strings = off
escape_string_warning = off
max_locks_per_transaction = 256
#log_min_duration_statement = 0
log_line_prefix = '%t [%p]: [%l-1] user=%u,db=%d,client=%h '
log_checkpoints = on
log_connections = on
log_disconnections = on
log_lock_waits = on
log_temp_files = 0
#log_autovacuum_min_duration = 0
lc_messages='C'
#log_duration = on
#log_statement = all
log_destination = stderr
plantuner.fix_empty_table = 'on'
online_analyze.table_type = 'temporary'
online_analyze.verbose = 'off'
Сохранить.
# SELECT name, setting, unit FROM pg_settings where category like '%Memory%';
# cat /proc/meminfo
Комментариев нет:
Отправить комментарий