Skip to content

办公室新Workstation的ubuntu上自己安装Abaqus2017的一些记录

办公室新Workstation的ubuntu上自己安装Abaqus2017的一些记录 published on No Comments on 办公室新Workstation的ubuntu上自己安装Abaqus2017的一些记录

1. 从别处拷过来的安装包,在拷贝过程中可能权限被修改导致无法运行,直接简单粗暴
chmod -R +x *
然后修改所有的Linux.sh
DSY_OS_Release="CentOS"
或者直接用命令
find . -name "Linux.sh" | sudo xargs sed -i 's/export DSY_OS_Release=${DSY_OS_Release}/export DSY_OS_Release=CentOS/g'

2. 运行./StartGUI.sh安装,如果出现错误
error while loading shared libraries: libXm.so.4: cannot open shared object file: No such file or directory
则安装
install libmotif-dev

3. 先安装service(solver),再安装cae

4. 如果安装cae的过程中无法链接license server
安装flexnet
/opt/SIMULIA/License/2017/linux_a64/code/bin/lmutil lmdiag -c 27008@flexnet
ref: http://www.harrisgeospatial.com/Support/SelfHelpTools/HelpArticles/HelpArticles-Detail/TabId/2718/ArtMID/10220/ArticleID/19294/3246.aspx

5. 运行cae的时候
X Error: code 2 major 154 minor 3: BadValue (integer parameter out of range for operation).
虽然没太大影响,总是看的不爽

"
I had a similar issue when running some GL applications via 'ssh -X' and solved it by adding "+iglx" to xserver-command in /usr/share/lightdm/lightdm.conf.d/50-xserver-command.conf.

# Dump core
xserver-command=X -core +iglx
After which you either reboot or Ctrl-Alt-F1, login, and 'sudo service lightdm restart'.
"

ref: https://polymerfem.com/forum/finite-element-modeling/computer-software-aa/3288-glx-error-when-launching-abaqus-on-debian

6. 这步不需要,仅作为记录
file ****
ln -s /lib64/ld-linux-x86-64.so.2 /lib64/ld-lsb-x86-64.so.3

另:
如果安装了CUDA,会导致编译很多软件出现locale error stray *** in program等问题。去掉环境变量即可

7. 对于ansys workbench,会出现Unable to resolve function glXMakeCurrent等等,参考
https://bugs.launchpad.net/ubuntu/+source/nvidia-graphics-drivers/+bug/589250

sudo ln -s /usr/lib/nvidia-384/libGL.so.384.98 /usr/lib/libGL.so.1

Transfer wordpress from one vps to another

Transfer wordpress from one vps to another published on No Comments on Transfer wordpress from one vps to another

1. backup database
https://codex.wordpress.org/Backing_Up_Your_Database
mysqldump --add-drop-table -h db01.example.net -u dbocodex -p wp > blog.bak.sql

2. backup wordpress
ftp download the folder

3. setup lnmp as before

4. lnmp vhost add ***
modify config file, change content to the name, such as www.nicklj.com

5. lnmp database add ****

6. restore database
if mysql is lower than 5.6, error may happen
Unknown collation: ‘utf8mb4_unicode_520_ci’
refer: https://wordpress.org/support/topic/1273-unknown-collation-utf8mb4_unicode_520_ci/
For this, delete all the 520_, and save, then

cat ***.sql | mysql -u username -p databasename

Sample code for vtk to display thousands of spheres with different radius

Sample code for vtk to display thousands of spheres with different radius published on No Comments on Sample code for vtk to display thousands of spheres with different radius

https://stackoverflow.com/questions/29840144/display-thousand-of-different-sphere

int main(int, char *[])
{
    srand(time(NULL));

    // create points
    vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();

    // setup scales
    vtkSmartPointer<vtkFloatArray> scales = vtkSmartPointer<vtkFloatArray>::New();
    scales->SetName("scales");

     // setup color label
    vtkSmartPointer<vtkFloatArray> col = vtkSmartPointer<vtkFloatArray>::New();
    col->SetName("col");

    // setup lookupTable and add some colors
    vtkSmartPointer<vtkLookupTable> colors = vtkSmartPointer<vtkLookupTable>::New();
    colors->SetNumberOfTableValues(4);
    colors->SetTableValue(0 ,1.0 ,0.0 ,0.0 ,1.0); // red
    colors->SetTableValue(1 ,0.0 ,1.0 ,0.0 ,1.0); // green
    colors->SetTableValue(2 ,0.0 ,0.0 ,1.0 ,1.0); // blue
    colors->SetTableValue(3 ,1.0 ,1.0 ,0.0 ,1.0); // yellow
    // the last double value is for opacity (1->max, 0->min)

    for(int i=0; i<100; i++)
    {
        points->InsertNextPoint(15*cos(i*PI/50), 15*sin(i*PI/50), 0); // sphere in circle
        scales->InsertNextValue((rand()% 100)/double(100)); // random radius between 0 and 0.99
        col->InsertNextValue((rand()% 4)); // random color label
    }

    // grid structured to append center, radius and color label
    vtkSmartPointer<vtkUnstructuredGrid> grid = vtkSmartPointer<vtkUnstructuredGrid>::New();
    grid->SetPoints(points);
    grid->GetPointData()->AddArray(scales);    
    grid->GetPointData()->SetActiveScalars("scales"); // !!!to set radius first
    grid->GetPointData()->AddArray(col);

    // create anything you want here, we will use a sphere for the demo
    vtkSmartPointer<vtkSphereSource> sphereSource = vtkSmartPointer<vtkSphereSource>::New();

    // object to group sphere and grid and keep smooth interaction
    vtkSmartPointer<vtkGlyph3D> glyph3D = vtkSmartPointer<vtkGlyph3D>::New();
    glyph3D->SetInputData(grid);
    glyph3D->SetSourceConnection(sphereSource->GetOutputPort());

    // create a mapper and actor
    vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
    mapper->SetInputConnection(glyph3D->GetOutputPort());

    mapper->SetScalarModeToUsePointFieldData(); // without, color are displayed regarding radius and not color label
    mapper->SetScalarRange(0, 3); // to scale color label (without, col should be between 0 and 1)
    mapper->SelectColorArray("col"); // !!!to set color (nevertheless you will have nothing)
    mapper->SetLookupTable(colors);

    vtkActor *actor = vtkActor::New();
    actor->SetMapper(mapper);

    // create a renderer, render window, and interactor
    vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();
    vtkSmartPointer<vtkRenderWindow> renderWindow = vtkSmartPointer<vtkRenderWindow>::New();
    renderWindow->AddRenderer(renderer);
    vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor = vtkSmartPointer<vtkRenderWindowInteractor>::New();
    renderWindowInteractor->SetRenderWindow(renderWindow);
    // add the actor to the scene
    renderer->AddActor(actor);
    renderer->SetBackground(0, 0, 0);
    // render and interact
    renderWindow->Render();
    renderWindowInteractor->Start();
    return EXIT_SUCCESS;

Install paraFOAM in any OpenFOAM version

Install paraFOAM in any OpenFOAM version published on No Comments on Install paraFOAM in any OpenFOAM version

Modify etc/config.csh/paraview

change
setenv ParaView_DIR $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$paraviewArchName
to
setenv ParaView_DIR YOUR_PARAVIEW_PATH

also remember to check ParaView_VERSION and ParaView_MAJOR

一个gcc版本的坑,以及解决方案

一个gcc版本的坑,以及解决方案 published on No Comments on 一个gcc版本的坑,以及解决方案

背景:
写程序可能要用到OpenMesh的库,去网上下了一个,编译安装,一切顺利。使用最简单的例子,qmake来配置,编译,出现问题
error: undefined reference to `OpenMesh::IO::_IOManager_::write(std::__cxx11::basic_string, std::allocator > const&, OpenMesh::IO::BaseExporter&, OpenMesh::IO::Options, long)'
看起来是很简单的问题,以前碰到很多次了,不就是链接的时候找不到库函数嘛,查看是否把库都包含进来了,咦,没问题啊,OpenMesh的两个库都在qmake包括了。以为是qt的锅,试了qt5, qt4,还是不行,算了不用qmake,直接写makefile,依然不行。

然后想起来是不是OpenMesh编译的库出现了问题。看到网官上是用cmake来配置的,好吧,上cmake,编译运行,成功。看来库并没有问题。

问题陷入僵局,回家后把OpenMesh和编译重新在家里电脑上编译一遍,一次通过。纠结了。

分析问题:
家里电脑的gcc是系统自带的5.x版,单位电脑是系统自带4.8带,我自己下载安装了5.2版。难道只有系统自带才可以?把单位电脑换4.8版,成功。
看似解决问题了,但根本说不通。难道是gcc安装的时候参数选择的问题?我一个参数一个参数的对照,发现没并有什么问题。
突然想到,是不是编译的库的gcc版本和运行gcc版本不同所造成的?查了一下cmake的默认编译器,果然是系统自带的。重新编译,CC=gcc CXX=g++ ccmake ../,安装,然后再用5.2来编译程序,成功。系统4.8编译,失败

关于cmake的设置
参考https://cmake.org/Wiki/CMake_FAQ#How_do_I_use_a_different_compiler.3F
CC=gcc-4.2 CXX=/usr/bin/g++-4.2 cmake -G "Your Generator" path/to/your/source 或者
cmake -G "Your Generator" -D CMAKE_C_COMPILER=gcc-4.2 -D CMAKE_CXX_COMPILER=g++-4.2 path/to/your/source
如果想看具体命令
make VERBOSE=1

果然问题就出现在这,可是为什么之前从来没出现过这种问题呢?
https://www.zhihu.com/question/51932153
这个页面已经讲的很详细了,在gcc4到gcc5的时候,ABI发生了变化,如果有string之类的暴露在二进制边界,就可能出现问题

GCC5 and the C++11 ABI


这个页面也说到了,如果错误信息有__cxx11之类的,8成是这个问题,也提出了解决方案

这个锅,库的编写者需要背一些。

看来可以告一段落了。c++的坑实在太多了。

另:
查看调用了哪些库
ldd binary

安装meshlab心得

安装meshlab心得 published on No Comments on 安装meshlab心得

Workstation的glibc版本过低,无解。只能往ubuntu装

1. 下载vcglib 1.01,
https://github.com/cnr-isti-vclab/vcglib/releases
这是一个header file only的库,不用安装

2. 选择相应meshlab版本,V2016.12,
http://www.meshlab.net/#download

3. 按照readme里面的提示放置。qt需要5.8版本,设置好路径

4. 安装
cd src/external/
gmake external.pro
make

cd src/
gmake meshlab_full.pro
make

5. 出错
Cannot find file: /home/nicklj/Platform/thirdparty/meshlab/src/plugins_experimental/io_TXT/io_TXT.pro.
make: *** [sub-plugins_experimental-io_TXT-make_first-ordered] Error 2
发现目录里面io_txt.pro是小写,这是在逗我?
mv plugins_experimental/io_TXT/io_txt.pro plugins_experimental/io_TXT/io_TXT.pro

5. 继续出错
/usr/bin/ld: ../../external/lib/linux-g++/libmpir.a(lt4-clear.o): unrecognized relocation (0x2a) in section `.text'
参考:https://github.com/cnr-isti-vclab/meshlab/issues/47

LibMpir is an external library that could be a little tricky to compile (that's particularly true on Windows...a lot easier on Linux), so we provide inside the MeshLab source code an already compile version of the library itself. Obviously that approach could be dangerous, considering the wide range of the compilers existing. If you are interested in the plugin I suggest you to:

download the mpir 2.4.0 source code from the mpir official site http://mpir.org/downloads.html
call ./configure --enable-cxx --enable-static --with-pic in the extracted library folder
call ./make
move the generated mpir.h and mpirxx.h in src\external\inc\linux-g++\mpir-2.4.0
move the static libs libmpir.a and libmpirxx.a in src\external\lib\linux-g+(be careful the files are compiled in a hidden folder if you have the "don't show hidden folders" file browser option set to true you can waste an afternoon, as it happens to me, to find the compiled libs 😀 )
try to compile again the filter_csg plugin in MeshLab

编译后的.a文件在.lib目录下

6. make meshlab, 搞定

qtcreator: /lib64/libc.so.6: version `GLIBC_2.14' not found (最后还是没有比较好的解决办法)

qtcreator: /lib64/libc.so.6: version `GLIBC_2.14' not found (最后还是没有比较好的解决办法) published on No Comments on qtcreator: /lib64/libc.so.6: version `GLIBC_2.14' not found (最后还是没有比较好的解决办法)

https://my.oschina.net/zhangxu0512/blog/262275

Run qtcreator, cannot find GLIBC_2.14

1. Check current glibc
strings /lib64/libc.so.6 |grep GLIBC

2. 从http://www.gnu.org/software/libc/ 下载源代码。我下载的版本是2.14,链接地址是http://ftp.gnu.org/gnu/glibc/glibc-2.14.tar.gz
However, 2.14 cannot be compiled by gcc5.2.0, so I download the 2.20

3.
tar xvf glibc-2.14.tar.gz
cd glibc-2.14
mkdir build
cd ./build
../configure --prefix=/opt/glibc-2.14
make -j4
make install

4. There will be
Error: no such instruction: `vinserti128 $1,%xmm0,%ymm0,%ymm0'

5. Install binutils-2.25

6. 运行的时候依然有问题
转自 https://herowong.me/archives/install-and-running-multiple-version-glibc-in-a-single-host-1.html

可以通过ldd命令查看程序依赖的动态库

一般情况下(在没有指定DT_RPATH和DT_RUNPATH的情况下)
1.先查找$LD_LIBRARY_PATH中的目录
2.再查找缓存文件/etc/ld.so.cache
3.再默认的目录/lib,/usr/lib或者是/lib64和/usr/lib64

ld.so.cache缓存文件可以通过ldconfig命令来配置,具体就不多说了
而在用gcc编译一个程序的时候加载动态库文件的顺序又是怎么样的呢?
1.由gcc写死的路径,通过gcc –print-search-dirs看到,这里加载的是一些 libgcc_s.so的库
2.$LIBRARY_PATH变量指定目录或者是编译-L参数指定的目录
3.由ld命令设定的目录,这部分也是在编译ld这个程序时写死的,可以通过“ld –verbose | grep SEARCH”来查看

回到刚才的问题,把新版本的Glibc添加到$LD_LIBRARY_PATH加会导致其它常用的程序如ls会挂掉,那我能不能把编译我想要的工具时指定使用新版的Glibc呢?当然可以,去google一下你可以看到so上的这个问题的答案 在编译的时候加上
-Wl,–rpath=/path/to/newglibc \
-Wl,–dynamic-linker=/path/to/newglibc/ld-linux.so.2

今天整了一天的VPS

今天整了一天的VPS published on No Comments on 今天整了一天的VPS

详细的过程网上一搜一大堆,就不写了,主要提几个关键步骤。
1. 购买vps
我买的是Kimsufi的独立服务器,价格还不错,有2t硬盘,可以装不少东西。100m上下行,大概15美刀一个月。我一个虚拟主机就要6刀,完全满足不了geek的心啊
主要是要认证地址,可以省去税,其它的没啥了。

2. 安装系统
还是ubuntu舒服,直接上了ubuntu server 16.04。在控制面版里点几下就装好了

3. 设置用户
直接用root实在可怕,添加一个自己的帐户
可以先看看已经有哪些用户
cat /etc/passwd
再添加
adduser user1
如果要改密码
passwd user1
添加sudo权限
adduser user1 sudo
查看是否添加成功
cat /etc/group | grep sudo
结果发现这样不太好,最好别给自己sudo权限,后面再讲

4. 安装LNMP
网上一搜一大堆,不多讲了。比如官网:
https://lnmp.org/install.html
以及安装和配置文件的详细解说:
https://lnmp.org/faq/lnmp-software-list.html
安装成功,再安装ftp
./pureftpd.sh
lnmp ftp add
添加vhost
lnmp vhost add
另外,网页默认目录是/home/wwwroot/default,为了调试方便我改了一下
配置文件/usr/local/nginx/conf/nginx.conf,两个地方要改,一看就知道了
比如我改为/home/wwwroot/www.nicklj.com
然后把default下的phpmyadmin拷到这个目录底下,并改名(为了安全),比如改为aaa

5. 导入wordpress
先把以前的godaddy虚拟主机中的wordpress备份数据库
不过这之前建议关掉statpress插件,太tmd占数据库空间了,有google analytics应该就不需要这个。通过phpmyadmin清除wp_statpress(记得先备份)
备份数据库有点烦,好像有些啥选项要选,参考了以下网站

Linux VPS/服务器上轻松导入、导出(恢复、备份)MySQL数据库


好像还有一个网站,等需要用的时候再调试吧
然后把整体网站备份过来,结果无法正常显示。算了重新下一个wordpress最新版吧,反正本来里面也没啥东西。简单设置以后,连接数据库成功,升级数据库,下载插件,ok了
wordpress中下载插件和主题,提示需要ftp用户名和密码。输入我之前设置的,发现无法建立目录,因为权限的问题。简单嘛
chmod 777 /home/wwwroot/www.nicklj.com
太不安全了......好像有比较安全的做法,比如 https://www.evernote.com/shard/s128/sh/8bcc23d7-92d7-4bf2-8be0-6aa65fac2157/0d85edf4944878cc 。不过反正能用,先这样吧

6. 安全
看看有多少人在试root登录
sudo grep "Failed password for root" /var/log/auth.log | awk '{print $11}' | sort | uniq -c | sort -nr | more
以及其它的user登录
sudo grep "Failed password for invalid user" /var/log/auth.log | awk '{print $13}' | sort | uniq -c | sort -nr | more
才1天就有3000多,有点吓人.....
我们目前要操心的主要是以下几个:
如果不怕多地登录的麻烦,使用rsa密钥应该是最安全的,不过我还不有喜欢用这个。所以我的设置是
(1) 禁止root登录
修改/etc/ssh/sshd_config
如果想关闭密码登录就 PasswordAuthentication no
如果想禁止root登录就 PermitRootLogin no
当需要root的时候,就随便登一个帐户,然后 su
(2) 取消之前设的普通帐户的sudo权限
deluser username sudo 或者
gpasswd -d username sudo
(3) 把普通帐户的密码改成比较正常的(不能太简单),把root密码改为非常复杂的
(4) 设置iptables,这个很麻烦,
https://www.91yun.org/zh/archives/1690 "看了那么多iptables的教程,这篇教程还是比较全面易懂的"
https://www.zhukun.net/archives/4906 "VPS被攻击时需要做的(用iptables封ip方法)"
最常用的应该是:
封ip: iptables -I INPUT -s 111.111.111.111 -j DROP
以及解封: iptables -D INPUT -s 111.111.111.111 -j REJECT
网上有推荐安装用denyhosts,我试了一下,然后把我自己的ip封了,要哭了,最后用手机开4g登录解封,所以暂时还是先手动吧
更安全的做法是根据需要开放端口,后面再学习
更多的关于安全设置
“新购VPS后的设置及网站迁移步骤”
http://ju.outofmemory.cn/entry/140153
“购买了VPS之后你应该做足的安全措施”

购买了VPS之后你应该做足的安全措施


“VPS 防止 SSH 暴力登录尝试攻击”

VPS 防止 SSH 暴力登录尝试攻击


“服务器被黑之后的心路历程”
http://monklof.com/post/10/

先这样吧,想到什么再补充