пятница, 19 июля 2019 г.

Тестовый сервер test2 настройка 1с

Тестовый сервер test2 базовая настройка
Тестовый сервер test2 настройка PostgreSQL и pg_probackup

В папку /test положить файлы:
deb64_8_3_13_1690.tar.gz

# установка 1с
$ mkdir -p /tmp/1ctmp
$ cd /tmp/1ctmp
$ sudo apt install imagemagick -y
#$sudo apt install -y unixodbc libgsf-1-114 libglib2.0
$ sudo apt install libfreetype6 libgsf-1-common unixodbc glib2.0
#ubuntu
$ sudo  apt install -y xfonts-utils cabextract
$ sudo apt install ttf-mscorefonts-installer -y
$  ls /home/user/test/
$ cp /home/user/test/deb64_8_3_13_1690.tar.gz /tmp/1ctmp
$ tar xvzf deb64_8_3_13_1690.tar.gz
$ sudo dpkg -i 1c-enterprise83-common_8.3.13-1690_amd64.deb
$ sudo dpkg -i 1c-enterprise83-server_8.3.13-1690_amd64.deb
#$ sudo dpkg -i 1c-enterprise83-ws_8.3.13-1690_amd64.deb
#$ sudo apt -f -y install
$ sudo chown -R usr1cv8:grp1cv8 /opt/1C
$ sudo echo -e "pass\npass\n" | sudo passwd usr1cv8
$ sudo service srv1cv83 start
$ sudo service srv1cv83 status
#$ sudo usermod -aG sudo usr1cv8

$ sudo  apt install -y libc6-i386
$ mkdir /tmp/hasp
$ cd /tmp/hasp
$ wget http://download.etersoft.ru/pub/Etersoft/HASP/last/x86_64/Ubuntu/16.04/haspd-modules_7.90-eter2ubuntu_amd64.deb  $ wget http://download.etersoft.ru/pub/Etersoft/HASP/last/x86_64/Ubuntu/16.04/haspd_7.90-eter2ubuntu_amd64.deb

$ sudo dpkg -i *.deb
#$ sudo apt-get install -f -y
$ sudo service haspd start
$ sudo service haspd status
$ sudo reboot

$ sudo service srv1cv83 status
$ ss -tlnp | grep :15
LISTEN     0      128          *:1560                     *:*
LISTEN     0      128          *:1540                     *:*
LISTEN     0      128          *:1541                     *:*
LISTEN     0      128         :::1560                    :::*
LISTEN     0      128         :::1540                    :::*
LISTEN     0      128         :::1541                    :::*


Не встал скриптом imagemagick?
Без строчки ниже будет ругаться при входе в 1с
$ sudo apt-get install imagemagick  -y

Для программной лицензии (прявязанной к hasp)

в /var/1C/licenses
Положить лицензию


$ sudo mv 20190207114003.lic /var/1C/licenses







======================================================

 Настройка технологического журнала

$ sudo mkdir /var/log/1c
$ sudo chown usr1cv8 /var/log/1c

$ sudo touch /opt/1C/v8.3/x86_64/conf/logcfg.xml
$ chmod 644 /opt/1C/v8.3/x86_64/conf/logcfg.xml
$ sudo nano /opt/1C/v8.3/x86_64/conf/logcfg.xml

<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://v8.1c.ru/v8/tech-log">
    <log history="24" location="/var/log/1C/common">
    <event>
      <eq property="Name" value="ADMIN"/>
    </event>
    <event>
      <eq property="Name" value="ATTN"/>
    </event>
    <event>
      <eq property="Name" value="CLSTR"/>
    </event>
    <event>
      <eq property="Name" value="CONN"/>
    </event>
    <event>
      <eq property="Name" value="EXCP"/>
    </event>
    <event>
      <eq property="RetExcp" value=""/>
    </event>
    <event>
      <ne property="RetExcp" value=""/>
    </event>
    <event>
      <eq property="Name" value="EXCPCNTX"/>
    </event>
    <event>
      <eq property="Name" value="PROC"/>
    </event>
        <property name="all"/>
    </log>
</config>

Сохранить.

Другой вариант:

<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://v8.1c.ru/v8/tech-log">
        <log location="/home/usr1cv8/log" history="96">
                <event>
                        <eq property="name" value="DBPOSTGRS"/>
                </event>
                <event>
                        <eq property="name" value="SDBL"/>
                </event>
                <event>
                        <eq property="name" value="EXCP"/>
                </event>
                <property name="all"/>
        </log>
</config>
Сохранить.

Другой вариант:

<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://v8.1c.ru/v8/tech-log">
        <log location="/home/usr1cv8/log" history="96">
                <event>
                        <ne property="name" value="DB2" />
                        <ne property="name" value="DBMSSQL" />
                        <ne property="name" value="DBMSSQLCONN" />
                        <ne property="name" value="DBORACLE" />
                        <ne property="name" value="DBPOSTGRS" />
                        <ne property="name" value="DBV8DBENG" />
                        <ne property="name" value="SDBL" />
                        <ne property="name" value="MEM" />
                        <ne property="name" value="TLOCK" />
                        <ne property="name" value="SRVC" />
                        <ne property="name" value="CALL" />
                        <ne property="name" value="CONN" />
                        <ne property="name" value="SCALL" />
                        <ne property="name" value="SCOM" />
                        <ne property="name" value="VRSREQUEST" />
                        <ne property="name" value="VRSRESPONSE" />
                </event>
                <property name="all" />
        </log>
</config>
====================================================== 

Настройка дампов

$ sudo mkdir -p /dumps
$ sudo chown -R usr1cv8:grp1cv8 /dumps
$ echo 'usr1cv8 soft core unlimited' | sudo tee -a /etc/security/limits.conf
$ echo 'usr1cv8 hard core unlimited' | sudo tee -a /etc/security/limits.conf
$ echo 'kernel.core_pattern=/dumps/core.%e.%p ' | sudo tee -a /etc/sysctl.conf
$ sudo sysctl -p
#$ sudo usermod -aG sudo usr1cv8
======================================================
Скрипт pg_dump для всех баз postgresql


$ sudo mkdir -p /backup/pg_dump
$ sudo nano /root/backup-sql.sh

#!/bin/sh
# crontab -e
# mkdir -p /backup/pg_dump
set -e

BACKUP_DIR="/backup/pg_dump"
#DIR_YANDEX="/backup/pg_dump/yandex"
echo "====================================================================" > $BACKUP_DIR/backup.log
# останавливаем сервер 1С
echo "останавливаем сервер 1С"
sudo systemctl stop  srv1cv83.service
echo "состояние сервера 1С"  >> $BACKUP_DIR/backup.log
sudo systemctl status  srv1cv83.service | grep 'Active:' >> $BACKUP_DIR/backup.log
echo "--------------------------------------------------------------------" >> $BACKUP_DIR/backup.log
# Устанавливаем дату
DATA=`date +"%Y-%m-%d_%H-%M-%S"`
DATA_NAME=`date +"%Y-%m-%d_%H-%M-%S"`
echo "$DATA Size database file: " >> $BACKUP_DIR/backup.log
sudo du -h -s /var/lib/postgresql/10/main/base  >> $BACKUP_DIR/backup.log
echo "--------------------------------------------------------------------" >> $BACKUP_DIR/backup.log
# делаем  backup
DB_BASE=`sudo /bin/su postgres -c "/usr/bin/psql -qAt -c 'SELECT * FROM pg_database;'" | \
     cut -d"|" -f1 | /bin/grep -v template | /bin/grep -v postgres`
#DB_BASE="demo test" #конкретные базы
#DB_BASE="" #пропустить
echo $DB_BASE
for DB_NAME in $DB_BASE
 do
     DATA=`date +"%Y-%m-%d_%H-%M-%S"`
     # Записываем информацию в лог с секундами
     echo "$DATA Начало backup базы ${DB_NAME}" >> $BACKUP_DIR/backup.log
     # Бэкапим базу данных demo и сразу сжимаем
     echo "$DATA Начало backup базы ${DB_NAME}"
     sudo /bin/su postgres -c "pg_dump -Fc ${DB_NAME}"  > $BACKUP_DIR/${DB_NAME}_$DATA_NAME.dump
     DATA=`date +"%Y-%m-%d_%H-%M-%S"`
     if [ $? -ne 0 ]
     then
         echo "$DATA Ошибка завершения backup для базы ${DB_NAME}"
         echo "$DATA Ошибка завершения backup для для базы ${DB_NAME}" >> $BACKUP_DIR/backup.log
         exit
     else
          echo "$DATA Успешное завершение backup для базы ${DB_NAME}"
          echo "$DATA Успешное завершение backup для базы ${DB_NAME}" >> $BACKUP_DIR/backup.log
     fi
     echo "--------------------------------------------------------------------" >> $BACKUP_DIR/backup.log
done

# запускаем сервер 1С
echo "Запускаем сервер 1С"
sudo systemctl start  srv1cv83.service
echo "Состояние сервера 1С"  >> $BACKUP_DIR/backup.log
sudo systemctl status  srv1cv83.service | grep 'Active:' >> $BACKUP_DIR/backup.log
echo "--------------------------------------------------------------------" >> $BACKUP_DIR/backup.log
echo "Закончено"
cat $BACKUP_DIR/backup.log >> $BACKUP_DIR/backupall.log
# посылаем сообщение
sleep 2
echo "backup" | mutt -s "backup"  f2@vt.com -a $BACKUP_DIR/backup.log


Сохранить.

$ sudo crontab -e

*/15 * * * * sudo sh /root/sysinfo.sh
00 3 * * * sh /root/fullbackup.sh
*/1 * * * *  sudo sh /root/session.sh
59 23 * * * sudo sh /root/mailses.sh
00 5 * * * sh /root/backup-sql.sh

Сохранить.
======================================================
Скрипт убить сессии

$ sudo nano /root/terminate.sh

#!/bin/bash
if ! pgrep 'ras'; then sudo su usr1cv8 -c "/opt/1C/v8.3/x86_64/ras --daemon cluster"; fi
sleep 5
_cluster=$(/opt/1C/v8.3/x86_64/rac cluster list  | grep 'cluster'| awk -F' ' '{print $3}')
_base=$(/opt/1C/v8.3/x86_64/rac infobase --cluster=$_cluster summary list | grep 'infobase '| awk '{print$3}')
_session=$(/opt/1C/v8.3/x86_64/rac session --cluster=$_cluster list | grep 'session '| awk '{print$3}')
echo 'кластер: ' $_cluster
echo 'базы: ' $_base
echo 'сессии:  ' $_session
for session in $_session
do
/opt/1C/v8.3/x86_64/rac session --cluster=$_cluster terminate --session=$session
done
_session=$(/opt/1C/v8.3/x86_64/rac session --cluster=$_cluster list | grep 'session '| awk '{print$3}')
echo 'сессии:  ' $_session

Сохранить.
======================================================
Скрипт sysinfo.sh

$ sudo nano /root/sysinfo.sh

#!/bin/sh
# Устанавливаем дату
DATA=`date +"%Y-%m-%d_%H-%M"`
#FILE= 'sys_$DATA.txt'
echo  $DATA  > sysinfo.txt
#echo  '12345'  > sys_$DATA.txt
echo "---------------------------------------------------------------------------------------" >> sysinfo.txt
echo "uptime" >> sysinfo.txt
uptime >> sysinfo.txt
echo "---------------------------------------------------------------------------------------" >> sysinfo.txt
echo "free -m" >> sysinfo.txt
free -m >> sysinfo.txt
echo "---------------------------------------------------------------------------------------" >> sysinfo.txt
echo "df -h" >> sysinfo.txt
df -h >> sysinfo.txt
echo "---------------------------------------------------------------------------------------" >> sysinfo.txt
echo "Размер папки с логами postgresql:" >> sysinfo.txt
echo "du -h -s /var/lib/postgresql/10/main/pg_log" >> sysinfo.txt
du -h -s /var/lib/postgresql/10/main/pg_log  >> sysinfo.txt
echo "---------------------------------------------------------------------------------------" >> sysinfo.txt
echo "Размер папки с базами postgresql:" >> sysinfo.txt
echo "du -h -s /var/lib/postgresql/10/main/base" >> sysinfo.txt
du -h -s /var/lib/postgresql/10/main/base  >> sysinfo.txt
echo "---------------------------------------------------------------------------------------" >> sysinfo.txt
echo "Размер папки с логами технологического журнала 1с:" >> sysinfo.txt
echo "du -h -s  /home/usr1cv8/log" >> sysinfo.txt
#du -h -s  /home/usr1cv8/log  >> sysinfo.txt
echo "---------------------------------------------------------------------------------------" >> sysinfo.txt
echo "Размер папки с dumps 1с:" >> sysinfo.txt
#echo "du -h -s  /dumps" >> sysinfo.txt
echo "du -h -s  /home/usr1cv8/dumps" >> sysinfo.txt
#du -h -s  /dumps  >> sysinfo.txt
#du -h -s  /home/usr1cv8/dumps  >> sysinfo.txt
echo "---------------------------------------------------------------------------------------" >> sysinfo.txt
echo "sensors" >> sysinfo.txt
sensors >> sysinfo.txt
echo "---------------------------------------------------------------------------------------" >> sysinfo.txt
echo "iostat -xz" >> sysinfo.txt
iostat -xz >> sysinfo.txt
echo "---------------------------------------------------------------------------------------" >> sysinfo.txt
echo "sar -r 1 1" >> sysinfo.txt
sar -r 1 1 >> sysinfo.txt
echo "---------------------------------------------------------------------------------------" >> sysinfo.txt
#echo "ps aux --sort -%mem | awk '{print $6/1024 " MB\t\t" $11}' | head -n10" >> sysinfo.txt
#ps aux --sort -%mem | awk '{print $6/1024 " MB\t\t" $11}' | head -n10 >> sysinfo.txt
#echo "---------------------------------------------------------------------------------------" >> sysinfo.txt
echo "top -b -n1 -o %MEM | head -n30"
top -b -n1 -o %MEM | head -n30 >> sysinfo.txt
echo "---------------------------------------------------------------------------------------" >> sysinfo.txt
ps -eo rss,pid,user,command | sort -rn | head -20 | awk '{ hr[1024**2]="GB"; hr[1024]="MB";\
 for (x=1024**3; x>=1024; x/=1024) {\
 if ($1>=x) { printf ("%-6.2f %s ", $1/x, hr[x]); break }\
 } } { printf ("%-6s %-10s ", $2, $3) }\
 { for ( x=4 ; x<=NF ; x++ ) { printf ("%s ",$x) } print ("\n") }\
 ' >> sysinfo.txt
echo "---------------------------------------------------------------------------------------" >> sysinfo.txt
echo "cat /proc/meminfo" >> sysinfo.txt
cat /proc/meminfo >> sysinfo.txt
echo "---------------------------------------------------------------------------------------" >> sysinfo.txt
echo "mpstat -P ALL" >> sysinfo.txt
mpstat -P ALL >> sysinfo.txt
echo "---------------------------------------------------------------------------------------" >> sysinfo.txt
echo "smartctl -A /dev/sda" >> sysinfo.txt
smartctl -A /dev/sda  >> sysinfo.txt
echo "---------------------------------------------------------------------------------------" >> sysinfo.txt
echo "smartctl -A /dev/sdb" >> sysinfo.txt
smartctl -A /dev/sdb  >> sysinfo.txt
echo "---------------------------------------------------------------------------------------" >> sysinfo.txt
echo "journalctl -b -p err" >> sysinfo.txt
journalctl -b -p err  >> sysinfo.txt
echo "---------------------------------------------------------------------------------------" >> sysinfo.txt
echo "Мониторинг 1С" >> sysinfo.txt
if ! pgrep 'ras'; then /opt/1C/v8.3/x86_64/ras --daemon cluster; fi
_cluster=$(/opt/1C/v8.3/x86_64/rac cluster list  | grep 'cluster'| awk -F' ' '{print $3}')
_base=$(/opt/1C/v8.3/x86_64/rac infobase --cluster=$_cluster summary list | grep 'infobase '| awk '{print$3}')
_session=$(/opt/1C/v8.3/x86_64/rac session --cluster=$_cluster list | grep 'session '| awk '{print$3}')
echo 'кластер: ' $_cluster >> sysinfo.txt
echo 'базы: ' $_base >> sysinfo.txt
echo 'сессии:  ' $_session >> sysinfo.txt
echo "---------------------------------------------------------------------------------------" >> sysinfo.txt
/opt/1C/v8.3/x86_64/rac cluster list  >> sysinfo.txt
echo "---------------------------------------------------------------------------------------" >> sysinfo.txt
for cluster in $_cluster
do
/opt/1C/v8.3/x86_64/rac session --cluster=$_cluster list >> sysinfo.txt
done
echo "---------------------------------------------------------------------------------------" >> sysinfo.txt
sleep 2
echo "test" | mutt -s $DATA  f2@vt.com -a sysinfo.txt

Сохранить.
$ sudo crontab -e

*/15 * * * * sh /root/sysinfo.sh
00 3 * * * sh /root/fullbackup.sh
*/1 * * * *  sh /root/session.sh
59 23 * * * sh /root/mailses.sh
00 5 * * * sh /root/backup-sql.sh

Сохранить.
======================================================
Скрипт session.sh

$ sudo nano /root/session.sh

#!/bin/sh
# /root/session.sh
current_date=`date +%Y-%m-%d`
current_time=`date +%H:%M`
if ! pgrep 'ras'; then /opt/1C/v8.3/x86_64/ras --daemon cluster; fi
_cluster=$(/opt/1C/v8.3/x86_64/rac cluster list  | grep 'cluster'| awk -F' ' '{print $3}')
_base=$(/opt/1C/v8.3/x86_64/rac infobase --cluster=$_cluster summary list | grep 'infobase '| awk '{print$3}')
_session=$(/opt/1C/v8.3/x86_64/rac session --cluster=$_cluster list | grep 'session '| awk '{print$3}')
#echo 'кластер: ' $_cluster >> sysinfo.txt
#echo 'базы: ' $_base >> sysinfo.txt
#echo 'сессии:  ' $_session >> sysinfo.txt
# сессии:   2cf54bf0-8365-11e9-9886-309c23451546 bbb8ca0e-8367-11e9-9886-309c23451546 c50f2426-838b-11e9-9886-309c2345154$
ses=0
for count in $_session
do
  ses=$(($ses+1))
done
echo  $current_time $ses  >> /root/ses_$current_date.log

Сохранить.

Сохранить.
$ sudo crontab -e

*/15 * * * * sh /root/sysinfo.sh
00 3 * * * sh /root/fullbackup.sh
*/1 * * * *  sh /root/session.sh
59 23 * * * sh /root/mailses.sh
00 5 * * * sh /root/backup-sql.sh

Сохранить.

======================================================
Скрипт mailses.sh

$ sudo nano /root/mailses.sh
 
#!/bin/sh
current_date=`date +%Y-%m-%d`
echo "test" | mutt -s "session $current_date"  f2@vt.com -a /root/ses_$current_date.log

Сохранить.

$ sudo crontab -e

*/15 * * * * sh /root/sysinfo.sh
00 3 * * * sh /root/fullbackup.sh
*/1 * * * *  sh /root/session.sh
59 23 * * * sh /root/mailses.sh
00 5 * * * sh /root/backup-sql.sh

Сохранить.


======================================================
Скрипт loadavg.sh

$ sudo nano /root/loadavg.sh

Вставить текст ниже

#!/bin/sh
#current_date_time=`date +%Y-%m-%d' '%H:%M:%S`
current_date=`date +%Y-%m-%d`
current_time=`date +%H:%M`
# cat /proc/loadavg
#0.44 0.16 0.06 1/233 2407
loadavg=`cat /proc/loadavg| awk '{print $1 " " $2 " "$3}'`
#echo  $current_time $loadavg
echo  $current_time $loadavg >> /root/la_$current_date.log

Сохранить.

Однократный запуск:
$ sudo sh /root/loadavg.sh

Запись значения в файл каждую минуту

$ sudo crontab -e
Добавить в конец:
# каждую  1 минуту


*/1 * * * * sudo sh /root/loadavg.sh

$ sudo nano mailavg.sh

#!/bin/sh
current_date=`date +%Y-%m-%d`
echo "test" | mutt -s "loadavg $current_date"  f2@vt.com -a /root/la_$current_date.log


Однократный запуск:
$ sudo sh /root/mailavg.sh

Отправка файла в конце конце дня

$ sudo crontab -e
Добавить в конец:



59 23 * * * sudo sh /root/mailavg.sh 

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

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