centos7安装distcc
依赖项:
安装g++
yum install -y gcc
yum install -y gcc-c++
python:
python3.1版本以上。
yum install -y python36
python环境
安装python3-devel, distcc安装时候需要其中的依赖
yum install -y python3-devel
安装libbinutils 库 distcc需要依赖
yum install -y binutils-devel
下载distcc包
https://distcc.github.io/
下载最新的安装包就好,我用的是distcc3.3.3
1 tar -xvf distcc-3.3.3.tar.gz
2 cd distcc-3.3.3
3 ./configure 如果报错Cannot find libiberty。需要安装libbinutils 库
4 make 如果报错,应该是上面的安装依赖项没安装全
5 make install
6 ln -s ./distcc-3.3.3/distcc /usr/lib/distcc
配置:
vim ~/.bashrc
export DISTCC_HOSTS="localhost"
export DISTCC_POTENTIAL_HOSTS="localhost"
export DISTCC_LOG="./distcc.log" #编译日志
意外:如果以上都配置好了,还是连不上,关掉防火墙,重试
systemctl stop firewall
安装ccache
yum install -y ccache
vim ~/.bash_profile
PATH=/usr/lib/ccache/bin:$PATH:$HOME/bin
开启指令
distccd --daemon --allow 192.168.0.0/8 --user nobody --enable-tcp-insecure
posted @
2021-01-19 10:20 长戟十三千 阅读(4) |
评论 (0) |
编辑 收藏
摘要: 1. 为什么要使用后缀名为 .d 的依赖文件?在 Makefile 中, 目标文件的依赖关系需要包含一系列的头文件。比如main.c 源文件内容如下:#include "stdio.h" #include "defs.h" int main(int argc, char *argv[]) { printf("Hello, %s!\n", NAME); return 0; } 12345...
阅读全文
posted @
2020-12-29 19:24 长戟十三千 阅读(11) |
评论 (0) |
编辑 收藏
1. 在 CentOS 7 上安装 .NET Core 运行时
- 在安装. net之前,您需要注册Microsoft密钥、注册产品存储库并安装所需的依赖项。这只需要在每台机器上执行一次。
sudo rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
sudo yum update sudo yum install aspnetcore-runtime-3.0
如果要安装 .NET SDK,使用 sudo yum install dotnet-sdk-3.0
这个命令。
如果运行该命令,打印出关于如何使用dotnet的信息,就可以开始了。
2. 准备一个 .NET Core 3 的 Web 应用
编辑一个 .NET Core 3 的 Web 应用
3. 发布程序
右键项目,选择发布,一步一步操作即可,目标运行时选择 linux-x64。
使用的 VS 2019
4. 发布的程序上传到 CentOS 服务器上
- cd 到指定目录
- 运行 dotnet 项目.dll 或者 nohup dotnet 项目.dll
- 访问网站,能够看到网站已经能够访问
查看防火墙状态:systemctl status firewalld
查询指定端口是否开启:firewalld-cmd --query-port=80/tcp
开启防火墙:systemctl start firewalld
关闭防火墙:systemctl stop firewalld
5. 安装 Nginx
6. 配置 Nginx 代理
- 定位到 nginx 配置文件目录
- 编辑配置文件
如下
location / { proxy_pass http://localhost:5000; }
将请求映射到本地请求的 5000 端口上。
- 如果报错 13: Permission denied while connecting to upstream 之类的错误,参考:https://www.cnblogs.com/songxingzhu/p/10063043.html
setsebool -P httpd_can_network_connect 1
7. 安装 Supervisor
8. 使用 Supervisor 配置守护进程
在 /etc/supervisor/conf.d/
下创建 sampleDemo.ini 文件
sampleDemo.ini 配置文件如下
[program:SampleDemo] ;程序名称 command=dotnet WebUI.dll ;需要执行的命令 directory=/usr/local/dotnetCore3/sampleDemo ;命令执行的目录 environment=ASPNETCORE__ENVIRONMENT=Production ;环境变量 user=root ;用户 stopsignal=INT ;当请求停止时用来终止程序的信号。这可以是任何术语,HUP, INT, QUIT, KILL, USR1或USR2。 autostart=true ;是否自启动 autorestart=true ;是否自动重启 startsecs=10 ;自动重启时间间隔(s) stderr_logfile=/var/log/sampleDemo/err.log ;错误日志文件 stdout_logfile=/var/log/sampleDemo/out.log ;输出日志文件
http://www.supervisord.org/configuration.html#program-x-section-settings
重启:supervisorctl reload
访问 Supervisor Web 管理器,可以实现对部署程序的启动、停止、重启等操作。
作者:一青叶
链接:https://www.jianshu.com/p/88662513c69b
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
posted @
2020-12-28 17:45 长戟十三千 阅读(10) |
评论 (0) |
编辑 收藏
1、p4 client my_workspace
修改view,配置myclient
2、/data/mydir/ 目录下创建 .p4config文件,添加内容:
P4USER=myuser
P4CLIENT=myclient
3、vim ~/.bashrc, 添加
export P4USER=myuser
export P4PORT=10.8.7.9:666
export P4CONFIG=.p4config
export P4IGNORE=.p4ignore
4、source ~/.bashrc
5、p4 set
6、p4 sync ./...
posted @
2020-11-25 15:19 长戟十三千 阅读(22) |
评论 (0) |
编辑 收藏
#!/bin/sh
if [ $# -lt 3 ];
then
echo "参数个数错误:log_path dst_path timeout_day, 例子: ./log ./backup 3"
exit
fi
#策略:3天前移动到备份并压缩
LOG_PATH=$1
DST_PATH=$2
BACKUP_LOG_DATE=`date -d "$3 day ago" +"%Y%m%d"`
echo $LOG_PATH $DST_PATH $BACKUP_LOG_DATE
function FuncTryMkdir()
{
# 创建备份目录
if test -d $1
then
#echo "已存在目标文件夹:"$1
return
else
mkdir $1
fi
}
FuncTryMkdir $DST_PATH
#遍历并移动过期日志文件
for FILE_NAME in $LOG_PATH/*
do
BASE_NAME=`basename $FILE_NAME`
DATA_DIR=${BASE_NAME:0-11:8}
#N天前的文件,创建目录,并移动
if (("$DATA_DIR" < "$BACKUP_LOG_DATE"));then
BACKUP_DIR=$DST_PATH"/"$DATA_DIR"/"
FuncTryMkdir $BACKUP_DIR
mv $FILE_NAME $BACKUP_DIR
fi
done
#遍历备份并压缩
cd $DST_PATH
for FILE_NAME in ./*
do
if test -d $FILE_NAME
then
BASE_NAME=`basename $FILE_NAME`
tar czf $BASE_NAME.tar.gz $BASE_NAME
rm -rf $BASE_NAME
fi
done
posted @
2020-10-15 19:01 长戟十三千 阅读(58) |
评论 (0) |
编辑 收藏
#!/bin/bash
WORK_DIR=`pwd`
FUN_NAME=$1
find $WORK_DIR -name "*.h" -o -name "*.cpp" -o -name "*.c" | xargs grep -n $FUN_NAME
posted @
2020-10-15 15:40 长戟十三千 阅读(32) |
评论 (0) |
编辑 收藏
1、描述
接入sdk, libshared.so, 编译时包含了libprotobuf.a, 但本地使用的brpc库,libbrpc.so编译依赖本地libprotobuf.so, 导致冲突
[libprotobuf FATAL google/protobuf/stubs/common.cc:79] This program was compiled against version 2.5.0 of the Protocol Buffer runtime library, which is not compatible with the installed version (3.5.1). Contact the program author for an update. If you compiled the program yourself, make sure that your headers are from the same version of Protocol Buffers as your link-time library. (Version verification failed in "google/protobuf/descriptor.pb.cc".)
terminate called after throwing an instance of 'google::protobuf::FatalException'
what(): This program was compiled against version 2.5.0 of the Protocol Buffer runtime library, which is not compatible with the installed version (3.5.1). Contact the program author for an update. If you compiled the program yourself, make sure that your headers are from the same version of Protocol Buffers as your link-time library. (Version verification failed in "google/protobuf/descriptor.pb.cc".)
2、解决
修改libShared.so编译脚本中, 编译依赖库protobuf时,添加命令: -fvisibility=hidden
./configure --with-pic --disable-shared --enable-static "CFLAGS=-fvisibility=hidden"
3、命令:
查询对外符号:
nm -CD libshared.so | grep " T" | grep google
临时添加链接目录:
export LD_LIBRARY_PATH=XXX
trol over symbol exports in GCCaaaa
Control over symbol exports in GCC
posted @
2020-10-14 17:18 长戟十三千 阅读(317) |
评论 (0) |
编辑 收藏
ssh 提供两种级别的安全认证:
- 基于口令的安全认证
- 基于密钥的安全认证
基于口令的安全认证
需要知道用户名和密码即可登录,该连接是加密的,但客户端不能确认目标主机是否为“伪造的”,也不能保证口令安全。
远程主机的 /etc/ssh/sshd_config 需配置:
PasswordAuthentication yes
重启 sshd 使改动生效:
$ /etc/init.d/sshd reload
基于密钥的安全认证
需要用户持有“公钥/私钥对”,远程服务器持有公钥,本地持有私钥。
客户端向服务器发出请求。服务器收到请求之后,先在用户的主目录下找到该用户的公钥,然后对比用户发送过来的公钥。如果一致,服务器用公钥加密“质询”并发送给客户端。客户端收到“质询”后用私钥解密,再发还给服务器。认证结束。
生成 ssh-key,选加密算法(rsa、dsa),给秘钥命名(可选):
$ ssh-keygen -t rsa -C "name"
passphrase 是证书口令,以加强安全性,避免证书被恶意复制。
会在 ~.ssh
下生成 id_rsa
, id_rsa.pub
两个文件,分别是 私钥/公钥。
公钥需保存到远程服务器 ~/.ssh/authorized_keys
里,私钥由客户端本地留存。
要保证 .ssh
和 authorized_keys
都只有用户自己有写权限。否则验证无效。
$ chmod -R 700 ~/.ssh/ $ chmod 600 ~/.ssh/authorized_keys
ssh 配置的一些实践
$ vim /etc/ssh/sshd_config # 禁用root账户登录,非必要,但为了安全性,请配置 PermitRootLogin no # 是否让 sshd 去检查用户家目录或相关档案的权限数据,这是为了担心使用者将某些重要档案的权限设错,可能会导致一些问题所致。例如使用者的 ~/.ssh/ 权限设错时,某些特殊情况下会不许用户登入 StrictModes no # 是否允许用户自行使用成对的密钥系统进行登入行为,仅针对 version 2。至于自制的公钥数据就放置于用户家目录下的 .ssh/authorized_keys 内 RSAAuthentication yes PubkeyAuthentication yes AuthorizedKeysFile %h/.ssh/authorized_keys # 有了证书登录了,就禁用密码登录吧,安全要紧 PasswordAuthentication no
持有多个 ssh-key 时的使用方法
简单情况下,通过手动指定私钥文件登录
$ ssh username@hostname -i ~/.ssh/my_id_rsa
觉得麻烦可以配置客户端的 /etc/ssh/ssh_config
# 其实默认 id_rsa 已经加入私钥路径了,这里只是示范 IdentityFile ~/.ssh/id_rsa # 如果有其他的私钥,再加入其他私钥的路径 IdentityFile ~/.ssh/my_id_rsa
你也可以使用 SSH Agent,下面以使用 GitHub 为场景简单介绍。
$ ssh-keygen -t rsa -C 'second@mail.com' $ ssh-add ~/.ssh/id_rsa_second
创建 ~/.ssh/config
# Default github user(first@mail.com) Host github.com HostName github.com User git IdentityFile C:/Users/username/.ssh/id_rsa # second user(second@mail.com) Host github-second HostName github.com User git IdentityFile C:/Users/username/.ssh/id_rsa_second
配置完成后,在连接非默认账号的仓库时,远端地址要修改为
git remote add test git@github-second:second/test.git # 原来是 git@github.com:second/test.git # git 根据配置的 user.email 来获取 github 帐号来显示 author 信息,记得将 user.email 改为相应的 email
作者:字母数字或汉字
链接:https://www.jianshu.com/p/fab3252b3192
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
posted @
2020-10-13 16:29 长戟十三千 阅读(55) |
评论 (0) |
编辑 收藏
摘要: 之前介绍了使用libcurl的HTTP GET将url地址中内容下载到本地 C/C++中libcurl的使用-Http GET方法使用详解,在更早的文章Linux下使用CURL模拟用户提交post表单中也介绍过在Linux环境使用curl命令提交POST表单。本文介绍使用libcurl的HTTP POST实现表单的提交,并获取表单的结果。libcurl的相关接口已经在上一篇文章中介绍,本...
阅读全文
posted @
2020-09-08 19:41 长戟十三千 阅读(92) |
评论 (0) |
编辑 收藏