Linux下分布式项目部署环境搭建与使用(druid-1.0.25.jar)数据库连接加密

一、JDK安装


  1.执行命令:cd Downloads/
  2.上  传:jdk-8u111-linux-x64.tar.gz 到Downloads
  3.执行命令:tar -zxvf jdk-8u111-linux-x64.tar.gz
  4.执行命令:mv jdk1.8.0_111 ~/soft/jdk1.8
  5.执行命令:vim ~/.bash_profile
  6.在文件末尾插入如下内容:

export JAVA_HOME=/home/redhat/soft/jdk1.8
export JRE_HOME=/home/redhat/soft/jdk1.8/jre
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$PATH

  7.执行命令:source ~/.bash_profile
  8.执行命令验证jdk版本:java -version
    返回如下内容表示安装成功:

java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)

 

二、zookeeper集群环境搭建

(也可参考:http://www.cnblogs.com/libingbin/p/6604585.html)


  注意:使用三台集群机器,提前确认锁定好ip分别为:
    192.176.0.33
    192.176.0.34
    192.176.0.35

  1.执行命令:cd Downloads/
  2.上传文件:zookeeper-3.4.6.tar.gz
  3.执行命令:tar -zxvf zookeeper-3.4.6.tar.gz
  4.执行命令:mv zookeeper-3.4.6 ~/soft/zookeeper
  5.执行命令:cd ~/soft/zookeeper/
  6.执行命令:mkdir data
  7.执行命令:mkdir logs
  8.执行命令:cd conf/
  9.执行命令:cp zoo_sample.cfg zoo.cfg
  10.执行命令:vim zoo.cfg


  修改
  ...
  dataDir=/tmp/zookeeper
  ...
  为
  ...
  dataDir=/home/redhat/soft/zookeeper/data
  dataLogDir=/home/redhat/soft/zookeeper/logs
  ...
  server.1=192.176.0.33:2888:3888
  server.2=192.176.0.34:2888:3888
  server.3=192.176.0.35:2888:3888
  其中灰色部分添加到文件末尾。
  11.执行命令:cd ~/soft/zookeeper/data/
  12.执行命令:vim myid
    在文件中新增
    1
  13.执行命令:vim ~/.bash_profile
    在文件末尾添加如下内容
    # zookeeper env
    export ZOOKEEPER_HOME=/home/redhat/soft/zookeeper
    export PATH=$ZOOKEEPER_HOME/bin:$PATH
  14.执行命令:source ~/.bash_profile
  15.防火墙中打开2181,2888,3888端口
  16.执行命令(启动zookeeper):zkServer.sh start(zkServer.sh start-foreground)
    zookeeper常用命令:
    启动zookeeper:zkServer.sh start-foreground;
    查看zookeeper进程:jps
    查看状态:zkServer.sh status
    停止服务:zkServer.sh stop

  此服务器搭建好后需要克隆两台机器,每台机器按照ip,修改:
    cd ~/soft/zookeeper/data/
    vim myid

    1-->192.176.0.33
    2-->192.176.0.34
    3-->192.176.0.35

  备注:myid的值是zoo.cfg文件里定义的server.A项A的值,Zookeeper 启动时会读取这个文件,拿到里面的数据与 zoo.cfg 里面的配置信息比较从而判断到底是那个server,只是一个标识作用。

 

三、redis及哨兵安装——redis安装


  1.root用户登录
  2.执行命令:yum install gcc tcl
  3.执行命令:cd /usr/local/src
  4.上传附件:redis-2.8.19.tar.gz
  5.执行命令:tar -zxvf redis-2.8.19.tar.gz
  6.执行命令:mv redis-2.8.19 redis2.8
  7.执行命令:mkdir /usr/local/redis
  8.执行命令:cd redis2.8
  9.执行命令:make PREFIX=/usr/local/redis install
  10.执行命令:cp /usr/local/src/redis2.8/utils/redis_init_script  /etc/rc.d/init.d/redis
  11.执行命令:mkdir /usr/local/redis/conf
  12.执行命令:mkdir /usr/local/redis/log
  13.执行命令:mkdir /usr/local/redis/data
  14.执行命令:cp /usr/local/src/redis2.8/redis.conf  /usr/local/redis/conf/6379.conf
  15.执行命令:vim /usr/local/redis/conf/6379.conf
    将:logfile "" 改为> logfile "/usr/local/redis/log/redis.log"
    将:daemonize no 改为> daemonize yes
    将:dir ./ 改为>dir /usr/local/redis/data
    将:pidfile /var/run/redis.pid 改为> pidfile /var/run/redis_6379.pid
    在:# requirepass foobared 下新增: requirepass "thinkpad"
    在:# masterauth <master-password> 下新增:masterauth "thinkpad"

  16.执行命令:vim /etc/rc.d/init.d/redis
    修改

#!/bin/sh
#
# 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/${REDISPORT}.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
        ;;
    stop)
        if [ ! -f $PIDFILE ]
        then
                echo "$PIDFILE does not exist, process is not running"
        else
                PID=$(cat $PIDFILE)
                echo "Stopping ..."
                $CLIEXEC -p $REDISPORT shutdown
                while [ -x /proc/${PID} ]
                do
                    echo "Waiting for Redis to shutdown ..."
                    sleep 1
                done
                echo "Redis stopped"
        fi
        ;;
    *)
        echo "Please use start or stop as first argument"
        ;;
esac

  为

#!/bin/sh
#
# Simple Redis init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem.
#chkconfig: 2345 80 90
REDISPORT=6379
EXEC=/usr/local/redis/bin/redis-server
CLIEXEC=/usr/local/redis/bin/redis-cli

PIDFILE=/var/run/redis_${REDISPORT}.pid
CONF="/usr/local/redis/conf/${REDISPORT}.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
        ;;
    stop)
        if [ ! -f $PIDFILE ]
        then
                echo "$PIDFILE does not exist, process is not running"
        else
                PID=$(cat $PIDFILE)
                echo "Stopping ..."
                $CLIEXEC -p $REDISPORT shutdown
                while [ -x /proc/${PID} ]
                do
                    echo "Waiting for Redis to shutdown ..."
                    sleep 1
                done
                echo "Redis stopped"
        fi
        ;;
    *)
        echo "Please use start or stop as first argument"
        ;;
esac

17.执行命令:vim /etc/profile
  末尾新增

# redis
export REDIS_HOME=/usr/local/redis
export PATH=$REDIS_HOME/bin:$PATH

18.执行命令:source /etc/profile
19.执行命令 : chkconfig --add redis
20.开放端口:6379

redis常用命令:
   启动redis:service redis start
   关闭redis: service redis stop(密码不方便直接写到脚本中,目前使用下面的命令停服务)
       redis-cli -p 6379 -a thinkpad shutdown
   redis客户端:redis-cli
   redis-cli -h <ip> -a <密码> info Replication

redis及哨兵安装——哨兵安装

 

  1.执行命令:mkdir /usr/local/redis/sentinel
  2.执行命令:cp /usr/local/src/redis2.8/src/redis-sentinel /usr/local/redis/sentinel/
  3.执行命令:cd /usr/local/redis/sentinel/
  4.执行命令:mkdir dir
  5.执行命令:cp /usr/local/src/redis2.8/sentinel.conf /usr/local/redis/sentinel/
  6.执行命令:vim sentinel.conf
    

将: daemonize no 改为> daemonize yes
    将: dir /tmp 改为> dir "/usr/local/redis/sentinel/dir"
    将: sentinel monitor mymaster 127.0.0.1 6379 2 改为> 
      sentinel monitor mymaster 192.176.0.35 6379 2(主节点)
    将: sentinel down-after-milliseconds mymaster 30000 改为>
      sentinel down-after-milliseconds mymaster 1000
    在:# sentinel auth-pass <master-name> <password> 下新增:
      sentinel auth-pass mymaster thinkpad
      logfile "/usr/local/redis/sentinel/sentinel.log"


    批注:行尾最后的一个2代表什么意思呢?我们知道,网络是不可靠的,有时候一个sentinel会因为网络堵塞而误以为一个master redis已经死掉了,当sentinel集群式,解决这个问题的方法就变得很简单,只需要多个sentinel互相沟通来确认某个master是否真的死了,这个2代表,当集群中有2个sentinel认为master死了时,才能真正认为该master已经不可用了。(sentinel集群中各个sentinel也有互相通信,通过gossip协议)。

  7.打开防火墙端(修改vim /etc/sysconfig/iptables命令添加使防火墙开放6272,26379端口):
    

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 6272 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 26379 -j ACCEPT

  备注:
    关闭/开启/重启防火墙
    /etc/init.d/iptables stop
    #iptables start 开启
    #iptables restart 重启
    #iptables status 查看

  8.起redis-sentinel服务命令:

./redis-sentinel sentinel.conf

 

 四、nginx安装

 

  1.执行命令:mkdir temp

  2.执行命令:cd temp

  3.上传文件到服务器:nginx-1.8.1.tar.gz,pcre-8.35.tar.gz,zlib-1.2.8.tar.gz

  4.执行命令:yum install -y gcc gcc-c++

  5.执行命令:tar -zxvf pcre-8.35.tar.gz

  6.执行命令:cd /root/temp/pcre-8.35

  7.执行命令:./configure

  8.执行命令:make

  9.执行命令:make install

  10.执行命令:cd /root/temp/

  11.执行命令:tar -zxvf zlib-1.2.8.tar.gz

  12.执行命令:cd zlib-1.2.8

  13.执行命令:./configure

  14.执行命令:make

  15.执行命令:make install

  16.执行命令:cd /root/temp/

  17.执行命令:tar -zxvf nginx-1.8.1.tar.gz

  18.执行命令:mkdir /usr/local/nginx

  19.执行命令:cd nginx-1.8.1

  20.执行命令:./configure --prefix=/usr/local/nginx/

  21.执行命令:make

  22.执行命令:make install

  23.执行命令:ln -s /usr/local/lib/libpcre.so.1 /lib64

  24.打开防火墙80端口:

  -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

 

 weblogic安裝

  进入weblogic安装包存放目录执行安装命令如:

    java –d64 –jar /home/fmw_12.1.3.0.0_wls.jar

   之后按照提示一步一步安装就好。

   (配置与部署可参考:http://www.cnblogs.com/libingbin/p/6759994.html)

 

备注:使用(druid-1.0.25.jar)数据库连接加密操作流程

  1.进入到附件:druid-1.0.25.jar对应的路径。例如(windows):

  2.执行命令:java -cp druid-1.0.25.jar com.alibaba.druid.filter.config.ConfigTools 密码
    如下图所示

  3.使用标记即可复制出内容,需要注意:无论是公钥还是密码都只取publicKey:,password:后面的数据,且如果有换行去掉换行,公钥和密码每个都是独立的一行。
  4.把加密后的密码公钥配置到配置文件中即可。

 

<!-- Start -->

获知及时信息,请关注我的个人微信订阅号:0与1的那点事

 <!-- End -->

 

本文为博主原创文章,转载请注明出处!

http://www.cnblogs.com/libingbin/

感谢您的阅读。

posted on 2017-05-02 11:24  bingbinlee  阅读(2068)  评论(0编辑  收藏  举报