2019年4月29日星期一

修改ubuntu镜像源

修改配置文件(/etc/apt/sources.list)将安装源设置为国内的镜像,例如清华Ubuntu 16.04的镜像

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse

可选的ubuntu国内源:
阿里云:http://mirrors.aliyun.com/ubuntu/
清华:https://mirrors.tuna.tsinghua.edu.cn/ubuntu/

2019年4月16日星期二

java读取resources文件遇到的一个问题

spring中用applicationContext.getResources获取到Resource类实例之后,因为打包为jar之后resource文件在jar中,不在文件系统中,通过resource.getURI().getPath()为null,可以通过resource.getURL().getPath()获取到路径,比如:file:/Users/chenxiaoyu/project/target/project-1.0-SNAPSHOT.jar!/BOOT-INF/classes!/data/xx.txt

2019年4月9日星期二

非root用户修改hosts

参考https://unix.stackexchange.com/a/104511

vim ~/.hosts,增加hosts配置,比如:
hostname x.x.x.x

export HOSTALIASES=~/.hosts,done

2019年2月20日星期三

mac中docker资源分配的问题

在mac中安装了docker后使用-m参数设置很高的内存发现没有用,启动后的container内存依旧是限制在了最大2g。后来发现在mac的右上角docker图标中选择设置 -> advanced中,有docker资源的配置。

2019年2月18日星期一

libstdc++.so.6: version `GLIBCXX_3.4.20' not found

今天在ubuntu 14.04上运行一个编译好的二进制文件,报错:/usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.20' not found

>> strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBCXX
GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBCXX_3.4.9
GLIBCXX_3.4.10
GLIBCXX_3.4.11
GLIBCXX_3.4.12
GLIBCXX_3.4.13
GLIBCXX_3.4.14
GLIBCXX_3.4.15
GLIBCXX_3.4.16
GLIBCXX_3.4.17
GLIBCXX_3.4.18
GLIBCXX_3.4.19
GLIBCXX_DEBUG_MESSAGE_LENGTH

>> ls -l /usr/lib/x86_64-linux-gnu/libstdc++.so.6
lrwxrwxrwx 1 root root 19 Jan 27  2016 /usr/lib/x86_64-linux-gnu/libstdc++.so.6 -> libstdc++.so.6.0.19

是libstdc++.so.6版本过低的原因,没有GLIBCXX_3.4.20,但c++代码中里的需要用到GLIBCXX_3.4.20,所以需要升级g++。

ubuntu 14.04 默认是gcc 4.8.4版本,如果还没有安装gcc,那么:
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
sudo apt-get update
sudo apt-get install -y --force-yes gcc

如果已经安装gcc,那么升级gcc版本到4.8.5(最好不这么升级,自行查一下如何升级gcc):
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade

2019年1月17日星期四

mac安装mysql

参考https://gist.github.com/operatino/392614486ce4421063b9dece4dfe6c21

Install brew services first : $ brew tap homebrew/services

Load and start the MySQL service : $ brew services start mysql@5.7
Expected output : Successfully started mysql (label: homebrew.mxcl.mysql)

Check of the MySQL service has been loaded : $ brew services list

Force link 5.7 version - $ brew link mysql@5.7 --force

Verify the installed MySQL instance : $ mysql -V

安装完成后mysql配置读取顺序默认为:/etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/my.cnf ~/.my.cnf

找到相应的文件,修改配置,然后brew services restart mysql@5.7

2019年1月11日星期五

tensorflow的c++ so编译问题

tensorflow1.6的二进制包是用gcc4编译的,bazel在gcc5上使用到tensorflow的库的话编译会有问题,如下:


如果需要在gcc5上兼容tensorflow库,需要在编译选项中加上 bazel build --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0"