среда, 23 января 2019 г.

LXD борьба за available space

Есть LXD 3.0.1
В контейнере не стало свободного пространства. Также есть расхождение в дисковом пространстве контейнера (lxc info cntn1 - 100Gb) и внутри контейнера (df -h - 50Gb)

lxc info cntn1
  root:
    path: /
    pool: lxd
    size: 110GB
    type: disk
df -h
Filesystem             Size  Used Avail Use% Mounted on
lxd/containers/cntn1   59G   50G  9.4G  85% /

Вначале добавил root size плюс 10Gb

lxc config device set abc104 root size 110GB

Но через некоторое время места опять стало мало.
После форума нашел, что причина - снепшоты
zfs list -o space | grep cntn1 NAME AVAIL USED USEDSNAP USEDDS USEDREFRESERV USEDCHILD lxd/containers/cntn1 6.98G 103G 53.3G 49.7G 0B 0B lxd/snapshots/cntn1 1.05T 590K 0B 24K 0B 566K lxd/snapshots/cntn1/cntn1_snap 1.05T 107K 0B 107K 0B 0B lxd/snapshots/cntn1/stable_migrate 1.05T 459K 0B 459K 0B 0B

zfs list | grep cntn1 NAME USED AVAIL REFER MOUNTPOINT lxd/containers/cntn1 104G 6.46G 50.2G /var/lib/lxd/storage- pools/lxd/containers/cntn1 lxd/snapshots/cntn1 590K 1.05T 24K /lxd/snapshots/cntn1 lxd/snapshots/cntn1/cntn1_snap 107K 1.05T 22.7G /var/lib/lxd/storage-pools/lxd/snapshots/cntn1/cntn1_snap lxd/snapshots/cntn1/stable_migrate 459K 1.05T 41.4G /var/lib/lxd/storage-pools/lxd/snapshots/cntn1/stable_migrate

Но удаление снепшота не помогло

lxc delete lxd/snapshots/cntn1/cntn1_snap

zfs destroy lxd/snapshots/cntn1/cntn1_snap

zfs list | grep cntn1 NAME USED AVAIL REFER MOUNTPOINT lxd/containers/cntn1 103G 6.59G 50.3G /var/lib/lxd/storage-pools/lxd/containers/cntn1 lxd/snapshots/cntn1 483K 1.05T 24K /lxd/snapshots/cntn1 lxd/snapshots/cntn1/stable_migrate 459K 1.05T 41.4G /var/lib/lxd/storage-pools/lxd/snapshots/cntn1/stable_migrate

Пока решение добавить еще root size плюс 10Gb и зарезервировать эти 10Gb

lxc config device set abc104 root size 120GB

zfs set refreservation=10g lxd/containers/cntn1


zfs get refreservation lxd/containers/abc104
NAME                   PROPERTY        VALUE      SOURCE
lxd/containers/abc104  refreservation  10G        local

После этих команд результат

zfs list | grep cntn1
NAME                               USED  AVAIL  REFER  MOUNTPOINT
lxd/containers/cntn1               110G  16.9G  49.9G  /var/lib/lxd/storage-pools/lxd/containers/cntn1
lxd/snapshots/cntn1                483K  1.05T    24K  /lxd/snapshots/cntn1
lxd/snapshots/cntn1/stable_migrate 459K  1.05T  41.4G  /var/lib/lxd/storage-pools/lxd/snapshots/cntn1/stable

df -h
Filesystem             Size  Used Avail Use% Mounted on

lxd/containers/abc104   67G   51G   17G  76% /

четверг, 17 января 2019 г.

Curl API HTTP запрос к сайту с only HTTPS

Для этого используем параметр L
from here
-L, --location

curl -L -I -H "Host: example.com" 1.2.3.4
(HTTP) If the server reports that the requested page has moved to a different location (indicated with a Location: header and a 3XX response code), this option will make curl redo the request on the new place. If used together with -i, --include or -I, --head, headers from all requested pages will be shown. When authentication is used, curl only sends its credentials to the initial host. If a redirect takes curl to a different host, it won't be able to intercept the user+password. See also --location-trusted on how to change this. You can limit the amount of redirects to follow by using the --max-redirs option.

When curl follows a redirect and the request is not a plain GET (for example POST or PUT), it will do the following request with a GET if the HTTP response was 301, 302, or 303. If the response code was any other 3xx code, curl will re-send the following request using the same unmodified method.

You can tell curl to not change the non-GET request method to GET after a 30x response by using the dedicated options for that: --post301, --post302 and --post303.

https://curl.haxx.se/docs/httpscripting.html#Location_header

When a resource is requested from a server, the reply from the server may include a hint about where the browser should go next to find this page, or a new page keeping newly generated output. The header that tells the browser to redirect is Location:.

Curl does not follow Location: headers by default, but will simply display such pages in the same manner it displays all HTTP replies. It does however feature an option that will make it attempt to follow the Location: pointers.

понедельник, 14 января 2019 г.

Linux java tmp noexec folder

При запуске java приложений ошибка:

Exception in thread "main" java.lang.UnsatisfiedLinkError: /tmp/jna-94103840/jna8715740055787765144.tmp failed to map segment from shared object

Проблема в том что /tmp смонтирована с параметром noexec, а этот параметр должен остаться.
Чтобы добавить свою tmp папку добавляем в строку запуска java приложения параметр:

-Djava.io.tmpdir=/home/user/tmp


четверг, 10 января 2019 г.

Linux Install Pyrhon 3.6 with pyenv

Мне нужно установить новую версию только для определенного пользователя.
отсюда
apt update && apt install git build-essential libbz2-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev zlib1g-dev
su user
curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
добавил в .bashrc, как было рекомендовано после установки

export PATH="/home/user/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"

pyenv install 3.6.4 (pyenv uninstall 3.6.4)
pyenv virtualenv 3.6.4 general (или pyenv virtualenv 3.6.4 other_proj and pyenv local other_proj)
pyenv global general (pyenv uninstall general)

(general) user@server:~$ python -V
Python 3.6.4

После этого, если выйти и зайти, то окружение для пользователя сохраняется.