Difference between revisions of "Server maintenence"

From TempusServa wiki
Jump to navigation Jump to search
old>Admin
 
(47 intermediate revisions by 3 users not shown)
Line 1: Line 1:


For internal setup instructions please refer to [TS hosting instructions]
For internal setup instructions please refer to [[TS hosting instructions]]
 
== Server automated services ==
This is the installation procedure for remote backup and monitoring.
 
Prerequisites:
* SSH accces to the server
* TS commandline tools installed and up to date
 
=== Set up monitoring ===
# Log in into [UptimeRobot.com]  
# Add new monitor
## Monitor type = Keyword
## Frindly name = <anything>
## URL = '''<url to service page>''' (see example below)
## Keyword = HEALTHY
## Alert when = Keyword not exists
## Click the persons to get notified
## Create monitor
# Tjeck the monitor is working
 
Example of service page
  https://gdpr.tempusserva.dk/demo/service?OkToday
 
=== Set up remote backup ===
 
==== Client server setup ====
# Log into server via SSH
# Run: tsrefreshscripts.sh
# Run: tsbackupcertificates.sh
# Check if cronjobs are missing: sudo crontab -l
## Run: tsinstallcronjobs.sh
 
==== Backup server setup ====
# FTP download: /tsBackup/tsBackupConfig.php
# Add the server entry in the format: name=URL  (semikolon seperated)
# FTP upload: /tsBackup/tsBackupConfig.php
 
 
Example of format:
  foo=foo.tempusserva.dk;bar=bar.tempusserva.dk;hello=hellojohn.tempusserva.dk
 
==== Validate backup ====
# Wait to 24h passes
# Check the backup status URL
#* Ensure server is in the list
#* Ensure size of backup is sensible (size > 1000)


== Server monitor page ==
== Server monitor page ==
Line 87: Line 41:
The following guide contains directions for setting up incremental backups to remote location, using [http://rsync.samba.org/ rsync] and SSH connections.
The following guide contains directions for setting up incremental backups to remote location, using [http://rsync.samba.org/ rsync] and SSH connections.


http://tempusserva.dk/mediawiki/index.php?title=Backup_and_restore
[[Backup_and_restore]]


=== Table naming conventions ===
=== Table naming conventions ===
Line 108: Line 62:


Deleted tables are prefixed by a timestamp
Deleted tables are prefixed by a timestamp
=== Restore multiple files (Linux) ===
From the backup directory you can execute these commands
  find . -name 'tslive_*.sql' -printf 'source  %P;\n' > restoreMe.txt
  mysql tslive -uroot -pPASSWORD -e "source restoreMe.txt"
Just change database (tslive) and password above


=== Accessing the database (MySQL) ===
=== Accessing the database (MySQL) ===
Line 118: Line 81:


We recommend the following database tool
We recommend the following database tool
* [http://www.navicat.com/en/products/navicat_mysql/mysql_overview.html NaviCat for MySQL]
* [https://www.navicat.com/en/products/navicat-for-mysql NaviCat for MySQL]


Other client tools include
Other client tools include
Line 138: Line 101:
* http://tuckey.org/urlrewrite/
* http://tuckey.org/urlrewrite/
* http://tuckey.org/urlrewrite/manual/3.0/guide.html
* http://tuckey.org/urlrewrite/manual/3.0/guide.html
== Moving files to S3 storage ==
Create a bucket at AWS
# Select same region as server is hosted in
# Go to https://eu-north-1.console.aws.amazon.com/s3/buckets
# Add bucket
# Select Directory if files are mainly media (pictures/video)
# Name the bucket: '''s3fs.CUSTOMER'''
Add IAM role to server
# Go to https://eu-north-1.console.aws.amazon.com/ec2/home
# Right click server > Security > Modify IAM role
# Choose '''ServerWithNetworkFilesystem'''
# Update IAM role
Install the mountpoint
# wget https://s3.amazonaws.com/mountpoint-s3-release/latest/x86_64/mount-s3.rpm
# sudo yum install ./mount-s3.rpm -y
# sudo nano /etc/fuse.conf
#* remove # before user_allow_other
#* save file
# sudo mkdir /mnt/s3fs
# sudo mount-s3 --allow-other --dir-mode 0777 --file-mode 0777 '''s3fs.CUSTOMER''' /mnt/s3fs
# --- MISSING SETUP FSTAB ---
# Option for multi instance server: sudo mkdir /mnt/s3fs/<instancename>
Change storage location and policy
# Go to Server > Backend > Modules > Configuration
# Change filesystemStorageBasePath: /mnt/s3fs
#* Option for multi instance server: /mnt/s3fs/<instancename>
# Change filesystemStorageActive: true
Migrate existing files til S3
# Call server URL
#* Manual: main?command=dk.tempusserva.codeunit.system.PageConvertBlobsToFiles
#* Full auto: main?command=dk.tempusserva.codeunit.system.PageConvertBlobsToFiles&convert

Latest revision as of 16:32, 26 September 2024

For internal setup instructions please refer to TS hosting instructions

Server monitor page

Each application contains a public page that can be queried for server status.

The page is: http://SERVER/APPLICATION/service?PASSWORD

Password can be set in the configuration: healthMonitorPassword

Reponse will look something like

<serverstatus>
<flag name="Source version">2081</flag>
<flag name="Unused storage">27%</flag>
<flag name="Database motor">OK</flag>
<flag name="Authentication">OK</flag>
<flag name="Daemon running">NO</flag>
<flag name="Server healthy">HEALTHY</flag>
<flag name="Is user online">NO</flag>
<flag name="Session length">30</flag>
<flag name="DB schema LIVE">tslive</flag>
<flag name="DB schema TEST">tstest</flag>
<flag name="Last view data">2013-02-12 16:53:11</flag>
<flag name="Last exception">2013-02-12 12:28:16</flag>
</serverstatus>

If the goodword HEALTY is found the following things are ok

  • Server is open for logins
  • DB connections are accessible
  • Data / log disc is not full

A good option for an online monitoring tool is Site24x7 which we strongly recommend.

Backup and restore

TS has inbuilt manual functions on the solution level, but measures have to taken to back the data IN the solutions.

Backups should optimally be done either by dumping the database. Alternatively the database can be stopped (important) and data folders can be backed up normally.

The following guide contains directions for setting up incremental backups to remote location, using rsync and SSH connections.

Backup_and_restore

Table naming conventions

Every solution has its own table namespace of "data_" followed by the system solution name.

Example for the solution named XXX:

  • data_XXX

Other related tables include

  • data_XXX_file
  • data_XXX_mail
  • data_XXX_comment
  • data_XXX_contact
  • data_XXX_measure
  • data_XXX_member
  • data_XXX_t_YYY
  • data_XXX_accesslog
  • data_XXX_statuslog
  • data_XXX_revisionlog

Deleted tables are prefixed by a timestamp


Restore multiple files (Linux)

From the backup directory you can execute these commands

 find . -name 'tslive_*.sql' -printf 'source  %P;\n' > restoreMe.txt
 mysql tslive -uroot -pPASSWORD -e "source restoreMe.txt"

Just change database (tslive) and password above

Accessing the database (MySQL)

Normally Tempus Serva will maintain the database by itself.

Sometimes direct access is needed, for example

  • Partial table data restore
  • Sharding large tables (+1M records or many Blobs)

We recommend the following database tool

Other client tools include

URL redirects and rewrites

Tempus Serva (version 2090+) contains server filters for URL rewrite, redirects and forwards.

The filter is deactivated by default, but can be enabled by

  1. Rename /WEB-INF/web.xml.urlrewrite to web.xml
  2. Change /WEB-INF/urlrewrite.xml as needed
  3. Restart the server

Other options include merging web.xml.urlrewrite into the existing web.xml.

Documentation can be found in following pages

Moving files to S3 storage

Create a bucket at AWS

  1. Select same region as server is hosted in
  2. Go to https://eu-north-1.console.aws.amazon.com/s3/buckets
  3. Add bucket
  4. Select Directory if files are mainly media (pictures/video)
  5. Name the bucket: s3fs.CUSTOMER

Add IAM role to server

  1. Go to https://eu-north-1.console.aws.amazon.com/ec2/home
  2. Right click server > Security > Modify IAM role
  3. Choose ServerWithNetworkFilesystem
  4. Update IAM role

Install the mountpoint

  1. wget https://s3.amazonaws.com/mountpoint-s3-release/latest/x86_64/mount-s3.rpm
  2. sudo yum install ./mount-s3.rpm -y
  3. sudo nano /etc/fuse.conf
    • remove # before user_allow_other
    • save file
  4. sudo mkdir /mnt/s3fs
  5. sudo mount-s3 --allow-other --dir-mode 0777 --file-mode 0777 s3fs.CUSTOMER /mnt/s3fs
  6. --- MISSING SETUP FSTAB ---
  7. Option for multi instance server: sudo mkdir /mnt/s3fs/<instancename>

Change storage location and policy

  1. Go to Server > Backend > Modules > Configuration
  2. Change filesystemStorageBasePath: /mnt/s3fs
    • Option for multi instance server: /mnt/s3fs/<instancename>
  3. Change filesystemStorageActive: true

Migrate existing files til S3

  1. Call server URL
    • Manual: main?command=dk.tempusserva.codeunit.system.PageConvertBlobsToFiles
    • Full auto: main?command=dk.tempusserva.codeunit.system.PageConvertBlobsToFiles&convert