openssl的编译

因为应用是跨平台,所以openssl的版本选择很重要,最好是应用使用的版本是与linux系统一致的。
当前Centos7.x已经开始使用1.0.2的版本,且官方也因为linux的广泛使用,也会一直维护该分支版。
打开其发布的版本页,找到1.0.2的最新版本:
https://github.com/openssl/openssl/releases

1.下载https://github.com/openssl/openssl/archive/OpenSSL_1_0_2u.tar.gz
2.解压并检查其下INSTALL.XXX文件,因为目标是WIN64,所以选择INSTALL.W64并按它的步骤下载相关组件及编译。
3.以下是摘取出来

 To build for Win64/x64:
 
 > perl Configure VC-WIN64A --prefix=c:\some\openssl\dir
 > ms\do_win64a
 > nmake -f ms\ntdll.mak
 > cd out32dll
 > ..\ms\test

4.仍需要下载并安装NASM工具,这个工具是INSTALL.WXX没有说及的。
http://www.nasm.us/pub/nasm/releasebuilds/2.14.02/
附带完整的编译脚本
build_static_openssl_x64.bat

echo "init vc env"
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"
set path_script=%~dp0
set path=C:\Users\honey\AppData\Local\bin\NASM;%path%
cd /D %path_script%\openssl_1_0_2u
perl Configure VC-WIN64A --prefix=%path_script%\lib\static
call ms\do_win64a
nmake -f ms\nt.mak clean
nmake -f ms\nt.mak
nmake -f ms\nt.mak install
nmake -f ms\nt.mak test

build_shared_openssl_x64.bat

echo "init vc env"
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"
set path_script=%~dp0
set path=C:\Users\honey\AppData\Local\bin\NASM;%path%
cd /D %path_script%\openssl_1_0_2u
perl Configure VC-WIN64A --prefix=%path_script%\lib\shared
call ms\do_win64a
nmake -f ms\ntdll.mak clean
nmake -f ms\ntdll.mak
nmake -f ms\ntdll.mak install
nmake -f ms\ntdll.mak test

Qt的CMakefiles样本1

cmake_minimum_required(VERSION 3.1)
 
project(untitled3 LANGUAGES CXX)
 
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
 
find_package(Qt5 COMPONENTS core widgets REQUIRED)
 
add_executable(${PROJECT_NAME} "main.cpp" "qml.qrc")
target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Widgets)
##特别注意是Qt5而不是Qt

the difference between vt100 and vt102

The VT102 was a member of the “second generation” of the VT100 family.
The original VT100 was sold with a number of options that could be inserted
into the box. The most significant was the AVO, or Advanced Video Option,
which was pretty much just extra memory. The base VT100 supported a 24×80
mode and a 14×132 mode. It supported normal text plus one video attribute,
which could be either underlining or reverse-video – which one you got
depended on whether you selected an underline or box cursor. AVO gave you
24×132 mode and the full four video attributes (underline, reverse, bold,
blink). The VT100 also had a modem control option, providing extra RS-232
signals.
The VT102 was a closed system (no options) which provided the equivalent of
a VT100 plus AVO plus (I think) modem control. It also added one or two
new commands – if I remember correctly, “Insert Line” (open a new line,
scroll stuff below it down) and “Delete Line”, and perhaps “Insert” and
“Delete Character in Line”.
DEC many years ago *defined* “VT100 compatibility” as “equivalent to a
VT102”. All subsequent DEC products that claimed VT100 compatibility
actually supported the full 24×132 display mode, four video attributes, and
the additional commands. (Modem control is a separate issue – “VT100
compatibility” is usually taken to refer only to *software* compatibility.)
As far as I know, the industry has pretty much followed DEC’s definition,
except that many terminal emulators are incapable of properly supporting
the 132-wide mode due to limitations of their displays.
There is absolutely no difference between the keypads of VT100’s and
VT102’s.

miniserver配置

version: '3.1'
 
services:
  mysql:
    image: mysql:5.6.40
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: 123456
    # links:
    ports:
      - 3306:3306
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
      - /opt/mysql/data:/var/lib/mysql
 
  redis:
    image: docker.io/redis:latest
    restart: always
    ports:
      - 6379:6379
 
  redis-cluster:
    image: grokzen/redis-cluster:5.0.7
    restart: always
    environment:
      STANDALONE: 'true'
      IP: '0.0.0.0'
    ports:
      - '7000-7050:7000-7050'
      - '5000-5010:5000-5010'
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
 
  prometheus:
    image: prom/prometheus:v2.15.2
    restart: always
    ports:
      - 9090:9090

DOS日期空格处理

set build_time="%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%"
set build_time=%build_time: =0%

node的typescript的常用操作

1.安装node版本,建议选择v8.11.3版本。

https://nodejs.org/dist/v8.11.3/node-v8.11.3-x64.msi<pre>
2.安装visual studio code,选择最新版。
【npm的所有命令,请不要powershell中执行,目前还不知道为什么在本人环境发现在执行npm config set注册下载源时,会出错,且错得很离谱。故需要用cmd.exe来解决。】
3.安装全局组件。
  <pre lang="geshi">
     npm install -g typescript
     npm install -g pm2
     npm install -g ts-node

4.安装本地组件
npm install
5.如果觉得安装有问题,可以直接清理npm缓存及组件。
%appdata%/npm和%appdata%/npm

ssh的连接复用

Host mini
   ControlPath ~/.ssh/master-%r@%h:%p
   ControlMaster auto
   ControlPersist yes
   HostName 192.168.10.104
   Port 22
   User abc

woweb的yii2容器化服务部署

version: '3.1'
 
networks:
  default:
    driver: bridge
    driver_opts:
      com.docker.network.enable_ipv6: "false"
    ipam:
      driver: default
      config:
        - subnet: 192.168.57.0/24
 
services:
  mysql:
    image: mysql:5.5.60
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: abc3.0123
    # links:
    ports:
      - 13306:3306
      # 13306端口是补人使用的,不能随便修改。
    volumes:
      - ./data/share/localtime:/etc/localtime:ro
      - ./data/share/timezone:/etc/timezone:ro
      - ./data/mysql/data:/var/lib/mysql
 
  php:
    image: yiisoftware/yii2-php:7.2-fpm
    restart: always
    ports:
      - 9900:9000
    links:
      - mysql:mysql
    extra_hosts:
      - mysql.woterm.com:abc.24.129.221
    depends_on:
      - mysql
    volumes:
      - ./data/share/localtime:/etc/localtime:ro
      - ./data/share/timezone:/etc/timezone:ro
      - ./data/wwwroot:/home/wwwroot
      - ./data/wwwlogs:/home/wwwlogs
      - ./../../woweb:/home/wwwroot/woweb
    # php-fpm运行的用户为www-data,需要将wwwroot的权限为[chmod a+w ]
 
  nginx:
    image: nginx:1.13.6
    restart: always
    ports:
      - 80:80
    links:
      - mysql
      - php
    depends_on:
      - mysql
      - php
    volumes:
      - ./data/share/localtime:/etc/localtime:ro
      - ./data/share/timezone:/etc/timezone:ro
      - ./data/nginx/conf/nginx.conf:/etc/nginx/nginx.conf:ro
      - ./data/nginx/conf/vhost:/etc/nginx/vhost:ro
      - ./data/wwwroot:/home/wwwroot
      - ./data/wwwlogs:/home/wwwlogs
      - ./../../woweb:/home/wwwroot/woweb
 
  ftp:
    image: stilliard/pure-ftpd
    restart: always
    ports:
      - "21:21"
    volumes:
      - ./data/vsftp:/home/vsftp
    environment:
      FTP_USER_NAME: uftp
      FTP_USER_PASS: xxxxxxx
      FTP_USER_HOME: ./data/vsftp/home

mongo分片及副本集搭建例子

https://github.com/senssei/mongo-cluster-docker

基于上面仓库,改造了一个副本集。
https://github.com/kxtry/mongo-cluster-docker

1.副本集docker-compose脚本

version: '3'
services:
    mgoprimary:
        container_name: "mgoprimary"
        image: mongo:4.2
        ports:
            - "27017:27017"
        command: mongod --replSet vmlocal --port 27017  --oplogSize 16
        links:
            - mgoreplica1:mgoreplica1
            - mgoreplica2:mgoreplica2
        restart: always
        extra_hosts:
            - "mgo.db.com:{{extern_ip}}"
        volumes:
            - /etc/localtime:/etc/localtime:ro
            - /etc/timezone:/etc/timezone:ro
            - ./data/mgoprimary/data:/data/db
 
    mgoreplica1:
        container_name: "mgoreplica1"
        image: mongo:4.2
        ports:
            - "27018:27017"
        command: mongod --replSet vmlocal --port 27017  --oplogSize 16
        restart: always
        extra_hosts:
            - "mgo.db.com:{{extern_ip}}" 
        volumes:
            - /etc/localtime:/etc/localtime:ro
            - /etc/timezone:/etc/timezone:ro
            - ./data/mgoreplica1/data:/data/db
 
    mgoreplica2:
        container_name: "mgoreplica2"
        image: mongo:4.2
        ports:
            - "27019:27017"
        command: mongod --replSet vmlocal --port 27017  --oplogSize 16        
        restart: always
        extra_hosts:
            - "mgo.db.com:{{extern_ip}}"
        volumes:
            - /etc/localtime:/etc/localtime:ro
            - /etc/timezone:/etc/timezone:ro
            - ./data/mgoreplica2/data:/data/db
 
    setup-vmlocal:
        container_name: "setup-vmlocal"
        image: mongo:4.2
        depends_on:
            - "mgoprimary"
            - "mgoreplica1"
            - "mgoreplica2"
        extra_hosts:
            - "mgo.db.com:{{extern_ip}}"
        links:
            - mgoprimary:mgoprimary
            - mgoreplica1:mgoreplica1
            - mgoreplica2:mgoreplica2
        volumes:
            - ./scripts:/scripts
        environment: 
            - MONGO1=mgo.db.com:27017
            - MONGO2=mgo.db.com:27018
            - MONGO3=mgo.db.com:27019
            - RS=vmlocal
        entrypoint: [ "/scripts/setup.sh" ]

3.与docker-compose.yml相同子目录下的./scripts/setup.sh脚本

#!/bin/bash 
 
mongodb1="${MONGO1}"
mongodb2="${MONGO2}"
mongodb3="${MONGO3}"
 
echo "Waiting for startup.."
until mongo --host ${mongodb1} --eval 'quit(db.runCommand({ ping: 1 }).ok ? 0 : 2)' &>/dev/null; do
  printf '.'
  sleep 1
done
 
echo "Started.."
 
echo setup.sh time now: `date +"%T" `
mongo --host ${mongodb1} <<EOF
   var cfg = {
        "_id": "${RS}",
        "protocolVersion": 1,
        "members": [
            {
                "_id": 0,
                "host": "${mongodb1}"
            },
            {
                "_id": 1,
                "host": "${mongodb2}"
            },
            {
                "_id": 2,
                "host": "${mongodb3}"
            }
        ]
    };
    rs.initiate(cfg, { force: true });
    rs.reconfig(cfg, { force: true });
EOF

3.构建脚本build_cluster.sh

#!/bin/sh                                                                                                                                                                                                   
 
path_current=`pwd`                                                                                                                                                                                          
path_script=$(cd "$(dirname "$0")"; pwd)                                                                                                                                                                    
 
mode=$1                                                                                                                                                                                                     
extern_ip=$2                                                                                                                                                                                                
 
case "$mode" in                                                                                                                                                                                             
     'build')                                                                                                                                                                                               
        if [ -f $path_script/docker-compose.yml ]; then                                                                                                                                                     
           echo 'the docker-compose.yml had been exist. if you want to continue, remove it.'                                                                                                                
           exit 1                                                                                                                                                                                           
        fi                                                                                                                                                                                                  
        /bin/cp $path_script/docker-compose.yml.template $path_script/docker-compose.yml && echo "$path_script/docker-compose.yml" | xargs /bin/sed -i "s#{{extern_ip}}#$extern_ip#g"                       
        echo 'success to build the file.'                                                                                                                                                                   
     ;;                                                                                                                                                                                                     
     *)                                                                                                                                                                                                     
       basename=`basename "$0"`                                                                                                                                                                             
       echo "Usage: $basename  {build}{extern_ip}"                                                                                                                                                          
       echo "---$basename build 192.168.10.104"                                                                                                                                                             
     ;;                                                                                                                                                                                                     
esac

Dockerfile的CMD和ENTRYPOINT的关系

以下示范,表示该形式下的CMD与ENTRYPOINT的关系。
CMD相当于应用程序的参数,ENTRYPOINT相当于应用的main入口或主程序入口。

FROM centos 
CMD ["echo 'p222 in cmd'"]     #传递给ENTRYPOINT的参数项。
ENTRYPOINT ["echo"]     #应用入口,相当于程序的main函数

1.构建

docker build  -t test .
<pre>
2.执行以下指令执行默认的CMD命令。
<pre lang="geshi">
docker run test
输出结果:
echo 'p222 in cmd'

3.修改程序输入参数

docker run test abct123
输出结果:
abct123