Advertisement
Guest User

Untitled

a guest
Apr 3rd, 2018
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.11 KB | None | 0 0
  1. #!/bin/bash
  2. # Author: krishna - and thanks to all the helpful folks on SO.
  3. # date: apr-03-2018
  4. # script
  5. # Notes: unattented script to install percona server. Pieced together from all over SO.
  6. # see versions below next to each item. they are current as on this script creation dates.
  7. # 2. percona server 5.7 or later
  8. # 4. ubuntu 64bit 16.4.3
  9. #
  10. # This script works for me but may not be the best bash script, Please help, to make it better.
  11. #
  12. # you have to run this script as sudo
  13. # if you saved this script as let's say install-percona.sh
  14. # then do this
  15. # chmod +x install-percona.sh
  16. # sudo ./install-percona.sh
  17. #
  18.  
  19. # do everything in downloads
  20. mkdir -p ~/downloads
  21. cd ~/downloads
  22.  
  23. # Variables
  24. # Passwords are like under garments.
  25. # 1. Dont leave them lying around
  26. # 2. Change Often
  27. # 3. Do not share it with others
  28. # 4. Dont be chaep. Invest in STRONG AND high quality one's.
  29. # So I hope you know what to do with the next 3 lines.
  30. MYSQL_ROOT_PASSWORD="SecretRootPassword123"
  31. DB_USERNAME="MickeyMouse"
  32. DB_PASSWORD="SecretDBPassword123"
  33.  
  34. export DEBIAN_FRONTEND=noninteractive
  35.  
  36. sudo apt-get install -y debconf-utils
  37.  
  38. # Install software
  39. # We are going to install Percona Server.
  40. #
  41. # By default, percona-server is going to ask for the root password and we automate that with debconf-set-selections
  42. # begin percona stuff
  43. # you need to change the next 2 lines, visit the percona server site to get latest values.
  44. wget https://repo.percona.com/apt/percona-release_0.1-4.$(lsb_release -sc)_all.deb
  45. dpkg -i percona-release_0.1-4.$(lsb_release -sc)_all.deb
  46. #
  47. apt-get update
  48.  
  49. # also change the version number accordingly. the -5.7 part
  50. # Note. its root-pass and re-root-pass unlike root_password and root_password_again for other flavors of mysql.
  51. #
  52. # !!!!! CAUTION !!!!
  53. # Be sure to check /var/cache/debconf/passwords.dat file for these 2 entries. After installation is completed.
  54. # The value fields were clear in my case but check anyway.
  55. # Y.M.M.V - dont want to leave passwords hanging in the clear.
  56. #
  57. #
  58. echo "percona-server-server-5.7 percona-server-server-5.7/root-pass password ${MYSQL_ROOT_PASSWORD}" | debconf-set-selections
  59. echo "percona-server-server-5.7 percona-server-server-5.7/re-root-pass password ${MYSQL_ROOT_PASSWORD}" | debconf-set-selections
  60. apt install -y percona-server-server-5.7
  61.  
  62. # Configure MySQL ie Percona
  63. # We are going to create a user also and the 3 CREATE FUNCTION lines are what percona suggests.
  64. # these may happen silently
  65.  
  66. echo "lets configure percona."
  67.  
  68. mysql -u root -p${MYSQL_ROOT_PASSWORD} <<EOF
  69. CREATE FUNCTION fnv1a_64 RETURNS INTEGER SONAME 'libfnv1a_udf.so';
  70. CREATE FUNCTION fnv_64 RETURNS INTEGER SONAME 'libfnv_udf.so';
  71. CREATE FUNCTION murmur_hash RETURNS INTEGER SONAME 'libmurmur_udf.so';
  72. CREATE USER '${DB_USERNAME}'@'localhost' IDENTIFIED BY '${DB_PASSWORD}';
  73. GRANT ALL ON *.* TO '${DB_USERNAME}'@'localhost' with grant option;
  74. FLUSH Privileges;
  75. EOF
  76.  
  77. echo "make sure you run mysql_secure_installation after install"
  78. # run the secure installation script
  79. mysql_secure_installation
  80. echo "done."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement