Chinaunix首页 | 论坛 | 博客
  • 博客访问: 460982
  • 博文数量: 237
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 0
  • 用 户 组: 普通用户
  • 注册时间: 2016-06-12 14:40
个人简介

  每个人生的当口,都是会有一个孤独的时刻,四顾无人,只有自己,于是不得不看明白自己的脆弱,自己的欲望,自己的念想,自己的界限,还有,自己真正的梦想。

文章分类

全部博文(237)

文章存档

2017年(3)

2016年(234)

分类: 系统运维

2016-05-11 11:12:42

主要功能如下:

-d download software 下载需要的MySQL安装包,编辑脚本在download函数内修改

-c setup cmake       $0 -c filename 安装cmake,使用方法为:脚本名+参数+文件名(不包含.tar.gz)

-h setup mysql 5.0.x $0 -h filename安装mysql5.0.x,使用方法为:脚本名+参数+文件名(不包含.tar.gz)

-i config mysql 5.0.x 配置mysql 5.0

-j setup mysql 5.5.x $0 -j filename  安装mysql5.5.x,使用方法为:脚本名+参数+文件名(不包含.tar.gz)

-k config mysql 5.5.x配置mysql 5.5

安装之后,

1,需要手动修改/etc/init.d/mysql.server文件,添加basedir和datadir

2,需要添加/etc/my.cnf配置文件



  1. #!/bin/bash
  2. # email:
  3. # last change time: 2011-08-17
  4. set -e
  5. set -u
  6. #TIME=`date +%Y%m%d%H%M%S`
  7. DIR_MYSQL='/usr/local/mysql'
  8. function download()
  9. {
  10. yum install gcc gcc-c++ ncurses-devel bison
  11. wget
  12. wget
  13. #wget http://dev.mysql.com/get/Downloads/MySQL-5.0/mysql-5.0.92.tar.gz/from/http://mysql.mirrors.pair.com/
  14. exit 0
  15. }
  16. function usage_error()
  17. {
  18. echo "error!!"
  19. echo "
  20. -d download software
  21. -c setup cmake $0 -c filename
  22. -h setup mysql 5.0.x $0 -h filename
  23. -i config mysql 5.0.x
  24. -j setup mysql 5.5.x $0 -j filename
  25. -k config mysql 5.5.x
  26. "
  27. exit 1
  28. }
  29. function setup_status()
  30. {
  31. sleep 3
  32. if [ $? -ne 0 ]; then
  33. exit 1
  34. fi
  35. }
  36. function setup_m50()
  37. {
  38. id mysql
  39. if [ $? -ne 0 ]; then
  40. # Preconfiguration setup
  41. groupadd mysql
  42. useradd -g mysql mysql
  43. fi
  44. if [ -e ${OPTARG}.tar.gz ];then
  45. # Beginning of source-build specific instructions
  46. tar -zxf ${OPTARG}.tar.gz
  47. setup_status
  48. cd ${OPTARG}
  49. else
  50. usage_error
  51. fi
  52. ./configure --prefix=${DIR_MYSQL} \
  53. --datadir=${DIR_MYSQL}/data \
  54. --without-debug \
  55. --without-bench \
  56. --enable-thread-safe-client \
  57. --enable-assembler \
  58. --with-mysqld-ldflags=-all-static \
  59. --with-client-ldflags=-all-static \
  60. --with-charset=utf8 \
  61. --with-collation=utf8_bin \
  62. --with-innodb
  63. setup_status
  64. make
  65. setup_status
  66. make install
  67. setup_status
  68. # End of source-build specific instructions
  69. }
  70. function configure_m50()
  71. {
  72. # Post installation setup
  73. cd ${DIR_MYSQL}
  74. chown -R mysql .
  75. chgrp -R mysql .
  76. bin/mysql_install_db --user=mysql --datadir=${DIR_MYSQL}/data
  77. setup_status
  78. chown -R root .
  79. chown -R mysql data
  80. # Next command is optional, used default mysqlserver config
  81. if [ -e /etc/my.cnf ]; then
  82. mv /etc/my.cnf /etc/my.cnf.${TIME}
  83. fi
  84. bin/mysqld_safe --user=mysql &
  85. setup_status
  86. if [ ! -e /etc/init.d/mysql.server ]; then
  87. cp ${DIR_MYSQL}/data/mysql/mysql.server /etc/init.d/mysql.server
  88. chmod +x /etc/init.d/mysql.server
  89. fi
  90. }
  91. function setup_cmake()
  92. {
  93. tar -xzf ${OPTARG}.tar.gz
  94. cd ${OPTARG}
  95. ./configure
  96. setup_status
  97. make
  98. setup_status
  99. make install
  100. }
  101. function setup_m55()
  102. {
  103. id mysql
  104. if [ $? -ne 0 ]; then
  105. # Preconfiguration setup
  106. groupadd mysql
  107. useradd -g mysql mysql
  108. fi
  109. if [ -e ${OPTARG}.tar.gz ];then
  110. # Beginning of source-build specific instructions
  111. tar -zxf ${OPTARG}.tar.gz
  112. cd ${OPTARG}
  113. else
  114. usage_error
  115. fi
  116. /usr/local/bin/cmake . -DCMAKE_INSTALL_PREFIX=$DIR_MYSQL\
  117. -DMYSQL_DATADIR=$DIR_MYSQL/data\
  118. -DMYSQL_UNIX_ADDR=$DIR_MYSQL/data/mysql.sock\
  119. -DINSTALL_LAYOUT=STANDALONE\
  120. -DDEFAULT_CHARSET=utf8\
  121. -DDEFAULT_COLLATION=utf8_general_ci\
  122. -DEXTRA_CHARSETS=all\
  123. -DWITH_INNOBASE_STORAGE_ENGINE=1\
  124. -DWITH_READLINE=1\
  125. -DENABLED_LOCAL_INFILE=1\
  126. -DMYSQL_TCP_PORT=3306\
  127. -DWITH_DEBUG=0
  128. setup_status
  129. make
  130. setup_status
  131. make install
  132. setup_status
  133. # End of source-build specific instructions
  134. }
  135. function configure_m55()
  136. {
  137. # Post installation setup
  138. cd ${DIR_MYSQL}
  139. chown -R mysql .
  140. chgrp -R mysql .
  141. scripts/mysql_install_db --user=mysql --datadir=${DIR_MYSQL}/data
  142. setup_status
  143. chown -R root .
  144. chown -R mysql data
  145. # Next command is optional, used default mysqlserver config
  146. if [ -e /etc/my.cnf ]; then
  147. mv /etc/my.cnf /etc/my.cnf.${TIME}
  148. fi
  149. bin/mysqld_safe --user=mysql &
  150. setup_status
  151. if [ ! -e /etc/init.d/mysql.server ]; then
  152. cp ${DIR_MYSQL}/support-files/mysql.server /etc/init.d/mysql.server
  153. chmod +x /etc/init.d/mysql.server
  154. fi
  155. }
  156. if [ $# -eq 0 ]; then
  157. usage_error
  158. else
  159. while getopts :dc:h:i:j arg
  160. do
  161. case $arg in
  162. d)
  163. download
  164. ;;
  165. c)
  166. setup_cmake
  167. ;;
  168. h)
  169. setup_m50
  170. ;;
  171. i)
  172. configure_m50
  173. ;;
  174. j)
  175. setup_m55
  176. ;;
  177. k)
  178. configure_m55
  179. ;;
  180. :)
  181. echo "$arg: 缺少参数"
  182. usage_error
  183. ;;
  184. \?)
  185. echo "$arg: 非法选项"
  186. usage_error
  187. ;;
  188. esac
  189. done
  190. fi


阅读(541) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~