07月04, 2017

linux基础环境安装

mysql

env

yum remove mariadb*
yum install epel-release
yum install -y jemalloc perl perl-Data-Dumper perl-JSON net-tools

ff

rpm -ivh *.rpm

关闭 THP
THP(Transparent Huge Pages) 在有数据库服务(Mysql、Redis、MongoDB)的机器上都是建议关闭的 不然总会发生莫名其妙的事情,TokuDB 也是一定要关闭的。

在 /etc/rc.local 加入如下语句,这样就算重启系统也会自动关闭 THP

echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag

# systemctl start mysqld
默认密码在:grep password /var/log/mysqld.log
首次登录需呀修改一次
set global validate_password_policy=0;
ALTER USER 'root'@'%' IDENTIFIED BY 'dev@mysql';
flush privileges;

mongo

yum install numactl -y
rpm -ivh Percona-Server-MongoDB-34-*
# 创建用户
/usr/bin/percona-server-mongodb-enable-auth.sh

redis

yum install -y wget make gcc tcl && make distclean && make && make install

jetty

init webapp

#!/bin/bash
JAVA_HOME=/www/env/java
export JAVA_HOME
JETTY_HOME=/www/server/jetty
JETTY_BASE=$(cd $(dirname $0);pwd)
java -jar $JETTY_HOME/start.jar --create-startd
# EXT_MODULES=jmx,jmx-remote,session-store-mongo
JETTY_MODULES=ext,server,resources,http,deploy,slf4j-log4j2,jsp,jstl,servlet,jvm
java -jar $JETTY_HOME/start.jar --add-to-start=$JETTY_MODULES

更新日志配置

mkdir $JETTY_BASE/resources -p
touch $JETTY_BASE/resources/log4j2.xml
cat > $JETTY_BASE/resources/log4j2.xml <<END
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="warn" name="Jetty" >
  <Properties>
    <Property name="jetty.logging.dir" value="logs"/>
  </Properties>
  <Loggers>
    <Root level="error">
      <AppenderRef ref="STDOUT"/>
    </Root>
  </Loggers>
  <Appenders>
    <Console name="console" target="SYSTEM_ERR">
      <PatternLayout>
        <Pattern>%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n</Pattern>
      </PatternLayout>
    </Console>
    <RollingFile name="file"
      fileName="logs/jetty.log"
      filePattern="logs/jetty-%d{MM-dd-yyyy}.log.gz"
      ignoreExceptions="false">
      <PatternLayout>
        <Pattern>%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n</Pattern>
      </PatternLayout>
      <SizeBasedTriggeringPolicy size="500MB"/>
      <DefaultRolloverStrategy max="160"/>
    </RollingFile>
  </Appenders>
  <Loggers>
    <Root level="info">
      <AppenderRef ref="console"/>
      <AppenderRef ref="file"/>
    </Root>
  </Loggers>
</Configuration>
END

更新jetty.sh

JAVA=/www/env/java/bin/java
JETTY_HOME=/www/server/jetty
JETTY_BASE=$(cd $(dirname $0);pwd)
NAME=$(basename $JETTY_BASE)
JETTY_PID=${JETTY_BASE}/${NAME}.pid
JETTY_STATE=${JETTY_BASE}/${NAME}.state

jvm config

-Xms1g
-Xmx2g
-XX:NewSize=256m
-XX:MaxNewSize=512m
-XX:MetaspaceSize=128m
-XX:MaxMetaspaceSize=512m
-XX:AutoBoxCacheMax=20000
-Xloggc:/www/logs/gc-www.log
-XX:+HeapDumpOnOutOfMemoryError
-XX:+PrintGCDetails
-XX:+PrintGCDateStamps
-XX:+PrintHeapAtGC
-XX:+PrintTenuringDistribution
-XX:+PrintGCApplicationStoppedTime
-XX:+PrintPromotionFailure
-XX:+UseGCLogFileRotation
-XX:NumberOfGCLogFiles=10
-XX:GCLogFileSize=10M
-Dcom.sun.management.jmxremote
-Djava.rmi.server.hostname=ip
-Dcom.sun.management.jmxremote.port=50001
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Dspring.profiles.active=test

本文链接:https://blog.jnliok.com/post/install.html

-- EOF --

Comments