• linux下服务器部署


    服务器部署

    1、增加交换空间swap(这一步可以不执行)

    mkdir -p /data/project/tools

    # 硬件8G内存,Swap 2倍则16G
    dd if=/dev/zero of=/data/swapfile bs=1024 count=16384000

    # 硬件4G内存,Swap 2倍则8G
    dd if=/dev/zero of=/data/swapfile bs=1024 count=8192000


    mkswap /data/swapfile
    swapon /data/swapfile

    vi /etc/fstab
    添加:
    # add new swap
    sudo /data/swapfile swap swap defaults 0 0


    一.# 增加pip源为阿里云

    mkdir -p ~/.pip/
    vi ~/.pip/pip.conf

    内容:
    [global]
    index-url = http://mirrors.aliyun.com/pypi/simple

    [install]
    trusted-host=mirrors.aliyun.com

    二.更新源

    sudo vi /etc/apt/sources.list


    内容:
    #aliyun
    deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse


    sudo apt-get update


    2、安装Python2.+ 和 Python 3.+

    sudo mkdir -p /data/project/tools
    cd /data/project/tools


    sudo wget https://www.python.org/ftp/python/2.7.15/Python-2.7.15.tgz
    sudo wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz


    apt-get update

    sudo apt-get install -y zlib1g zlib1g-dbg zlib1g-dev zlib-bin zlibc zlib-gst
    sudo apt-get install -y bison build-essential bzip2 curl flex g++ g++-multilib gcc git gnupg gperf libbz2-dev libc6-dev libcurl3 libdbi-dev libevent-dev libffi-dev libfontconfig1-dev libfreetype6 libgdbm-dev libgl1-mesa-dev libgl1-mesa-glx libicu-dev libjpeg-dev libncurses5-dev libpng-dev libpython-all-dev:amd64 libpython-dev:amd64 libreadline-dev libreadline6 libreadline6-dev libsqlite3-dev libssl-dev libtcl8.6 libtk8.6 libx11-dev libxext-dev libxml2 libxml2-dev libxml2-utils libxslt1-dev libxslt1.1 libxtst-dev openssl perl ruby sqlite sqlite3 tcl tcl-dev tk tk-dev tofrodos tree vim x11proto-core-dev xsltproc zip zlib1g-dev libmysqld-dev
    sudo apt-get install -y subversion libsvn-java libsvnkit-java


    sudo tar zvxf Python-2.7.15.tgz
    sudo rm -rvR /usr/local/lib/python2.7
    cd Python-2.7.15
    sudo ./configure --prefix=/usr/local --enable-optimizations
    sudo make
    sudo make install
    sudo make clean


    cd /data/project/tools

    sudo curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
    sudo python get-pip.py

    sudo pip install virtualenv

    tar zvxf Python-3.6.5.tgz
    cd Python-3.6.5
    sudo ./configure --prefix=/usr/local --enable-optimizations
    sudo make
    sudo make install
    sudo make clean


    pip3.6 install --upgrade pip
    pip3.6 install wheel virtualenv

    3、配置xxx、yyy、ccc虚拟环境

    cd /data/project/
    virtualenv -p /usr/local/bin/python2.7 xxx
    virtualenv -p /usr/local/bin/python3.6 yyy
    virtualenv -p /usr/local/bin/python2.7 xxx
    virtualenv -p /usr/local/bin/python2.7 ccc

    4、安装MySQL数据库

    # MySQL 5.5
    sudo apt-get install mysql-client-5.5 mysql-client-core-5.5 mysql-server-5.5 mysql-server-core-5.5 mysql-source-5.5 mysql-testsuite-5.5 mysql-common mysql-utilities mysql-mmm-agent mysql-mmm-common mysql-mmm-monitor mysql-mmm-tools mysql-proxy mysqltcl mysqltuner mysql-workbench mysql-workbench-data libmysqld-dev libmysqlclient-dev apparmor

    用户:root
    密码:yoquant

    主从分离根据自己开发部署需要:一般只需要部署主库即可:
    主库下:
    mysql -u root -p

    create user slave;
    GRANT REPLICATION SLAVE ON *.* TO 'slave'@'192.168.x.xxx' IDENTIFIED BY '密码xxx';


    从库下:
    mysql -u root -p

    change master to master_host='192.168.xx.xxx',
    master_port=3306,
    master_user='slave',
    master_password='xxxxx',
    master_log_file='master-bin.000001',
    master_log_pos=107;

    start slave;


    # 结合自己实际添加xxxxx用户

    GRANT SELECT,INSERT,UPDATE,DELETE,EXECUTE,SHOW VIEW,TRIGGER ON chatbot.* TO 'chatbot'@'%' IDENTIFIED BY 'twstwstws.' WITH GRANT OPTION;
    GRANT SELECT,INSERT,UPDATE,DELETE,EXECUTE,SHOW VIEW ON cms.* TO 'chatbot'@'%' WITH GRANT OPTION;
    GRANT SELECT,INSERT,UPDATE,DELETE,EXECUTE,SHOW VIEW,TRIGGER ON stock.* TO 'chatbot'@'%' WITH GRANT OPTION;
    GRANT SELECT,INSERT,UPDATE,DELETE,EXECUTE,SHOW VIEW,TRIGGER ON autocar.* TO 'chatbot'@'%' WITH GRANT OPTION;

    flush privileges;

    show grants for chatbot;


    # 添加stock用户

    GRANT SELECT,INSERT,UPDATE,DELETE,EXECUTE,SHOW VIEW,TRIGGER ON stock.* TO 'stock'@'%' IDENTIFIED BY 'twstwstws.' WITH GRANT OPTION;

    flush privileges;

    show grants for stock;


    # 添加autocar用户

    GRANT SELECT,INSERT,UPDATE,DELETE,EXECUTE,SHOW VIEW,TRIGGER ON autocar.* TO 'autocar'@'%' IDENTIFIED BY 'twstwstws.' WITH GRANT OPTION;

    flush privileges;

    show grants for autocar;

    5、安装MongoDB数据库

    cd /data/project/tools
    wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1404-3.6.5.tgz


    或者

    sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5

    echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list

    sudo apt-get update

    sudo apt-get install -y mongodb-org=3.6.5 mongodb-org-server=3.6.5 mongodb-org-shell=3.6.5 mongodb-org-mongos=3.6.5 mongodb-org-tools=3.6.5

    6、安装Redis

    sudo apt-get install -y redis-server

    cd /etc/redis/
    sudo mv redis.conf redis.conf.back
    sudo wget http://10.9.0.91/redis.conf
    service redis-server restart

    7、安装Memcached

    sudo apt-get install -y memcached

    8、安装Supervisor

    pip2 install supervisor


    cd /etc
    mkdir -p /etc/supervisor
    mkdir -p /etc/supervisor/conf.d
    mkdir -p /var/supervisor/
    mkdir -p /var/log/supervisord/

    ln -s /etc/supervisor/supervisord.conf supervisord.conf

    cd /etc/init.d/
    vi supervisord

    # 输入supervisord内容

    chmod ugo+x supervisord

    9、安装Nginx

    sudo apt-get install -y nginx

  • 相关阅读:
    exec系列函数和system函数
    fork函数相关总结
    文件的内核结构file和dup实现重定向
    进程基本概述
    fcntl 函数与文件锁
    文件的属性
    目录的操作
    文件的读取写入
    文件的打开关闭
    浅谈原始套接字 SOCK_RAW 的内幕及其应用(port scan, packet sniffer, syn flood, icmp flood)
  • 原文地址:https://www.cnblogs.com/DJRemix/p/11382896.html
Copyright © 2020-2023  润新知