解析文件:./startup.sh 启动tomcat ./shutdown.sh 关闭tomcat
service tomcat stop停止tomcat服务
service tomcat start启动tomcat服务
添加端口(–permanent永久生效,没有此参数重启后失效)
firewall-cmd --add-port=8080/tcp --permanen
1、首先安装jdk在Xshell安装rz命令
服务器安装rz与sz命令:
yum install lrzsz
、准备JDK文件 可以去官网下载例如
rpm -e --nodeps java-1.7.0-openjdk-1.7.0.79-2.5.5.4.el6.x86_64rpm -e --nodeps java-1.6.0-openjdk-1.6.0.35-1.13.7.1.el6_6.x86_64这些类型
:检查之前版本;rpm -qa | grep java2:卸载之前安装所有;rpm -e --nodeps java-1.7.0-openjdk-1.7.0.79-2.5.5.4.el6.x86_64rpm -e --nodeps java-1.6.0-openjdk-1.6.0.35-1.13.7.1.el6_6.x86_64
- 安装jdk以及查看安装目录:1
- :安装jdk;rpm -ivh jdk-8u101-linux-x64.rpm2:查看安装目录;rpm -ql jdk1.8.0_101 | more
- 修改配置:1:修改指令;vi ~/.bash_profile 2:进入编辑模式追加;export JAVA_HOME=/usr/java/jdk1.8.0_101export PATH=$PATH:$JAVA_HOME/bin
- 设置立刻生效:source ~/.bash_profile(对于vi ~/.bash_profile要找jdk的安装路径里面有)
- 查看是否安装成功:java -version
注:一定要将mariaDB包和自带mysql包卸载干净,否则安装时出现各种奇妙错误,导致失败。
#rpm -qa | grep -i mariadb //查询安装的MariaDB
#rpm -e --nodeps 上面查到软件名 //卸载相关MariaDB的所有软件
找到的依赖要自己打,不可以填充
#find / -iname mariadb或者whereis mariadb 查找是否有相关配置目录及文件,如有,则 rm -rf 删除
卸载已有MySQL
//卸载旧版本的Mysql
rpm -qa | grep -i mysql //查看有没有安装mysql
rpm -e MySQL-client-5.6.38-1.el7.x86_64 //如果有,卸载旧版本Mysql及相关依赖包
//删除服务
chkconfig --list | grep -i mysql //查看服务
chkconfig --del mysql //删除服务
//删除mysql分散的文件夹
whereis mysql //查出相应的mysql文件夹,也可以用find / -name *mysql*
rm -rf /use/lib/mysql //删除
1、安装依赖软件注:先装好依赖,再装mysql。即使顺序出错,装完依赖一定要卸载mysql并重新装mysql,否则mysql装上了也会出现各种错误。
yum -y install autoconf
2、安装mysql将mysql的服务和客户端的rpm包放到opt目录下
安装的命令 #rpm -ivh MySQL-server-5.6.27-1.linux_glibc2.5.x86_64.rpm //-i是安装,-v是列出更多详细信息,-h是在安装时列出hash标记
安装一下三个就行:
MySQL-client-5.6.51-1.el7.x86_64
MySQL-server-5.6.51-1.el7.x86_64
MySQL-devel-5.6.51-1.el7.x86_64
3、设置mysql的root用户密码也可以去根目录
mysqld_safe --user=root --skip-grant-tables --skip-networking & //绕过密码登录,mysql未启动前设置
service mysql start //启动mysql
mysql -u root -p //登录
use mysql //切换数据库
UPDATe user SET password=password("123456") WHERe user='root'; //修改密码
quit //退出
#service mysql restart //重启mysql服务
#mysql -u root -proot // -proot,p代表password,root是密码
>use mysql //切换数据库
>set password = password('123456'); //第一次登陆必须修改mysql密码
>flush privileges; //刷新权限
4、赋予任何主机访问数据库的权限(远程访问)>grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option;
>flush privileges;//刷新权限
>quit //退出
# mysql service mysql restart //重启mysql
再root登陆mysql,重新设置一遍root的密码
5、设置防火墙开放3306端口 (Centos7以上是由firewall来管理的)//查看firewall状态(runing:运行,not runing:没有运行),如果没有运行,用systemctl start firewalld启动
firewall-cmd --state
firewall-cmd --permanent --zone=public --add-port=3306/tcp //添加3306端口
firewall-cmd --reload //重新加载firewall
6、设置mysql开机自启动#chkconfig mysql on //开启MySQL服务自动开启命令
修改数据库配置文件my.cnf
具体如下:
# The following options will be passed to all MySQL clients [client] # #password = [your_password] port = 3306 #`socket = /tmp/mysql.sock # # # # # # The MySQL server # # # [mysqld] # # #设置密码复杂度 # plugin-load-add=/usr/lib64/mysql/plugin/validate_password.so # #如果是windows设置密码复杂度 # plugin-load-add=validate_password.dll # port = 3306 # bind-address= 0.0.0.0 #socket = /tmp/mysql.socks # datadir = /home/mysql-data/mysql_data # tmpdir = /home/mysql-data/mysql_data/tmp # 为了提高效率 直接使用内存 来存放临时文件 # pid-file = /home/mysql-data/mysql_data/mysql_db.pid # ######basedir = /usr/local/mysql5.6.25 #bin路径 一般不该 character-set-server=utf8 lower_case_table_names=1 # #skip-locking #新版skip-external-locking # skip-external-locking # skip-host-cache # skip-name-resolve # # wait_timeout=3600 # 8 hour # #interactive_timeout=4233600 max_connections = 3000 max_connect_errors = 30 # #table_cache = 614 #给经常访问的表分配的内存,物理内存越大,设置就越大。5.6不支持哈 # table_open_cache = 4096 #设置表高速缓存的数目,如果Opened_tables数量过大,说明配置中table_open_cache的值可能太小 max_allowed_packet=2G # binlog_cache_size =4M # max_binlog_size = 500M # max_binlog_cache_size=128M # tmp_table_size = 128M # max_heap_table_size = 512M # join_buffer_size=64M # sort_buffer_size=64M # read_buffer_size=8M # thread_cache_size=64 #Threads_created如果此值过大,则说明线程池太小,需要调大线程池:thread_cache_size,建议和连接池相当 # #thread_concurrency = 4 #thread_concurrency应设为CPU核数的2倍 这个参数到5.6版本就去掉了 # query_cache_type=0 #建议关闭 0 # query_cache_size=64M # query_cache_limit = 4M # long_query_time=4 # log-queries-not-using-indexes #没有使用索引的查询也会被记录 # slow_query_log=0 # slow_query_log_file=/home/mysql-data/mysql-log/mysql-slow.log # open_files_limit=65535 # optimizer_switch=engine_condition_pushdown=on #控制mysql优化器行为 # back_log=500 # memlock # explicit_defaults_for_timestamp=true #列TIMESTAMP未声明为NULL的默认行为 # ft_min_word_len=1 # #*** INNODB *** # innodb_buffer_pool_size =2G #memory 60-80% 不超过数据大小 # #innodb_buffer_pool_instances = 8 #此设置待进一步优化 # innodb_data_file_path = ibdata1:1G:autoextend #初始化才使用 千万不要用默认的10M,否则在有高并发事务时,会受到不小的影响; # innodb_file_io_threads = 8 # innodb_thread_concurrency = 16 #几个CPU就设置为几 # innodb_flush_log_at_trx_commit = 2 #合理选择LOG刷新机制,主一般设置为1或者2,从库可以设置0. 1最安全,2较好性能,0最好性能 # innodb_log_buffer_size = 16M # innodb_log_file_size = 256M # innodb_log_files_in_group = 2 #循环方式将日志文件写到多个文件 # innodb_max_dirty_pages_pct = 90 # innodb_lock_wait_timeout = 120 # innodb_file_per_table = 1 #InnoDB为独立表空间模式,0关闭,1开启 # #innodb_force_recovery=1 #InnoDB re # #innodb_fast_shutdown #加速InnoDB的关闭 # #innodb_data_home_dir = # #innodb_log_group_home_dir= # #innodb_flush_method=O_DIRECT #OLTP 设置InnoDB同步IO的方式: # 如果要使用innodb,添加下面这些参数 # innodb_buffer_pool_size =128M # innodb_data_file_path = ibdata1:128M:autoextend # innodb_file_io_threads = 4 # innodb_thread_concurrency = 8 # innodb_flush_log_at_trx_commit = 2 # innodb_log_buffer_size = 16M # innodb_log_file_size = 256M # innodb_log_files_in_group = 2 # innodb_max_dirty_pages_pct = 90 # innodb_lock_wait_timeout = 120 # innodb_file_per_table = 1 # sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION" # #*** GTID log *** # #sync-master-info=1 # #master-info-repository=TABLE # #relay-log-info-repository=TABLE #slave on # #binlog-checksum=CRC32 # #master-verify-checksum=1 # #slave-sql-verify-checksum=1 #slave on # #binlog-rows-query-log_events=1 # log be good for ROW # #slave_allow_batching = 1 #slave on # #***master-salve*** # server-id=1 # log-bin=mysql-bin # log-bin=/home/mysql-data/mysql-log/mysql-bin # log-bin-index=/home/mysql-data/mysql-log/mysql-bin.index # #relay-log=/home/mysql-data/mysql-log/relay-bin # #relay_log_index =/home/mysql-data/mysql-log/relay-bin.index # log_error=/home/mysql-data/mysql-log/mysql-error.log # binlog-format=mixed #GTID use ROW other is mixed # #slave-parallel-workers=4 #多从库复制 # #relay_log_purge = 1 #Automatic repair relay # #relay_log_recovery = 1 #Automatic repair relay # #log_slave_updates=1 #slave on master off 是否把所有的 *** 作写入到binary log # sync_binlog = 1 #主从同步建议打开,负载高可以关闭 # #slave-skip-errors=all # ###binlog-do-db=syslog # ###binlog-ignore-db=mysql # ###replicate-do-db=syslog # ###replicate-ignore-db=mysql,test # expire_logs_days = 7 #auto del log # #***GTID config *** # #gtid-mode=on # #enforce-gtid-consistency = true # #report-port=3306 # #report-host=192.168.88.7 #ues localhost IP # #***end***** [mysqldump] quick max_allowed_packet = 2000M [mysqld_safe] open-files-limit = 8192 [mysql] no-auto-rehash #3、使用jsvc启动tomcat 1、首先下载
Jsvc安装
下载安装包tomcat,地址如下:
Apache Downloads
commons-daemon-1.0.15-src.tar.gz就在apache里面
二、安装步骤,参考链接
Daemon – Daemon : Java Service
2、解压文件commons-daemon-1.0.15-src.tar.gz,
进入到目录commons-daemon-1.0.15-src/src/native/unix
3、安装以下工具
$sudo apt-get install autoconf
如果GCC, Make, SDK等工具未安装,则一次安装。
3. Buildingfrom source
$ shsupport/buildconf.sh
4. Buildingfrom a release tarball.
$ export JAVA_HOME
$ ./configure
或者用以下命令代替以上两个命令(效果一样)
$./configure --with-Java=/usr/java(这里是JAVA_HOME的路径)
5.开始编译,成功后可在commons-daemon-1.0.15-src/src/native/unix目录下看到jsvc工具
$ make
6. 检查jsvc是否安装成功,出现相关的帮助信息则安装成功
$./jsvc –help
7、编译完成后出现jsvc文件夹,复制jsvc到/usr/lib/tomcat/apache-tomcat-xxxx/bin目录下面
[root@localhost ~]# cp jsvc /usr/lib/tomcat/apache-tomcat-xxxx/bin
8、在/etc/init.d/(注意不是init文件夹)目录下编写tomcat6启动服务配置文件。
[root@localhost ~]#cd /etc/init.d/
[root@localhost ~]# vi tomcat
tomcat配置文件如下#!/bin/sh #chkconfig:2345 90 15 # description Tomcat-en Manager # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR ConDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # ----------------------------------------------------------------------------- # Commons Daemon wrapper script. # # $Id: daemon.sh 1202058 2011-11-15 06:37:12Z mturk $ # ----------------------------------------------------------------------------- # # resolve links - $0 may be a softlink JAVA_HOME=/usr/java/jdk1.7.0_80 CATALINA_HOME=/usr/local/apache-tomcat-7.0.69 DAEMON_HOME=$CATALINA_HOME/bin TOMCAT_USER=op CATALINA_base=$CATALINA_HOME CATALINA_OPTS="-server -XX:MaxPermSize=512m -XX:MaxNewSize=512m -Xmx2048m" proc="Tomcat 7.0.69" #注意这里的名字将会在启动或停止的时候显示(标识名称) ARG0="$0" while [ -h "$ARG0" ]; do ls=`ls -ld "$ARG0"` link=`expr "$ls" : '.*-> .∗$'` if expr "$link" : '/.*' > /dev/null; then ARG0="$link" else ARG0="`dirname $ARG0`/$link" fi done DIRNAME="`dirname $ARG0`" PROGRAM="`basename $ARG0`" while [ ".$1" != . ] do case "$1" in --java-home ) JAVA_HOME="$2" shift; shift; continue ;; --catalina-home ) CATALINA_HOME="$2" shift; shift; continue ;; --catalina-base ) CATALINA_base="$2" shift; shift; continue ;; --catalina-pid ) CATALINA_PID="$2" shift; shift; continue ;; --tomcat-user ) TOMCAT_USER="$2" shift; shift; continue ;; * ) break ;; esac done # OS specific support (must be 'true' or 'false'). cygwin=false; darwin=false; case "`uname`" in CYGWIN*) cygwin=true ;; Darwin*) darwin=true ;; esac # Use the maximum available, or set MAX_FD != -1 to use that test ".$MAX_FD" = . && MAX_FD="maximum" # Setup parameters for running the jsvc # test ".$TOMCAT_USER" = . && TOMCAT_USER=tomcat # Set JAVA_HOME to working JDK or JRE # If not set we'll try to guess the JAVA_HOME # from java binary if on the PATH # if [ -z "$JAVA_HOME" ]; then JAVA_BIN="`which java 2>/dev/null || type java 2>&1`" test -x "$JAVA_BIN" && JAVA_HOME="`dirname $JAVA_BIN`" test ".$JAVA_HOME" != . && JAVA_HOME=`cd "$JAVA_HOME/.." >/dev/null; pwd` else JAVA_BIN="$JAVA_HOME/bin/java" fi # only set CATALINA_HOME if not already set test ".$CATALINA_HOME" = . && CATALINA_HOME=`cd "$DIRNAME/.." >/dev/null; pwd` test ".$CATALINA_base" = . && CATALINA_base="$CATALINA_HOME" test ".$CATALINA_MAIN" = . && CATALINA_MAIN=org.apache.catalina.startup.Bootstrap test ".$JSVC" = . && JSVC="$CATALINA_base/bin/jsvc" # Ensure that any user defined CLASSPATH variables are not used on startup, # but allow them to be specified in setenv.sh, in rare case when it is needed. CLASSPATH= if [ -r "$CATALINA_base/bin/setenv.sh" ]; then . "$CATALINA_base/bin/setenv.sh" elif [ -r "$CATALINA_HOME/bin/setenv.sh" ]; then . "$CATALINA_HOME/bin/setenv.sh" fi # Add on extra jar files to CLASSPATH test ".$CLASSPATH" != . && CLASSPATH="${CLASSPATH}:" CLASSPATH="$CLASSPATH$CATALINA_HOME/bin/bootstrap.jar:$CATALINA_HOME/bin/commons-daemon.jar" test ".$CATALINA_OUT" = . && CATALINA_OUT="$CATALINA_base/logs/catalina-daemon.out" test ".$CATALINA_TMP" = . && CATALINA_TMP="$CATALINA_base/temp" # Add tomcat-juli.jar to classpath # tomcat-juli.jar can be over-ridden per instance if [ -r "$CATALINA_base/bin/tomcat-juli.jar" ] ; then CLASSPATH="$CLASSPATH:$CATALINA_base/bin/tomcat-juli.jar" else CLASSPATH="$CLASSPATH:$CATALINA_HOME/bin/tomcat-juli.jar" fi # Set juli LogManager config file if it is present and an override has not been issued if [ -z "$LOGGING_CONFIG" ]; then if [ -r "$CATALINA_base/conf/logging.properties" ]; then LOGGING_ConFIG="-Djava.util.logging.config.file=$CATALINA_base/conf/logging.properties" else # Bugzilla 45585 LOGGING_ConFIG="-Dnop" fi fi test ".$LOGGING_MANAGER" = . && LOGGING_MANAGER="-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager" JAVA_OPTS="$JAVA_OPTS $LOGGING_MANAGER" # Set -pidfile test ".$CATALINA_PID" = . && CATALINA_PID="$CATALINA_base/logs/catalina-daemon.pid" # Increase the maximum file descriptors if we can if [ "$cygwin" = "false" ]; then MAX_FD_LIMIT=`ulimit -H -n` if [ "$?" -eq 0 ]; then # Darwin does not allow RLIMIT_INFINITY on file soft limit if [ "$darwin" = "true" -a "$MAX_FD_LIMIT" = "unlimited" ]; then MAX_FD_LIMIT=`/usr/sbin/sysctl -n kern.maxfilesperproc` fi test ".$MAX_FD" = ".maximum" && MAX_FD="$MAX_FD_LIMIT" ulimit -n $MAX_FD if [ "$?" -ne 0 ]; then echo "$PROGRAM: Could not set maximum file descriptor limit: $MAX_FD" fi else echo "$PROGRAM: Could not query system maximum file descriptor limit: $MAX_FD_LIMIT" fi fi # ----- Execute The Requested Command ----------------------------------------- case "$1" in run ) shift "$JSVC" $* -java-home "$JAVA_HOME" -pidfile "$CATALINA_PID" -wait 10 -nodetach -outfile "&1" -errfile "&2" -classpath "$CLASSPATH" "$LOGGING_CONFIG" $JAVA_OPTS $CATALINA_OPTS -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -Dcatalina.base="$CATALINA_base" -Dcatalina.home="$CATALINA_HOME" -Djava.io.tmpdir="$CATALINA_TMP" -Dfile.encoding="UTF-8" $CATALINA_MAIN echo -n "start $proc success." exit $? ;; start ) "$JSVC" -java-home "$JAVA_HOME" -user $TOMCAT_USER -pidfile "$CATALINA_PID" -wait 10 -outfile "$CATALINA_OUT" -errfile "&1" -classpath "$CLASSPATH" "$LOGGING_CONFIG" $JAVA_OPTS $CATALINA_OPTS -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -Dcatalina.base="$CATALINA_base" -Dcatalina.home="$CATALINA_HOME" -Djava.io.tmpdir="$CATALINA_TMP" -Dfile.encoding="UTF-8" $CATALINA_MAIN echo -n "start $proc success." exit $? ;; stop ) "$JSVC" $JSVC_OPTS -stop -pidfile "$CATALINA_PID" -classpath "$CLASSPATH" -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -Dcatalina.base="$CATALINA_base" -Dcatalina.home="$CATALINA_HOME" -Djava.io.tmpdir="$CATALINA_TMP" $CATALINA_MAIN echo -n "Stop $proc success." exit $? ;; version ) "$JSVC" -java-home "$JAVA_HOME" -pidfile "$CATALINA_PID" -classpath "$CLASSPATH" -errfile "&2" -version -check $CATALINA_MAIN if [ "$?" = 0 ]; then "$JAVA_BIN" -classpath "$CATALINA_HOME/lib/catalina.jar" org.apache.catalina.util.ServerInfo fi exit $? ;; * ) echo "Unknown command: `$1'" echo "Usage: $PROGRAM ( commands ... )" echo "commands:" echo " run Start Tomcat without detaching from console" echo " start Start Tomcat" echo " stop Stop Tomcat" echo " version What version of commons daemon and Tomcat" echo " are you running?" exit 1 ;; esac
对于权限问题,
总共有两个路径都要改
4、启动项目
把自己的在本地运行的项目拷贝出来,命名为Root
项目在tomcatapache-tomcat-7.0.69workCatalinalocalhost项目名
把项目拷出来,放到你要部署的服务器上边,具体放到的是你的tomcat里面的webapps里面
/opt/apache-tomcat-7.0.104/webapps/ROOT/
ROOT它是你走本地拷贝的文件,把他改成ROOT
在部署项目的时候这是本地配置
一些没写出来的还请见谅,还望指点一二。琪琪宝贝!
转载请艾特原创。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)