一、Hardware Requirements

Minimal:

  • CPU Cores: 2
  • andom-Access Memory: 4GB
  • Hard Disk: 20GB free

Recommended:

  • CPU Cores: 4
  • Random-Access Memory: 8GB
  • Hard Disk: 60GB free

二、 Prerequisites

install curl

yum install curl -y

sudo apt install curl -y

install docker

yum install -y yum-utils
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install docker-ce docker-ce-cli containerd.io

sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt install docker.io

install docker-compose

yum install python3-pip -y
python3 -m pip install --user docker-compose

sudo apt install python3 python3-pip -y
python3 -m pip install --user docker-compose

三、 SET UP

Docker Compose File


services:
vulnerability-tests:
image: greenbone/vulnerability-tests
environment:
STORAGE_PATH: /var/lib/openvas/22.04/vt-data/nasl
volumes:
- vt_data_vol:/mnt

notus-data:
image: greenbone/notus-data
volumes:
- notus_data_vol:/mnt

scap-data:
image: greenbone/scap-data
volumes:
- scap_data_vol:/mnt

cert-bund-data:
image: greenbone/cert-bund-data
volumes:
- cert_data_vol:/mnt

dfn-cert-data:
image: greenbone/dfn-cert-data
volumes:
- cert_data_vol:/mnt
depends_on:
- cert-bund-data

data-objects:
image: greenbone/data-objects
volumes:
- data_objects_vol:/mnt

report-formats:
image: greenbone/report-formats
volumes:
- data_objects_vol:/mnt
depends_on:
- data-objects

gpg-data:
image: greenbone/gpg-data
volumes:
- gpg_data_vol:/mnt

redis-server:
image: greenbone/redis-server
restart: on-failure
volumes:
- redis_socket_vol:/run/redis/

pg-gvm:
image: greenbone/pg-gvm:stable
restart: on-failure
volumes:
- psql_data_vol:/var/lib/postgresql
- psql_socket_vol:/var/run/postgresql

gvmd:
image: greenbone/gvmd:stable
restart: on-failure
volumes:
- gvmd_data_vol:/var/lib/gvm
- scap_data_vol:/var/lib/gvm/scap-data/
- cert_data_vol:/var/lib/gvm/cert-data
- data_objects_vol:/var/lib/gvm/data-objects/gvmd
- vt_data_vol:/var/lib/openvas/plugins
- psql_data_vol:/var/lib/postgresql
- gvmd_socket_vol:/run/gvmd
- ospd_openvas_socket_vol:/run/ospd
- psql_socket_vol:/var/run/postgresql
depends_on:
pg-gvm:
condition: service_started
scap-data:
condition: service_completed_successfully
cert-bund-data:
condition: service_completed_successfully
dfn-cert-data:
condition: service_completed_successfully
data-objects:
condition: service_completed_successfully
report-formats:
condition: service_completed_successfully

gsa:
image: greenbone/gsa:stable
restart: on-failure
ports:
- 9392:80
volumes:
- gvmd_socket_vol:/run/gvmd
depends_on:
- gvmd

ospd-openvas:
image: greenbone/ospd-openvas:stable
restart: on-failure
init: true
hostname: ospd-openvas.local
cap_add:
- NET_ADMIN # for capturing packages in promiscuous mode
- NET_RAW # for raw sockets e.g. used for the boreas alive detection
security_opt:
- seccomp=unconfined
- apparmor=unconfined
command:
[
"ospd-openvas",
"-f",
"--config",
"/etc/gvm/ospd-openvas.conf",
"--mqtt-broker-address",
"mqtt-broker",
"--notus-feed-dir",
"/var/lib/notus/advisories",
"-m",
"666"
]
volumes:
- gpg_data_vol:/etc/openvas/gnupg
- vt_data_vol:/var/lib/openvas/plugins
- notus_data_vol:/var/lib/notus
- ospd_openvas_socket_vol:/run/ospd
- redis_socket_vol:/run/redis/
depends_on:
redis-server:
condition: service_started
gpg-data:
condition: service_completed_successfully
vulnerability-tests:
condition: service_completed_successfully

mqtt-broker:
restart: on-failure
image: greenbone/mqtt-broker
ports:
- 1883:1883
networks:
default:
aliases:
- mqtt-broker
- broker

notus-scanner:
restart: on-failure
image: greenbone/notus-scanner:stable
volumes:
- notus_data_vol:/var/lib/notus
- gpg_data_vol:/etc/openvas/gnupg
environment:
NOTUS_SCANNER_MQTT_BROKER_ADDRESS: mqtt-broker
NOTUS_SCANNER_PRODUCTS_DIRECTORY: /var/lib/notus/products
depends_on:
- mqtt-broker
- gpg-data
- vulnerability-tests

gvm-tools:
image: greenbone/gvm-tools
volumes:
- gvmd_socket_vol:/run/gvmd
- ospd_openvas_socket_vol:/run/ospd
depends_on:
- gvmd
- ospd-openvas

volumes:
gpg_data_vol:
scap_data_vol:
cert_data_vol:
data_objects_vol:
gvmd_data_vol:
psql_data_vol:
vt_data_vol:
notus_data_vol:
psql_socket_vol:
gvmd_socket_vol:
ospd_openvas_socket_vol:
redis_socket_vol:

Downloading the Greenbone Community Containers

docker-compose -f $DOWNLOAD_DIR/docker-compose.yml -p greenbone-community-edition pull

Starting the Greenbone Community Containers

docker-compose -f $DOWNLOAD_DIR/docker-compose.yml -p greenbone-community-edition up -d

Show log messages of all services from the running containers

docker-compose -f $DOWNLOAD_DIR/docker-compose.yml -p greenbone-community-edition logs -f

一、 安装

系统 –> 软件包 –> 更新列表

搜索 frpc 根据实际安装

二、 luci界面报错

/usr/lib/lua/luci/model/cbi/frp/basic.lua:2: module 'luci.model.ipkg' not found:
no field package.preload['luci.model.ipkg']
no file './luci/model/ipkg.lua'
no file '/usr/share/lua/luci/model/ipkg.lua'
no file '/usr/share/lua/luci/model/ipkg/init.lua'
no file '/usr/lib/lua/luci/model/ipkg.lua'
no file '/usr/lib/lua/luci/model/ipkg/init.lua'
no file './luci/model/ipkg.so'
no file '/usr/lib/lua/luci/model/ipkg.so'
no file '/usr/lib/lua/loadall.so'
no file './luci.so'
no file '/usr/lib/lua/luci.so'
no file '/usr/lib/lua/loadall.so'
stack traceback:
[C]: in function 'require'
/usr/lib/lua/luci/model/cbi/frp/basic.lua:2: in function 'func'
/usr/lib/lua/luci/cbi.lua:66: in function 'load'
/usr/lib/lua/luci/dispatcher.lua:1385: in function '_cbi'
/usr/lib/lua/luci/dispatcher.lua:1056: in function 'dispatch'
/usr/lib/lua/luci/dispatcher.lua:483: in function </usr/lib/lua/luci/dispatcher.lua:482>

三、 问题解决

编辑文件 /usr/lib/lua/luci/model/cbi/frp/basic.lua

注释 require("luci.model.ipkg")

环境

os: centos7.9
hw: X86-64

介绍

tigervnc 和 tightvnc 区别

特性 TigerVNC TightVNC
历史和开发 由 Red Hat 公司开发,基于 TightVNC 代码 由 Constantin Kaplinsky 开发
支持的平台 Windows、Linux、Mac OS X、Android、iOS 等 Windows、Linux
性能 经过优化,提供更流畅的体验 性能也很好,但在某些情况下可能不如 TigerVNC
安全性 支持更多安全选项,例如 TLS 加密和 SSH 隧道 支持一些安全选项,但不如 TigerVNC 丰富
其他功能 支持 Java 客户端和 Web 浏览器访问 支持 ActiveX 控件和 RDP 协议

Kali Linux 上默认使用 TightVNC 1.3.10版本.
License原因, 只能下载旧版本的tightvnc, 所以我们选择 tigerVNC.
图

一、 rpm部署tigerVNC

1.1 安装

yum install tigervnc-server -y

1.2 配置 service

复制配置文件:
cp /usr/lib/systemd/system/[email protected] /etc/systemd/system/[email protected]

修改: vim /etc/systemd/system/[email protected]
41行: <USER> –> 实际用户
生效: systemctl daemon-reload

1.3 配置 vnc 密码

vncpasswd

1.4 启动 vnc

要启动并启用服务,请在 命令中直接指定显示号。以上 为单个用户配置 VNC 显示 中配置的文件作为模板运行,其中 %i 被 systemd 替换为显示号。使用有效的显示号,执行以下命令:

systemctl start vncserver@:display_number.service

这里面我们实际运行: systemctl start vncserver@:3.service
可以看到相关服务和端口都起来了
图

1.5 多用户配置

配置两个 VNC 服务器,[email protected][email protected],可以启用不同的显示号。例如,以下命令将 USER_1 的 VNC 服务器在桌面 3 中启动, USER_2 的 VNC 服务器在桌面 5 中启动:

su 切换到用户, 执行 vncpassword 后使用

~]# systemctl start vncserver-USER_1@:3.service
~]# systemctl start vncserver-USER_2@:5.service

1.6 关闭 vnc 服务

systemctl disable vncserver@:1.service

1.7 相关问题 “A VNC server is already running as :1”

rm -rf /tmp/.X0-lock
rm -rf /tmp/.X11-unix/X0

二、 源码部署tigerVNC (适用于大部分 GNU/Linux)

2.0 依赖

yum install cmake zlib pixman fltk libjpeg-turbo

引用文档: 注意以下包的版本

================================
Build Requirements (All Systems)
================================

-- CMake (http://www.cmake.org) v3.10 or later
-- zlib
-- pixman
-- FLTK 1.3.3 or later
-- If building TLS support:
* GnuTLS 3.x
* See "Building TLS Support" below.
-- If building RSA-AES support:
* Nettle 3.0 or later
-- If building native language support (NLS):
* Gnu gettext 0.14.4 or later
* See "Building Native Language Support" below.
-- libjpeg-turbo
* "Normal" libjpegv6 is also supported, although it is not
recommended as it is much slower.

2.1 下载

https://github.com/TigerVNC/tigervnc/releases

2.2 解压

tar -xzvf tigervnc-1.13.1.tar.gz

2.3 tigerVNC-server 编译

一、 环境

主机名 OpenWrt
型号 Raspberry Pi 3 Model B Rev 1.2
架构 ARMv8 Processor rev 4
目标平台 bcm27xx/bcm2710

二、 开启文件上传

opkg install openssh-sftp-server

三、 下载软件包

根据自己的硬件版本下载相应的包
这里 树莓派3B 选择 aarch64_cortex-a53.zip
https://github.com/xiaorouji/openwrt-passwall/releases

四、 解压上传

五、 安装

5.1 安装依赖

opkg install *.ipk

5.2 安装passwall-luci

opkg install luci-app-passwall_4.66-4_all.ipk
opkg install luci-i18n-passwall-zh-cn_4.66-4_all.ipk

六、 重启OpenWrt

零、 环境说明

wang@ubuntu:~/Desktop$ sudo screenfetch
./+o+- root@ubuntu
yyyyy- -yyyyyy+ OS: Ubuntu 22.04 jammy
://+//////-yyyyyyo Kernel: x86_64 Linux 5.19.0-38-generic
.++ .:/++++++/-.+sss/` Uptime: 2d 2h 14m
.:++o: /++++++++/:--:/- Packages: 2193
o:+o+:++.`..```.-/oo+++++/ Shell: sudo
.:+o:+o/. `+sssoo+/ Resolution: 1920x1080
.++/+:+oo+o:` /sssooo. WM: Mutter
/+++//+:`oo+o /::--:. WM Theme: Adwaita
\+/+o+++`o++o ++////. GTK Theme: Yaru [GTK3]
.++.o+++oo+:` /dddhhh. Disk: 31G / 234G (14%)
.+.o+oo:. `oddhhhh+ CPU: Intel Core i7-6500U @ 4x 3.1GHz [54.0°C]
\+.++o+o``-````.:ohdhhhhh+ GPU: Intel Corporation Skylake GT2 [HD Graphics 520] (rev 07)
`:o+++ `ohhhhhhhhyo++os: RAM: 2305MiB / 7831MiB
.o:`.syhhhhhhh/.oo++o`
/osyyyyyyo++ooo+++/
````` +oo+++o\:
`oo++.

一、 安装依赖

sudo apt install -y \
qemu-kvm \
virt-manager \
libvirt-daemon-system \
virtinst \
libvirt-clients \
bridge-utils
软件包 用途
qemu-kvm 提供硬件仿真的开源仿真器和虚拟化包
virt-manager 通过 libvirt 守护进程,基于 QT 的图形界面的虚拟机管理工具
libvirt-daemon-system 为运行 libvirt 进程提供必要配置文件的工具
virtinst 一套为置备和修改虚拟机提供的命令行工具
libvirt-clients 一组客户端的库和API,用于从命令行管理和控制虚拟机和管理程序
bridge-utils 一套用于创建和管理桥接设备的工具

二、 启用虚拟化守护进程(libvirtd)

sudo systemctl enable libvirtd --now
sudo systemctl status libvirtd

三、 将当前用户加入kvm和libvirt用户组

sudo usermod -aG kvm wang
sudo usermod -aG libvirt wang

四、 创建虚拟机

4.1 图形管理工具 virt-manager 创建虚拟机

图形化操作较为简单, 按照提下一步即可.
png

4.2 使用 virt-install 创建虚拟机

virt-install 支持多种方式部署虚拟机, 详细参见文档.
常见有如下几种:

  1. iso/image固件
  2. 网络安装
  3. 从虚拟磁盘导入镜像
  4. PXE
  5. Kickstart

下面选择较为简单的通过iso固件部署虚拟机

sudo virt-install \ 
--name vhost1 \
--memory 2048 \
--vcpus 2 \
--disk size=8 \
--cdrom /path/to/centos.iso \
--os-variant centos7

png

五、 常见问题

5.1 权限问题

may not be accessible by the hypervisor. You will need to grant the ‘libvirt-qemu’ user
png

解决:

  1. 确保将当前用户加入kvm和libvirt用户组
  2. 将镜像文件放置其他目录下.

六、 虚拟机共享主机网络(vhost模式)

如果希望虚拟机共享物理机的网络, 需要创建网桥来实现.
查看当前的网络情况
png

创建网桥br0 接口为 wlp9s0

#sudo vim /etc/netplan/br.yaml

network:
version: 2
renderer: networkd
ethernets:
wlp9s0:
dhcp4: false
dhcp6: false
bridges:
br0:
macaddress: aa:bb:cc:11:22:33
dhcp4: false
dhcp6: false
addresses:
- 192.168.110.157/24
routes:
- to: default
via: 192.168.110.1
metric: 100
on-link: true
nameservers:
addresses:
- 223.6.6.6
interfaces:
- wlp9s0
parameters:
stp: true
forward-delay: 4

适用于 Ubuntu 20.04 及以上使用 netplan 的版本

static:

network:
renderer: networkd
ethernets:
enp1s0:
addresses:
- 192.168.1.10/24
nameservers:
addresses: [192.168.1.1]
routes:
- to: default
via: 192.168.1.1
version: 2

DHCP:

network:
ethernets:
enp1s0:
dhcp4: true
nameservers:
addresses: [223.6.6.6,223.5.5.5]
version: 2

bridge:

network:
version: 2
renderer: networkd
ethernets:
enp1s0:
dhcp4: false
dhcp6: false
bridges:
br0:
macaddress: aa:bb:cc:11:22:33
dhcp4: false
dhcp6: false
addresses:
- 192.168.110.161/24
routes:
- to: default
via: 192.168.110.1
metric: 100
on-link: true
nameservers:
addresses:
- 223.6.6.6
interfaces:
- enp1s0
parameters:
stp: true
forward-delay: 4

零、 前言

openwrt分区有很多方式, 可以直接ssh到openwrt上, 也可以将TF卡拔出来, 放到其他Linux上进行分区操作
当时想着图简单, 将TF卡拔出来放到Ubuntu上使用Gparted分区, 但是总是在最后一步报错.
使用命令行进行最后一步也是报错.
resize2fs: Invalid argument While trying to add group #1

查了相关资料后解决了分区问题.记录如下:

一、 查看当前分区详情

sda           8:0    1  14.8G  0 disk 
├─sda1 8:1 1 64M 0 part /media/wang/boot
└─sda2 8:2 1 5G 0 part /media/wang/rootfs

二、 重新对/media/wang/rootfs进行分区

分区思路: 先删除/media/wang/rootfs 再从原来的起点重新分区达到扩容的目的

2.0 进入交互模式: fdisk /dev/sda

wang@ubuntu:~$ sudo fdisk /dev/sda
Welcome to fdisk (util-linux 2.37.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

This disk is currently in use - repartitioning is probably a bad idea.
It's recommended to umount all file systems, and swapoff all swap
partitions on this disk.

2.1 打印当前分区表: p

记住 /dev/sda2 开始的数值 147456

Command (m for help): p

Disk /dev/sda: 14.84 GiB, 15931539456 bytes, 31116288 sectors
Disk model: Storage Device
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x4005cfed

Device Boot Start End Sectors Size Id Type
/dev/sda1 * 8192 139263 131072 64M c W95 FAT32 (LBA)
/dev/sda2 147456 21121023 20973568 10G 83 Linux

2.2 删除分区: d

Command (m for help): d
Partition number (1,2, default 2): 2
Partition 2 has been deleted.

2.3 创建新分区: n

Command (m for help): n
Partition type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2): 2
First sector (2048-31116287, default 2048): 147456 ## 注意这里的First sector的数值是上面我们要记住的147456
Last sector, +/-sectors or +/-size{K,M,G,T,P} (147456-31116287, default 31116287): +5g ## 要扩容的大小

Created a new partition 2 of type 'Linux' and of size 5 GiB.
Partition #2 contains a ext4 signature.

Do you want to remove the signature? [Y]es/[N]o: n ## 保留原有标识

2.4 保存分区信息: w

Command (m for help): w
The partition table has been altered.
Syncing disks.

2.5 更新分区大小

wang@ubuntu:~$ sudo resize2fs -p /dev/sda2 
resize2fs 1.46.5 (30-Dec-2021)
Filesystem at /dev/sda2 is mounted on /media/wang/rootfs; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 1
Performing an on-line resize of /dev/sda2 to 1310720 (4k) blocks.
resize2fs: Invalid argument While trying to add group #1

可以看到这里resize2fs 发生报错
报错信息: resize2fs: Invalid argument While trying to add group #1

三、 解决 resize2fs 报错

3.1 查看当前循环设备

losetup

wang@ubuntu:~$ losetup 
NAME SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE DIO LOG-SEC
/dev/loop1 0 0 1 1 /var/lib/snapd/snaps/core18_2708.snap 0 512
/dev/loop19 0 0 1 1 /var/lib/snapd/snaps/sublime-text_116.snap 0 512
/dev/loop17 0 0 1 1 /var/lib/snapd/snaps/snapd-desktop-integration_43.snap 0 512
/dev/loop8 0 0 1 1 /var/lib/snapd/snaps/gnome-3-38-2004_119.snap 0 512
/dev/loop15 0 0 1 1 /var/lib/snapd/snaps/snap-store_638.snap 0 512
/dev/loop6 0 0 1 1 /var/lib/snapd/snaps/gnome-3-38-2004_115.snap 0 512
/dev/loop13 0 0 1 1 /var/lib/snapd/snaps/snap-store_599.snap 0 512
/dev/loop4 0 0 1 1 /var/lib/snapd/snaps/core18_2714.snap 0 512
/dev/loop21 0 0 1 1 /var/lib/snapd/snaps/snapd_18596.snap 0 512
/dev/loop11 0 0 1 1 /var/lib/snapd/snaps/hunspell-dictionaries-1-7-2004_2.snap 0 512
/dev/loop2 0 0 1 1 /var/lib/snapd/snaps/firefox_2432.snap 0 512
/dev/loop0 0 0 1 1 /var/lib/snapd/snaps/bare_5.snap 0 512
/dev/loop18 0 0 1 1 /var/lib/snapd/snaps/core20_1828.snap 0 512
/dev/loop9 0 0 1 1 /var/lib/snapd/snaps/gtk-common-themes_1534.snap 0 512
/dev/loop16 0 0 1 1 /var/lib/snapd/snaps/snapd-desktop-integration_49.snap 0 512
/dev/loop7 0 0 1 1 /var/lib/snapd/snaps/core20_1852.snap 0 512
/dev/loop14 0 0 1 1 /var/lib/snapd/snaps/snapd_18357.snap 0 512
/dev/loop5 0 0 1 1 /var/lib/snapd/snaps/sublime-text_118.snap 0 512
/dev/loop12 0 0 1 1 /var/lib/snapd/snaps/firefox_2487.snap 0 512
/dev/loop3 0 0 1 1 /var/lib/snapd/snaps/core20_1822.snap (deleted) 0 512
/dev/loop10 0 0 1 1 /var/lib/snapd/snaps/gtk-common-themes_1535.snap 0 512
wang@ubuntu:~$

3.2 将/dev/sda2 映射到循环设备后再更新分区

sudo losetup /dev/loop100 /dev/sda2
sudo e2fsck -f /dev/loop100

wang@ubuntu:~$sudo losetup /dev/loop100 /dev/sda2 
wang@ubuntu:~$ sudo resize2fs /dev/loop100
resize2fs 1.46.5 (30-Dec-2021)
Please run 'e2fsck -f /dev/loop100' first.

wang@ubuntu:~$ sudo e2fsck -f /dev/loop100
e2fsck 1.46.5 (30-Dec-2021)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Padding at end of inode bitmap is not set. Fix<y>? yes

rootfs: ***** FILE SYSTEM WAS MODIFIED *****
rootfs: 1421/6656 files (0.0% non-contiguous), 5486/32768 blocks
wang@ubuntu:~$
wang@ubuntu:~$ sudo resize2fs /dev/loop100
resize2fs 1.46.5 (30-Dec-2021)
Resizing the filesystem on /dev/loop100 to 1310720 (4k) blocks.
The filesystem on /dev/loop100 is now 1310720 (4k) blocks long.

wang@ubuntu:~$

直接上例子

Server A 192.168.1.1
Server B 192.168.1.2

Server A

ssh-keygen -t rsa -b4096
ssh-copy-id [email protected]

Server B

ssh-keygen -t rsa -b4096
ssh-copy-id [email protected]

生成SSH密钥和公钥

ssh-keygen -t rsa -b 4096
-t: 指定加密算法
-b: 指定密钥长度
id_rsa: 私钥
id_rsa.pub: 公钥
authorized_keys 已保存的公钥

tree .ssh/
png

免密登录

这里, 只需要将本地生成的id_rsa.pub导入需要被免密登录的服务器的 authorized_keys中即可
复制id_rsa.pub内容到authorized_keys也可以

使用命令导入:
ssh-copy-id username@remote-server

互相免密登录

在另外一台服务器重复上面指令

推荐文章(由hexo文章推荐插件驱动)

一、 下载

get --no-check-certificate https://download.redis.io/redis-stable.tar.gz

二、 解压

tar -xzvf redis-stable.tar.gz

三、 编译安装

cd redis-stable
make PREFIX=/usr/local/redis install

报错: zmalloc.h:50:31: fatal error: jemalloc/jemalloc.h: No such file or directory
解决: make MALLOC=libc PREFIX=/usr/local/redis install

四、 修改配置

cp /root/redis-stable/redis.conf /usr/local/redis/

line309: daemonize yes # 以守护进程方式运行

五、 配置systemd

# vim /usr/lib/systemd/system/redis.service
[Unit]
Description=Redis persistent key-value database
After=network.target
After=network-online.target
Wants=network-online.target

[Service]
Type=forking
ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/redis.conf
ExecReload=/usr/local/redis/bin/redis-server -s reload
ExecStop=/usr/local/redis/bin/redis-cli shutdown
#Type=notify
#User=redis
#Group=redis
#RuntimeDirectory=redis
#RuntimeDirectoryMode=0755
[Install]
WantedBy=multi-user.target

systemctl daemon-reload
systemctl enable redis
systemctl start redis
systemctl status redis

关闭保护模式

编辑配置文件: vim /usr/local/redis/redis.conf
111行左右: protected-mode no

配置密码

编辑配置文件: vim /usr/local/redis/redis.conf
1036行左右: requirepass $YOURPASSWORD

验证配置的密码