服务器运维相关问题

83 阅读2分钟

启动svn服务:

svnserve -d -r /opt/svn

停止svn服务:

killall svnserve


2018-09-17

spring 开发环境与生产环境配置

1.开发、生产配置文件

将已有的resources.properties拆分为resources-dev.propertiesresources-prod.properties,分别存放开发与生产环境下的DB连接、MQ连接;

2.在spring配置文件中设置profile,引入对应的beans

<context:property-placeholder location="classpath:conf/resources-dev.properties"/>

<context:property-placeholder location="classpath:conf/resources-prod.properties"/>

Note: 必须放在配置文件xml的最下面(包括import),否则xml报错,无法启动。

3.激活profile

Method1. web.xml配置

spring.profiles.active

dev

Method2. 修改 Tomcat 启动脚本 catalina.bat

set JAVA_OPTS="-Dspring.profiles.active=prod"


2018-09-29

node.js 安装nodejieba报错

node-gyp rebuild

if not defined npm_config_node_gyp (node "E:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\....\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "E:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )

gyp ERR! configure error

gyp ERR! stack Error: Can't find Python executable "E:\Anaconda3\python.EXE", you can set the PYTHON env variable.

gyp ERR! stack at PythonFinder.failNoPython (E:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:483:19)

gyp ERR! stack at PythonFinder. (E:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:508:16)

gyp ERR! stack at E:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js:284:29

gyp ERR! stack at FSReqWrap.oncomplete (fs.js:152:21)

gyp ERR! System Windows_NT 6.1.7601

MSBUILD : error MSB3428: 未能加载 Visual C++ 组件“VCBuild.exe”。

需要安装windows环境构建工具:npm install --global --production windows-build-tools

其中包含python 2.7与vs_BuildTools.exe


2018-10-12

MySQL 保存微信昵称(含表情等特殊字符)报错

  • 修改my.cnf配置文件,character-set-server=utf8mb4,并重启

[mysqld]

character-set-server=utf8mb4

  • 修改数据表字段编码类型

ALTER TABLE b_wx CHANGE nickname nickname varchar(30) character set utf8mb4 collate utf8mb4_unicode_ci;

这样,可以将包含表情的微信昵称保存至数据表,不过表中仍然无法显示,在Web页面可以显示相应的表情。

  • Appearance:

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-d0iEBZE7-1632377389090)(github.com/heartsuit/h…]

PS:一个有趣的发现:昵称中的表情在FireFox中显示为彩色,Chrome中显示为灰色;


2018-11-02

https下使用WebSocket

小程序要求服务器必须为https的,将阿里云的http升级为https后,发现客户端的WebSocket无法与服务器建立连接了:DOMException: “The operation is insecure.”

ws://127.0.0.1:8080/websocket 改为 wss://127.0.0.1:8080/websocket

vue-cli, axios 参数使用URLSearchParams,在IE中报错: ReferenceError: “URLSearchParams”未定义

1 npm i url-search-params-polyfill --save

2 在main.js import 'url-search-params-polyfill';

然后又报 ReferenceError:“Promise”未定义

1 npm i babel-polyfill --save

2 在main.js import 'babel-polyfill';

Spring Boot配置HTTP2

  • 版本:

操作系统:Ubuntu 16.04.2 LTS

Spring Boot:2.1.1

JDK:1.8.0_191

  • 实现HTTP2配置

刚开始采用Tomcat作为Servlet容器,但是通过

Spring Boot文档 发现有比较多的限制,比如要求Tomcat9.x以上等,很是繁琐,尝试多次未果。转而使用Undertow替代Tomcat,因为从Spring Boot文档可以看出,使用Undertow基本不用任何配置便可实现对HTTP2的支持。

需要做的是,在pom.xml中移除Tomcat的依赖,增加Undertow的依赖:

org.springframework.boot

spring-boot-starter-web

org.springframework.boot

spring-boot-starter-tomcat

org.springframework.boot

spring-boot-starter-undertow

在application-prod.yml