.. _setup_os_requirements_debian: ============================ Setup OS Requirements Debian ============================ This section describes how to perform the setup for Debian Linux 10. The Peek platform is designed to run on Linux. Please read through all of the documentation before commencing the installation procedure. .. note:: These instructions are for Debian 10, AKA Buster Installation Objective ---------------------- This Installation Guide contains specific Debian Linux 10 operating system requirements for the configuring of synerty-peek. Required Software ````````````````` Some of the software to be installed requires internet access. For offline installation some steps are required to be installed on another online server for the files to be packaged and transferred to the offline server. Below is a list of all the required software: * Python 3.9.x * Postgres 12.x Suggested Software `````````````````` The following utilities are often useful. * rsync * git * unzip Optional Software ````````````````` - Oracle Client Installing Oracle Libraries is required if you intend on installing the peek agent. Instruction for installing the Oracle Libraries are in the Online Installation Guide. - FreeTDS FreeTDS is an open source driver for the TDS protocol, this is the protocol used to talk to the MSSQL SQLServer database. .. _debian_install_prerequisites: Installation Guide ------------------ Follow the remaining section in this document to prepare your debian operating system for to run the Peek Platform. The instructions on this page don't install the peek platform, that's done later. Install Debian 10 OS -------------------- This section installs the Debian 10 64bit Linux operating system. Create VM ````````` Create a new virtual machine with the following specifications * 4 CPUs * 8gb of ram * 60gb of disk space Install OS `````````` Download the debian ISO, navigate to the following site and click **amd64** under **netinst CD image** `Download Debian `_ ---- Mount the ISO in the virtual machine and start the virtual machine. Run through the installer manually, do not let your virtual machine software perform a wizard or express install. Staring Off ~~~~~~~~~~~ At the **Debian GNU/Linux installer boot menu** screen, select: :: Install ---- At the **Select a language** screen, select: :: English ---- At the **Select your location** screen, select the appropriate location. ---- At the **Configure the keyboard** screen, select the appropriate keyboard, or leave as default. ---- At the **Configure the network** screen, enter your desired hostname or: :: peek ---- At the **Configure the network** screen, enter your desired domain, or: :: localdomain ---- At the **Setup users and passwords screen**, watch for the following prompts, replace and with your desired passwords. .. csv-table:: Setup users and passwords screen prompts :header: "Prompt", "Enter :" :widths: auto "Root password", "" "Re-enter password to verify", "" "Full name for the new user", "Peek Platform" "Username for your account", "peek" "Choose a password for the new user:", "" "Re-enter password to verify:", "" ---- On the **Configure the clock** screen, select your desired timezone. ---- Partition Table ~~~~~~~~~~~~~~~ On the **Partition disks** screen, select: :: Manual Then, select the disk, it will look similar to: :: SCSI3 (0,0,0) (sda) - 32.2 GB VMware ... Then it will prompt to **Create new empty partition table on this device?**, select: :: We'll be creating three partitions, /boot / and swap. For a heavily used production server you may want to create more virtual disks and separate out /var, /home, and /tmp. With one file system per disk. Having one file system per disk removes the need for the overhead of LVM, and the VM software can still expand the disk and filesystem as required. /boot ~~~~~ Select the following disk from the menu: :: pri/log **.* GB FREE SPACE Enter the following responses to the prompts .. csv-table:: /boot partition prompts part1 :header: "Prompt", "Enter :" :widths: auto "How to user this free space", "Create a new partition" "New partition size", "500m" "Type for the new partition", "Primary" "Location for the new Partition", "Beginning" At the **Partition Settings** prompt, enter the following: .. csv-table:: /boot partition prompts part2 :header: "Prompt", "Enter :" :widths: auto "Use as:", "Ext2 file system" "Mount point", "/boot" "Done setting up the partition", "" swap ~~~~ Select the following disk from the menu: :: pri/log **.* GB FREE SPACE Enter the following responses to the prompts .. csv-table:: swap partition prompts part1 :header: "Prompt", "Enter :" :widths: auto "How to user this free space", "Create a new partition" "New partition size", "4g" "Type for the new partition", "Primary" "Location for the new Partition", "Beginning" At the **Partition Settings** prompt, enter the following: .. csv-table:: swap partition prompts part2 :header: "Prompt", "Enter :" :widths: auto "Use as:", "swap" "Done setting up the partition", "" / (root) ~~~~~~~~ The root file system is created at the end of the disk, ensuring that if we use the VM software to expand the virtual disk, this is the file system that will be expanded. The default guided install doesn't do this. ---- Select the following disk from the menu: :: pri/log **.* GB FREE SPACE Enter the following responses to the prompts .. csv-table:: swap partition prompts part1 :header: "Prompt", "Enter :" :widths: auto "How to user this free space", "Create a new partition" "New partition size", "100%" "Type for the new partition", "Primary" "Location for the new Partition", "Beginning" At the **Partition Settings** prompt, enter the following: .. csv-table:: swap partition prompts part2 :header: "Prompt", "Enter :" :widths: auto "Use as", "Ext4 journaling file system" "Mount point", "/" "Reserved blocks", "1%" "Done setting up the partition", "" ---- All done, select: :: Finish partitioning and write changes to disk ---- At the **Write the changes to disk?** prompt, Select: :: Finishing Up ~~~~~~~~~~~~ On the **Configure the package manager** screen, select the location closest to you. ---- At the **Debian archive mirror**, select your preferred site. ---- At the **HTTP proxy information** prompt, select: :: ---- The installer will now download the package lists. ---- At the **Configure popularity-contest** screen, select: :: .. note:: It'd be good to select , but as Peek is an enterprise platform, it's most likely installed behind a corporate firewall. ---- At the **Software selection** screen, select the following, and deselect all the other options: * SSH server * standard system utilities Optionally, select a desktop environment, Peek doesn't require this. "MATE" is recommended if one is selected. ---- The OS will now install, it will take a while to download and install the packages. ---- At the **Install the GRUB boot loader on a hard disk** screen, select: ---- At the **Device for boot loader installation** prompt, select: :: /dev/sda ---- At the **Finish the installation** screen, select: :: ---- Deconfigure the Debian ISO from DVD drive in the VM software. ---- The OS installtion is now complete. SSH Setup --------- SSH is this documentations method of working with the Peek Debian VM. SSH clients are availible out of the box with OSX and Linux. There are many options for windows users, This documentation recommends `MobaXterm `_ is used for windows as it also supports graphical file copying. This document assumes users are familair with what is required to use the SSH clients for connecting to and copying files to the Peek VM. If this all sounds too much, reinstall the Peek OS with a graphical desktop environment and use that instead of SSH. .. note:: You will not be able to login as root via SSH by default. ---- Login to the console of the Peek Debian VM as **root** and install ifconfig with the following command: :: apt-get install net-tools ---- Run the following command: :: ifconfig Make note of the ipaddress, you will need this to SSH to the VM. The IP addresss will be under **eth0**, second line, **inet addr**. ---- Install sudo with the following command: :: apt-get install sudo ---- Give Peek sudo privielges with the following command: :: usermod -a -G sudo peek ---- You must now logout from the root console. Login as Peek ------------- Login to the Debian VM as the :code:`peek` user, either via SSH, or the graphical desktop if it's installed. .. important:: All steps after this point assume you're logged in as the peek user. Configure Static IP (Optional) ------------------------------ If this is a production server, it's more than likely that you want to assign a static IP to the VM, Here is how you do this. ---- Edit file :file:`/etc/network/interfaces` Find the section: :: allow-hotplug eth0 iface eth0 inet dhcp Replace it with: :: auto eth0 iface eth0 inet static address netmask gateway ---- Edit the file :file:`/etc/resolv.conf`, and update it. #. Replace "localdomain" with your domain #. Replace the IP for the :code:`nameserver` with the IP of you DNS. For multiple name servers, use multiple :code:`nameserver` lines. :: domain localdomain search localdomain nameserver 172.16.40.2 Installing General Prerequisites -------------------------------- This section installs the OS packages required. .. note:: Run the commands in this step as the :code:`peek` user. ---- Install the C Compiler package, used for compiling python or VMWare tools, etc: :: PKG="gcc make linux-headers-amd64" sudo apt-get install -y $PKG ---- Install some utility packages: :: PKG="rsync unzip wget git" sudo apt-get install -y $PKG ---- Install the Python build dependencies: :: PKG="build-essential curl git m4 ruby texinfo libbz2-dev libcurl4-openssl-dev" PKG="$PKG libexpat-dev libncurses-dev zlib1g-dev libgmp-dev libssl-dev" sudo apt-get install -y $PKG ---- Install the Postgres build dependencies: :: PKG="bison flex" PKG="$PKG libreadline-dev python-dev" sudo apt-get install -y $PKG ---- Install Libs that some python packages link to when they install: :: # For the cryptography package PKG="libffi-dev" sudo apt-get install -y $PKG ---- Install Libs required for LDAP: :: PKG="libsasl2-dev libldap-common libldap2-dev" sudo apt-get install -y $PKG ---- Install Libs that database access python packages link to when they install: :: # For Shapely and GEOAlchemy PKG="libgeos-dev libgeos-c1v5" # For the PostGresQL connector PKG="$PKG libpq-dev" # For the SQLite python connector PKG="$PKG libsqlite3-dev" sudo apt-get install -y $PKG ---- Install Libs that the oracle client requires: :: # For LXML and the Oracle client PKG="libxml2 libxml2-dev" PKG="$PKG libxslt1.1 libxslt1-dev" PKG="$PKG libaio1 libaio-dev" sudo apt-get install -y $PKG ---- Cleanup the downloaded packages :: sudo apt-get clean Installing VMWare Tools (Optional) ---------------------------------- This section installs VMWare tools. The compiler tools have been installed from the section above. ---- In the VMWare software, find the option to install VMWare tools. ---- Mount and unzip the tools :: sudo rm -rf /tmp/vmware-* sudo mount /dev/sr0 /mnt sudo tar xzf /mnt/VM*gz -C /tmp sudo umount /mnt ---- Install the tools with the default options :: cd /tmp/vmware-tools-distrib sudo ./vmware-install.pl -f -d ---- Cleanup the tools install :: sudo rm -rf /tmp/vmware-* ---- Reboot the virtual machine. :: sudo shutdown -r now Keep in mind, that if the static IP is not set, the IP address of the VM may change, causing issues when reconnecting with SSH. .. _debian_setup_bashrc: Preparing .bashrc ----------------- .. warning:: Open :file:`~/.bashrc` insert the following at the start, before: :: # If not running interactively, don't do anything If you do not place the below code before that line, it will not be parsed. :: ##### SET THE PEEK ENVIRONMENT ##### # Setup the variables for PYTHON and POSTGRESQL export PEEK_PY_VER="3.9.1" export PEEK_TSDB_VER="1.7.4" export PGDATA=~peek/pgdata/12 export PATH="$HOME/opt/bin:$PATH" export LD_LIBRARY_PATH="$HOME/opt/lib:$LD_LIBRARY_PATH" # Set the variables for the platform release # These are updated by the deploy script export PEEK_ENV="" [ -n "${PEEK_ENV}" ] && export PATH="${PEEK_ENV}/bin:$PATH" ---- .. warning:: Restart your terminal to get the new environment. Compile and Install Python 3.9.1 -------------------------------- The Peek Platform runs on Python. These instructions download, compile and install the latest version of Python. ---- Download and unarchive the supported version of Python: :: cd source .bashrc wget https://github.com/python/cpython/archive/v${PEEK_PY_VER}.zip unzip v${PEEK_PY_VER}.zip cd cpython-${PEEK_PY_VER} ---- Configure the build: :: ./configure --prefix=/home/peek/opt/ --enable-optimizations --enable-shared ---- Make and Make install the software: :: make install ---- Cleanup the download and build dir: :: cd rm -rf cpython-${PEEK_PY_VER} rm v${PEEK_PY_VER}.zip ---- Symlink the python3 commands so they are the only ones picked up by path: :: cd /home/peek/opt/bin ln -s pip3 pip ln -s python3 python cd ---- Test that the setup is working: :: RED='\033[0;31m' GREEN='\033[0;32m' NC='\033[0m' # No Color SHOULD_BE="/home/peek/opt/bin/python" if [ `which python` == ${SHOULD_BE} ] then echo -e "${GREEN}SUCCESS${NC} The python path is right" else echo -e "${RED}FAIL${NC} The python path is wrong, It should be ${SHOULD_BE}" fi SHOULD_BE="/home/peek/opt/bin/pip" if [ `which pip` == ${SHOULD_BE} ] then echo -e "${GREEN}SUCCESS${NC} The pip path is right" else echo -e "${RED}FAIL${NC} The pip path is wrong, It should be ${SHOULD_BE}" fi ---- Upgrade pip: :: pip install --upgrade pip ---- synerty-peek is deployed into python virtual environments. Install the virtualenv python package: :: pip install virtualenv ---- The Wheel package is required for building platform and plugin releases: :: pip install wheel .. _debian_install_postgresql: Install PostgreSQL ------------------ Install the relational database Peek stores its data in. This database is PostgreSQL 12. .. note:: Run the commands in this step as the :code:`peek` user. Download the PostgreSQL source code :: PEEK_PG_VER=12.5 SRC_DIR="$HOME/postgresql-${PEEK_PG_VER}" # Remove the src dir and install file rm -rf ${SRC_DIR} || true cd $HOME wget https://ftp.postgresql.org/pub/source/v${PEEK_PG_VER}/postgresql-${PEEK_PG_VER}.tar.bz2 tar xjf postgresql-${PEEK_PG_VER}.tar.bz2 cd ${SRC_DIR} ---- Configure and build PostGresQL :: export CPPFLAGS=" -I`echo $HOME/opt/include/python*m` " export LDFLAGS=" -L$HOME/opt/lib " ./configure \ --disable-debug \ --prefix=$HOME/opt \ --enable-thread-safety \ --with-openssl \ --with-python make -j4 make install-world # this is required for timescale to compile cp ${SRC_DIR}/src/test/isolation/pg_isolation_regress ~/opt/bin ---- Remove install files to clean up the home directory :: # Remove the src dir and install file cd rm -rf ${SRC_DIR}* ---- Initialise a PostgreSQL database :: #Refresh .bashrc so initdb can find postgres source .bashrc initdb --pgdata=$HOME/pgdata/12 --auth-local=trust --auth-host=md5 ---- Tune the :file:`postgresql.conf` :: F="$HOME/pgdata/12/postgresql.conf" sed -i 's/max_connections = 100/max_connections = 200/g' $F ---- Make PostgreSQL a service : .. note:: This will require sudo permissions Run the following command :: touch postgresql-12.service F=postgresql-12.service cat <<"EOF" | sed "s,\$HOME,`echo ~peek`,g" > $F [Unit] Description=PostgreSQL 12 database server After=syslog.target After=network.target [Service] Type=forking User=peek Group=peek # Location of database directory Environment=PGDATA=$HOME/pgdata/12 # Disable OOM kill on the postmaster OOMScoreAdjust=-1000 Environment=PG_OOM_ADJUST_FILE=/proc/self/oom_score_adj Environment=PG_OOM_ADJUST_VALUE=0 ExecStart=$HOME/opt/bin/pg_ctl -D ${PGDATA} start ExecStop=$HOME/opt/bin/pg_ctl -D ${PGDATA} stop ExecReload=/bin/kill -HUP $MAINPID KillMode=mixed KillSignal=SIGINT # Do not set any timeout value, so that systemd will not kill postmaster # during crash recovery. TimeoutSec=0 [Install] WantedBy=multi-user.target EOF sudo mv $F /etc/systemd/system/postgresql-12.service ---- Reload the daemon :: sudo systemctl daemon-reload Install CMake ````````````` Download CMake source code:: PEEK_CMAKE_VER=3.19.2 SRC_DIR="$HOME/CMake-${PEEK_CMAKE_VER}" wget https://github.com/Kitware/CMake/archive/v${PEEK_CMAKE_VER}.zip unzip v${PEEK_CMAKE_VER}.zip cd ${SRC_DIR} Compile CMake from source:: ./configure --prefix=$HOME/opt make -j6 install # Remove the src dir and install file cd rm -rf ${SRC_DIR}* rm v${PEEK_CMAKE_VER}.zip Install PostgreSQL Timescaledb `````````````````````````````` Next install timescaledb, this provides support for storing large amounts of historical data. `www.timescale.com `_ ---- Download the timescaledb source code :: PEEK_TSDB_VER=1.7.4 cd wget https://github.com/timescale/timescaledb/archive/${PEEK_TSDB_VER}.zip unzip ${PEEK_TSDB_VER}.zip cd timescaledb-${PEEK_TSDB_VER} ---- Install the packages: :: export CPPFLAGS=`pg_config --cppflags` export LDFLAGS=`pg_config --ldflags` # Bootstrap the build system ./bootstrap -DAPACHE_ONLY=1 # To build the extension cd build && make # To install make install # Cleanup the source code cd rm -rf ${PEEK_TSDB_VER}.zip rm -rf timescaledb-${PEEK_TSDB_VER} ---- Add the timescale repository: :: curl -s https://packagecloud.io/install/repositories/timescale/timescaledb/script.deb.sh | sudo bash ---- Install timescaledb-tune: :: sudo apt install -y timescaledb-tools ---- Tune the database: :: PGVER=12 FILE="$HOME/pgdata/${PGVER}/postgresql.conf" timescaledb-tune -quiet -yes -conf-path ${FILE} -pg-version ${PGVER} ---- Start PostgreSQL: :: systemctl enable postgresql-12 --now Finish PostgreSQL Setup ```````````````````````` Finish configuring and starting PostgreSQL. ---- Allow the peek OS user to login to the database as user peek with no password :: F=$HOME/pgdata/12/pg_hba.conf cat | sudo tee $F < ~/freetds/freetds.conf <