CentOS 7.x update lightsail redmine instance

From Notes_Wiki

Home > CentOS > CentOS 7.x > DevOps > CentOS 7.x ticketing > Redmine > CentOS 7.x update lightsail redmine instance

Home > CentOS > CentOS 7.x > CentOS 7.x Setup lightsail instances > CentOS 7.x update lightsail redmine instance

Steps for updating redmine instance by creating a new instance and terminating old one are: Note that it is also possible to update redmine within same instance using similar steps. For example refer in-place update of owncloud described at CentOS 7.x Update lightsail owncloud instance in-place

For updating redmine use:

  1. Create a new machine for newer version of redmine
  2. Install required packages
    yum -y install vim epel-release wget
    yum -y install perl-Data-Dumper byobu
  3. Copy self admin station public key as authorized for root user of new instance
  4. Download new version of redmine from https://bitnami.com/stack/redmine/installer
  5. 'chmod +x' downloaded file.
  6. If required add appropriate swap by referring CentOS 7.x adding swap space using file
  7. Install new redmine with following values
    Language
    English (Default)
    Subversion
    Yes (Default)
    PhpMyAdmin
    Yes (Default)
    Git
    Yes (Default)
    Folder
    /opt/redmine-<version> (Default)
    Username
    admin
    Email address
    saurabh [at] sbarjatiya.com
    Login user
    admin
    Password
    Something very simple (It is overwritten by old redmine admin password during database restore anyway)
    Data language
    English (Default)
    Email support
    : Y (Custom, saurabh [at] sbarjatiya.com, secret, mail.sbarjatiya.com, 587, TLS)
    Continue redmine bitnami installation
  8. Login into older redmine server and go to '/opt/redmine-<version>'. Execute './ctlscript.sh stop apache'. For extra safety you can stop access to ports 80, 443 of old redmine via firewall.
  9. If mysql is not running start it using './ctlscript.sh start mysql'
  10. On old server go to location '/opt/redmine-<version>/apps/redmine/htdocs/config'. Open database.yml and note production database details.
  11. Take MySQL database backup of old redmine using
    cd /root
    /opt/redmine-<version>/mysql/bin/mysqldump -u bitnami -p<old-server-password> bitnami_redmine > bitnami_redmine.sql
  12. In /etc/hosts of old server add entry for new-<fqdn> pointing to new servers private IP
  13. If required generate root ssh-key pair on old server. Copy old server root public key on new server as authorized
  14. Copy MySQL database dump to new server /root
  15. On new server go to location '/opt/redmine-<version>/apps/redmine/htdocs/config'. Open database.yml and note production database details.
  16. Restore MySQL database on new redmine using
    cd /root
    /opt/redmine-<version>/mysql/bin/mysql -u bitnami -p<new-server-password> bitnami_redmine < bitnami_redmine.sql
  17. Copy files from '/opt/redmine-<version>/apps/redmine/htdocs/files' of old server to new server
    rsync -a /opt/redmine-<old-version>/apps/redmine/htdocs/files/ root@new-<fqdn>:/opt/redmine-<new-version>/apps/redmine/htdocs/files/
  18. Same for /opt/redmine-<version>/apps/redmine/htdocs/plugins after validating that plugins are compatible with new version
    rsync -a /opt/redmine-<old-version>/apps/redmine/htdocs/plugins/ root@new-<fqdn>:/opt/redmine-<new-version>/apps/redmine/htdocs/plugins/
  19. On new server migrate database to new version using:
    cd /opt/redmine-<version>
    ./use_redmine
    cd /opt/redmine-<version>/apps/redmine/htdocs
    sudo /opt/redmine-<version>/ruby/bin/ruby bin/rake db:migrate RAILS_ENV=production
  20. Optionally import plugins if copied and compatible using:
    sudo /opt/redmine-<version>/ruby/bin/ruby bin/rake redmine:plugins RAILS_ENV=production
  21. Clear cache
    sudo /opt/redmine-<version>/ruby/bin/ruby bin/rake tmp:clear
  22. Restart redmine
    /opt/redmine-<version>/ctrlscript.sh restart
  23. Copy '/opt/redmine-<version>/apache2/htdocs/index.html' to new server at similar location
  24. Allow access to port 80 and 443 of new redmine server
  25. Access new server and test. Note that admin password of old-server would work and not the password typed during installation
  26. Search for issues with any file. Try to access files uploaded on any issue and check that uploaded files are accessible
  27. Setup fail2ban using CentOS 7.x fail2ban including firewalld using CentOS 7.x Basic firewalld configuration
  28. Set correct time zone CentOS 7.x Change system timezone
  29. Configure system to store history date time using Storing date / time along with commands in history
  30. Stop old instance or server
  31. Associate public IP or old instance with new instance or Update DNS to point to static IP of new instance
  32. Generate SSL certificate using:
    /opt/redmine-4.1.1-4/bncert-tool #Update tool if prompted and re-run
    Inputs for update are: Domain list - <fqdn>, No www.<fqdn> domain, Enable HTTPS redirection - Yes, Agree to multiple changes, Email address - saurabh [at] sbarjatiya.com, Agree to Let's encrypt agreement
    Refer - https://docs.bitnami.com/general/how-to/understand-bncert/
  33. Update crontab using 'crontab -e and set first value between 3 and 6, second value between 10 and 50. Set last * to 0 so that certificate checks happen only weekly on Sundays.
  34. Access site using https://<fqdn> and validate
  35. Configure backups to happen from new server
    1. Install packages
      yum -y install bzip2
    2. Edit /etc/rsnapshot.conf private IP in backup server
    3. Copy backup server SSH keys as authorized on new redmine server
    4. ssh from backup server to new redmine server and test
    5. Create /opt/take-database-backup.sh on redmine server with following contents
      /opt/redmine-<ver>/mysql/bin/mysqldump -u bitnami -p<password> bitnami_redmine | bzip2 > /opt/bitnami_redmine.sql.bz2
      Validate name of script take-database-backup.sh in /etc/rsnapshot.conf of backup server
    6. chmod +x /opt/take-database-backup.sh
    7. /opt/take-database-backup.sh #Ignore some of the errors shown
    8. bunzip2 the dump and validate it is proper
    9. rsnapshot hourly #Validate
  36. Configure logwatch
    1. yum -y install logwatch
    2. Set correct hostname. Reconnect if required
    3. vim /etc/logwatch/conf/logwatch.conf
      MailTo = saurabh [at] sbarjatiya.com
      MailFrom = saurabh [at] sbarjatiya.com
    4. Edit /etc/aliases and set root: saurabh [at] sbarjatiya.com
    5. Edit /etc/postfix/main.cf
      1. myhostname = redmine.sbarjatiya.com
      2. mydomain = sbarjatiya.com
      3. myorigin = $myhostname
      4. inet_interfaces = all
      5. inet_protocols = ipv4
      6. relayhost = mail.sbarjatiya.com
    6. Ensure public IP of redmine.sbarjatiya.com is part of mynetworks on mail.sbarjatiya.com
    7. Run newaliases
    8. systemctl restart postfix
    9. /etc/cron.daily/0logwatch #Test
  37. Reset MySQL root password and grant process privilege to bitnami user
    1. Create file /tmp/mysql-init with contents:
      ALTER USER 'root'@'localhost' IDENTIFIED BY '<new-root-password>';
      FLUSH PRIVILEGES;
    2. Stop services '/opt/redmine-<version>/ctlscript.sh stop'
    3. Start mysql with following command
      cd /opt/redmine-<version>
      ./use_redmine
      sudo $PWD/mysql/bin/mysqld_safe --pid-file=$PWD/mysql/data/mysqld.pid --datadir=$PWD/mysql/data --init-file=/tmp/mysql-init 2> /dev/null &
    4. Try to login with root user using:
      mysql/bin/mysql -u root -p
    5. Check existing GRANTs for bitnami using:
      show grants for bitnami@'localhost';
      Example output could be
      +----------------------------------------------------------------------+
      | Grants for bitnami@localhost |
      +----------------------------------------------------------------------+
      | GRANT USAGE ON *.* TO 'bitnami'@'localhost' |
      | GRANT ALL PRIVILEGES ON `bitnami_redmine`.* TO 'bitnami'@'localhost' |
      +----------------------------------------------------------------------+
    6. Add process to existing list of GRANTS
      GRANT USAGE,PROCESS ON *.* TO 'bitnami'@'localhost';
      FLUSH PRIVILEGES;
      \q
    7. Try to take fresh backup via /opt/take_mysql_backup.sh file and see that no warnings or errors are generated.
  38. Delete old instance


Refer:


Home > CentOS > CentOS 7.x > DevOps > CentOS 7.x ticketing > Redmine > CentOS 7.x update lightsail redmine instance

Home > CentOS > CentOS 7.x > CentOS 7.x Setup lightsail instances > CentOS 7.x update lightsail redmine instance