вторник, 12 ноября 2019 г.

Установка lxd на Ubuntu 18.04.3 server

How To Fix “Kernel driver not installed (rc=-1908)” VirtualBox Error In Ubuntu
Oracle VirtualBox 6.0.14 Released with Linux 5.3 Support
tasksel
Ubuntu 18.04: Connect to Xfce desktop environment via XRDP
Пошаговая инструкция настройки LXD на Ubuntu 16.04
LXD, ZFS and bridged networking on Ubuntu 16.04 LTS+
Production setup

Нужно временное решение для поддержки virtualbox, поэтому выбран xubuntu-desktop
$ sudo apt update
$ sudo apt upgrade
$ sudo apt install mc samba ssh
$ tasksel --list-tasks
$ sudo tasksel install xubuntu-desktop
$ sudo reboot

$ sudo sh -c 'echo "deb [arch=amd64] http://download.virtualbox.org/virtualbox/debian $(lsb_release -sc) contrib" >> /etc/apt/sources.list.d/virtualbox.list'
$ wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
$ sudo apt update
$ sudo apt install virtualbox-6.0
#$ sudo apt autoremove --purge virtualbox-6.0
$ sudo usermod -a -G vboxusers $USER
$ sudo /sbin/vboxconfig
$ sudo reboot

$ sudo apt install -y xrdp
$ sudo systemctl enable xrdp
$ echo "xfce4-session" > ~/.xsession
$ D=/usr/share/xfce4:/usr/share/xubuntu:/usr/local/share
$ D=${D}:/usr/share:/var/lib/snapd/desktop:/usr/share
$ cat <<EOF > ~/.xsessionrc
export XDG_SESSION_DESKTOP=xubuntu
export XDG_DATA_DIRS=${D}
export XDG_CONFIG_DIRS=/etc/xdg/xdg-xubuntu:/etc/xdg:/etc/xdg
EOF

$ sudo reboot


$ sudo apt-get install bridge-utils -y
$ ip a
enp0s31f6 192.168.0.7
$ sudo nano /etc/netplan/01-netcfg.yaml

# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
  version: 2
  renderer: networkd
  ethernets:
    enp0s31f6:
      dhcp4: yes

  bridges:
    br0:
      interfaces: [enp0s31f6]
      addresses: [192.168.0.7/24]
      gateway4: 192.168.0.1
      mtu: 1500
      nameservers:
        addresses: [8.8.8.8]
      parameters:
        stp: true
        forward-delay: 4
      dhcp4: no
      dhcp6: no

Сохранить.

$ sudo netplan generate
$ sudo netplan --debug apply


#$ sudo systemctl stop networking.service
#$ sudo systemctl disable networking.service

$ cat /proc/cpuinfo | grep MHz
$ sudo systemctl stop ondemand
$ sudo systemctl disable ondemand

$ nano tuning.sh
 
#!/bin/bash
# отключим ipv6
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"
#lxd
sudo /bin/su -c "echo 'fs.inotify.max_queued_events = 1048576' >> /etc/sysctl.conf"
sudo /bin/su -c "echo 'fs.inotify.max_user_instances = 1048576' >> /etc/sysctl.conf"
sudo /bin/su -c "echo 'fs.inotify.max_user_watches = 1048576' >> /etc/sysctl.conf"
sudo sysctl -p

Сохранить.

$ sudo sh tuning.sh
$ sudo reboot

$ ls -l /dev/disk/by-uuid
$ sudo nano /etc/fstab
Добавить:
UUID=5238c225-69c3-4c28-a633-5177867f0696 /home/user/Документы ext4 defaults 0 0
Сохранить.
$ sudo reboot
Конвертировать OVA в Qcow2


1. На хосте созаем файл (берем с машины где стоят драйвера)
$ sudo nano /etc/udev/rules.d/80-hasp.rules
# HASP rules
ACTION=="add|change|bind", SUBSYSTEM=="usb", ATTRS{idVendor}=="0529", ATTRS{idProduct}=="0001", MODE="664", ENV{HASP}="1", SYMLINK+="aks/hasp/%k", RUN+="/usr/sbin/aksusbd_x86_64 -c $root/aks/hasp/$kernel"
ACTION=="remove", ENV{HASP}=="1", RUN+="/usr/sbin/aksusbd_x86_64 -r $root/aks/hasp/$kernel"

# SENTINEL rules
ACTION=="add|change|bind", SUBSYSTEM=="usb", ATTRS{idVendor}=="0529", ATTRS{idProduct}=="0003", KERNEL!="hiddev*", MODE="666", GROUP="plugdev", ENV{SENTINELHID}="1", SYMLINK+="aks/sentinelhid/%k"

# SENTINEL rules для второго серверного ключа добавить еще запись:
ACTION=="add|change|bind", SUBSYSTEM=="usb", ATTRS{idVendor}=="0529", ATTRS{idProduct}=="0004", KERNEL!="hiddev*", MODE="666", GROUP="plugdev", ENV{SENTINELHID}="1", SYMLINK+="aks/sentinelhid/%k"
 

$ sudo lxd init

Would you like to use LXD clustering? (yes/no) [default=no]:
Do you want to configure a new storage pool? (yes/no) [default=yes]:
Name of the new storage pool [default=default]:
Name of the storage backend to use (btrfs, dir, lvm) [default=btrfs]: dir
Would you like to connect to a MAAS server? (yes/no) [default=no]:
Would you like to create a new local network bridge? (yes/no) [default=yes]: no
Would you like to configure LXD to use an existing bridge or host interface? (yes/no) [default=no]: yes
Name of the existing bridge or host interface: br0
Would you like LXD to be available over the network? (yes/no) [default=no]:
Would you like stale cached images to be updated automatically? (yes/no) [default=yes]
Would you like a YAML "lxd init" preseed to be printed? (yes/no) [default=no]:


Восстановление на другом компьютере:
$ lxc image import /home/user/backup/ud1804-2019-11-10.tar.gz.tar.gz --alias ud1804-backup
Образ, импортирован с снимком: b900ce0db69f0a57afd52af682f8a47229b5ea8fcdfa2a566af2034a6f6766a2
$ lxc launch ud1804-backup ud1804
###$ lxc image delete ud1804-backup

$ lxc image import /home/user/backup/test-2019-11-12.tar.gz.tar.gz --alias test-backup
Образ, импортирован с снимком: f442e1c60b9c1353f3d665a61e67bb7c13d383fe65af530fbe7f482699233d5

$ lxc launch test-backup test
$ lxc config device add test hasp3 unix-char path=/dev/bus/usb/001/003 mode=0777
$ lxc config device add test hasp4 unix-char path=/dev/bus/usb/001/004 mode=0777
$ lxc config device add test aks2 unix-char path=/dev/aks/hasp/1-3 mode=0777
$ lxc config device add test aks3 unix-char path=/dev/aks/hasp/1-4 mode=0777
$ lxc config set test security.privileged true
$ printf 'lxc.cgroup.devices.allow = c 198:* rwm' | lxc config set test raw.lxc -

$ lxc config edit test
$ lxc restart test

 lxd на хосте


 lxd на virtualbox



Поскольку сервер рабочий настроим архивацию

Настройка Ubuntu 16.04, 18.04

$ sudo nano /etc/default/rsync

#RSYNC_ENABLE=false
RSYNC_ENABLE=true

Сохранить.


$ sudo nano /etc/rsyncd.conf

[backup]
# destination directory to copy

path = /home/user/Документы/Archiv
# hosts you allow to access

hosts allow = 192.168.0.0/255.255.255.0
hosts deny = *
list = true
uid = root
gid = root
read only = false

Сохранить.

$ sudo mkdir -p  /home/user/Документы/Archiv
$ sudo systemctl enable rsync
$ sudo systemctl start rsync


Под windows 10 :


Можно сделать один скрипт и поставить в планировщик:

ping -n 1 -w 1000 192.168.0.7|Find "TTL=">nul
If %ErrorLevel%==0 (
CALL d:\Copy\rsync\rsync -avz  /cygdrive/D/Copy/Archiv 192.168.0.7::backup --progress
) Else (
Echo Offline
)

 $ sudo crontab -e
@reboot fstrim / -v

Комментариев нет:

Отправить комментарий