邢栋博客

邢栋博客,Action博客,记录工作和生活中的点点滴滴

Mac下使用clion调试redis源码

1、先从github上下载源码
1)搜索 https://github.com/search?q=redis+clion
2)最好是选择别人配置好CMakeLists.txt的,不然自己配置也很麻烦


2、下载完成,开始配置
//选择一个想要调试的版本进行下载
wget https://github.com/htw0056/redis-3.0-annotated-cmake-in-clion/archive/master.zip
//解压
unzip redis-3.0-annotated-cmake-in-clion-master.zip
//重命名+拷贝
mv redis-3.0-annotated-cmake-in-clion-master redis-3.0
cp -R redis-3.0 redis-3.0-make

//编译
cd redis-3.0-make/src
make


3、打开clion软件,导入redis-3.0项目
1)搜索到saddCommand命令,打个断点,开启debug模式

image2020-12-9_20-56-1.png
4、进入到客户端服务器,执行sadd命令
1)进入到redis-3.0-make/src,开始执行命令
./redis-cli
sadd numbers 1 77777 xd
这个时候就打开clion软件一步一步往下走了

image2020-12-9_20-57-44.png

Mac下安装gdb证书
1、先按照csdn上面的这边文章进行添加证书,名称设为 code_gdbsign
https://blog.csdn.net/LU_ZHAO/article/details/104803399/

2、假如你的mac系统大于Mac OS X 10.14,则

vim gdb-entitlement.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>com.apple.security.cs.allow-jit</key>
    <true/>
    <key>com.apple.security.cs.allow-unsigned-executable-memory</key>
    <true/>
    <key>com.apple.security.cs.allow-dyld-environment-variables</key>
    <true/>
    <key>com.apple.security.cs.disable-library-validation</key>
    <true/>
    <key>com.apple.security.cs.disable-executable-page-protection</key>
    <true/>
    <key>com.apple.security.cs.debugger</key>
    <true/>
    <key>com.apple.security.get-task-allow</key>
    <true/>
</dict>
</plist>
</pre>

然后执行
codesign --entitlements gdb-entitlement.xml -fs code_gdbsign $(which gdb)

3、如果mac系统早于10.14,则执行以下命令即可


codesign -fs code_gdbsign $(which gdb)




Mac系统实现git命令补全
1、先安装brew,安装过的可以忽略
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

2、安装bash-completion
brew install bash-completion

3、系统配置

下载此文件
https://github.com/git/git/blob/master/contrib/completion/git-completion.bash
然后复制到家目录
cp xxx/git-completion.bash ~/.git-completion.bash

vim ~/.bash_profile 加入以下代码
if [ -f ~/.git-completion.bash ]; then
   . ~/.git-completion.bash
fi

读取文件
source ~/.git-completion.bash

mac命令行终端显示当前git分支


vim ~/.bash_profile,写入以下内容

function git_branch {
  branch="`git branch 2>/dev/null | grep "^\*" | sed -e "s/^\*\ //"`"
  if [ "${branch}" != "" ];then
    if [ "${branch}" = "(no branch)" ];then
      branch="(`git rev-parse --short HEAD`...)"
    fi
    echo " ($branch)"
  fi
}
export PS1='\u@\h \[\033[01;36m\]\W\[\033[01;32m\]$(git_branch)\[\033[00m\] \$ '


阿里云服务器执行df和du查看磁盘结果不一致
lsof | grep deleted (如果lsof命令不存在,执行yum install lsof进行安装)

我这里执行后,显示都是nginx相关进程

于是我执行
nginx -s reload
如果不行,可以执行
killall nginx; nginx -c /usr/local/nginx/conf/nginx.conf
linux查看某个进程的安装目录
1.=====获取到进程号=====
ps aux|grep php-fpm 
得到php-fpm的master进程的id号是10100

2.=====查看安装目录=====
ll /proc/10100/exe
centos7下gcc升级
=====下载地址=====
https://ftp.gnu.org/gnu/gcc/

=====下载gcc和相关依赖=====
wget https://ftp.gnu.org/gnu/gcc/gcc-5.4.0/gcc-5.4.0.tar.gz
tar -zxvf gcc-5.4.0.tar.gz
cd gcc-5.4.0
./contrib/download_prerequisites //相关依赖


=====建立存放编译文件的文件夹+编译=====
mkdir gcc-build-5.4.0
cd gcc-build-5.4.0/
../configure --prefix=/usr/local/gcc5 --enable-languages=c,c++,go  --disable-multilib
make  //耗时很长很长
make install 

=====复制命令=====
rm -f /usr/bin/gcc
rm -f /usr/bin/g++
ln -s /usr/local/gcc5/bin/gcc /usr/bin/gcc
ln -s /usr/local/gcc5/bin/g++ /usr/bin/g++


=====关联新的动态库=====
cd /usr/local/gcc5/lib64/
cp libstdc++.so.6.0.21 /usr/lib64/
rm -rf /usr/lib64/libstdc++.so.6
ln -s libstdc++.so.6.0.21 libstdc++.so.6
centos7下安装gitlab问题总结
=====问题1 执行 systemctl start  postfix
Job for postfix.service failed because the control process exited with error code. See "systemctl status postfix.service" and "journalctl -xe" for details.=====

解决方法
vim /etc/postfix/main.cf 
myhostname = mail.flycoder.cn
mydomain = flycoder.cn
myorigin = $mydomain
inet_interfaces = localhost // all表示接受来自所有网络的请求
mydestination = $myhostname, localhost.$mydomain, localhost  //指定发给本地邮件的域名
inet_protocols = ipv4

优惠券
最新微语