====== Firebird3 ======
===== Instalace Windows =====
* rozzipovat Firebird-3.0.8.33535-0_x64.zip
* spustit jako Admin cmd
* install_service.bat
* isql -user sysdba employee
* create user SYSDBA password 'SomethingCryptic'; commit; exit;
* povolit firewall port 3050
===== Instalace Linux =====
* nastavit [[:firebird:setenv|.obis_profile + .bashrc]]
apt install zsh
useradd -m -g users -G sudo -s /bin/zsh obis
passwd obis
#pridat contrib do /etc/apt/sources.list
sudo apt update
sudo apt-get install libtommath1 libncurses5 vim mc unzip lftp ttf-mscorefonts-installer liblua5.3-0
cd /usr/lib/x86_64-linux-gnu/
sudo ln -s libtommath.so.1 libtommath.so.0
sudo dpkg-reconfigure locales
cd /tmp
wget https://github.com/FirebirdSQL/firebird/releases/download/... #http://firebirdsql.org/en/firebird-3-0/
tar -xzvf Firebird-3.0
cd /tmp/Firebird-3.0
sudo ./install.sh #nastavuje heslo sysdba
sudo systemctl status firebird-superserver.service
sudo /opt/firebird/bin/changeServerMode.sh
sudo vim /lib/systemd/system/firebird-classic.socket #zmenit post 3050
sudo systemctl restart firebird-classic.socket
echo "show version;" | isql localhost:employee
sudo usermod -d /home/firebird firebird
sudo mkdir -p /home/firebird/fdbs
sudo chown firebird:firebird /home/firebird -R
sudo chmod g+rwX /home/firebird/fdbs
sudo tar -xzvf /tmp/data.tar.gz -C /home/firebird/fdbs
sudo chown firebird:firebird /home/firebird -R
sudo usermod -a -G firebird obis
isql localhost:/home/firebird/fdbs/licence.fdb
isql /home/firebird/fdbs/licence.fdb
==== OBIS ====
unzip install/obis-client-64bit.zip
tar -xzvf install/obis-client-64bit.tar.gz
vim etc/obisrc.xml
cd lualib5.3/lib/x86_64-Linux
ln -s ssl.so.3.0.0 ssl.so
ln -s openssl.so.3.0.0 openssl.so
./bin64/passwd -dbpass $ISC_PASSWORD
./bin64/licencec -list
==== SAMBA ====
sudo apt-get install samba
sudo vim /etc/samba/smb.conf
sudo smbpasswd -a obis
sudo systemctl restart smbd.service
** smb.conf**
preserve case = yes
[obis]
comment = Obis
path = /mnt/data/obis5
writeable = yes
create mode = 664
directory mode = 775
guest ok = no
#valid users = @users
[obisdoc]
comment = Obis dokumenty
path = /mnt/data/obisdoc
writeable = yes
create mode = 664
directory mode = 775
guest ok = no
#valid users = @users
===== Instalace/upgrade FB2->3 Linux =====
* **nejprve zazalohovat databaze pomoci gbak 2.5**, po instalaci FB3 se restoruje pomoci gbak 3
sudo apt-get install libtommath1 libncurses5
cd /usr/lib/x86_64-linux-gnu/
sudo ln -s libtommath.so.1 libtommath.so.0
sudo systemctl stop cron
wget https://github.com/FirebirdSQL/firebird/releases/download/... #https://firebirdsql.org/en/firebird-3-0/
tar -xzvf Firebird-3.0
cd /tmp/Firebird-3.0
gbak -V localhost:/home/firebird/licence.fdb /mnt/backup/licence25.fbk
gbak -V localhost:/home/firebird/data.fdb /mnt/backup/data25.fbk
sudo mv /etc/xinetd.d/firebird /$HOME/
sudo systemctl restart xinetd.service
sudo systemctl status xinetd.service
sudo mv /opt/firebird /opt/firebird25.bk
sudo killall fb_inet_server
sudo ./install.sh #nastavuje heslo sysdba
sudo systemctl status firebird-superserver.service
sudo /opt/firebird/bin/changeServerMode.sh
sudo systemctl status firebird-classic.socket
echo "show version;" | isql localhost:employee.fdb
sudo mv /home/firebird/*.fdb /tmp/
gbak -R -V /mnt/backup/licence25.fbk localhost:/home/firebird/licence.fdb
gbak -R -V /mnt/backup/data25.fbk localhost:/home/firebird/data.fdb
sudo systemctl start cron
sudo systemctl status cron
**Změna hesla sysdba**
alter user sysdba password 'heslo';
select SEC$USER_NAME, SEC$PLUGIN from sec$users;
===== SLES 15 =====
* FB3 vyzaduje ICU 52, ktere neni v repo (nelze instalovat z tar.gz)
sudo zypper install firebird
===== Script na vytvoreni backup a restore scriptu DB ODS 11->12 =====
**create_fbupgrade_scripts.sh**
#!/bin/bash
#etc/obisrc.xml - presunout data.fdb na prvni misto
#uzivatel musi mit pravo zapisu do /firebird/fdbs - jinak nejede restore rychle lokalne ale pomalu pres remote
#vytvoreni scriptu pro prevod: create_fbupgrade_scripts.sh [-d dataname] [/tmp/firebird64] #pro pomocnou embed verzi 2.5 - prevod zapomenutych DB
#nasledne pouziti: [dellog_all_db.sh]; backup_all_db.sh; move_all_db.sh; instalace FB3; restore_all_db.sh
#vytvoreni /tmp/firebird64 - verze 2.5 embed pro zapomenute databaze:
# cd /tmp/
# lftp ftp.epos.cz -e "get obis/firebird-clients/259/linux64-embed.tgz; exit"
# tar -xzvf linux64-embed.tgz
#zkopirovat DB do /tmp/data.fdb
#./create_fbupgrade_scripts.sh -d data-tmp /home/kaja/obis4git/firebird25
# nasledne: backup_restore_all_db.sh
#databaze velikost 1.6GB backup 60sec, restore 100sec, backup+restore 100sec (dellog_all_db zrychluje minimalne - 15sec)
. `dirname $0`/setenv.sh
[ -d $BACKUPPATH ] || echo "ERROR: BACKUPPATH "$BACKUPPATH" neexistuje"
[ -d $SCRIPTSDIR ] || echo "ERROR: SCRIPTSDIR "$SCRIPTSDIR" neexistuje"
touch $DATABASEPATH/fb3_upgrade
if [ $? -ne 0 ]; then
echo "ERROR: nelze zapisovat do $DATABASEPATH"
fi
if [ "$1" = "-d" ]; then
`$ROOTDIR/bin64/loginc -syspass "$SYSPASS" -dataname $2 -exec "$ROOTDIR/bin64/setisc.sh"`
ALLDB="$ISC_DATABASE"
shift 2
else
`$ROOTDIR/bin64/loginc -syspass "$SYSPASS" -licence -exec "$ROOTDIR/bin64/setisc.sh"`
LICDB=$ISC_DATABASE
`$ROOTDIR/bin64/loginc -syspass "$SYSPASS" -alldata -exec "$ROOTDIR/bin64/setisc.sh"`
ALLDB="$LICDB;$ISC_DATABASE"
fi
#echo $ALLDB
DELLOGSCRIPT=$SCRIPTSDIR/dellog_all_db.sh
BACKUPSCRIPT=$SCRIPTSDIR/backup_all_db.sh
MOVESCRIPTS=$SCRIPTSDIR/move_all_db.sh
RESTORESCRIPT=$SCRIPTSDIR/restore_all_db.sh
echo "#!/bin/sh" | tee $DELLOGSCRIPT $BACKUPSCRIPT $MOVESCRIPTS $RESTORESCRIPT > /dev/null
chmod +x $DELLOGSCRIPT $BACKUPSCRIPT $MOVESCRIPTS $RESTORESCRIPT
if [ "$1" = "" ]; then
FBOLD=$FIREBIRD
else
FBOLD=$1
echo "export FIREBIRD=$FBOLD" | tee -a $DELLOGSCRIPT $BACKUPSCRIPT > /dev/null
echo "export LD_LIBRARY_PATH=$FBOLD/lib" | tee -a $DELLOGSCRIPT $BACKUPSCRIPT > /dev/null
BACKUPRESTORESCRIPT=$SCRIPTSDIR/backup_restore_all_db.sh
echo "#!/bin/sh" > $BACKUPRESTORESCRIPT
chmod +x $BACKUPRESTORESCRIPT
shift
fi
FBNEW=$FIREBIRD
while IFS=';' read -ra DBS; do
for DB in "${DBS[@]}"; do
LOCDB=${DB#*:}
DBFN=`basename $LOCDB .fdb`
cat <> $DELLOGSCRIPT
LIMIT=100
echo "delete log $LOCDB"
echo "delete from common_log where datum>$BACKUPSCRIPT
echo "backup $LOCDB log /tmp/$DBFN-25.log"
rm -f /tmp/$DBFN-25.log
$FBOLD/bin/gbak -z -b -g -v -y /tmp/$DBFN-25.log $LOCDB $BACKUPPATH/$DBFN.fbk
ls -lh $BACKUPPATH/$DBFN.fbk
EOF
cat <>$MOVESCRIPTS
mv $LOCDB $BACKUPPATH/$DBFN.ods11.fdb
ls -lh $BACKUPPATH/$DBFN.ods11.fdb
EOF
cat <>$RESTORESCRIPT
echo "restore $LOCDB log /tmp/$DBFN-30.log"
rm -f /tmp/$DBFN-30.log
$FBNEW/bin/gbak -z -c -v -y /tmp/$DBFN-30.log $BACKUPPATH/$DBFN.fbk $LOCDB
sudo chown firebird:firebird $LOCDB
echo "show version;" | $FBNEW/bin/isql $DB | tail -n 1
EOF
if [ "$BACKUPRESTORESCRIPT" != "" ]; then
cat <>$BACKUPRESTORESCRIPT
echo "backup + restore $LOCDB log /tmp/$DBFN-25.log /tmp/$DBFN-30.log"
rm -f /tmp/$DBFN-25.log /tmp/$DBFN-30.log
mv $LOCDB $LOCDB.ods11
FIREBIRD=$FBOLD LD_LIBRARY_PATH=$FBOLD/lib $FBOLD/bin/gbak -z -b -g -v -y /tmp/$DBFN-25.log $LOCDB.ods11 stdout | pv | $FBNEW/bin/gbak -z -c -v -y /tmp/$DBFN-30.log stdin $LOCDB
sudo chown firebird:firebird $LOCDB
echo "show version;" | $FBNEW/bin/isql $DB | tail -n 1
EOF
fi
done
done <<< "$ALLDB"
cat << EOF | tee -a $RESTORESCRIPT $BACKUPRESTORESCRIPT > /dev/null
echo "Vytvarim zalohy backup-firebird 0-2"
sudo -u firebird $SCRIPTSDIR/backup-firebird.sh 0
sudo -u firebird $SCRIPTSDIR/backup-firebird.sh 1
sudo -u firebird $SCRIPTSDIR/backup-firebird.sh 2
EOF
===== Prevod zapomenutych databazi ODS 11.2->12 po instalaci FB3 =====
* [[https://ib-aid.com/en/articles/fast-conversion-of-firebird-2-5-databases-to-firebird-3/]]
* [[http://www.ibphoenix.com/files/Embedded_fb3.pdf]]
* pro embed firebird 3 se NENASTAVUJE promenna FIREBIRD
cd /tmp/
lftp ftp.epos.cz -e "get obis/firebird-clients/259/linux64-embed.tgz; exit"
tar -xzvf linux64-embed.tgz
export FIREBIRD=/tmp/firebird64
export LD_LIBRARY_PATH=/tmp/firebird64/lib
/tmp/firebird64/bin/gbak -B /tmp/datapok2.fdb stdout | /opt/firebird/bin/gbak -R -V stdin /tmp/datapok3.fdb
FB_3_Migration_Guide_rev120.pdf
===== Nastavení kompatibility =====
firebird.conf
#Kompatibilita s klienty v2.5
AuthServer = Srp, Legacy_Auth
UserManager = Srp, Legacy_UserManager
WireCrypt = Enabled
#Pro testování
RemoteServicePort = 3055
Nastavení hesla pro uživatele SYSDBA
service firebird-superserver stop
isql -u SYSDBA security3.fdb
#pro klienty v2.5
ALTER USER SYSDBA PASSWORD 'Heslo' USING PLUGIN Legacy_UserManager;
#pro klienty v3
ALTER USER SYSDBA PASSWORD 'Heslo' USING PLUGIN Srp;
COMMIT;
#seznam uživatelů
SELECT * FROM SEC$USERS;
service firebird-superserver start
===== Klient =====
apt-get install libtommath0
===== Převod zpět ODS 12->11.2 =====
* pomoci gbak z FB3 backup/restore z FB3 na FB2.5 přes remote protokol
* :!: nezapomenout explicitně napsat port 3050 při restore (jinak gbak z 3.5 použije port z FB3/firebird.conf)
* při povoleni legacy auth lze použít i gbak z FB2.5