Linux下分佈式項目部署環境搭建與使用(druid-1.0.25.jar)數據庫鏈接加密

1、JDK安裝html


  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.在文件末尾插入以下內容:java

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
    返回以下內容表示安裝成功:linux

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)

 

2、zookeeper集羣環境搭建nginx

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


  注意:使用三臺集羣機器,提早確認鎖定好ip分別爲:
    192.176.0.33
    192.176.0.34
    192.176.0.35web

  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.cfgredis


  修改
  ...
  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 myidvim

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

  備註:myid的值是zoo.cfg文件裏定義的server.A項A的值,Zookeeper 啓動時會讀取這個文件,拿到裏面的數據與 zoo.cfg 裏面的配置信息比較從而判斷究竟是那個server,只是一個標識做用。

 

3、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

 

 4、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/

感謝您的閱讀。

相關文章
相關標籤/搜索