美文网首页
Liunx 腾讯开发框架Tars 使用一键安装

Liunx 腾讯开发框架Tars 使用一键安装

作者: iCircle | 来源:发表于2018-09-26 16:47 被阅读0次

    yum list | grep initscripts
    yum install -y initscripts

    创建固定ip容器
    1、创建自定义网络类型,并且指定网段
    sudo docker network create --subnet=192.168.0.0/16 staticnet
    通过docker network ls可以查看到网络类型中多了一个staticnet

    2、使用新的网络类型创建并启动容器
    sudo docker run -it --name userserver --net staticnet --ip 192.168.0.2 ubuntu /bin/bash
    通过docker inspect可以查看容器ip为192.168.0.2,关闭容器并重启,发现容器ip并未发生改变


    docker run -d -it --name tars --link mysql --env MOUNT_DATA=false --env TZ=Asia/Shanghai --env DBIP=172.17.0.2 --env DBPort=3306 --env DBUser=root --env DBPassword=password --env DBTarsPass=tars2015 -p 8080:8080 -p 3000:3000 -v /Users/circle/docker/tars_data:/data tarscloud/tars:dev

    在docker中使用centos tars
    yum install openssh-server
    yum install openssh-clients

    在执行systemctl httpd start时,出现错误:Failed to get D-Bus connection: Operation not permitted

    原因:好像是因为dbus-daemon没能启动。

    解决方法:

    创建container时,在后面加上/usr/sbin/init:

    docker run -d -e "container=docker" --privileged=true [ID] /usr/sbin/init

    然后再进入container:

    docker exec -it [Container ID] /bin/bash

    yum -y install libxml2-devel openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel openldap-devel libmcrypt-devel

    尝试手动运行/usr/sbin/sshd
    报如下错误:
    Could not load host key: /etc/ssh/ssh_host_rsa_key
    Could not load host key: /etc/ssh/ssh_host_ecdsa_key
    Could not load host key: /etc/ssh/ssh_host_ed25519_key
    sshd: no hostkeys available -- exiting.

    手动执行/usr/sbin/sshd-keygen -A

    再执行/usr/sbin/sshd成功。

    为了免密码本机跳本机,执行如下命令:

    ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
    cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
    chmod 0600 ~/.ssh/authorized_keys

    /etc/sysconfig/network-scripts

    TYPE="Ethernet"
    PROXY_METHOD="none"
    BROWSER_ONLY="no"
    BOOTPROTO="dhcp"
    DEFROUTE="yes"
    IPV4_FAILURE_FATAL="no"
    IPV6INIT="yes"
    IPV6_AUTOCONF="yes"
    IPV6_DEFROUTE="yes"
    IPV6_FAILURE_FATAL="no"
    IPV6_ADDR_GEN_MODE="stable-privacy"
    NAME="eth0"
    UUID="9d4548e1-464b-4a2d-97ea-276cdb8fdd63"
    DEVICE="eth0"
    ONBOOT="yes"
    IPADDR="10.211.55.25"
    PREFIX="24"
    GATEWAY="10.211.55.1"
    DNS1="10.211.55.1"
    IPV6_PRIVACY="no"
    
    
    1. 安装ntpdate工具
      yum -y install ntp ntpdate
    2. 设置系统时间与网络时间同步
      ntpdate cn.pool.ntp.org
    3. 将系统时间写入硬件时间
      hwclock --systohc

    如题,在进行拉取的时候,发现原先unix格式,会变成dos格式,后来发现使用
    git config --global core.autocrlf false

    Step:
    1.install mysql on your machine, and change the db infomation in comm.properties.
    2.use this script to checkout the code
        cd /data
        git clone https://github.com/TarsCloud/Tars.git --recursive
        cd /data/Tars/deploy
        python ./deploy.py all
    
    Attention:
    1.support with python 2.7
    2.network unobstructed
    3.you had installed :gcc,gcc-c++,cmake,yasm,glibc-devel,flex,bison,ncurses-devel,zlib-devel,autoconf ,if not ,we will install it ,but It's possible to fail.
    yum install -y gcc gcc-c++ cmake yasm glibc-devel flex bison ncurses-devel zlib-devel autoconf
    

    yum install ntp
    systemctl enable ntpd
    vi /etc/sysconfig/ntpd
    "-g -x"
    service ntpd restart
    ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
    date

    1、安装epel扩展源:yum install epel-release
    2、安装python-pip:sudo yum install python-pip
    3、升级pip:pip install --upgrade pip
    4、安装requests包:pip install requests

    yum groupinstall -y "Development tools"
    yum install -y zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel
    curl https://bootstrap.pypa.io/get-pip.py | python
    pip install requests

    yum install -y gcc gcc-c++ cmake yasm glibc-devel flex bison ncurses-devel zlib-devel autoconf

    1、firewalld的基本使用
    启动: systemctl start firewalld
    关闭: systemctl stop firewalld
    查看状态: systemctl status firewalld
    开机禁用 : systemctl disable firewalld
    开机启用 : systemctl enable firewalld

    1.下载CentOS

    CentOS-7-x86_64-Minimal-1804.iso

    http://ftp.sjtu.edu.cn/centos/7.5.1804/isos/x86_64/CentOS-7-x86_64-Minimal-1804.iso

    2.获取Tars

    git clone --recursive https://github.com/TarsCloud/Tars.git

    3.软件包

    
    cmake-2.8.8.tar.gz
    
    mysql-5.6.26.tar.gz
    

    4.安装依赖

    yum install wget*
    
    yum install git*
    
    yum insall -y  gcc gcc-c++ make automake*
    
    rm -rf /etc/my.cnf*
    

    5.mysql安装

    
    #!/bin/bash
    
    PWD_DIR=`pwd`
    
    MachineIp=192.168.23.142
    
    MachineName=localhost.localdomain
    
    MysqlIncludePath=
    
    MysqlLibPath=
    
    ##安装glibc-devel
    
    yum install -y glibc-devel
    
    ##安装flex、bison
    
    yum install -y flex bison
    
    ##安装cmake
    
    tar zxvf cmake-2.8.8.tar.gz
    
    cd cmake-2.8.8
    
    ./bootstrap
    
    make
    
    make install
    
    cd -
    
    ## 安装mysql
    
    yum install -y ncurses-devel
    
    yum install -y zlib-devel
    
    if [  ! -n "$MysqlIncludePath"  ]
    
      then
    
    tar zxvf mysql-5.6.26.tar.gz
    
    cd mysql-5.6.26
    
    cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.6.26 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_USER=mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
    
    make
    
    make install
    
    ln -s /usr/local/mysql-5.6.26 /usr/local/mysql
    
    cd -
    
      else
    
      ## 根据mysql 库路径 配置 设置framework/CMakeLists.txt tarscpp/CMakeList.txt
    
      sed -i "s@/usr/local/mysql/include@${MysqlIncludePath}@g" ../framework/CMakeLists.txt
    
      sed -i "s@/usr/local/mysql/lib@${MysqlLibPath}@g" ../framework/CMakeLists.txt
    
      sed -i "s@/usr/local/mysql/include@${MysqlIncludePath}@g" ../framework/tarscpp/CMakeLists.txt
    
      sed -i "s@/usr/local/mysql/lib@${MysqlLibPath}@g" ../framework/tarscpp/CMakeLists.txt
    
    fi
    
    yum install -y perl
    
    cd /usr/local/mysql
    
    useradd mysql
    
    rm -rf /usr/local/mysql/data
    
    mkdir -p /data/mysql-data
    
    ln -s /data/mysql-data /usr/local/mysql/data
    
    chown -R mysql:mysql /data/mysql-data /usr/local/mysql/data
    
    cp support-files/mysql.server /etc/init.d/mysql
    
    yum install -y perl-Module-Install.noarch
    
    perl scripts/mysql_install_db --user=mysql
    
    cd -
    
    sed -i "s/192.168.2.131/${MachineIp}/g" `grep 192.168.2.131 -rl ./conf/*`
    
    cp ./conf/my.cnf /usr/local/mysql/
    
    ##启动mysql
    
    service mysql start
    
    chkconfig mysql on
    
    ##添加mysql的bin路径
    
    echo "PATH=\$PATH:/usr/local/mysql/bin" >> /etc/profile
    
    echo "export PATH" >> /etc/profile
    
    source /etc/profile
    
    ##修改mysql root密码
    
    cd /usr/local/mysql/
    
    ./bin/mysqladmin -u root password 'root@appinside'
    
    ./bin/mysqladmin -u root -h ${MachineName} password 'root@appinside'
    
    cd -
    
    ##添加mysql的库路径
    
    echo "/usr/local/mysql/lib/" >> /etc/ld.so.conf
    
    ldconfig
    
    ##下载C++基础服务框架
    
    yum install -y git
    
    cd ../
    
    git submodule update --init --recursive framework
    
    cd -
    
    ##安装c++语言框架
    
    cd ../framework/build/
    
    chmod u+x build.sh
    
    ./build.sh all
    
    ./build.sh install
    
    cd -
    
    ##Tars数据库环境初始化
    
    mysql -uroot -proot@appinside -e "grant all on *.* to 'tars'@'%' identified by 'tars2015' with grant option;"
    
    mysql -uroot -proot@appinside -e "grant all on *.* to 'tars'@'localhost' identified by 'tars2015' with grant option;"
    
    mysql -uroot -proot@appinside -e "grant all on *.* to 'tars'@'${MachineName}' identified by 'tars2015' with grant option;"
    
    mysql -uroot -proot@appinside -e "flush privileges;"
    
    cd ../framework/sql/
    
    sed -i "s/192.168.2.131/${MachineIp}/g" `grep 192.168.2.131 -rl ./*`
    
    sed -i "s/db.tars.com/${MachineIp}/g" `grep db.tars.com -rl ./*`
    
    chmod u+x exec-sql.sh
    
    ./exec-sql.sh
    
    cd -
    
    ##打包框架基础服务
    
    cd ../framework/build/
    
    make framework-tar
    
    make tarsstat-tar
    
    make tarsnotify-tar
    
    make tarsproperty-tar
    
    make tarslog-tar
    
    make tarsquerystat-tar
    
    make tarsqueryproperty-tar
    
    cd -
    
    ##安装核心基础服务
    
    mkdir -p /usr/local/app/tars/
    
    cd ../framework/build/
    
    cp framework.tgz /usr/local/app/tars/
    
    cd /usr/local/app/tars
    
    tar xzfv framework.tgz
    
    sed -i "s/192.168.2.131/${MachineIp}/g" `grep 192.168.2.131 -rl ./*`
    
    sed -i "s/db.tars.com/${MachineIp}/g" `grep db.tars.com -rl ./*`
    
    sed -i "s/registry.tars.com/${MachineIp}/g" `grep registry.tars.com -rl ./*`
    
    sed -i "s/web.tars.com/${MachineIp}/g" `grep web.tars.com -rl ./*`
    
    chmod u+x tars_install.sh
    
    ./tars_install.sh
    
    ./tarspatch/util/init.sh
    
    ##安装nodejs环境
    
    wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
    
    source ~/.bashrc
    
    nvm install v8.11.3
    
    ##安装web管理系统
    
    cd ../
    
    git submodule update --init --recursive web
    
    cd /home/circle/tars/web/
    
    npm install -g pm2 --registry=https://registry.npm.taobao.org
    
    sed -i "s/registry.tars.com/${MachineIp}/g" `grep registry1.tars.com -rl ./config/*`
    
    sed -i "s/db.tars.com/${MachineIp}/g" `grep db.tars.com -rl ./config/*`
    
    npm install --registry=https://registry.npm.taobao.org
    
    npm run prd
    
    cd -
    
    mkdir -p /data/log/tars/
    

    相关文章

      网友评论

          本文标题:Liunx 腾讯开发框架Tars 使用一键安装

          本文链接:https://www.haomeiwen.com/subject/zrhjoftx.html