2019软件安装脚本

 

201906项目软件安装1

主机A

#!/bin/bash
#install_host_A
#homeward

#kafka
HOST_IP=192.168.9.11
#mysql
USER=solexa

#install_jdk1.8
if [ -d /opt/local/soft ]
then
    mkdir -p /opt/local/usr/java;
    cd  /opt/local/soft;
    tar -zxvf jdk-8u201-linux-x64.tar.gz;
    if [ -d /opt/local/soft/jdk1.8.0_201 ]
    then
        cd  /opt/local/soft;
        mv jdk1.8.0_201/ /opt/local/usr/java/
    fi >> output_host_A.log
    echo -e "export PATH=$PATH:/opt/local/usr/java/jdk1.8.0_201/bin" >> ~/.bash_profile;
    source ~/.bash_profilea
fi >> output_host_A.log

#install_kafka_and_zookeeper
if [ -d /opt/local/soft ]
then
    mkdir -p  /opt/local/usr/local/kafka-logs;
    mkdir -p /opt/local/usr/zookeeper;
    #kafka
    cd /opt/local/soft;
    tar -zxvf kafka_2.12-2.2.0.tgz;
    if [ -d /opt/local/soft/kafka_2.12-2.2.0 ]
    then
        mv kafka_2.12-2.2.0 /opt/local/usr/kafka/;
    fi >> output_host_A.log
    if [ -d /opt/local/usr/kafka/config/ ]
    then
        cd /opt/local/usr/kafka/config;
        sed -i 's/broker.id=0/broker.id=1/' server.properties;
        sed -i 's/log.dir=\/tmp\/kafka-logs/log.dir=\/opt\/local\/usr\/local\/kafka-logs/' server.properties
        listeners=PLAINTEXT://$HOST_IP:9092 >> server.properties;
    fi >> output_host_A.log

    #zookeeper
    cd /opt/local/soft;
    tar -zxvf zookeeper-3.4.14.tar.gz;
    if [ -d /opt/local/soft/zookeeper-3.4.14 ]
    then
        mv zookeeper-3.4.14 /opt/local/usr/zookeeper/
    fi >> output_host_A.log
    if [ -d /opt/local/usr/zookeeper/zookeeper-3.4.14/conf ] 
    then
        cd /opt/local/usr/zookeeper/zookeeper-3.4.14/conf;
        mv zoo_sample.cfg zoo.cfg;
    fi >> output_host_A.log
fi >> output_host_A.log
#start_kafka_and_zookeeper
if [ -d /opt/local/usr/zookeeper/zookeeper-3.4.14/bin ]
then
    cd /opt/local/usr/zookeeper/zookeeper-3.4.14/bin;
    sh zkServer.sh start;
fi >> output_host_A.log
if [ -d /opt/local/usr/kafka/bin ]
then
    cd /opt/local/usr/kafka/bin;
    nohup ./kafka-server-start.sh ../config/server.properties &
fi >> output_host_A.log

#INSTALL_nodejs
if [ -d /opt/local/soft ]
then
    mkdir -p /opt/local/usr/nodejs;
    cd /opt/local/soft;
    tar -zxvf node-v11.11.0-linux-x64.tar.gz;
    if [ -d node-v11.11.0-linux-x64 ]
    then
        mv node-v11.11.0-linux-x64  /opt/local/usr/nodejs/;
    fi >> output_host_A.log
    echo -e "export PATH=$PATH:/opt/local/usr/nodejs/node-v11.11.0-linux-x64/bin" >> ~/.bash_profile;
    source ~/.bash_profile;
fi >> output_host_A.log

#INSTALL_nginx
if [ -d /opt/local/soft ]
then
    mkdir -p /opt/local/usr/local/nginx-1.10.3;
    cd  /opt/local/soft;
    tar -zxvf nginx-1.10.3.tar.gz;
    if [ -d /opt/local/soft/nginx-1.10.3 ]
    then
        cd /opt/local/soft/nginx-1.10.3;
        ./configure --user=homeward --prefix=/opt/local/usr/local/nginx-1.10.3 --with-http_stub_status_module --with-http_ssl_module;
        make && make install;
    fi >> output_host_A.log
    #
    if [ -d /opt/local/usr/local/nginx-1.10.3/conf ]
    then
        cd /opt/local/usr/local/nginx-1.10.3/conf;
        sed -i 's/user  nobody/user  homeward/' nginx.conf;
        sed -i 's/listen       80/listen       8088/' nginx.conf;
    fi >> output_host_A.log
    #start nginx
    cd /opt/local/usr/local/nginx-1.10.3/sbin;
    ./nginx;         
fi >> output_host_A.log
  
#INSTALL_MySQL
if [ -d /opt/local/soft ]
then
    mkdir -p /opt/local/usr/local;
    mkdir -p /opt/local/usr/local/data;
    mkdir /opt/local/usr/local/log;
    cd  /opt/local/soft;
    tar -zxvf mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz;
    if [ -d /opt/local/soft/mysql-5.7.25-linux-glibc2.12-x86_64 ]
    then
        mv mysql-5.7.25-linux-glibc2.12-x86_64 /opt/local/usr/local/mysql;
    fi >> output_host_A.log  
fi >> output_host_A.log
if [ -d /opt/local/usr/local/mysql/ ]
then
    cd /opt/local/usr/local/mysql/;
    echo -e "[client]" >> my.cnf;
    echo -e "port=3306" >> my.cnf;
    echo -e "socket=/opt/local/usr/local/mysql/mysql.sock" >> my.cnf;
    echo -e "" >> my.cnf;
    echo -e "[mysqld]" >> my.cnf;
    echo -e "port=3306" >> my.cnf;
    echo -e "#设置mysql的安装目录" >> my.cnf;
    echo -e "basedir=/opt/local/usr/local/mysql" >> my.cnf;
    echo -e "# 设置mysql数据库的数据的存放目录" >> my.cnf;
    echo -e "datadir=/opt/local/usr/local/data" >> my.cnf;
    echo -e "pid-file=/opt/local/usr/local/mysql/mysql.pid" >> my.cnf;
    echo -e "socket=/opt/local/usr/local/mysql/mysql.sock" >> my.cnf;
    echo -e "log_error=/opt/local/usr/local/log/error.log" >> my.cnf;
    echo -e "collation_server=utf8_general_ci" >> my.cnf;
    echo -e "# 服务端使用的字符集默认为8比特编码的latin1字符集" >> my.cnf;
    echo -e "character_set_server=utf8" >> my.cnf;
    echo -e "log-bin=/opt/local/usr/local/log/mysql-bin" >> my.cnf;
    echo -e "server-id=100" >> my.cnf;   
fi >> output_host_A.log
#
if [ -d /opt/local/usr/local/mysql ]
then
    cd /opt/local/usr/local/mysql;
    ./bin/mysqld --defaults-file=/opt/local/usr/local/mysql/my.cnf --initialize --user=$USER --basedir=/opt/local/usr/local/mysql --datadir=/opt/local/usr/local/data
fi >> output_host_A.log
#
if [ -d /opt/local/usr/local/mysql/bin/ ]
then
    cd /opt/local/usr/local/mysql/bin/;
    ./mysqld_safe --defaults-file=/opt/local/usr/local/mysql/my.cnf --user=$USER &
fi
#get_mysql_passwd...
PASSWD_MySQL=`cat /opt/local/usr/local/log/error.log |grep root@localhost | awk -F: '{ print $4 }'`
PASSWD_MySQL_ROOT=$PASSWD_MySQL
#
if [ -d /opt/local/usr/local/mysql/bin/ ]
then
    cd /opt/local/usr/local/mysql/bin/;
    ./mysql -uroot -P3306 -p$PASSWD_MySQL_ROOT -S /opt/local/usr/local/mysql/mysql.sock;
    alter user 'root'@'localhost' identified by 'mysql@123';
    grant all privileges on *.* to 'root'@'%' identified by 'mysql@123' with grant option;
    FLUSH PRIVILEGES;
    use mysql;
    exit;
fi >> output_host_A.log
#
echo -e "export PATH=$PATH:/opt/local/usr/local/mysql/bin" >> ~/.bash_profile;
source ~/.bash_profile;

#end
View Code

 

主机B

#!/bin/bash
#host_B_install
#homeward

#install_python2.7.10
if [ -d /opt/local/soft ]
then
    mkdir -p /opt/local/usr/bin/python2.7.10;
    cd  /opt/local/soft;
    tar -zxvf Python-2.7.10.tgz;
    if [ -d /opt/local/soft/Python-2.7.10 ]
    then
        cd /opt/local/soft/Python-2.7.10;
        ./configure prefix=/opt/local/usr/bin/python2.7.10;
        make && make install;
    fi >> output_host_B.log
    echo -e "export PATH=$PATH:/opt/local/usr/bin/python2.7.10/bin" >> ~/.bash_profile
    source ~/.bash_profile   
fi >> output_host_B.log
#install_setuptools,pip,PyMySQL,cx-Oracle,kafka-python,DBUtil,pbr,lockfile
if [ -d /opt/local/soft ]
then 
    #setuptools
    cd /opt/local/soft;
    unzip setuptools-37.0.0.zip;
    if [ -d /opt/local/soft/setuptools-37.0.0 ]
    then
        source ~/.bash_profile;
        cd /opt/local/soft/setuptools-37.0.0;
        python2.7 setup.py install
    fi >> output_host_B.log
    #pip
    cd /opt/local/soft;
    tar -zxvf pip-9.0.1.tar.gz;
    if [ -d /opt/local/soft/pip-9.0.1 ]
    then
        source ~/.bash_profile;
        cd /opt/local/soft/pip-9.0.1;
        python2.7 setup.py install
        source ~/.bash_profile;  
    fi >> output_host_B.log
    #PyMySQL...
    cd /opt/local/soft;
    source ~/.bash_profile;
    pip2.7 install PyMySQL-0.7.11.tar.gz;
    pip2.7 install cx_Oracle-7.1.2.tar.gz;
    pip2.7 install kafka-python-1.4.3.tar.gz;
    pip2.7 install DBUtils-1.3.tar.gz;
    pip2.7 install pbr-1.8.1-py2.py3-none-any.whl;
    pip2.7 install lockfile-0.12.2.tar.gz    

fi >> output_host_B.log



#install_oracle_client18.5
if [ -d /opt/local/soft ]
then
    mkdir -p /opt/local/opt/oracle/;
    unzip instantclient-basiclite-linux.x64-18.5.0.0.0dbru.zip;
    if [ -d /opt/local/soft/instantclient_18_5 ]
    then
        mv instantclient_18_5/ /opt/local/opt/oracle/;    
    fi >> output_host_B.log
    echo -e "export LD_LIBRARY_PATH=/opt/local/opt/oracle/instantclient_18_5:$LD_LIBRARY_PATH" >> ~/.bash_profile
    source ~/.bash_profile
fi >> output_host_B.log

#end
#
View Code

 

主机C、D

#!/bin/bash
#
#install_host_C_or_D
#
#install_python2.7.10
if [ -d /opt/local/soft ]
then
    mkdir -p /opt/local/usr/bin/python2.7.10;
    cd  /opt/local/soft;
    tar -zxvf Python-2.7.10.tgz;
    if [ -d /opt/local/soft/Python-2.7.10 ]
    then
        cd /opt/local/soft/Python-2.7.10;
        ./configure prefix=/opt/local/usr/bin/python2.7.10;
        make && make install;
    fi >> output_host_CD.log
    echo -e "export PATH=$PATH:/opt/local/usr/bin/python2.7.10/bin" >> ~/.bash_profile
    source ~/.bash_profile   
fi >> output_host_CD.log
#
#install_setuptools,pip,PyMySQL,cx-Oracle,kafka-python,DBUtil,pbr,lockfile
if [ -d /opt/local/soft ]
then 
    #setuptools
    cd /opt/local/soft;
    unzip setuptools-37.0.0.zip;
    if [ -d /opt/local/soft/setuptools-37.0.0 ]
    then
        source ~/.bash_profile;
        cd /opt/local/soft/setuptools-37.0.0;
        python2.7 setup.py install
    fi >> output_host_CD.log
    #pip
    cd /opt/local/soft;
    tar -zxvf pip-9.0.1.tar.gz;
    if [ -d /opt/local/soft/pip-9.0.1 ]
    then
        source ~/.bash_profile;
        cd /opt/local/soft/pip-9.0.1;
        python2.7 setup.py install
        source ~/.bash_profile;  
    fi >> output_host_CD.log
    #PyMySQL...
    cd /opt/local/soft;
    source ~/.bash_profile;
    pip2.7 install PyMySQL-0.7.11.tar.gz;
    pip2.7 install cx_Oracle-7.1.2.tar.gz;
    pip2.7 install kafka-python-1.4.3.tar.gz;
    pip2.7 install DBUtils-1.3.tar.gz;
    pip2.7 install pbr-1.8.1-py2.py3-none-any.whl;
    pip2.7 install lockfile-0.12.2.tar.gz    

fi >> output_host_CD.log
#
#install sshpass
if [ -d /opt/local/usr/bin/sshpass/ ]
then
    mkdir -p  /opt/local/usr/bin/sshpass/;
    cd  /opt/local/soft;
    tar -zxvf sshpass-1.06.tar.gz;
    if [ -d /opt/local/soft/sshpass-1.06 ]
    then
        cd /opt/local/soft/sshpass-1.06;
        ./configure --prefix=/opt/local/usr/bin/sshpass/;
        make && make install;
    fi
    echo -e "export PATH=$PATH:/opt/local/usr/bin/sshpass/bin" >> ~/.bash_profile;
    source .bash_profile;    
fi 
View Code

 

Google双因子验证

一,安装软件

 

 参考链接:

https://blog.csdn.net/my_bai/article/details/62432746
https://blog.csdn.net/chengxuyuanyonghu/article/details/47283239/

 

系统版本CentOS7.5

步骤

命令

1,yum安装

# yum install google-authenticator -y

#报错No package google-authenticator available.

# yum install epel-release -y

# yum install google-authenticator -y

# yum -y install mercurial pam-devel

#yum -y install unzip bzip2

2,安装Google Authenticator

下载软件包并上传包Google-Authenticator-master.zip

https://codeload.github.com/yangcvo/Google-Authenticator/zip/master

Google-Authenticator-master.zip

# unzip Google-Authenticator-master.zip

# cd Google-Authenticator-master

# tar jxvf libpam-google-authenticator-1.0-source.tar.bz2 

# cd libpam-google-authenticator-1.0

# make && make install

#

 

 

2、配置

SSH登录时调用google-authenticator模块,编辑:

/etc/pam.d/sshd

第一行添加:

auth       required     pam_google_authenticator.so

 

#######################

修改SSH配置文件:

vim /etc/ssh/sshd_config

添加或修改以下内容:

ChallengeResponseAuthentication yes

UsePAM yes

#############################

重启SSH:

#systemctl restart sshd

 

 

3、生成

完成后可通过google-authenticator命令对当前用户创建随机密码,之后选项都选择yes即可;

创建后在家目录下有个隐藏文件为.google-authenticator的文件,记住第一行私钥

 

4、下载

在手机上安装google-authenticator客户端

通过输入私钥即可实时显示密码

以后再远程登录的时候就会弹出验证码,而要输入客户端上实时产生的动态验证码才能进行登录;

 

 

 

 

 

 

 

 

 

 

补充:

1,centos7.5  python2.7.10安装paramiko

    步骤:#pip install pycrypto-2.6.tar.gz    #pip install ecdsa-0.13.3.tar.gz  #pip install paramiko-1.17.6.tar.gz

 2,报错转换格式报错如下:

解决方法:缺少安装包  ## yum install ghostscript -y

 

 

 

 

 

 

posted on 2019-07-29 16:28  微子天明  阅读(232)  评论(0编辑  收藏  举报

导航