jenkins+nginx+tomcat+redis集群搭建

环境

  • [x] centos7
  • [x] jdk1.8
  • [x] tomcat7[一台服务器配置多个tomcat]
  • [x] maven
  • [x] redis-5.0.8不建议使用最新版本
  • [x] nginx1.7

软件安装

安装文件下载上传到服务器/tools,需要修改可执行权限

[root@localhost /]# chmod 777 /tools/*

如下,每个tar包都是可执行:

[root@bogon tools]# ll
total 205608
-rwxrwxrwx.  1 root root   9063587 Apr 22 19:29 apache-maven-3.6.0-bin.tar.gz
-rwxrwxrwx.  1 root root   9604761 Apr 22 19:29 apache-tomcat-7.0.103.tar.gz
-rwxrwxrwx.  1 root root 189784266 Apr 22 19:29 jdk-8u152-linux-x64.tar.gz
drwxr-xr-x. 10 1001 1001      4096 Apr 23 12:12 nginx-1.17.10
-rwxrwxrwx.  1 root root   1039541 Apr 14 10:24 nginx-1.17.10.tar.gz
-rwxrwxrwx.  1 root root   1039530 Apr 22 19:29 nginx-1.18.0.tar.gz

jdk安装

安装:

tar -zxvf jdk-8u152-linux-x64.tar.gz

配置

vim /etc/profile
添加如下


export JAVA_HOME=/usr/jdk1.8.0_152
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH


查看是否配置

执行命令:java -version

如下显示:

[root@bogon opt]# java -version
java version "1.8.0_152"
Java(TM) SE Runtime Environment (build 1.8.0_152-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.152-b16, mixed mode)
[root@bogon opt]# 

maven安装配置

安装

tar -zxvf apache-maven-3.6.0-bin.tar.gz

配置

vim /etc/profile
添加如下


export M2_HOME=/data/maven3
export MAVEN_OPTS=-"Xms512m -Xmx512m"
export PATH=$PATH:$M2_HOME/bin


查看是否配置

执行命令:mvn -version

显示如下:

[root@bogon opt]# mvn -version
Apache Maven 3.6.0 (97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 2018-10-24T14:41:47-04:00)
Maven home: /data/maven3
Java version: 1.8.0_152, vendor: Oracle Corporation, runtime: /usr/jdk1.8.0_152/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-327.el7.x86_64", arch: "amd64", family: "unix"
[root@bogon opt]# 

tomcat7安装配置

tomcat集群配置:参考http://xstarcd.github.io/wiki/Java/tomcat_cluster.html
https://blog.csdn.net/weixin_43840640/article/details/88847591
***********************************************

解压缩

tar -zxvf apache-tomcat-7.0.103

创建软链接

#tomcat1
[root@localhost software]# cp -r apache-tomcat-7.0.103 /opt/
[root@localhost opt]# ln -s apache-tomcat-7.0.103 tomcat

重复以上步骤两次

#tomcat2
[root@localhost opt]# cp -r apache-tomcat-8.5.38  apache-tomcat-8.5.38-2
[root@localhost opt]# ln -s apache-tomcat-8.5.38-2 tomcat2
#tomcat3
[root@localhost software]# cp -r apache-tomcat-8.5.38 apache-tomcat-8.5.38-3
[root@localhost opt]# ln -s apache-tomcat-8.5.38-3 tomcat3

结果如图所示:

[root@bogon opt]# ll
total 12
drwxr-xr-x. 10 root root 4096 Apr 23 19:18 apache-tomcat-7.0.103
drwxr-xr-x.  9 root root 4096 Apr 23 10:55 apache-tomcat-7.0.103-2
drwxr-xr-x.  9 root root 4096 Apr 23 10:38 apache-tomcat-7.0.103-3
drwxr-xr-x.  2 root root    6 Apr 23 19:18 tmp
lrwxrwxrwx.  1 root root   21 Apr 23 10:36 tomcat -> apache-tomcat-7.0.103
lrwxrwxrwx.  1 root root   23 Apr 23 10:38 tomcat2 -> apache-tomcat-7.0.103-2
lrwxrwxrwx.  1 root root   23 Apr 23 10:38 tomcat3 -> apache-tomcat-7.0.103-3
[root@bogon opt]# 

修改配置文件[3个文件]

因为配置了三个tomcat,防止启动文件冲突,修改tomcat的查找路径

首先,配置环境变量

[root@localhost ~]#vim /etc/profile

export CATALINA_BASE=/opt/tomcat
export CATALINA_HOME=/opt/tomcat
export TOMCAT_HOME=/opt/tomcat

export CATALINA2_BASE=/opt/tomcat2
export CATALINA2_HOME=/opt/tomcat2
export TOMCAT2_HOME=/opt/tomcat2

export CATALINA3_BASE=/opt/tomcat3
export CATALINA3_HOME=/opt/tomcat3
export TOMCAT3_HOME=/opt/tomcat3

修改后,运行source /etc/profile使该文件更新生效

随后,修改tomcat的启动文件,修改tomcat2和tomcat3的启动文件,因为该文件中的变量依旧是CATALINA_HOME 和 CATALINA_BASE

tomcat2:

[root@localhost ~]# vim  /opt/tomcat2/bin/catalina.sh 
添加如下:
export CATALINA_BASE=$CATALINA2_BASE
export CATALINA_HOME$CATALINA2_HOME
vi /opt/tomcat3/bin/catalina.sh
添加如下:
export CATALINA_BASE=$CATALINA3_BASE
export CATALINA_HOME$CATALINA3_HOME

修改tomcat端口号

部署的三台tomcat,默认的端口号是一样的,如果不修改的话,将第三个tomcat都启动之后,发现只有一个是可以被执行的。

一共需要修改三处:

第一处:tomcat、tomcat2、tomcat3依次设置为8005、8006、8007

cd /opt/tomcat/conf
vi server.xml
修改如下


第二处:tomcat、tomcat2、tomcat3依次设置为8080、8081、8082


第三处:tomcat、tomcat2、tomcat3依次设置为8009、8010、8011

    

tomcat配置开机启动

复制tomcat启动文件到开机目录下:cp /opt/tomcat/bin/catalina.sh /etc/rc.d/init.d/tomcat

修改上面的tomcat启动文件:vim /etc/rc.d/init.d/tomcat(在文件的最顶上添加下列几行)

#chkconfig:35 85 15
#description:tomcat1 server
CATALINA_HOME=/opt/tomcat
JRE_HOME=/usr/jdk1.8.0_152/

保存后执行以下命令:

[root@localhost ~]# chkconfig --add  tomcat
[root@localhost ~]# chkconfig --list tomcat
[root@localhost ~]# chkconfig tomcat on
[root@localhost ~]# service tomcat start

tomcat2和tomcat3自启动配置:重复上面的步骤

#tomcat2配置
[root@localhost ~]# cp /opt/tomcat2/bin/catalina.sh /etc/rc.d/init.d/tomcat2
[root@localhost ~]#vim /etc/rc.d/init.d/tomcat2

添加如下配置:
#chkconfig:35 85 15
#description:tomcat2 server
CATALINA_HOME=/opt/tomcat2
JRE_HOME=/usr/jdk1.8.0_152/

保存后执行以下命令:

[root@localhost ~]# chkconfig --add  tomcat2
[root@localhost ~]# chkconfig --list tomcat2
[root@localhost ~]# chkconfig tomcat2 on
[root@localhost ~]# service tomcat2 start
#tomcat3配置
[root@localhost ~]# cp /opt/tomcat2/bin/catalina.sh /etc/rc.d/init.d/tomcat3
[root@localhost ~]#vim /etc/rc.d/init.d/tomcat3

添加如下配置:
#chkconfig:35 85 15
#description:tomcat3 server
CATALINA_HOME=/opt/tomcat3
JRE_HOME=/usr/jdk1.8.0_152/

保存后执行以下命令:

[root@localhost ~]# chkconfig --add  tomcat3
[root@localhost ~]# chkconfig --list tomcat3
[root@localhost ~]# chkconfig tomcat3 on
[root@localhost ~]# service tomcat3 start

开启防火墙


#tomcat开启端口防火墙
firewall-cmd --add-port=8080/tcp --permanent && firewall-cmd --reload
firewall-cmd --add-port=8081/tcp --permanent && firewall-cmd --reload
firewall-cmd --add-port=8082/tcp --permanent && firewall-cmd --reload
#重新加载防火墙规则
firewall-cmd --reload

  1. 查看启动和端口号

[root@localhost ~]# netstat -ntap | grep 8080
[root@localhost ~]# netstat -ntap | grep 8081
[root@localhost ~]# netstat -ntap | grep 8082
[root@localhost ~]# ps -ef |grep tomcat

如图显示,启动正常

[root@bogon opt]# netstat -antp |grep 8080
tcp6       0      0 :::8080                 :::*                    LISTEN      1579/java     
[root@bogon opt]# netstat -antp |grep 8081
tcp6       0      0 :::8081                 :::*                    LISTEN      2062/java           
tcp6       1      0 192.168.1.144:53632     192.168.1.202:8081      CLOSE_WAIT  1580/java           
tcp6       1      0 192.168.1.144:53633     192.168.1.202:8081      CLOSE_WAIT  2062/java           
tcp6       1      0 192.168.1.144:53631     192.168.1.202:8081      CLOSE_WAIT  1579/java           
[root@bogon opt]# netstat -antp |grep 8082
tcp6       0      0 :::8082                 :::*                    LISTEN      1580/java           

tomcat启动正常显示如下:

[root@bogon opt]# ps -ef |grep tomcat
root      1579     1  1 13:22 ?        00:04:54 /usr/jdk1.8.0_152//bin/java -Djava.util.logging.config.file=/opt/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 -Dignore.endorsed.dirs= -classpath /opt/tomcat/bin/bootstrap.jar:/opt/tomcat/bin/tomcat-juli.jar -Dcatalina.base=/opt/tomcat -Dcatalina.home=/opt/tomcat -Djava.io.tmpdir=/opt/tomcat/temp org.apache.catalina.startup.Bootstrap start
root      1580     1  1 13:22 ?        00:05:13 /usr/jdk1.8.0_152//bin/java -Djava.util.logging.config.file=/opt/tomcat3/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 -Dignore.endorsed.dirs= -classpath /opt/tomcat3/bin/bootstrap.jar:/opt/tomcat3/bin/tomcat-juli.jar -Dcatalina.base=/opt/tomcat3 -Dcatalina.home=/opt/tomcat3 -Djava.io.tmpdir=/opt/tomcat3/temp org.apache.catalina.startup.Bootstrap start
root      2062     1  1 13:22 ?        00:05:23 /usr/jdk1.8.0_152//bin/java -Djava.util.logging.config.file=/opt/tomcat2/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 -Dignore.endorsed.dirs= -classpath /opt/tomcat2/bin/bootstrap.jar:/opt/tomcat2/bin/tomcat-juli.jar -Dcatalina.base=/opt/tomcat2 -Dcatalina.home=/opt/tomcat2 -Djava.io.tmpdir=/opt/tomcat2/temp org.apache.catalina.startup.Bootstrap start
root      3167  2787  0 17:54 pts/0    00:00:00 grep --color=auto tomcat

nginx安装配置

1、检查依赖软件

检查并安装 Nginx 所需的依赖软件

  1. gcc:nginx编译依赖gcc环境

    安装命令:yum install gcc-c++

  2. pcre:(Perl Compatible Regular Expressions)是一个Perl库,包括 perl 兼容的正则表达式库。nginx的http模块使用 pcre来解析正则表达式.

    安装命令:yum install -y pcre pcre-devel

  3. zlib:该库提供了很多种压缩和解压缩的方式,nginx使用zlib对 http包的内容进行gzip。

    安装命令:yum install -y zlib zlib-devel

  4. openssl:一个强大的安全套接字层密码库,囊括主要的密码算法、常用的密钥和证书封装管理功能及SSL协议,并提供丰富的应用程序供测试或其它目的使用。nginx不仅支持http 协议,还支持https

    安装命令:yum install -y openssl openssl-devel

2、安装 nginx

点击进入 nginx 官网 里面有最新的主线版本、稳定版和历史版本,这里我们选择最新的主线版本--1.17.10,即:

mkdir tools
cd tools

接着下载 Nginx 1.17.6 的主线版本 ,下载命令:

wget https://nginx.org/download/nginx-1.17.10.tar.gz

解压缩源码包并进入,命令如下:

tar -zxvf nginx-1.17.10.tar.gz
cd nginx-1.17.10

执行之前我们需要下载并解压 pcre ,这里我们使用 pcre 源码编译的方式让 Nginx 支持 pcre 模块,这里选择的版本是--8.43,下载命令:

wget https://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gz
tar -zxvf pcre-8.43.tar.gz

安装之前需要手动创建上面指定的nginx文件夹,分别是 --prefix 指定的目录、 /var/run/nginx、/var/temp 和 /var/temp/nginx

mkdir /var/run/nginx
mkdir /var/temp
mkdir /var/temp/nginx

配置编译参数命令(重要),配置如下:非常重要!!!

./configure \
--prefix=/usr/local/nginx \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/temp/nginx/client \
--http-proxy-temp-path=/var/temp/nginx/proxy \
--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \
--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \
--http-scgi-temp-path=/var/temp/nginx/scgi

下面这个编译过程出错,可以参考一下:

./configure \
--prefix=/mnt/sdc/server/nginx \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/temp/nginx/client \
--http-proxy-temp-path=/var/temp/nginx/proxy \
--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \
--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \
--http-scgi-temp-path=/var/temp/nginx/scgi \
--with-pcre=../pcre-8.43 \
--with-http_ssl_module --with-http_v2_module \
--with-http_gzip_static_module \
--with-http_gunzip_module \
--with-stream \
--with-stream_ssl_module \
--with-http_sub_module \
--with-http_flv_module \
--with-http_addition_module \
--with-http_realip_module \
--with-http_mp4_module \
--with-ld-opt=-Wl,-E \
--with-cc-opt=-Wno-error \
--with-pcre-jit \
--with-http_stub_status_module

编译安装

make && make install

等待安装完成,验证是否安装成功,可以进入 --prefix 指定的目录查看是否存在conf、sbin、html文件夹,若存在则安装成功。

3、配置

1、nginx.conf配置文件修改

修改配置文件,设置集群,打开文件nginx.conf,在文件头部添加代码如下

user root;
gzip  on;
    #服务器集群
    upstream  test {  #服务器集群名字    
        server    localhost:8080  weight=1;#服务器配置weight是权重的意思权重越大分配的概率越大。
        server    localhost:8081  weight=2;
        server    localhost:8082  weight=2;
    }
        access_log  /var/log/nginx/access.log;
        access_log  /var/log/nginx/error.log;
pid        /usr/local/nginx/logs/nginx.pid;
        location / {
           # root   html;
           #index  index.html index.htm;
           proxy_pass http://test;  #请求转向自定义的服务器列表
        }

这里要注意,集群名字test和下面的请求转向自定义的服务器列表名称必须一致!

完整nginx.conf文件如下

user root;
#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;
pid        /usr/local/nginx/logs/nginx.pid;

events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    gzip  on;
    #服务器集群
    upstream  test {  #服务器集群名字    
        server    localhost:8080  weight=1;#服务器配置weight是权重的意思权重越大分配的概率越大。
        server    localhost:8081  weight=2;
        server    localhost:8082  weight=2;
    }

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;
        access_log  /var/log/nginx/access.log;
        access_log  /var/log/nginx/error.log;

        location / {
           # root   html;
           #index  index.html index.htm;
           proxy_pass http://test;  #请求转向自定义的服务器列表
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

2、开启防火墙和443端口
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --zone=public --add-port=443/tcp --permanent
firewall-cmd --reload #重启

查看 返回 yes 代表开启成功

firewall-cmd --state
firewall-cmd --zone=public --query-port=80/tcp
3、设置开机自启动

在系统服务目录里创建nginx.service文件,写入一下内容:

[Unit]
Description=nginx
After=network.target
  
[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true
  
[Install]
WantedBy=multi-user.target

说明:

Description:描述服务
After:描述服务类别
[Service]服务运行参数的设置
Type=forking是后台运行的形式
ExecStart为服务的具体运行命令
ExecReload为重启命令
ExecStop为停止命令
PrivateTmp=True表示给服务分配独立的临时空间
注意:[Service]的启动、重启、停止命令全部要求使用绝对路径
[Install]运行级别下服务安装的相关设置,可设置为多用户,即系统运行级别为3

设置开机自启动
systemctl enable nginx.service
查看nginx状态
systemctl status nginx.service
杀死nginx重启nginx

pkill -9 nginx
ps aux | grep nginx
systemctl start nginx
启动
cd /usr/local/nginx/sbin/
./nginx
systemctl status nginx.service
检查是否启动成功

打开浏览器,输入你服务器的IP地址,看是否出现nginx欢迎界面,没有出现可以检测一下服务器的安全组或防火墙,看看80和443的端口是否开启,开启即可。

redis安装配置

下载指定tar包

wget http://download.redis.io/releases/redis-5.0.8.tar.gz

解压到指定目录

#创建目录
mkdir /usr/redis
#解压
tar -zvxf redis-5.0.8.tar.gz -C /usr/redis

编译&安装

#进入目录
cd /usr/redis/redis-5.0.8
#编译&安装
make & make install

配置

配置本机外访问&&关闭保护模式
#修改配置文件
vi /usr/redis/redis-5.0.8/redis.conf

#更换绑定
#将bind 127.0.0.1 更换为本机IP,例如:192.168.11.11
bind 192.168.1.144

#关闭保护模式
protected-mode no
开放端口
#增加redis端口:6379
firewall-cmd --add-port=6379/tcp --permanent
#重新加载防火墙设置
firewall-cmd --reload
配置Redis开机启动

复制脚本redis_init_script到/etc/rc.d/init.d文件夹,并将其改名为redis(说明:/etc/rc.d/init.d/文件夹下的脚本在系统启动的时候某些指定脚本将被运行)

[root@Slave1pc ~]# cd /usr/redis/redis-5.0.8/utils/

[root@Slave1pc utils]# cp redis_init_script  /etc/rc.d/init.d/redisd
vim /etc/init.d/redisd 
配置添加如下

# chkconfig: 2345 80 90  
#
# Simple Redis init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem.

REDISPORT=6379
EXEC=/usr/local/bin/redis-server
CLIEXEC=/usr/local/bin/redis-cli

PIDFILE=/var/run/redis_${REDISPORT}.pid
CONF="/etc/redis/redis.conf"
$CLIEXEC -a "20192020" -p $REDISPORT shutdown

[root@Slave1pc ~]# chkconfig --add redisd 

[root@Slave1pc ~]# chkconfig --list redisd
[root@Slave1pc ~]# service redisd start  
错误解析

重新启动redis,出现例如以下错误:

Starting Redis server...

[6384] 14 Jul 21:43:19.992 # Fatal error, can't open config file '/etc/redis/6379.conf'

解决方法:

将redis配置文件复制到/etc/redis/${REDISPORT}.conf

[root@Slave1pc ~]# mkdir /etc/redis

[root@Slave1pc ~]# cp /usr/redis/redis-5.0.8/redis.conf /etc/redis/6379.conf

这样。redis服务脚本指定的conf就存在了;在默认情况下。redis未启用认证,能够通过开启6379.conf的requirepass 指定一个验证password。

改动/etc/redis/6379.conf,设置redis进程为后台守护进程,并指定一个password:

[root@Slave1pc ~]# vim /etc/redis/6379.conf 
daemonize yes   //daemonize:是否以后台daemon方式执行

requirepass 20192020 //设置password为20192020

设置完毕后,能够加入注冊服务:

[root@Slave1pc ~]# chkconfig --add redis 

[root@Slave1pc ~]# service redis start

Starting Redis server...

查看是否启动成功:

[root@Slave1pc ~]# ps -ef | grep redis 

root   2099   1 0 22:17 ?

​    00:00:00 /usr/local/redis/bin/redis-server *:6379       

root   2475 2270 0 22:19 pts/1  00:00:00 grep redis

调用redis-cli的命令进行简单操作(注意是否启动password验证):

[root@Slave1pc ~]# redis-cli        

127.0.0.1:6379> ping

(error) NOAUTH Authentication required.

127.0.0.1:6379> auth 20192020  //须要输入password

OK

127.0.0.1:6379> ping

PONG

127.0.0.1:6379> set name lebron james

(error) ERR syntax error

127.0.0.1:6379> set name "lebron james" //有空格的字符串须要加“”

OK

127.0.0.1:6379> get name

"lebron james"

127.0.0.1:6379> set name lebronjames

OK

127.0.0.1:6379> get name

"lebronjames"

127.0.0.1:6379> 

其他针对项目的配置如下:

spring-context-shiro.xml 
spring-context.xml 
rcm.properties

需要修复rcm.properties中的redis的配置信息。

export LANG="en_US.UTF-8"
source /etc/profile
cp -rf  /opt/tmp/rcm*.war /opt/tomcat/webapps/rcm/rcm.war
cp -rf  /opt/tmp/rcm*.war /opt/tomcat2/webapps/rcm/rcm.war
cp -rf  /opt/tmp/rcm*.war /opt/tomcat3/webapps/rcm/rcm.war
sleep 10s
cd /opt/tomcat/webapps/rcm/
ls | grep -v *.war | xargs rm -rf

cd /opt/tomcat2/webapps/rcm/
ls | grep -v *.war | xargs rm -rf

cd /opt/tomcat3/webapps/rcm/
ls | grep -v *.war | xargs rm -rf

cd /opt/tomcat/webapps/rcm/
jar xvf rcm.war
cd /opt/tomcat2/webapps/rcm/
jar xvf rcm.war
cd /opt/tomcat3/webapps/rcm/
jar xvf rcm.war

cp /sql_bak/rcm.properties /opt/tomcat/webapps/rcm/WEB-INF/classes/rcm.properties
cp /sql_bak/license.lic /opt/tomcat/webapps/rcm/WEB-INF/classes/license.lic
cp /sql_bak/spring-context-shiro.xml /opt/tomcat/webapps/rcm/WEB-INF/classes/spring-context-shiro.xml
cp /sql_bak/spring-context.xml /opt/tomcat/webapps/rcm/WEB-INF/classes/spring-context.xml
cp /sql_bak/rcm.properties /opt/tomcat2/webapps/rcm/WEB-INF/classes/rcm.properties
cp /sql_bak/license.lic /opt/tomcat2/webapps/rcm/WEB-INF/classes/license.lic
cp /sql_bak/spring-context-shiro.xml /opt/tomcat2/webapps/rcm/WEB-INF/classes/spring-context-shiro.xml
cp /sql_bak/spring-context.xml /opt/tomcat2/webapps/rcm/WEB-INF/classes/spring-context.xml
cp /sql_bak/rcm.properties /opt/tomcat3/webapps/rcm/WEB-INF/classes/rcm.properties
cp /sql_bak/license.lic /opt/tomcat3/webapps/rcm/WEB-INF/classes/license.lic
cp /sql_bak/spring-context-shiro.xml /opt/tomcat3/webapps/rcm/WEB-INF/classes/spring-context-shiro.xml
cp /sql_bak/spring-context.xml /opt/tomcat3/webapps/rcm/WEB-INF/classes/spring-context.xml
mv /opt/tmp/rcm*.war /sql_bak/rcm_bak/rcm_`date +%Y%m%d%H`.war
cd /opt/tomcat/webapps/rcm
rm rcm.war
cd /opt/tomcat2/webapps/rcm
rm rcm.war
cd /opt/tomcat3/webapps/rcm
rm rcm.war
echo  "starting tomcat"
cd /opt/tomcat/bin
./shutdown.sh
./startup.sh
sleep 10
echo  "starting tomcat2"
cd /opt/tomcat2/bin
./shutdown.sh
./startup.sh
sleep 10
echo  "starting tomcat"
cd /opt/tomcat3/bin
./shutdown.sh
./startup.sh
sleep 10

致谢:

1.https://blog.csdn.net/weixin_43840640/article/details/88847591

2.https://www.jianshu.com/p/ca5ee5f7075c

3.https://juejin.im/post/5ddf94555188256ecf7792dc

4.https://www.cnblogs.com/zfyouxi/p/5235292.html

你可能感兴趣的:(jenkins+nginx+tomcat+redis集群搭建)