- 浏览: 7431 次
- 性别:
- 来自: 北京
最新评论
suse 服务器配置
#!/bin/bash
#作者:duanyunxi
#版本:v2.0
touch /var/installserver.tmp
##开始准备工作##
echo "##开始准备工作!##"
if [ -f /var/installserver.tmp ]; then
RETVAL=`grep 'ready' /var/installserver.tmp`
if [ "$RETVAL" == "" ]; then
echo "##确认server_2.0的路径!##"
echo "请输入server_2.0所在的位置,例如:/home/server_2.0.tar.gz"
INPUT="n"
until [ "$INPUT" == "Y" ] || [ "$INPUT" == "y" ]
do
read SERVERPATH
echo "您输入server_2.0所在的位置是:$SERVERPATH,请确认(y|n)?"
read INPUT
if [ "$INPUT" != "Y" ] && [ "$INPUT" != "y" ]; then
echo "请确认server_2.0所在的位置后,重新输入:"
else
echo "server_2.0所在的位置为:$SERVERPATH"
fi
done
echo "##解压server_2.0!##"
cd /home
cp $SERVERPATH /home/server_2.0.tar.gz
tar xzf server_2.0.tar.gz
chmod 755 -R server_2.0
echo "ready ok!" >> /var/installserver.tmp
echo "准备工作已经完成!"
sleep 10
else
echo "准备工作已经做过!"
fi
fi
##开始安装JDK##
echo "##开始安装JDK!##"
if [ -f /var/installserver.tmp ]; then
RETVAL=`cat /var/installserver.tmp|grep 'jdk'|grep 'successfully'`
if [ "$RETVAL" == "" ]; then
cd /home/server_2.0
chmod u+x ./jdk-6u19-linux-i586.bin
./jdk-6u19-linux-i586.bin
mv jdk1.6.0_19 /usr/local/jdk
ln -s /usr/local/jdk/bin/java /usr/bin/java
ln -s /usr/local/jdk/bin/javac /usr/bin/javac
ln -s /usr/local/jdk/jre /usr/local/jre
echo "jdk has installed successfully!" >> /var/installserver.tmp
echo "JDK安装完成!"
sleep 10
else
echo "JDK已经安装过了!"
fi
fi
##开始配置JDK环境变量##
echo "##开始配置JDK环境变量!##"
if [ -f /var/installserver.tmp ]; then
RETVAL=`cat /etc/profile|grep 'JAVA_HOME'`
if [ "$RETVAL" == "" ]; then
echo "" >> /etc/profile
echo 'JAVA_HOME=/usr/local/jdk' >> /etc/profile
echo 'JRE_HOME=/usr/local/jre' >> /etc/profile
echo 'PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin' >> /etc/profile
echo 'CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib:' >> /etc/profile
echo 'export JAVA_HOME JRE_HOME PATH CLASSPATH' >> /etc/profile
source /etc/profile
echo "JDK环境变量配置完成!"
else
echo "JDK环境变量已经配置过了!"
fi
java -version
fi
##开始安装resin##
echo "##开始安装resin!##"
if [ -f /var/installserver.tmp ]; then
RETVAL=`cat /var/installserver.tmp|grep 'resin'|grep 'successfully'`
if [ "$RETVAL" == "" ]; then
#####duanyunxi-2010-10-28
INPUT="n"
until [ "$INPUT" == "Y" ] || [ "$INPUT" == "y" ]
do
PORT=""
echo "请输入resin的端口号?(8000-8999)"
read PORT
if [ ${PORT} -lt 8000 ] || [ ${PORT} -gt 8999 ]; then
echo "您输入的端口号超出范围,重新输入:"
read PORT
fi
echo "您输入端口号是:$PORT,请确认(y|n)?"
read INPUT
if [ "$INPUT" != "Y" ] && [ "$INPUT" != "y" ]; then
echo "请确认端口后,重新输入:"
else
echo "RESIN_PORT=$PORT" >> /var/installserver.tmp
echo "端口为:$PORT"
fi
done
cd /home/server_2.0
tar -zxvf resin-pro-3.1.10.tar.gz
cd resin-pro-3.1.10
./configure --prefix=/usr/local/resin --enable-jni
sleep 10
make
sleep 10
make install
sleep 10
RETVAL=`cat /etc/profile|grep 'RESIN_HOME'`
if [ "$RETVAL" == "" ]; then
echo "" >> /etc/profile
echo 'RESIN_HOME=/usr/local/resin' >> /etc/profile
echo 'export RESIN_HOME ' >> /etc/profile
source /etc/profile
echo "resin环境变量配置完成!"
fi
##duanyunxi
sed -i -e "s@8080@$PORT@" /usr/local/resin/conf/resin.conf
cp /home/server_2.0/resin.init /etc/init.d/resin
chmod +x /etc/init.d/resin
chkconfig --del resin && chkconfig --add resin
chkconfig resin on
echo "resin has installed successfully!" >> /var/installserver.tmp
echo "resin安装完成!"
sleep 10
else
echo "resin已经安装过了!"
fi
fi
##开始安装nginx##
echo "##开始安装nginx!##"
if [ -f /var/installserver.tmp ]; then
RETVAL=`cat /var/installserver.tmp|grep 'nginx'|grep 'successfully'`
if [ "$RETVAL" == "" ]; then
cd /home/server_2.0
tar -zxvf pcre-7.8.tar.gz
tar -zxvf zlib-1.2.2.tar.gz
tar zxvf openssl-0.9.8k.tar.gz
tar zxvf nginx-0.8.38.tar.gz
cd nginx-0.8.38/
./configure --prefix=/usr/local/nginx --with-pcre=/home/server_2.0/pcre-7.8 --with-zlib=/home/server_2.0/zlib-1.2.2 --with-openssl=/home/server_2.0/openssl-0.9.8k \
--with-http_ssl_module --with-http_realip_module --with-http_flv_module --with-http_gzip_static_module --with-http_stub_status_module
sleep 10
make
sleep 10
make install
sleep 10
cp /home/server_2.0/nginx.init /etc/init.d/nginx
chmod +x /etc/init.d/nginx
chkconfig --del nginx && chkconfig --add nginx
chkconfig nginx on
echo "nginx has installed successfully!" >> /var/installserver.tmp
echo "nginx安装完成!"
else
echo "nginx已经安装过了!"
sleep 10
fi
fi
##开始安装mysql##
echo "##开始安装mysql!##"
if [ -f /var/installserver.tmp ]; then
RETVAL=`cat /var/installserver.tmp|grep 'mysql'|grep 'successfully'`
if [ "$RETVAL" == "" ]; then
INPUT="n"
until [ "$INPUT" == "Y" ] || [ "$INPUT" == "y" ]
do
ENCODE=""
echo "请选择mysql的编码(g:gbk|u:utf8)?"
read ENCODE
if [ "$ENCODE" == "G" ] || [ "$ENCODE" == "g" ]; then
echo "您选择的编码是gbk,请确认(y|n)?"
ENCODE="gbk"
elif [ "$ENCODE" == "U" ] || [ "$ENCODE" == "u" ]; then
echo "您选择的编码是utf8,请确认(y|n)?"
ENCODE="utf8"
fi
read INPUT
if [ "$INPUT" != "Y" ] && [ "$INPUT" != "y" ]; then
echo "请确认后,重新输入:"
else
echo "MYSQL_ENCODE=$ENCODE" >> /var/installserver.tmp
echo "mysql的编码为:$ENCODE"
fi
done
#####duanyunxi-2010-10-28
INPUT="n"
until [ "$INPUT" == "Y" ] || [ "$INPUT" == "y" ]
do
PORT=""
echo "请输入mysql的端口号?(8000-8999)"
read PORT
if [ ${PORT} -lt 8000 ] || [ ${PORT} -gt 8999 ]; then
echo "您输入的端口号超出范围,重新输入:"
read PORT
fi
echo "您输入端口号是:$PORT,请确认(y|n)?"
read INPUT
if [ "$INPUT" != "Y" ] && [ "$INPUT" != "y" ]; then
echo "请确认端口后,重新输入:"
else
echo "MYSQL_PORT=$PORT" >> /var/installserver.tmp
echo "端口为:$PORT"
fi
done
INPUT="n"
until [ "$INPUT" == "Y" ] || [ "$INPUT" == "y" ]
do
DATAPATH=""
echo "请输入数据存放位置,例如:/var/data"
read DATAPATH
echo "您输入数据存放位置是:$DATAPATH,请确认(y|n)?"
read INPUT
if [ "$INPUT" != "Y" ] && [ "$INPUT" != "y" ]; then
echo "请确认数据存放位置后,重新输入:"
else
echo "DATA_PATH=$DATAPATH" >> /var/installserver.tmp
echo "数据存放位置为:$DATAPATH"
fi
done
INPUT="n"
until [ "$INPUT" == "Y" ] || [ "$INPUT" == "y" ]
do
PASSWORD=""
echo "请输入mysql管理员用户root的密码?"
read PASSWORD
echo "您输入密码是:$PASSWORD,请确认(y|n)?"
read INPUT
if [ "$INPUT" != "Y" ] && [ "$INPUT" != "y" ]; then
echo "请确认密码后,重新输入:"
else
echo "密码为:$PASSWORD"
fi
done
rm -rf /etc/my.cnf
groupadd mysql
useradd -g mysql mysql
cd /home/server_2.0
tar -zxvf mysql-5.1.45.tar.gz
cd mysql-5.1.45
./configure --prefix=/usr/local/mysql --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static --enable-assembler --with-extra-charsets=gb2312,big5,utf8,binary,ascii --enable-thread-safe-client --with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock
sleep 10
make
sleep 10
make install
sleep 10
cp support-files/my-medium.cnf /etc/my.cnf
RETVAL=`cat /etc/my.cnf|grep 'default-character-set'`
if [ "$RETVAL" == "" ]; then
sed -i -e "s@\[client\]@\[client\]\ndefault-character-set = $ENCODE@" /etc/my.cnf
sed -i -e "s@\[mysqld\]@\[mysqld\]\ndefault-character-set = $ENCODE@" /etc/my.cnf
fi
##duanyunxi
sed -i -e "s@3306@$PORT@" /etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysql
chmod +x /etc/init.d/mysql
###duanyunxi
sed -i -e "40,50s@basedir=@basedir=/usr/local/mysql@" /etc/init.d/mysql
sed -i -e "40,50s@datadir=@datadir=$DATAPATH@" /etc/init.d/mysql
chkconfig --del mysql && chkconfig --add mysql
chkconfig mysql on
cd /usr/local/mysql
bin/mysql_install_db --user=mysql --datadir=$DATAPATH
chown -R root .
chown -R mysql var
chgrp -R mysql .
service mysql start
rm -rf /usr/bin/mysql
ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
ln -s /usr/local/mysql/bin/mysqladmin /usr/bin/mysqladmin
####duanyunxi
ln -s /usr/local/mysql/bin/mysqldump /usr/bin/mysqldump
mysqladmin -u root password "$PASSWORD"
mysqladmin -h localhost -u root password "$PASSWORD"
mysqladmin -uroot -p$PASSWORD version 1> /dev/null 2>&1
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
echo "mysql has installed successfully!" >> /var/installserver.tmp
echo "mysql安装完成!"
fi
touch /var/mysql.sql
echo "SET NAMES utf8;" >> /var/mysql.sql
echo "USE \`mysql\`;" >> /var/mysql.sql
echo "INSERT INTO \`user\` VALUES ('%','root',PASSWORD('$PASSWORD'),'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','N','N','N','N','N','','','','',0,0,0,0);" >> /var/mysql.sql
mysql -uroot -p$PASSWORD mysql</var/mysql.sql
rm -rf /var/mysql.sql
service mysql stop
sleep 10
else
echo "mysql已经安装过了!"
fi
fi
# ##设置防火墙##
# echo "##设置防火墙!##"
# if [ -f /var/installserver.tmp ]; then
# RETVAL=`cat /etc/sysconfig/SuSEfirewall2|grep 'FW_SERVICES_EXT_TCP'|grep '80 8080 443 3306'`
# if [ "$RETVAL" == "" ]; then
# sed -i -e "s@FW_SERVICES_EXT_TCP=\"\"@FW_SERVICES_EXT_TCP=\"80 8080 443 3306\"@" /etc/sysconfig/SuSEfirewall2
# fi
#
# RETVAL=`cat /etc/sysconfig/SuSEfirewall2|grep 'FW_SERVICES_EXT_UDP'|grep '177'`
# if [ "$RETVAL" == "" ]; then
# sed -i -e "s@FW_SERVICES_EXT_UDP=\"\"@FW_SERVICES_EXT_UDP=\"177\"@" /etc/sysconfig/SuSEfirewall2
# fi
# rcSuSEfirewall2 restart
# echo "防火墙设置完成!"
# fi
######duanyunxi
##设置防火墙##
echo "##设置防火墙!##"
if [ -f /var/installserver.tmp ]; then
RETVAL=`cat /var/installserver.tmp|grep 'SuSEfirewall2'|grep 'successfully'`
if [ "$RETVAL" == "" ]; then
INPUT="n"
until [ "$INPUT" == "Y" ] || [ "$INPUT" == "y" ]
do
PORTS=""
echo "请输入开放resin,mysql的端口号?(*空格隔开)"
read PORTS
echo "您输入端口号是:$PORTS,请确认(y|n)?"
read INPUT
if [ "$INPUT" != "Y" ] && [ "$INPUT" != "y" ]; then
echo "请确认开放端口后,重新输入:"
else
echo "SuSEfirewall2_PORTS=$PORTS" >> /var/installserver.tmp
echo "SuSEfirewall2 has set successfully!" >> /var/installserver.tmp
echo "开放resin,mysql的端口有:$PORTS"
fi
sed -i -e "s@FW_SERVICES_EXT_TCP=\"@FW_SERVICES_EXT_TCP=\"$PORTS 80 22 443 @" /etc/sysconfig/SuSEfirewall2
sed -i -e "s@FW_SERVICES_EXT_UDP=\"\"@FW_SERVICES_EXT_UDP=\"177\"@" /etc/sysconfig/SuSEfirewall2
done
rcSuSEfirewall2 restart
echo "防火墙设置完成!"
fi
fi
echo "service resin (start|stop|restart)"
echo "service nginx (start|stop|restart)"
echo "service mysql (start|stop|restart|status)"
#作者:duanyunxi
#版本:v2.0
touch /var/installserver.tmp
##开始准备工作##
echo "##开始准备工作!##"
if [ -f /var/installserver.tmp ]; then
RETVAL=`grep 'ready' /var/installserver.tmp`
if [ "$RETVAL" == "" ]; then
echo "##确认server_2.0的路径!##"
echo "请输入server_2.0所在的位置,例如:/home/server_2.0.tar.gz"
INPUT="n"
until [ "$INPUT" == "Y" ] || [ "$INPUT" == "y" ]
do
read SERVERPATH
echo "您输入server_2.0所在的位置是:$SERVERPATH,请确认(y|n)?"
read INPUT
if [ "$INPUT" != "Y" ] && [ "$INPUT" != "y" ]; then
echo "请确认server_2.0所在的位置后,重新输入:"
else
echo "server_2.0所在的位置为:$SERVERPATH"
fi
done
echo "##解压server_2.0!##"
cd /home
cp $SERVERPATH /home/server_2.0.tar.gz
tar xzf server_2.0.tar.gz
chmod 755 -R server_2.0
echo "ready ok!" >> /var/installserver.tmp
echo "准备工作已经完成!"
sleep 10
else
echo "准备工作已经做过!"
fi
fi
##开始安装JDK##
echo "##开始安装JDK!##"
if [ -f /var/installserver.tmp ]; then
RETVAL=`cat /var/installserver.tmp|grep 'jdk'|grep 'successfully'`
if [ "$RETVAL" == "" ]; then
cd /home/server_2.0
chmod u+x ./jdk-6u19-linux-i586.bin
./jdk-6u19-linux-i586.bin
mv jdk1.6.0_19 /usr/local/jdk
ln -s /usr/local/jdk/bin/java /usr/bin/java
ln -s /usr/local/jdk/bin/javac /usr/bin/javac
ln -s /usr/local/jdk/jre /usr/local/jre
echo "jdk has installed successfully!" >> /var/installserver.tmp
echo "JDK安装完成!"
sleep 10
else
echo "JDK已经安装过了!"
fi
fi
##开始配置JDK环境变量##
echo "##开始配置JDK环境变量!##"
if [ -f /var/installserver.tmp ]; then
RETVAL=`cat /etc/profile|grep 'JAVA_HOME'`
if [ "$RETVAL" == "" ]; then
echo "" >> /etc/profile
echo 'JAVA_HOME=/usr/local/jdk' >> /etc/profile
echo 'JRE_HOME=/usr/local/jre' >> /etc/profile
echo 'PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin' >> /etc/profile
echo 'CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib:' >> /etc/profile
echo 'export JAVA_HOME JRE_HOME PATH CLASSPATH' >> /etc/profile
source /etc/profile
echo "JDK环境变量配置完成!"
else
echo "JDK环境变量已经配置过了!"
fi
java -version
fi
##开始安装resin##
echo "##开始安装resin!##"
if [ -f /var/installserver.tmp ]; then
RETVAL=`cat /var/installserver.tmp|grep 'resin'|grep 'successfully'`
if [ "$RETVAL" == "" ]; then
#####duanyunxi-2010-10-28
INPUT="n"
until [ "$INPUT" == "Y" ] || [ "$INPUT" == "y" ]
do
PORT=""
echo "请输入resin的端口号?(8000-8999)"
read PORT
if [ ${PORT} -lt 8000 ] || [ ${PORT} -gt 8999 ]; then
echo "您输入的端口号超出范围,重新输入:"
read PORT
fi
echo "您输入端口号是:$PORT,请确认(y|n)?"
read INPUT
if [ "$INPUT" != "Y" ] && [ "$INPUT" != "y" ]; then
echo "请确认端口后,重新输入:"
else
echo "RESIN_PORT=$PORT" >> /var/installserver.tmp
echo "端口为:$PORT"
fi
done
cd /home/server_2.0
tar -zxvf resin-pro-3.1.10.tar.gz
cd resin-pro-3.1.10
./configure --prefix=/usr/local/resin --enable-jni
sleep 10
make
sleep 10
make install
sleep 10
RETVAL=`cat /etc/profile|grep 'RESIN_HOME'`
if [ "$RETVAL" == "" ]; then
echo "" >> /etc/profile
echo 'RESIN_HOME=/usr/local/resin' >> /etc/profile
echo 'export RESIN_HOME ' >> /etc/profile
source /etc/profile
echo "resin环境变量配置完成!"
fi
##duanyunxi
sed -i -e "s@8080@$PORT@" /usr/local/resin/conf/resin.conf
cp /home/server_2.0/resin.init /etc/init.d/resin
chmod +x /etc/init.d/resin
chkconfig --del resin && chkconfig --add resin
chkconfig resin on
echo "resin has installed successfully!" >> /var/installserver.tmp
echo "resin安装完成!"
sleep 10
else
echo "resin已经安装过了!"
fi
fi
##开始安装nginx##
echo "##开始安装nginx!##"
if [ -f /var/installserver.tmp ]; then
RETVAL=`cat /var/installserver.tmp|grep 'nginx'|grep 'successfully'`
if [ "$RETVAL" == "" ]; then
cd /home/server_2.0
tar -zxvf pcre-7.8.tar.gz
tar -zxvf zlib-1.2.2.tar.gz
tar zxvf openssl-0.9.8k.tar.gz
tar zxvf nginx-0.8.38.tar.gz
cd nginx-0.8.38/
./configure --prefix=/usr/local/nginx --with-pcre=/home/server_2.0/pcre-7.8 --with-zlib=/home/server_2.0/zlib-1.2.2 --with-openssl=/home/server_2.0/openssl-0.9.8k \
--with-http_ssl_module --with-http_realip_module --with-http_flv_module --with-http_gzip_static_module --with-http_stub_status_module
sleep 10
make
sleep 10
make install
sleep 10
cp /home/server_2.0/nginx.init /etc/init.d/nginx
chmod +x /etc/init.d/nginx
chkconfig --del nginx && chkconfig --add nginx
chkconfig nginx on
echo "nginx has installed successfully!" >> /var/installserver.tmp
echo "nginx安装完成!"
else
echo "nginx已经安装过了!"
sleep 10
fi
fi
##开始安装mysql##
echo "##开始安装mysql!##"
if [ -f /var/installserver.tmp ]; then
RETVAL=`cat /var/installserver.tmp|grep 'mysql'|grep 'successfully'`
if [ "$RETVAL" == "" ]; then
INPUT="n"
until [ "$INPUT" == "Y" ] || [ "$INPUT" == "y" ]
do
ENCODE=""
echo "请选择mysql的编码(g:gbk|u:utf8)?"
read ENCODE
if [ "$ENCODE" == "G" ] || [ "$ENCODE" == "g" ]; then
echo "您选择的编码是gbk,请确认(y|n)?"
ENCODE="gbk"
elif [ "$ENCODE" == "U" ] || [ "$ENCODE" == "u" ]; then
echo "您选择的编码是utf8,请确认(y|n)?"
ENCODE="utf8"
fi
read INPUT
if [ "$INPUT" != "Y" ] && [ "$INPUT" != "y" ]; then
echo "请确认后,重新输入:"
else
echo "MYSQL_ENCODE=$ENCODE" >> /var/installserver.tmp
echo "mysql的编码为:$ENCODE"
fi
done
#####duanyunxi-2010-10-28
INPUT="n"
until [ "$INPUT" == "Y" ] || [ "$INPUT" == "y" ]
do
PORT=""
echo "请输入mysql的端口号?(8000-8999)"
read PORT
if [ ${PORT} -lt 8000 ] || [ ${PORT} -gt 8999 ]; then
echo "您输入的端口号超出范围,重新输入:"
read PORT
fi
echo "您输入端口号是:$PORT,请确认(y|n)?"
read INPUT
if [ "$INPUT" != "Y" ] && [ "$INPUT" != "y" ]; then
echo "请确认端口后,重新输入:"
else
echo "MYSQL_PORT=$PORT" >> /var/installserver.tmp
echo "端口为:$PORT"
fi
done
INPUT="n"
until [ "$INPUT" == "Y" ] || [ "$INPUT" == "y" ]
do
DATAPATH=""
echo "请输入数据存放位置,例如:/var/data"
read DATAPATH
echo "您输入数据存放位置是:$DATAPATH,请确认(y|n)?"
read INPUT
if [ "$INPUT" != "Y" ] && [ "$INPUT" != "y" ]; then
echo "请确认数据存放位置后,重新输入:"
else
echo "DATA_PATH=$DATAPATH" >> /var/installserver.tmp
echo "数据存放位置为:$DATAPATH"
fi
done
INPUT="n"
until [ "$INPUT" == "Y" ] || [ "$INPUT" == "y" ]
do
PASSWORD=""
echo "请输入mysql管理员用户root的密码?"
read PASSWORD
echo "您输入密码是:$PASSWORD,请确认(y|n)?"
read INPUT
if [ "$INPUT" != "Y" ] && [ "$INPUT" != "y" ]; then
echo "请确认密码后,重新输入:"
else
echo "密码为:$PASSWORD"
fi
done
rm -rf /etc/my.cnf
groupadd mysql
useradd -g mysql mysql
cd /home/server_2.0
tar -zxvf mysql-5.1.45.tar.gz
cd mysql-5.1.45
./configure --prefix=/usr/local/mysql --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static --enable-assembler --with-extra-charsets=gb2312,big5,utf8,binary,ascii --enable-thread-safe-client --with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock
sleep 10
make
sleep 10
make install
sleep 10
cp support-files/my-medium.cnf /etc/my.cnf
RETVAL=`cat /etc/my.cnf|grep 'default-character-set'`
if [ "$RETVAL" == "" ]; then
sed -i -e "s@\[client\]@\[client\]\ndefault-character-set = $ENCODE@" /etc/my.cnf
sed -i -e "s@\[mysqld\]@\[mysqld\]\ndefault-character-set = $ENCODE@" /etc/my.cnf
fi
##duanyunxi
sed -i -e "s@3306@$PORT@" /etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysql
chmod +x /etc/init.d/mysql
###duanyunxi
sed -i -e "40,50s@basedir=@basedir=/usr/local/mysql@" /etc/init.d/mysql
sed -i -e "40,50s@datadir=@datadir=$DATAPATH@" /etc/init.d/mysql
chkconfig --del mysql && chkconfig --add mysql
chkconfig mysql on
cd /usr/local/mysql
bin/mysql_install_db --user=mysql --datadir=$DATAPATH
chown -R root .
chown -R mysql var
chgrp -R mysql .
service mysql start
rm -rf /usr/bin/mysql
ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
ln -s /usr/local/mysql/bin/mysqladmin /usr/bin/mysqladmin
####duanyunxi
ln -s /usr/local/mysql/bin/mysqldump /usr/bin/mysqldump
mysqladmin -u root password "$PASSWORD"
mysqladmin -h localhost -u root password "$PASSWORD"
mysqladmin -uroot -p$PASSWORD version 1> /dev/null 2>&1
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
echo "mysql has installed successfully!" >> /var/installserver.tmp
echo "mysql安装完成!"
fi
touch /var/mysql.sql
echo "SET NAMES utf8;" >> /var/mysql.sql
echo "USE \`mysql\`;" >> /var/mysql.sql
echo "INSERT INTO \`user\` VALUES ('%','root',PASSWORD('$PASSWORD'),'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','N','N','N','N','N','','','','',0,0,0,0);" >> /var/mysql.sql
mysql -uroot -p$PASSWORD mysql</var/mysql.sql
rm -rf /var/mysql.sql
service mysql stop
sleep 10
else
echo "mysql已经安装过了!"
fi
fi
# ##设置防火墙##
# echo "##设置防火墙!##"
# if [ -f /var/installserver.tmp ]; then
# RETVAL=`cat /etc/sysconfig/SuSEfirewall2|grep 'FW_SERVICES_EXT_TCP'|grep '80 8080 443 3306'`
# if [ "$RETVAL" == "" ]; then
# sed -i -e "s@FW_SERVICES_EXT_TCP=\"\"@FW_SERVICES_EXT_TCP=\"80 8080 443 3306\"@" /etc/sysconfig/SuSEfirewall2
# fi
#
# RETVAL=`cat /etc/sysconfig/SuSEfirewall2|grep 'FW_SERVICES_EXT_UDP'|grep '177'`
# if [ "$RETVAL" == "" ]; then
# sed -i -e "s@FW_SERVICES_EXT_UDP=\"\"@FW_SERVICES_EXT_UDP=\"177\"@" /etc/sysconfig/SuSEfirewall2
# fi
# rcSuSEfirewall2 restart
# echo "防火墙设置完成!"
# fi
######duanyunxi
##设置防火墙##
echo "##设置防火墙!##"
if [ -f /var/installserver.tmp ]; then
RETVAL=`cat /var/installserver.tmp|grep 'SuSEfirewall2'|grep 'successfully'`
if [ "$RETVAL" == "" ]; then
INPUT="n"
until [ "$INPUT" == "Y" ] || [ "$INPUT" == "y" ]
do
PORTS=""
echo "请输入开放resin,mysql的端口号?(*空格隔开)"
read PORTS
echo "您输入端口号是:$PORTS,请确认(y|n)?"
read INPUT
if [ "$INPUT" != "Y" ] && [ "$INPUT" != "y" ]; then
echo "请确认开放端口后,重新输入:"
else
echo "SuSEfirewall2_PORTS=$PORTS" >> /var/installserver.tmp
echo "SuSEfirewall2 has set successfully!" >> /var/installserver.tmp
echo "开放resin,mysql的端口有:$PORTS"
fi
sed -i -e "s@FW_SERVICES_EXT_TCP=\"@FW_SERVICES_EXT_TCP=\"$PORTS 80 22 443 @" /etc/sysconfig/SuSEfirewall2
sed -i -e "s@FW_SERVICES_EXT_UDP=\"\"@FW_SERVICES_EXT_UDP=\"177\"@" /etc/sysconfig/SuSEfirewall2
done
rcSuSEfirewall2 restart
echo "防火墙设置完成!"
fi
fi
echo "service resin (start|stop|restart)"
echo "service nginx (start|stop|restart)"
echo "service mysql (start|stop|restart|status)"
相关推荐
DNS 服务器配置是 SuSE Linux 中的一项重要任务,本文档旨在指导用户如何配置 SUSE Linux DNS 服务器,涵盖了 DNS 服务器的基础知识、 BIND 套件安装、 DNS 服务器配置、区域文档文件创建等内容。 一、DNS 服务器...
- 使用SSH或CRT等终端工具登录到SUSE服务器。 2. **启动YAST** - 输入`yast`命令启动YAST配置工具。 ##### 3.2 配置Network Services 1. **选择Network Services** - 在YAST界面中,左侧列表选择“Network ...
Suselinux11 NTP服务器端搭建设置宣贯 1. 查看系统时钟 在 Linux 系统中,查看系统时钟可以使用 `date` 命令。该命令将显示当前系统的日期和时间信息。系统时钟是 Linux 内核时钟,用于记录系统的当前时间。 2. ...
### SUSE 下 Samba 服务器配置详解 #### 一、Samba 服务器简介与功能 Samba 是一款在 Linux 或 Unix 类系统上实现 SMB(Server Message Block)协议的开源软件,它可以让用户在 Linux 和 Windows 系统之间共享文件...
SUSE系统telnet安装和配置 Telnet是一种常用的网络服务,允许用户远程登录到服务器,执行命令和管理服务器。以下是SUSE系统中telnet的安装和配置步骤: 1. 安装telnet 在SUSE系统中,telnet通常是默认安装的。...
"Suse 11 安装配置 Sybase 15.0.3 主要流程" 本文主要介绍了在 Suse 11 操作系统上安装和配置 Sybase 15.0.3 的主要流程。整个安装过程可以分为五个步骤:配置系统参数、建立 Sybase 账户、复制解压 Sybase 安装...
1. **硬件**:需要两台装有Suse Linux 11 SP1操作系统的服务器,每台服务器至少配置两块网卡,以实现网络冗余和心跳检测。 2. **软件**:除了操作系统基础镜像外,还需要Suse 11 SP1的HA扩展镜像(SLE-11-SP1-HA-x86_...
根据给定的文件信息,我们可以提炼出以下关于在SUSE Linux环境下配置SVN(Subversion)服务器的关键知识点,尽管原始内容提及的是在Red Hat Linux 5.5下的配置流程,但核心步骤和概念同样适用于SUSE Linux系统。...
在Linux系统中,SUSE Linux Enterprise(SLE)是一个广泛使用的服务器操作系统,尤其在企业环境中。网卡配置是系统管理中的重要环节,确保网络连接稳定可靠。本文将深入讲解SUSE Linux中的网卡配置,包括基本概念、...
在SUSE Linux 10系统中配置VNC服务器是一个实用的过程,这允许用户通过VNC客户端从远程位置访问和控制Linux桌面环境。以下是一个详细的步骤指南: 1. **下载VNC软件**: 首先,你需要从RealVNC的官方网站下载VNC...
在SUSE Linux Enterprise Server 11 SP1上安装SUSE自带的HA产品是一个关键任务,涉及到服务器的高可用性和故障转移能力。以下是对整个安装过程的详细说明: ### 1. 准备阶段 在开始安装之前,确保你有一个完整的...
SUSE_Linux搭建企业服务器的双机配置过程SUSE_Linux搭建企业服务器的双机配置过程
《SuSE Linux企业服务器权威指南》是一本专为IT专业人士准备的深度解析SuSE Linux Enterprise Server的书籍。这本书详尽地介绍了如何安装、配置、管理和维护SuSE Linux Enterprise Server,帮助读者掌握在企业环境中...
### SUSE 9 自动安装服务器配置指南 #### 一、引言 本文将详细介绍如何在IBM X226服务器上配置SUSE Linux Enterprise Server (SLES) 9的自动安装服务器。通过这种方式,可以实现SLES 9的批量部署,极大提高工作效率...
SUSE配置PHP是一种常见的服务器配置方法,涉及到多个组件的安装和配置,包括apache、php、mysql、gd2等。下面将逐步解析这些组件的安装和配置过程。 一、安装mysql 在SUSE系统中,安装mysql可以通过凯莉系统安装,...
SUSE LINUX 系统备份恢复配置收集 Suselinux 系统备份恢复配置收集是指在 Suselinux 操作系统中对系统进行备份和恢复的配置收集,旨在确保系统的安全和可靠性。下面是 Suselinux 系统备份恢复配置收集的详细说明:...
SUSE-Linux下配置PXE自动安装SUSE-Linux系统。Linux下DNS服务器的配置。
本文将详细探讨Dell服务器在SUSE11SP1环境下配置和管理RAID驱动的相关知识点。 首先,了解RAID的基本概念。RAID是一种通过在多个硬盘上分布数据来提高存储性能、容错能力或两者兼有的技术。常见的RAID级别有RAID 0...
### Suse Linux 10.3 配置 CVS 服务 #### 一、概述 CVS(Concurrent Versions System)是一种版本控制系统,主要用于管理软件项目的源代码版本控制。本文将详细介绍如何在 Suse Linux 10.3 上配置并设置 CVS 服务...
总之,OceanStor V3系列存储系统与SUSE服务器的IP SAN配置是一个复杂但关键的过程,涉及到网络规划、存储系统设置、服务器配置等多个环节。正确配置和管理IP SAN能够提高数据中心的灵活性、可靠性和效率,确保业务...