Table of contents
Open a new project and keep loading go list -m json all
Debug prompts that gcc does not exist, install GCC on Ubuntu 20.04
environment variable disappears
#Delete the ./idea file when selecting a project
Redis踩坑——MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on
Why do you choose to install golang independently? My local environment is wsl2+ubuntu+idea. If you want to debug directly through the local virtual machine, you cannot install golang in dokcer
download
wget https://golang.google.cn/dl/go1.18.7.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.18.7.linux-amd64.tar.gz
vim /etc/profile
export PATH=$PATH:/usr/local/go/bin
export GOPATH=/home/go
export GOBIN=$GOPATH/bin
#保存
source /etc/profile
export GO111MODULE=on
export GOPROXY='https://goproxy.io'
export GOPROXY=https://mirrors.aliyun.com/goproxy/
golang imports wsl code
Open a new project and keep loading go list -m json all
Stillnnnnnnn
Remember to open an agent
Debug prompts that gcc does not exist, install GCC on Ubuntu 20.04
The default Ubuntu software repositories contain a package group named "build-essential", which contains the GNU Editor Collection, GNU Debugger, and other development libraries and tools necessary to compile software. To install the development tools package, run the following command as a user with sudo privileges or as root:
sudo apt update
sudo apt install build-essential
This command will install a series of packages, including gcc
, g++
, and make
. You may also want to install the manual on how to develop with GNU/Linux.
sudo apt-get install manpages-dev
Verify that the GCC compiler is successfully installed by running the following command to print the GCC version.
gcc --version
The default version numbers of GCC available in the Ubuntu 20.04 software sources are 9.3.0
:
gcc (Ubuntu 9.3.0-10ubuntu2) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
environment variable disappears
#注意查看env环境变量里面的路劲
sudo vim ~/.profile
export GOROOT="/usr/local/go"
export GOBIN=$GOROOT/bin
export GOPATH="/home/go"
export PATH=$PATH:$GOPATH/bin
sudo vim ~/.bashrc
#添加
export GOROOT="/usr/local/go"
export GOBIN=$GOROOT/bin
export GOPATH="/home/go"
export PATH=$PATH:$GOPATH/bin
#保存
source ~/.bashrc
Red bread in the editor
#Give permissions first
#因为你的用个人账户开,比如我的账户test,遇到事情先给权限
sudo chown -R test:test-R /home
#Delete the ./idea file when selecting a project
abnormal
Mysql sql model 报错 which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mod e=only_full_group_by"
SELECT @@sql_mode; set @@global.sql_mode ='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
complete solution
-
Enter mysql: docker exec -ti 14ea13dd0cf8 /bin/bash
-
Enter password: mysql -uroot -p
-
查看sql_model:SELECT version(),@@SESSION.sql_mode,@@GLOBAL.sql_mode;
At this time, ONLY_FULL_GROUP_BY was found
-
Execute the following script:
mysql -uroot -p
SET SESSION sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
SET GLOBAL sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
#查询sql model
SELECT version(),@@SESSION.sql_mode,@@GLOBAL.sql_mode;
-
Looking at sql_model at this time: SELECT version(), @@SESSION.sql_mode, @@GLOBAL.sql_mode;
-
Restart the project to dokcer restart mysql
Redis踩坑——MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on
cannot be completely resolved
root@ubuntu:/usr/local/redis/bin# ./redis-cli
127.0.0.1:6379> config set stop-writes-on-bgsave-error no
solve it completely
vim /etc/sysctl.conf
'vm.overcommit_memory = 1'
#然后重启
将vm.overcommit_memory改为1有什么作用呢,网上看到一个博客是如下解释,我个人也比较同意
0 — 默认设置。个人理解:当应用进程尝试申请内存时,内核会做一个检测。内核将检查是否有足够的可用内存供应用进程使用;如果有足够的可用内存,内存申请允许;否则,内存申请失败,并把错误返回给应用进程。举个例子,比如1G的机器,A进程已经使用了500M,当有另外进程尝试malloc 500M的内存时,内核就会进行check,发现超出剩余可用内存,就会提示失败。
1 — 对于内存的申请请求,内核不会做任何check,直到物理内存用完,触发OOM杀用户态进程。同样是上面的例子,1G的机器,A进程500M,B进程尝试malloc 500M,会成功,但是一旦kernel发现内存使用率接近1个G(内核有策略),就触发OOM,杀掉一些用户态的进程(有策略的杀)。
2 — 当 请求申请的内存 >= SWAP内存大小 + 物理内存 * N,则拒绝此次内存申请。解释下这个N:N是一个百分比,根据overcommit_ratio/100来确定,比如overcommit_ratio=50,那么N就是50%。