入手了一台16核128G 100M CentOS 6.8
cd /usr/local
官方下载jdk-8u111-linux-x64.tar.gz
mkdir java
tar -zxvf jdk-8u111-linux-x64.tar.gz -C java
配置环境变量
vi /etc/profile.d/jvm.sh
内容写入
JAVA_HOME=/usr/local/java/jdk1.8.0_111
CLASSPATH=$JAVA_HOME/lib/
PATH=$PATH:$JAVA_HOME/bin
export PATH JAVA_HOME CLASSPATH
官方下载apache-tomcat-9.0.0.M15.tar.gz
tar -zxvf apache-tomcat-9.0.0.M15.tar.gz
mv apache-tomcat-9.0.0.M15 tomcat
安装库
yum install pcre pcre-devel -y
yum install openssl openssl-devel -y
官方下载nginx-1.11.8.tar.gz
tar -zxvf nginx-1.11.8.tar.gz
cd nginx-1.11.8
useradd -s /sbin/nologin -M nginx
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module
make && make install
cd ..
配置脚本
参考https://www.nginx.com/resources/wiki/start/topics/examples/redhatnginxinit/
vim /etc/init.d/nginx
写入
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
nginx="/usr/local/nginx/sbin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE="/usr/local/nginx/nginx.conf"
[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
lockfile=/var/lock/subsys/nginx
make_dirs() {
# make required directories
user=`$nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
if [ -z "`grep $user /etc/passwd`" ]; then
useradd -M -s /bin/nologin $user
fi
options=`$nginx -V 2>&1 | grep 'configure arguments:'`
for opt in $options; do
if [ `echo $opt | grep '.*-temp-path'` ]; then
value=`echo $opt | cut -d "=" -f 2`
if [ ! -d "$value" ]; then
# echo "creating" $value
mkdir -p $value && chown -R $user $value
fi
fi
done
}
start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
make_dirs
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
configtest || return $?
stop
sleep 1
start
}
reload() {
configtest || return $?
echo -n $"Reloading $prog: "
killproc $nginx -HUP
RETVAL=$?
echo
}
force_reload() {
restart
}
configtest() {
$nginx -t -c $NGINX_CONF_FILE
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit 2
esac
修改权限
chmod 755 /etc/init.d/nginx
增加到服务
chkconfig --add /etc/init.d/nginx
chkconfig nginx on
检查旧版本mysql,然后移除
yum list installed | grep mysql
yum -y remove mysql-libs.x86_64
find / -name mysql
rm -rf /var/lib/mysql
rm -rf /etc/my.cnf #这个玩意不会被自动移除
开始安装
wget http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
rpm -ivh mysql-community-release-el6-5.noarch.rpm
yum install mysql-server
service mysqld start
chkconfig mysqld on
mysql_secure_installation
tar -zxvf redis-4.0.1.tar.gz
cd redis-4.0.1
make && make install PREFIX=/usr/local/redis
cd ..
cp redis-4.0.1/redis.conf redis/
配置redis
vi redis/redis.conf
方便远程调式
line 70
bind 127.0.0.1
->
bind 0.0.0.0
设置为后台运行
line 136
daemonize no
->
daemonize yes
设置密码
line 500
# requirepass foobared
->
requirepass 新密码
设置redis最大内存使用,默认是不限
line 559
# maxmemory
->
maxmemory 68719476736
内存策略
line 590
# maxmemory-policy noeviction
->
maxmemory-policy volatile-ttl
安装完毕后发现有3个WARNING
1. WARNING: The TCP backlog setting of 511 ……
2. WARNING overcommit_memory is set to 0! Backgr ……
3. WARNING you have Transparent Huge Pages (THP) support ……
解决#1,2
vi /etc/sysctl.conf
追加内容
net.core.somaxconn = 511
vm.overcommit_memory=1
保存后使之生效
sysctl -p
解决#3
vi /etc/rc.local
追加内容
if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
echo never > /sys/kernel/mm/transparent_hugepage/enabled
fi
if test -f /sys/kernel/mm/transparent_hugepage/defrag; then
echo never > /sys/kernel/mm/transparent_hugepage/defrag
fi
配置写脚本
vi /etc/init.d/redis
内容
PATH=/usr/local/bin:/sbin:/usr/bin:/bin
REDISPORT=6379
EXEC=/usr/local/redis/bin/redis-server
REDIS_CLI=/usr/local/redis/bin/redis-cli
PIDFILE=/var/run/redis.pid
CONF="/usr/local/redis/redis.conf"
case "$1" in
start)
if [ -f $PIDFILE ]
then
echo "$PIDFILE exists, process is already running or crashed."
else
echo "Starting Redis server..."
$EXEC $CONF
fi
if [ "$?"="0" ]
then
echo "Redis is running..."
fi
;;
stop)
if [ ! -f $PIDFILE ]
then
echo "$PIDFILE exists, process is not running."
else
PID=$(cat $PIDFILE)
echo "Stopping..."
$REDIS_CLI -p $REDISPORT SHUTDOWN
sleep 2
while [ -x $PIDFILE ]
do
echo "Waiting for Redis to shutdown..."
sleep 1
done
echo "Redis stopped"
fi
;;
restart|force-reload)
${0} stop
${0} start
;;
*)
echo "Usage: /etc/init.d/redis {start|stop|restart|force-reload}" >&2
exit 1
esac
修改权限
chmod 755 /etc/init.d/redis
增加到服务
chkconfig --add /etc/init.d/redis
chkconfig redis on