PaddleRec

从Docker中的Ubuntu16.04

1
2
3
4
5
6
7
8
# 拉取镜像
docker pull ubuntu:16.04

# 绑定8888端口并启动
docker run -p 8888:8888 -itd --name ubuntu ubuntu:16.04

# 进入容器内部
docker exec -it ubuntu /bin/bash

在更新容器内的操作系统

1
2
3
4
5
# 更新源
apt update

# 更新操作系统
apt upgrade

安装依赖

1
apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl vim zip unzip wget

更新openssl版本至1.1.1c

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

# 切换到主目录
cd ~

# 下载源代码
wget https://www.openssl.org/source/openssl-1.1.1c.tar.gz

# 解压源代码
tar -zxf openssl-1.1.1c.tar.gz

# 进入源代码目录
cd openssl-1.1.1c

# 执行编译安装
./config
make
make install

# 链接库文件
ln -s /usr/local/lib/libcrypto.so.1.1 /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1
ln -s /usr/local/lib/libssl.so.1.1 /usr/lib/x86_64-linux-gnu/libssl.so.1.1

# 备份openssl
mv /usr/bin/openssl /root/

# 链接目录
ln -s /usr/local/bin/openssl /usr/bin/openssl

# 查看当前openssl版本
openssl version

安装Git

1
apt-get install git -y

安装 pyenv 方便安装Python3.7.4

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
curl https://pyenv.run | bash

#添加 对应文件到 .bashrc


#安装 python3.7.4
pyenv install 3.7.4

#全局使用
pyenv global 3.7.4

# 更新pip
python -m pip install --upgrade pip

#安装飞桨1.8.4
python -m pip install paddlepaddle==1.8.4 -i https://mirror.baidu.com/pypi/simple

# 降低飞桨默认安装最新版本的protobuf
pip install protobuf==3.20.1

安装 Jupyter lab

1
2
3
pip install jupyterlab
pip install jupyterlab-language-pack-zh-CN
jupyter lab --allow-root

Rocky

Rocky下安装Python3.7.4

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 更新操作系统
dnf check-update -y
dnf update -y
dnf install gcc openssl-devel bzip2-devel libffi-devel zlib-devel wget make -y

# 下载源代码
wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tar.xz
# 解压
tar -xf Python-3.7.4.tar.xz
# 目录切换
cd Python-3.7.4
# 进行编译
./configure --enable-optimizations

make -j 6
nproc
make altinstall

# 版本
python3.7 --version

# 更新pip
python3.7 -m pip install --upgrade pip

飞桨安装

1
2
python3 -m pip install paddlepaddle==1.8.4 -i https://mirror.baidu.com/pypi/simple

初始化Node.js项目

创建项目

1
mkdir projectname && npm init

安装依赖

1
2
3
4
5
6
7
8
9
10
# 使用d3
npm i d3

# 使用rollup打包
npm install rollup --global
rollup -c

#添加压缩
npm install rollup-plugin-terser

MySQL安全

MySQL 安全

SSL启用

1
2
3
4
参考文档:[https://www.cnblogs.com/mysql-dba/p/7061300.html](https://www.cnblogs.com/mysql-dba/p/7061300.html)
JDBC:[https://www.codenong.com/cs106646667/](https://www.codenong.com/cs106646667/)
JDBC: [https://www.huaweicloud.com/articles/b6f3c64228a6089ad415b4cb085af5d4.html](https://www.huaweicloud.com/articles/b6f3c64228a6089ad415b4cb085af5d4.html)

审计

第三方插件:第三方插件

漏洞升级

1
2
3
4
5
6
yum list| grep mysql
yum update mysql-server
yum update mysqld mysql-devel
systemctl restart mysqld

# 主从情况下,全部停机,先启主再启从

登录限制

官方文档传送门: https://dev.mysql.com/doc/refman/5.7/en/connection-control-installation.html

中文文档:https://www.docs4dev.com/docs/zh/mysql/5.7/reference/connection-control-installation.html

网友文档:https://blog.csdn.net/leonpenn/article/details/104790469

CentOS7 openssl升级

openssl升级

下载

1
2
3
4
5
6

# openssl 路径:
wget https://www.openssl.org/source/openssl-1.1.1l.tar.gz

#openssh 路径:
wget https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.7p1.tar.gz

安装工具与依赖

1
2
3
yum install gcc gcc-c++ glibc make autoconf openssl openssl-devel pcre-devel  pam-deve

yum install -y pam* zlib*

安装 openssl

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 备份原来的openssl

mv /usr/bin/openssl /usr/bin/openssl_bak

mv /usr/include/openssl /usr/include/openssl_bak

# 安装
tar -xzf openssl-1.1.1l.tar.gz && cd openssl-1.1.1l && ./config --prefix=/usr/local/openssl --shared && make && make install

ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl

ln -s /usr/local/openssl/include/openssl /usr/include/openssl

`echo "/usr/local/openssl/lib" >>/etc/ld.so.conf`

ln -s /usr/local/lib64/libssl.so.1.1 /usr/lib64/libssl.so.1.1

ln -s /usr/local/lib64/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1

ldconfig

openssl version

# OpenSSL 1.1.1h 22 Sep 2020

安装openssh

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#安装openssh前 将openssl 安装到/usr/local/openssl

# 备份原来的 ssh配置


tar -xzf openssh-8.7p1.tar.gz

cd /etc/ssh && mkdir –p /root/sshbak && mv ./* /root/sshbak

cd /data/openssh-8.7p1

./configure --prefix=/usr/local/openssh --sysconfdir=/etc/ssh --with-openssl-includes=/usr/local/openssl/include --with-ssl-dir=/usr/local/openssl --with-zlib --with-md5-passwords --with-pam

make && make install

mv /usr/bin/ssh /usr/bin/ssh-bak20210830

ln -s /usr/local/openssh/bin/ssh /usr/bin/ssh

cp -a contrib/redhat/sshd.init /etc/init.d/sshd

cp -a contrib/redhat/sshd.pam /etc/pam.d/sshd.pam

chmod +x /etc/init.d/sshd

chkconfig --add sshd && systemctl enable sshd

mv /usr/lib/systemd/system/sshd.service /data/

chkconfig sshd on

ssh -V

# OpenSSH_8.4p1, OpenSSL 1.1.1h 22 Sep 2020
1
2
3
vim /etc/ssh/sshd_config
# 设置 usePAM = yes
systemctl restart sshd

CentOS7-swap

调整Swap分区大小

查看磁盘使用情况

1
df -h

添加swap文件并设置其大小为2G

1
2
3
4
5
6
# if 表示infile
# of 表示outfile
# bs=1MB 代表增加的模块大小
# count=2048 代表2048个模块,也就是2G空间,
# 将目的文件设置为swap分区文件
dd if=/dev/zero of=/tmp/swap bs=1MB count=2048

使用mkswap命令创建swap空间

1
mkswap /tmp/swap

启用新的swap

1
swapon /tmp/swap

查看swap是否生效

1
free -h

永久生效该分区,需要修改 /etc/fstab 文件,在文件最后增加以下内容:

1
/tmp/swap swap swap defaults 0 0

清除不再需要的swap分区

1
swapoff /tmp/swap

CentOS7-显卡

安装所需要的驱动

从NVIDIA官网上下载所需要的驱动文件(.run)。 https://www.nvidia.cn/Download/index.aspx?lang=cn

具体的选择是:Quadro Series -> K4000 -> Linux 64bit -> English(US)。

安装依赖关系

三个依赖:gcc,kernel-devel,dkms。要注意kernel-devel要与当前内核版本一致,检查方式如下:

1
2
uname -r # 检查当前内核版本
rpm -aq | grep kernel-devel # 检查安装的kernel-devel版本

我的检查结果是源码有多个版本共存,但后面安装过程正常,应该没什么问题。

屏蔽系统的nouveau

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

# <方法一> 修改/lib下的dist-blacklist.conf文件:
$ sudo vi /lib/modprobe.d/dist-blacklist.conf

#把"nvidiafb"注释掉:

# blacklist nvidiafb

#添加语句:

blacklist nouveau
options nouveau modeset=0

# 重新建立initramfs image文件
$ sudo mv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.bak

$ sudo dracut /boot/initramfs-$(uname -r).img $(uname -r)

# 重启
$ reboot

安装驱动

先修改.run文件的权限为可执行

$ chmod +x NVIDIA-Linux-x86_64-xxxxxx.run

然后执行!

$ sudo ./NVIDIA-Linux-x86_64-xxxxxx.run

在这过程中遇到的选择:
1: “XXXXXX” 大体意思是现在没有完全退出X Windows

A:退出驱动安装,确认系统完全退出图形界面。比如:

$ init 5                 # 进入图形界面

$ systemctl set-default multi-user.target        # 准备进入文本模式

$ reboot              # 重启后自动进入文本模式,之后再重新run

2:Install NVIDIA‘s 32-bit compatibility libraries?

A:选择NO继续。

3:Would you like to run the nvidia-xconfigutility to automatically update your x configuration so that the NVIDIA x driver will be used when you restart x? Any pre-existing x confile will be backed up.

A:选择YES继续。

安装完成!

CentOS7 更新 make

安装过程

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 官方地址
https://ftp.gnu.org/gnu/make/

# 解压
tar -zxvf make-4.2.1.tar.gz

# 安装
cd make-4.2.1
# 建立编译目录
mkdir build
cd build
# 执行
../configure --prefix=/usr

# 执行完,这里需要编译,会生成build.sh文件,然后执行这个文件
sh build.sh
# 然后安装
make install

# 然后就安装完成了,查看版本
make -v
GNU Make 4.2.1

安装bison

1
yum install -y bison

CentOS7 更新 gcc

前置条件:建议更新make

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46

yum -y install wget bzip2 gcc gcc-c++ glibc-headers

# 下载gcc包到自己的目录,-P后面的下载目录自己指定
# 下载这个文件可以直接去官网下,反而更快一些,
# 下载地址:https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc(自己选择版本)
wget -c -P /opt/software/ https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc/gcc-8.2.0/gcc-8.2.0.tar.gz

# 解压
cd /opt/software/
tar -zxvf gcc-8.2.0.tar.gz
# 解压要好久,可以喝杯茶放松一下

cd gcc-8.2.0
./contrib/download_prerequisites #下载gmp mpfr mpc等供编译需求的依赖项

# 不能在source目录下configure,必须在上一层的目录下
mkdir build

cd bulid

../configure --prefix=/usr/local/gcc-8.2.0 --enable-bootstrap --enable-checking=release --enable-languages=c,c++ --disable-multilib

# 启用cpu 12个线程进行编译
make -j12
# 结果:

# 接下来安装它
make install

# 写配置文件
echo -e '\nexport PATH=/usr/local/gcc-8.2.0/bin:$PATH\n' >> /etc/profile.d/gcc.sh && source /etc/profile.d/gcc.sh

# 导出头文件
ln -sv /usr/local/gcc-9.2.0/include/ /usr/include/gcc

#配置生效
ldconfig -v
# 结果:

# 导出验证
ldconfig -p |grep gcc
# 结果:

# 查看版本
gcc -v

CentOS7 更新 glibc

前置条件更新gcc

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
官网下载Glibc2.28,官网地址:http://ftp.gnu.org/gnu/glibc/(选择你想要的版本)

# 完整步骤:
tar -xf glibc-2.28.tar.gz
cd glibc-2.28
mkdir build
cd build

../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin

make -j12
make install # 这一步的2个问题可以忽略

ls -l /lib64/libc.so.6

# 最后来看看我们的结果吧
strings /lib64/libc.so.6 | grep GLIBC

# 编译glibc会出现中文不支持的情况
make localedata/install-locales # 用来处理安装glibc后中文变乱码的现象,几乎所有教程没有,这就"安装失败"了

# 如果出现找不到就自己手动link一下
cd /usr/local/lib64
cp libstdc++.so.6.0.22 /usr/lib64/
cd /usr/lib64/
mv libstdc++.so.6 libstdc++.so.6.OLD
ln -sf libstdc++.so.6.0.22 libstdc++.so.6