部署记录

发布于 2020-01-12  352 次阅读


伺服器(正式)

host 核心 内存 储存 带宽 部署
master 2c 8g 40g 1m nginx、webApp、Kibana、jenkins、maven、git、logstash
redis 1c 4g 40g 2m redis
es-1 2c 8g 40g 1m elasticsearch
es-2 2c 8g 40g 2m elasticsearch
es-3 2c 8g 40g 2m elasticsearch
gateway 1c 4g 120g 5m nginx、mariadb、
frontend 1c 2g 50g 5m nginx(静态文件)、jenkins
pic 1c 2g 60g 共享 临时图片服务器

伺服器(测试)

host 核心 内存 储存 带宽 部署
master 1c 2g 40g 1m nginx、webApp、mariadb
node01 1c 2g 40g 1m elasticsearch
node02 1c 2g 120g 5m redis、kibana、jenkins、maven、git
node03 1c 2g 50g 5m logstash

初始化

网络重装为debian9

使用moeclub.org的脚本

bash <(wget --no-check-certificate -qO- 'https://moeclub.org/attachment/LinuxShell/InstallNET.sh') -d 9 -v 64 -a

重装完成后修改root密码

开启BBR

修改系统变量

echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf

保存生效

sysctl -p

查看内核是否已开启BBR

sysctl net.ipv4.tcp_available_congestion_control

显示以下即已开启:

# sysctl net.ipv4.tcp_available_congestion_control
net.ipv4.tcp_available_congestion_control = bbr cubic reno

查看BBR是否启动

lsmod | grep bbr

显示以下即启动成功:

# lsmod | grep bbr
tcp_bbr                20480  14

安装字体

# apt install fontconfig -y

基本设置

  • 修改镜像源为阿里云

    vim /etc/apt/sources.list
    deb http://mirrors.aliyun.com/debian/ stretch main non-free contrib
    deb-src http://mirrors.aliyun.com/debian/ stretch main non-free contrib
    deb http://mirrors.aliyun.com/debian-security stretch/updates main
    deb-src http://mirrors.aliyun.com/debian-security stretch/updates main
    deb http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib
    deb-src http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib
    deb http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib
    deb-src http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib
  • 设置主机名

    hostnamectl set-hostname xxx
  • 配置hosts文件

    192.168.0.3   master
    192.168.0.4   worker
    10.0.0.3  gateway
  • 设置内网免密ssh

    ssh-keygen
    ssh-copy-id -i .ssh/id_rsa.pub root@gateway
  • 禁止内网机器ssh

  • 修改外网机器ssh端口

  • 进行快照用于备份

  • 设置时区

    dpkg-reconfigure tzdata

安装Mariadb

安装最新版

apt -y install software-properties-common dirmngr
apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xF1656F24C74CD1D8
add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://mirror.zol.co.zw/mariadb/repo/10.4/debian stretch main'

初始化

systemctl start mariadb
systemctl enable mariadb
mysql_secure_installation
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '密码' WITH GRANT OPTION;
FLUSH PRIVILEGES;

备份

nohup mysqldump -uroot -pCheerfun.dev --single-transaction --flush-logs -q pixivic | gzip >pixivic.gz &

还原

nohup gunzip < pixivic.gz | mysql -uroot -pCheerfun.dev pixivic 1>mysql 2>&1 &

性能检测

mysqltuner.pl tuning-primer.sh

安装Nginx

安装最新版

apt install curl gnupg2 ca-certificates lsb-release -y
echo "deb http://nginx.org/packages/debian `lsb_release -cs` nginx" \
    | tee /etc/apt/sources.list.d/nginx.list
curl -fsSL https://nginx.org/keys/nginx_signing.key | apt-key add -
apt update -y & apt install nginx -y

安装Kibana

https://www.elastic.co/guide/en/kibana/current/deb.html

配置外网访问以及es的api地址

安装Logstash

https://s0www0elastic0co.icopy.site/guide/en/logstash/current/installing-logstash.html

配置mysql驱动以及同步配置文件

安装Elasticsearch

  • jdk

  • es下载解压

  • 安装日语分词器插件

    bin/elasticsearch-plugin install file:///usr/local/elasticsearch-7.3.1/analysis-kuromoji-7.3.1.zip
  • 新建用户

  • 在/etc/sysctl.conf加上vm.max_map_count=655360

  • 修改jvm.options

    -Xms5g
    -Xmx5g
  • 修改elasticsearch.yml

安装Redis

下载源代码

wget http://download.redis.io/releases/redis-5.0.7.tar.gz
apt install build-essential    
apt-get install libc6-dev-i386
tar -zxvf redis-5.0.7.tar.gz 
cd redis-5.0.7
make 32bit MALLOC=libc
make install

安装Jenkins

图片服务器

部署nginx+nginx-upload-module

apt安装nginx最新版 nginx -V复制配置信息再加上--add-module=/root/nginx-upload-module-2.3.0

之后重新编译就行


面向ACG编程