目录
一、系统选用官方系统Debian(vcgencmd)
1.Windows下
2.MacOS下
3.恢复SD卡
二、SSH连接及VNC连接设置
三、换源
四、Vim及Oh-my-zsh
五、ftp服务及ufw防火墙
六、Nginx+PHP7.3
六、MySQL数据库
七、Java+Tomcat
八、Docker
九、VSCODE
十、Redis
Ngrok穿透(依托官网)
官方下载地址
32bit
https://www.raspberrypi.org/downloads/raspbian/
64bit(只支持 Pi 3 和Pi 4,并且这是测试版(beta)很多功能用不了,并且很多bug请仔细阅读链接内容)
https://www.raspberrypi.org/forums/viewtopic.php?f=117&t=275370
官方烧写器
https://github.com/raspberrypi/rpi-imager/releases
Win32DiskImager
###确认img镜像
[@mac: pi]$ls -lh
total 3788800
-rw-r--r-- 1 zhangshenjia staff 1.8G 2 9 03:44 2013-02-09-wheezy-raspbian.img
###查看系统已经挂载(接入)的卷
[@mac: pi]$df -h
Filesystem Size Used Avail Capacity Mounted on
/dev/disk0s2 112Gi 96Gi 15Gi 87% /
devfs 183Ki 183Ki 0Bi 100% /dev
map -hosts 0Bi 0Bi 0Bi 100% /net
map auto_home 0Bi 0Bi 0Bi 100% /home
/dev/disk1s1 15Gi 2.3Mi 15Gi 1% /Volumes/未命名
###卸载sd卡或需要烧写的分区
[@mac: pi]$diskutil unmount /dev/disk1s1
Volume 未命名 on disk1s1 unmounted
###确认设备
[@mac: pi]$diskutil list
/dev/disk0
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *121.3 GB disk0
1: EFI 209.7 MB disk0s1
2: Apple_HFS Macintosh HD 120.5 GB disk0s2
3: Apple_Boot Recovery HD 650.0 MB disk0s3
/dev/disk1
#: TYPE NAME SIZE IDENTIFIER
0: FDisk_partition_scheme *15.8 GB disk1
1: Windows_NTFS 未命名 15.8 GB disk1s1
###dd命令 以4m 将镜像写入disk1
[@mac: pi]$dd bs=4m if=2013-02-09-wheezy-raspbian.img of=/dev/rdisk1
###(光标在此处停留几分钟到几十分钟后出现如下提示则已经烧写完成)
462+1 records in
462+1 records out
1939865600 bytes transferred in 163.133220 secs (11891297 bytes/sec)
###用diskutil unmountDisk卸载设备(可用其他方式推出):
[@mac: pi]$diskutil unmountDisk /dev/disk1
Unmount of all volumes on disk1 was successful
查系统版本
https://elinux.org/RPI_vcgencmd_usage
###多少位
pi@raspberrypi:~ $ getconf LONG_BIT
32
pi@raspberrypi:~ $ uname
Linux
###系统信息
pi@raspberrypi:~ $ uname -a
Linux raspberrypi 4.19.75-v7l+ #1270 SMP Tue Sep 24 18:51:41 BST 2019 armv7l GNU/Linux
###主机名称
pi@raspberrypi:~ $cat /etc/hostname
raspberrypi
###欢迎语
pi@raspberrypi:~ $cat /etc/issue
Raspbian GNU/Linux 10 \n \l
###CPU
pi@raspberrypi:~ $ grep "model name" /proc/cpuinfo
model name : ARMv7 Processor rev 3 (v7l)
model name : ARMv7 Processor rev 3 (v7l)
model name : ARMv7 Processor rev 3 (v7l)
model name : ARMv7 Processor rev 3 (v7l)
pi@raspberrypi:~ $cat /proc/cpuinfo
processor : 0
model name : ARMv7 Processor rev 3 (v7l)
BogoMIPS : 270.00
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xd08
CPU revision : 3
processor : 1
model name : ARMv7 Processor rev 3 (v7l)
BogoMIPS : 270.00
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xd08
CPU revision : 3
processor : 2
model name : ARMv7 Processor rev 3 (v7l)
BogoMIPS : 270.00
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xd08
CPU revision : 3
processor : 3
model name : ARMv7 Processor rev 3 (v7l)
BogoMIPS : 270.00
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xd08
CPU revision : 3
Hardware : BCM2835
Revision : c03111
Serial : 1000000083836922
Model : Raspberry Pi 4 Model B Rev 1.1
###内存
pi@raspberrypi:~ $cat /proc/meminfo
MemTotal: 3947004 kB
MemFree: 1745840 kB
MemAvailable: 3190216 kB
Buffers: 96304 kB
Cached: 1442376 kB
SwapCached: 0 kB
Active: 1212728 kB
Inactive: 796260 kB
Active(anon): 469752 kB
Inactive(anon): 22972 kB
Active(file): 742976 kB
Inactive(file): 773288 kB
Unevictable: 16 kB
Mlocked: 16 kB
HighTotal: 3211264 kB
HighFree: 1284972 kB
LowTotal: 735740 kB
LowFree: 460868 kB
SwapTotal: 102396 kB
SwapFree: 102396 kB
Dirty: 1824 kB
Writeback: 0 kB
AnonPages: 470484 kB
Mapped: 145312 kB
Shmem: 23264 kB
Slab: 122720 kB
SReclaimable: 79288 kB
SUnreclaim: 43432 kB
KernelStack: 1920 kB
PageTables: 5712 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 2075896 kB
Committed_AS: 1360504 kB
VmallocTotal: 245760 kB
VmallocUsed: 0 kB
VmallocChunk: 0 kB
Percpu: 752 kB
CmaTotal: 262144 kB
CmaFree: 218684 kB
###温度
pi@raspberrypi:~ $cat /sys/class/thermal/thermal_zone0/temp
77419
###硬盘
df -h
###内存
free -m
###vcgencmd
vcgencmd measure_clock
查看开机启动服务
###查看已启动的服务
systemctl list-units --type=service
###查看是否设置开机启动
systemctl list-unit-files | grep enable
MacOS恢复SD卡
df –h
diskutil unmount/dev/disk2s1
diskutil list
sudo dd bs=512 count=1if=/dev/zero of=/dev/rdisk2
###执行效果可以参考烧写部分
###拔插磁盘后弹出初始化 最后进行磁盘分区
Windows恢复SD卡
格式化之后合并卷
###在sd卡root根目录下新建一个ssh(无后缀)
###查看局域网IP地址
arp -a
###连接ssh
ssh pi@raspberrypi
ssh [email protected]
ssh [email protected]
ssh [email protected]
ssh 192.168.xx.xx -l pi
sudo raspi-config
###开启vnc模式
5 Interfacing Options Configure connections to peripher
P3 VNC
###设置分辨率(不设置连上去可能会黑屏)
7 Advanced Options Configure advanced settings
A5 Resolution Set a specific screen resolution
DMT Mode 4 640*480 60Hz 4:3
https://www.raspbian.org/RaspbianMirrors
备份
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo cp /etc/apt/sources.list.d/raspi.list /etc/apt/sources.list.d/raspi.list.bak
sudo nano /etc/apt/sources.list
#deb http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi
#deb http://mirrors.ustc.edu.cn/raspbian/raspbian/ buster main contrib non-free rpi
deb http://mirrors.aliyun.com/raspbian/raspbian/ buster main contrib non-free rpi
#deb http://archive.raspberrypi.org/debian/ buster main
deb http://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ buster main
sudo nano /etc/apt/sources.list.d/raspi.list
###安装
sudo apt install vim
###配置
sudo vim /etc/vim/vimrc
set nu #显示行号
syntax on #语法高亮
set tabstop=4 #tab 退四格
###查看系统shell
echo $SHELL
###查看可用shell
cat /etc/shells
###安装zsh
sudo apt install git zsh
###切换zsh
chsh -s /bin/zsh
###获取oh-my-zsh
wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh
###安装方法二
git clone https://github.com/ohmyzsh/ohmyzsh.git ~/.oh-my-zsh
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
####zsh-autosuggestions根据使用习惯自动显示建议,按→补充
$ git clone https://github.com/zsh-users/zsh-autosuggestions.git
$ZSH_CUSTOM/plugins/zsh-autosuggestions
####zsh-syntax-highlighting//终端命令提示,正确为绿色,错误为红色
$ git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM}/plugins/zsh-syntax-highlighting
###sudo按两下Esc补充sudo
###colored-man-pages //man手册页面,高亮版,更容易阅读
###last-working-dir //返回上次打开终端的目录
###command-time //显示某命令执行完成所用的时间
git clone https://github.com/popstas/zsh-command-time.git ~/.oh-my-zsh/custom/plugins/command-time
###alias-tips //提示可用的alias
git clone https://github.com/djui/alias-tips.git ~/.oh-my-zsh/custom/plugins/alias-tips
###zsh-you-should-use //与上面类似,提示可用的alias,可配置
git clone https://github.com/MichaelAquilina/zsh-you-should-use.git ~/.oh-my-zsh/custom/plugins/you-should-use
###dirhistory //使用alt+左右方向键来切换历史上级或下级目录
###Z
###autojump //目录跳转,同上,Z不需要安装,autojump需要安装
###extract //x 一键解压
###修改主题及添加插件
vim ~/.zshrc
##主题
ZSH_THEME="ys"
##插件
plugins=(
git
sudo
zsh-autosuggestions
zsh-syntax-highlighting
command-time
alias-tips
)
##加载profile中的环境变量
source /etc/profile
source $ZSH/oh-my-zsh.sh
# Alias Settings
alias cls='clear'
alias ll='ls -l'
alias la='ls -Al'
alias cp='cp -i'
alias mv='mv -i'
alias rm='rm -i'
alias vi='vim'
alias ps='ps -A'
alias ifconfig='sudo ifconfig'
alias zshconfig="vim ~/.zshrc"
##别人的配置
plugins=(git sudo colored-man-pages last-working-dir command-not-found
cp debian common-aliases dirhistory systemd extract autojump
zsh-syntax-highlighting zsh-autosuggestions command-time alias-tips you-should-use
auto-ls vi-mode z )
###更新
$ upgrade_oh_my_zsh
###卸载
$ uninstall_oh_my_zsh
sudo apt install vsftpd
sudo service vsftpd start
sudo vim /etc/vsftpd.conf
anonymous_enable=NO
###表示:不允许匿名访问
local_enable=YES
###设定本地用户可以访问。
write_enable=YES
###设定可以进行写操作
local_umask=022
###设定上传后文件的权限掩码。
sudo service vsftpd restart
sudo apt-get install ufw
sudo ufw allow http
sudo ufw allow ssh
sudo ufw deny smtp ###禁止外部访问smtp服务
sudo ufw allow from 192.168.1.1 ###允许此IP访问所有的本机端口
sudo ufw delete allow smtp ###删除上面建立的某条规则
sudo ufw deny proto tcp from 10.0.0.0/8 to 192.168.0.1 port 22
###要拒绝所有的流量从TCP的10.0.0.0/8 到端口22的地址192.168.0.1
sudo ufw allow from 10.0.0.0/8
sudo ufw allow from 172.16.0.0/12
sudo ufw allow from 192.168.0.0/16
sudo apt-get install ufw
sudo ufw enable
sudo ufw disable
sudo ufw status
#安装
$ sudo apt-get install nginx
#停止
$ sudo systemctl stop nginx
#重启
$ sudo systemctl restart nginx
#平滑加载配置命令(不会断开用户访问):
$ sudo systemctl reload nginx
#禁止nginx开机启动:
$ sudo systemctl disable nginx
#重新配置nginx开机自动启动:
$ sudo systemctl enable nginx
#查询nginx状态:
$ sudo systemctl status nginx
###安装php
$ sudo apt-get install php7.3-fpm
###修改nginx对php适配并重启服务
$ sudo vim /etc/nginx/sites-enabled/default
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.php index.html index.htm;
server_name _;
location / {
try_files $uri /index.php$is_args$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
}
location ~ /\.ht {
deny all;
}
$ sudo systemctl reload nginx
$ sudo vim /var/www/html/index.php
测试php
$ sudo vim /var/www/html/index.php
树莓派系统监测
sudo apt install mariadb-server
sudo mysql_secure_installation
###输入密码登陆 首次登陆时无密码直接回车
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
###是否设置密码选择y
Set root password? [Y/n] y
yNew password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
###是否禁止远程登陆
Disallow root login remotely? [Y/n] n
... skipping.
By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
####进入数据库
sudo mysql -u root -p
USE mysql;GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION ;FLUSH PRIVILEGES;
Reading table information for completion of table and column names
sudo service mysql stop
sudo service mysql start
service mysql status
###修改localhost登陆权限
MariaDB [(none)]> grant all privileges on *.* to root@'localhost' identified by 'password';flush privileges;
###修改其它ip登陆权限
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
FLUSH PRIVILEGES
###修改登陆权限
/etc/mysql/mariadb.conf.d
vim 50-server.cnf
user = mysql
pid-file = /run/mysqld/mysqld.pid
socket = /run/mysqld/mysqld.sock
##开放接口
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
#skip-external-locking
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
##允许所有ip地址登陆
bind-address = 0.0.0.0
PhpMyAdmin
https://www.phpmyadmin.net/
sudo apt install php-mysql
wget https://files.phpmyadmin.net/phpMyAdmin/4.9.2/phpMyAdmin-4.9.2-all-languages.zip
unzip phpMyAdmin-4.9.2-all-languages.zip
###基于nginx
sudo mv phpMyAdmin-4.9.2-all-languages /var/www/html/
http://192.168.xxx.xxx/phpMyAdmin-4.9.2/index.php
####登陆出现如下问题
mysqli_real_connect(): (HY000/1698): Access denied for user 'root'@'localhost'
下载jdk-8u231-linux-arm32-vfp-hflt.tar.gz
https://www.oracle.com/technetwork/java/javase/downloads/index.html
解压
pi@raspberrypi:~/Downloads $ sudo tar -zxvf jdk-8u231-linux-arm32-vfp-hflt.tar.gz
移动 此时文件夹名字也变了
mv ~/Downloads/jdk1.8.0_231/ /usr/lib/java/
sudo vim /etc/profile
##↓不修改
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).
if [ "`id -u`" -eq 0 ]; then
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
else PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games"
fi
##↑不修改
##↓添加路径即环境变量
##注意跟自己实际路径保持一致
export JAVA_HOME=/usr/lib/java
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:JAVA_MOE/lib/dt.jar:JAVA_HOME/lib/tool.jar
##↑添加
##↓不修改
export PATH
if [ "${PS1-}" ]; then
if [ "${BASH-}" ] && [ "$BASH" != "/bin/sh" ]; then
# The file bash.bashrc already sets the default PS1.
# PS1='\h:\w\$ '
if [ -f /etc/bash.bashrc ]; then
. /etc/bash.bashrc
fi
else
if [ "`id -u`" -eq 0 ]; then
PS1='# '
else
PS1='$ '
fi
fi
fi
if [ -d /etc/profile.d ]; then
for i in /etc/profile.d/*.sh; do
if [ -r $i ]; then
. $i
fi
done
unset i
fi
##↑不修改
重载配置
source /etc/profile
下载 tomcat
apache-tomcat-9.0.29.tar.gz
解压
tar -zxvf apache-tomcat-9.0.29.tar.gz
移到etc目录下
sudo mv /home/pi/Downloads/apache-tomcat-9.0.29/ /etc/
在tomcat的bin目录下启动tomcat
pi@raspberrypi:/etc/apache-tomcat-9.0.29/bin$ sh startup.sh
Using CATALINA_BASE: /etc/apache-tomcat-9.0.29
Using CATALINA_HOME: /etc/apache-tomcat-9.0.29
Using CATALINA_TMPDIR: /etc/apache-tomcat-9.0.29/temp
Using JRE_HOME: /usr/lib/java
Using CLASSPATH: /etc/apache-tomcat-9.0.29/bin/bootstrap.jar:/etc/apache-tomcat-9.0.29/bin/tomcat-juli.jar
Tomcat started.
配置环境变量
export TOM_HOME=/etc/apache-tomcat-9.0.29
export JAVA_HOME=/usr/lib/java
export PATH=$JAVA_HOME/bin:$TOM_HOME/bin:$PATH
export CLASSPATH=.:JAVA_MOE/lib/dt.jar:JAVA_HOME/lib/tool.jar:TOM_HOME/bin/tomcat-juli.jar
查看进程
ps -ef | grep tomcat
##脚本自动安装
curl -sSL https://get.docker.com | sh
##验证
sudo docker run hello-world
##安装docker-compose
sudo apt-get install libffi-dev libssl-dev
sudo apt-get install -y python python-pip
sudo apt-get remove python-configparser
pip install docker-compose
###其它命令
#查看 Docker 版本
docker -v
sudo docker pull 仓库/镜像:版本(留空的话默认为 latest)
sudo docker run 加参数,用来创建容器
#查看运行容器
sudo docker ps
#查看所有下载的镜像
sudo docker images
#进入容器终端
sudo docker exec -i -t ha /bin/bash
#实时查看10行的 ha 日志
sudo docker logs -f -t --tail 10 ha
#重启 systemctl 守护进程
sudo systemctl daemon-reload
#设置 Docker 开机启动
sudo systemctl enable docker
#开启 Docker 服务
sudo systemctl start docker
##换源
sudo vim /etc/docker/daemon.json
{
"registry-mirrors": [
"https://dockerhub.azk8s.cn",
"https://hub-mirror.c.163.com"
]
}
#下载 Docker 图形化界面 portainer
sudo docker pull portainer/portainer
#创建 portainer 容器
sudo docker volume create portainer_data
#运行 portainer
sudo docker run -d -p 9000:9000 --name portainer --restart always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer
docker run -p 8080:80 -d -v /data/owncloud/:/var/www/html owncloud
https://packagecloud.io/headmelted/codebuilds?page=1
$ sudo wget -qO - https://packagecloud.io/headmelted/codebuilds/gpgkey | sudo apt-key add -;
wget --content-disposition https://packagecloud.io/headmelted/codebuilds/packages/debian/stretch/code-oss_1.42.0-1575969827_armhf.deb/download.deb
sudo apt install ./code-oss_1.42.0-1575969827_armhf.deb
###升级失败
sudo apt update && sudo apt upgrade
###锁定code-oss版本
sudo echo "code-oss hold" | sudo dpkg --set-selections
###解锁
sudo echo "code-oss install" | sudo dpkg --set-selections
###查看锁定列表
sudo dpkg --get-selections |grep hold
###安装
$ sudo apt install redis-server
###修改配置
$ sudo vim /etc/redis/redis.conf
###允许远程连接
#bind 127.0.0.1 ::1
###设置连接密码
requirepass 123
###打开
$ redis-server /etc/redis/redis.conf
$ redis-cli
127.0.0.1:6379> auth "qwas1234"
OK
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> keys *
1) "localhost:6379:KeyCount:1579175211"
2) "localhost:6379:KeyCount:1579175231"
3) "localhost:6379:KeyCount:1579177134"
4) "localhost:6379:CommandCount:1579175238"
127.0.0.1:6379> info
# Server
redis_version:5.0.3
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:afa0decbb6de285f
redis_mode:standalone
os:Linux 4.19.75-v7l+ armv7l
arch_bits:32
multiplexing_api:epoll
atomicvar_api:atomic-builtin
gcc_version:8.3.0
process_id:543
run_id:671d27b2a759f700dda4dff96be1edc9bd20e029
tcp_port:6379
uptime_in_seconds:72856
uptime_in_days:0
hz:10
configured_hz:10
lru_clock:2095590
executable:/usr/bin/redis-server
config_file:/etc/redis/redis.conf
……
127.0.0.1:6379> set mykey hello
OK
127.0.0.1:6379> exists my
(integer) 0
127.0.0.1:6379> exists mykey
(integer) 1
127.0.0.1:6379> del mykey
(integer) 1
127.0.0.1:6379> exists mykey
(integer) 0
127.0.0.1:6379> set mykey x
OK
127.0.0.1:6379> type mykey
string
127.0.0.1:6379> keys my*
1) "mykey"
127.0.0.1:6379> type mykey
string
127.0.0.1:6379> randomkey
"mykey"
127.0.0.1:6379> mykey
(error) ERR unknown command 'mykey'
127.0.0.1:6379> dbsize
(integer) 1
127.0.0.1:6379> get mykey
"x"
127.0.0.1:6379>quit
###性能测试工具
$ redis-benchmark -h localhost -p 6379 -c 50 -n 1000
###RedisLive
#tornado
$ pip install tornado
#redis.py
$ pip install -v redis==2.10.6
#python-dateutil
$ pip install python-dateutil
###You'll also need argparse if you're running Python < 2.7:
#argparse
$ pip install argparse
$ git clone https://github.com/nkrode/RedisLive.git
redis-live.conf
#按照以下方式修改配置文件
{
"RedisServers":
[
#在此处添加需要监控的redis实例
{
"server": "127.0.0.1",
#redis监听地址,此处为本机
"port" : 6379,
#redis端口号,可以通过lsof -i | grep redis-ser查看 redis-server端口号
"password" : "some-password"
#redis认证密码,如果没有可以删除该行,注意json格式
}
],
"DataStoreType" : "redis", #监控数据存储方案的配置,可选择redis或sqllite
#用来存储监控数据的 Redis 实例
"RedisStatsServer":
{
"server" : "127.0.0.1",
"port" : 6379,
"password" : "some-password"
},
#监控数据持久化数据存储配置
"SqliteStatsStore" :
{
"path": "db/redislive.sqlite" #redis数据文件
}
}
#http://localhost:8888/index.html
###Redis_exporter
编译redis(测试用非使用步骤)
###http://download.redis.io/releases/
###https://github.com/antirez/redis.git
###官网下载源码
wget http://download.redis.io/releases/redis-5.0.8.tar.gz
tar -zxvf redis-5.0.8.tar.gz
cd redis-5.0.8
make