有待完善 #!/bin/bash # echo ‘Mysql Installing...‘ echo ‘Cmake install...‘ read -p "Please input compress type[bz2|gz]: " COMPRESS read -p "Please input a cmake VERSION[cmake-‘VERSION‘.tar.$COMPRESS]: " CMAKEVER while ! echo $CMAKEVER | grep "[![:alpha:]]*" &> /dev/null ; do read -p "Please input a apr version[cmake-"VERSION".tar.$COMPRESS]: " CMAKEVER done tar -xf cmake-$CMAKEVER.tar.$COMPRESS cd cmake-$CMAKEVER ./configure make && make install cd - read -p "Please input compress type[bz2|gz]: " COMPRESS read -p "Please input a mysql VERSION[mysql-‘VERSION‘.tar.$COMPRESS]: " MYVER while ! echo $MYVER | grep "[![:alpha:]]*" &> /dev/null ; do read -p "Please input a apr version[mysql-"VERSION".tar.$COMPRESS]: " MYVER done echo "LVM building..." echo -e "Disk list:" MAX=`fdisk -l 2> /dev/null | grep -o "[[:space:]]/dev/sd[[:alpha:]]*" | wc -l` fdisk -l 2> /dev/null | grep -o "[[:space:]]/dev/sd[[:alpha:]]*" | cat -n read -p "Please input the number of disk[1-`echo ${MAX}`]: " DISKNUM DISK=`fdisk -l 2> /dev/null | grep -o "[[:space:]]/dev/sd[[:alpha:]]*" | cat -n | grep "$DISKNUM" | grep -o "/dev/sd[[:alpha:]]*"` pvcreate $DISK vgcreate -s 16M myvg $DISK lvcreate -L 1024M -n mysql /dev/myvg mke2fs -t ext4 /dev/myvg/mysql mkdir -pv /mydata/data mount /dev/myvg/mysql /mydata/data if ! id mysql &> /dev/null ; then groupadd -r mysql useradd -r -s /sbin/nologin -g mysql mysql fi chown -R mysql: /mydata/data tar -xf mysql-$MYVER.tar.$COMPRESS cd mysql-$MYVER cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/mydata/data -DSYSCONFDIR=/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_LIBWRAP=0 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci make && make install cd /usr/local/mysql chown -R mysql: ./ scripts/mysql_install_db --user=mysql --datadir=/mydata/data cp support-files/my-default.cnf /etc/my.cnf cp support-files/mysql.server /etc/init.d/mysqld sed ‘s@#[[:space:]]*\(datadir = \).*@\1/mydata/data@‘ -e ‘s@#[[:space:]]*\(basedir = \).*@\1/usr/local/mysql@‘ -e ‘s@#[[:space:]]*\(port = \).*@\13340@‘ -e ‘s@#[[:space:]]*\(socket = \).*@\1/tmp/mysql.sock@‘ /etc/my.cnf echo "export PATH=$PATH:/usr/local/mysql/bin" > /etc/profile.d/mysql.sh source /etc/profile.d/mysql.sh chkconfig --add mysqld
原文:http://10900996.blog.51cto.com/10890996/1757504