板子的配置

### 适配pyodbc

sudo apt update && sudo apt install -y unixodbc unixodbc-dev

### 定时重启

sudo apt-get install cron
sudo crontab -e
0 0 * * * /sbin/reboot
crontab -l

###windows任务管理器设置定时重启

### 插电重启

1.开机短按del
2.选择: Advanced
3.更改After Power loss --> on

### 更新系统时间(方式一)

# 更新时间
1. sudo apt install ntpdate
2. rm -rf /etc/localtime
3. cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
4. ntpdate -u ntp.api.bz    # 更新
5. hwclock -w    # 保存

### 自动同步系统时间(方式二)

timedatectl list-timezones
sudo timedatectl set-timezone Asia/Shanghai
sudo vim /etc/systemd/timesyncd.conf
[Time]
NTP=cn.ntp.org.cn
FallbackNTP=s1c.time.edu.cn,s1b.time.edu.cn,ntp.ntsc.ac.cn 
RootDistanceMaxSec=5
PollIntervalMinSec=32
PollIntervalMaxSec=2048
# 重启服务
service systemd-timesyncd restart

### openssh的安装

### 无法解析域名的解决方案

1.临时解决->重启失效
sudo vim /etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 127.0.0.1
Esc :wq
sudo /etc/init.d/networking restart

2.永久解决
sudo apt install resolvconf
sudo vim /etc/resolvconf/resolv.conf.d/head
nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 127.0.0.1
Esc :wq
sudo resolvconf -u
cat /etc/resolv.conf

### nssm的使用

1. ubuntu换源:

# 清华源
https://mirrors.tuna.tsinghua.edu.cn/

# 更新
apt-get update

2. python3.6的指向

ln -s /usr/bin/python3 /usr/bin/python

3. 安装python3的pip

apt-get install python3-pip

4. pip3的指向

ln -s /usr/bin/pip3 /usr/bin/pip

5. pip换源

# 创建文件夹
mkdir ~/.pip

# 创建config文件
cd .pip/
touch pip.conf
vim pip.conf

# 写入豆瓣源
[global]
timeout = 6000
index-url = https://pypi.doubanio.com/simple
trusted-host = pypi.doubanio.com

6. pip更新

pip install --upgrade pip
# 或
sudo -H python -m pip install --upgrade pip

7. 如果是ac2000

# 创建与windows之间的共享文件夹
mkdir windows_share

# 如果是X86
apt install cifs-utils

# 如果是arm
apt install nfs-common

# 注: 实例为ubuntu挂载windows的共享文件

8. 如果是nfs挂载windows安装nfs-server

# 1.官网
https://www.hanewin.net/nfs-e.htm
# 2.配置参考
https://blog.csdn.net/bryanwang_3099/article/details/109900361
# 3.设置windows下的共享文件夹
自个搞

9. 挂载nfs

# 1.创建一个用于挂载的目录
mkdir ~/windows_share

# 2.挂载将NFS服务器IP上的目录,挂载到本地的/root/windows_share目录下
mount -t nfs ip_localname:/excl_file /root/windows_share

# 查询挂载情况
df -h

# 自动挂载设置
vim /etc/fstab
ip_localname:/excl_file /root/windows_share nfs defaults 0 0

10. 如果是mount cifs挂载

(1). windows安装samba服务

 

 (2). ubuntu安装cifs, 配置挂载

1. 安装
sudo apt-get install cifs-utils

2. 创建挂载目录
cd /root
mkdir windows_share

3. 测试挂载
mount -t cifs //10.210.208.63/csv_file /root/windows_share/ -o username=user,password=1,workgroup=Administrator,vers=1.0,iocharset=utf8

4. 取消挂载
umount /root/windows_share

5. 永久挂载
vim /etc/fstab
# 添加到文件的最后一行
//10.210.208.63/csv_file /root/windows_share/ cifs defaults,username=user,password=1,workgroup=Administrator,iocharset=utf8,vers=1.0 0 0

6. error处理
(1). windows控制面板->程序->smb程序-安装
(2). 重启windows

# 注: 参数列表

NFS常用参数
ro——只读访问
rw——读写访问
sync——所有数据在请求时写入共享
async——nfs在写入数据前可以响应请求
secure——nfs通过1024以下的安全TCP/IP端口发送
insecure——nfs通过1024以上的端口发送
wdelay——如果多个用户要写入nfs目录,则归组写入(默认)
no_wdelay——如果多个用户要写入nfs目录,则立即写入,当使用async时,无需此设置
hide——在nfs共享目录中不共享其子目录
no_hide——共享nfs目录的子目录
subtree_check——如果共享/usr/bin之类的子目录时,强制nfs检查父目录的权限(默认)
no_subtree_check——和上面相对,不检查父目录权限
all_squash——共享文件的UID和GID映射匿名用户anonymous,适合公用目录。
no_all_squash——保留共享文件的UID和GID(默认)
root_squash——root用户的所有请求映射成如anonymous用户一样的权限(默认)
no_root_squash——root用户具有根目录的完全管理访问权限
anonuid=xxx——指定nfs服务器/etc/passwd文件中匿名用户的UID
anongid=xxx——指定nfs服务器/etc/passwd文件中匿名用户的GID
View Code

10. 安装supervisor

(1). 安装配置

# 安装
pip install supervisor==4.2.5
# 配置转义
echo_supervisord_conf > /etc/supervisor/supervisord.conf

(2). 配置详情

# 创建需要的文件夹
# 目录所在地: /etc/supervisor
mkdir conf.d
mkdir log
mkdir pid
mkdir  serverurl
; Sample supervisor config file.
;
; For more information on the config file, please see:
; http://supervisord.org/configuration.html
;
; Notes:
;  - Shell expansion ("~" or "$HOME") is not supported.  Environment
;    variables can be expanded using this syntax: "%(ENV_HOME)s".
;  - Quotes around values are not supported, except in the case of
;    the environment= options as shown below.
;  - Comments must have a leading space: "a=b ;comment" not "a=b;comment".
;  - Command will be truncated if it looks like a config file comment, e.g.
;    "command=bash -c 'foo ; bar'" will truncate to "command=bash -c 'foo ".
;
; Warning:
;  Paths throughout this example file use /tmp because it is available on most
;  systems.  You will likely need to change these to locations more appropriate
;  for your system.  Some systems periodically delete older files in /tmp.
;  Notably, if the socket file defined in the [unix_http_server] section below
;  is deleted, supervisorctl will be unable to connect to supervisord.

[unix_http_server]
file=/etc/supervisor/serverurl/supervisor.sock   ; the path to the socket file
;chmod=0700                 ; socket file mode (default 0700)
;chown=nobody:nogroup       ; socket file uid:gid owner
;username=user              ; default is no username (open server)
;password=123               ; default is no password (open server)

; Security Warning:
;  The inet HTTP server is not enabled by default.  The inet HTTP server is
;  enabled by uncommenting the [inet_http_server] section below.  The inet
;  HTTP server is intended for use within a trusted environment only.  It
;  should only be bound to localhost or only accessible from within an
;  isolated, trusted network.  The inet HTTP server does not support any
;  form of encryption.  The inet HTTP server does not use authentication
;  by default (see the username= and password= options to add authentication).
;  Never expose the inet HTTP server to the public internet.

;[inet_http_server]         ; inet (TCP) server disabled by default
;port=127.0.0.1:9001        ; ip_address:port specifier, *:port for all iface
;username=user              ; default is no username (open server)
;password=123               ; default is no password (open server)

[supervisord]
logfile=/etc/supervisor/log/supervisord.log ; main log file; default $CWD/supervisord.log
logfile_maxbytes=50MB        ; max main logfile bytes b4 rotation; default 50MB
logfile_backups=10           ; # of main logfile backups; 0 means none, default 10
loglevel=info                ; log level; default info; others: debug,warn,trace
pidfile=/etc/supervisor/pid/supervisord.pid ; supervisord pidfile; default supervisord.pid
nodaemon=false               ; start in foreground if true; default false
silent=false                 ; no logs to stdout if true; default false
minfds=1024                  ; min. avail startup file descriptors; default 1024
minprocs=200                 ; min. avail process descriptors;default 200
;umask=022                   ; process file creation umask; default 022
;user=supervisord            ; setuid to this UNIX account at startup; recommended if root
;identifier=supervisor       ; supervisord identifier, default is 'supervisor'
;directory=/tmp              ; default is not to cd during start
;nocleanup=true              ; don't clean up tempfiles at start; default false
;childlogdir=/tmp            ; 'AUTO' child log dir, default $TEMP
;environment=KEY="value"     ; key value pairs to add to environment
;strip_ansi=false            ; strip ansi escape codes in logs; def. false

; The rpcinterface:supervisor section must remain in the config file for
; RPC (supervisorctl/web interface) to work.  Additional interfaces may be
; added by defining them in separate [rpcinterface:x] sections.

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

; The supervisorctl section configures how supervisorctl will connect to
; supervisord.  configure it match the settings in either the unix_http_server
; or inet_http_server section.

[supervisorctl]
serverurl=unix:///etc/supervisor/serverurl/supervisor.sock ; use a unix:// URL  for a unix socket
;serverurl=http://127.0.0.1:9001 ; use an http:// url to specify an inet socket
;username=chris              ; should be same as in [*_http_server] if set
;password=123                ; should be same as in [*_http_server] if set
;prompt=mysupervisor         ; cmd line prompt (default "supervisor")
;history_file=~/.sc_history  ; use readline history if available

; The sample program section below shows all possible program subsection values.
; Create one or more 'real' program: sections to be able to control them under
; supervisor.

;[program:theprogramname]
;command=/bin/cat              ; the program (relative uses PATH, can take args)
;process_name=%(program_name)s ; process_name expr (default %(program_name)s)
;numprocs=1                    ; number of processes copies to start (def 1)
;directory=/tmp                ; directory to cwd to before exec (def no cwd)
;umask=022                     ; umask for process (default None)
;priority=999                  ; the relative start priority (default 999)
;autostart=true                ; start at supervisord start (default: true)
;startsecs=1                   ; # of secs prog must stay up to be running (def. 1)
;startretries=3                ; max # of serial start failures when starting (default 3)
;autorestart=unexpected        ; when to restart if exited after running (def: unexpected)
;exitcodes=0                   ; 'expected' exit codes used with autorestart (default 0)
;stopsignal=QUIT               ; signal used to kill process (default TERM)
;stopwaitsecs=10               ; max num secs to wait b4 SIGKILL (default 10)
;stopasgroup=false             ; send stop signal to the UNIX process group (default false)
;killasgroup=false             ; SIGKILL the UNIX process group (def false)
;user=chrism                   ; setuid to this UNIX account to run the program
;redirect_stderr=true          ; redirect proc stderr to stdout (default false)
;stdout_logfile=/a/path        ; stdout log path, NONE for none; default AUTO
;stdout_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
;stdout_logfile_backups=10     ; # of stdout logfile backups (0 means none, default 10)
;stdout_capture_maxbytes=1MB   ; number of bytes in 'capturemode' (default 0)
;stdout_events_enabled=false   ; emit events on stdout writes (default false)
;stdout_syslog=false           ; send stdout to syslog with process name (default false)
;stderr_logfile=/a/path        ; stderr log path, NONE for none; default AUTO
;stderr_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
;stderr_logfile_backups=10     ; # of stderr logfile backups (0 means none, default 10)
;stderr_capture_maxbytes=1MB   ; number of bytes in 'capturemode' (default 0)
;stderr_events_enabled=false   ; emit events on stderr writes (default false)
;stderr_syslog=false           ; send stderr to syslog with process name (default false)
;environment=A="1",B="2"       ; process environment additions (def no adds)
;serverurl=AUTO                ; override serverurl computation (childutils)

; The sample eventlistener section below shows all possible eventlistener
; subsection values.  Create one or more 'real' eventlistener: sections to be
; able to handle event notifications sent by supervisord.

;[eventlistener:theeventlistenername]
;command=/bin/eventlistener    ; the program (relative uses PATH, can take args)
;process_name=%(program_name)s ; process_name expr (default %(program_name)s)
;numprocs=1                    ; number of processes copies to start (def 1)
;events=EVENT                  ; event notif. types to subscribe to (req'd)
;buffer_size=10                ; event buffer queue size (default 10)
;directory=/tmp                ; directory to cwd to before exec (def no cwd)
;umask=022                     ; umask for process (default None)
;priority=-1                   ; the relative start priority (default -1)
;autostart=true                ; start at supervisord start (default: true)
;startsecs=1                   ; # of secs prog must stay up to be running (def. 1)
;startretries=3                ; max # of serial start failures when starting (default 3)
;autorestart=unexpected        ; autorestart if exited after running (def: unexpected)
;exitcodes=0                   ; 'expected' exit codes used with autorestart (default 0)
;stopsignal=QUIT               ; signal used to kill process (default TERM)
;stopwaitsecs=10               ; max num secs to wait b4 SIGKILL (default 10)
;stopasgroup=false             ; send stop signal to the UNIX process group (default false)
;killasgroup=false             ; SIGKILL the UNIX process group (def false)
;user=chrism                   ; setuid to this UNIX account to run the program
;redirect_stderr=false         ; redirect_stderr=true is not allowed for eventlisteners
;stdout_logfile=/a/path        ; stdout log path, NONE for none; default AUTO
;stdout_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
;stdout_logfile_backups=10     ; # of stdout logfile backups (0 means none, default 10)
;stdout_events_enabled=false   ; emit events on stdout writes (default false)
;stdout_syslog=false           ; send stdout to syslog with process name (default false)
;stderr_logfile=/a/path        ; stderr log path, NONE for none; default AUTO
;stderr_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
;stderr_logfile_backups=10     ; # of stderr logfile backups (0 means none, default 10)
;stderr_events_enabled=false   ; emit events on stderr writes (default false)
;stderr_syslog=false           ; send stderr to syslog with process name (default false)
;environment=A="1",B="2"       ; process environment additions
;serverurl=AUTO                ; override serverurl computation (childutils)

; The sample group section below shows all possible group values.  Create one
; or more 'real' group: sections to create "heterogeneous" process groups.

;[group:thegroupname]
;programs=progname1,progname2  ; each refers to 'x' in [program:x] definitions
;priority=999                  ; the relative start priority (default 999)

; The [include] section can just contain the "files" setting.  This
; setting can list multiple files (separated by whitespace or
; newlines).  It can also contain wildcards.  The filenames are
; interpreted as relative to this file.  Included files *cannot*
; include files themselves.

[include]
files = /etc/supervisor/conf.d/*.ini
View Code

11. 服务端启动

supervisord -c /etc/supervisor/supervisord.conf

12. 客户端启动

supervisorctl -c /etc/supervisor/supervisord.conf

13. supervisor的配置启动项

# 1.创建配置文件
cd conf.d/
vim captain_node.ini
[program:captain_node]
# 程序启动命令
command=/usr/bin/python manage.py 
# 命令执行的目录
directory=/root/captain_node_backend
# 添加环境变量
# environment=PATH="/home/pyvip/.virtualenvs/Cel_proj/bin",B="2"
# 输出日志文件
stdout_logfile=/root/captain_node_backend/logs/supervisor_info.log
# 输入日志文件大小  默认是50MB
stdout_logfile_maxbytes=50MB
# 输入日志文件发备份  (0-不备份  默认是10)
stdout_logfile_backups=10
# capturemode 字节数  默认是10
stdout_capture_maxbytes=10MB   ; number of bytes in 'capturemode' (default 0)
# 突发事件写入 stfout中 默认是false
stdout_events_enabled=false
# 错误日志文件
stderr_logfile=/root/captain_node_backend/logs/supervisor_error.log
# 输入日志文件大小  默认是50MB
stderr_logfile_maxbytes=50MB
# 输入日志文件发备份  (0-不备份  默认是10)
stderr_logfile_backups=10
# capturemode 字节数  默认是10
stderr_capture_maxbytes=10MB   ; number of bytes in 'capturemode' (default 0)
# 突发事件写入 stfout中 默认是false
stderr_events_enabled=false
# 是否自动启动
autostart=true
# 程序意外退出是否自动重启
autorestart=true
# 启动10秒后没有异常退出,就表示进程正常启动了,默认为1秒
startsecs=10
# 进程启动优先级,默认999,值小的优先启动
priority=1
# 进程执行的用户身份
user=root
# 启动失败自动重试次数,默认是3
startretries=3
# 把stderr重定向到stdout,默认false
redirect_stderr=true
# 默认为false,进程被杀死时,是否向这个进程组发送stop信号,包括子进程
stopasgroup=false
# 默认为false,向进程组发送kill信号,包括子进程
killasgroup=false
View Code

# 注: 因为此配置文件引用到了项目文件中的log文件夹, 所以要想此配置生效必须先在项目文件中新建log文件夹 

14.配置supervisor的开机自启动

# 1.进入文件
cd /lib/systemd/system

# 2.新增并编辑配置文件
vim supervisord.service

# 3.配置文件内容
[Unit]
Description=supervisord
After=network.target

[Service]
Type=forking
ExecStart=/usr/local/bin/supervisord -c /etc/supervisor/supervisord.conf
ExecStop=/usr/local/bin/supervisorctl $OPTIONS shutdown
ExecReload=/usr/local/bin/supervisorctl $OPTIONS reload
KillMode=process
Restart=on-failure
RestartSec=42s

[Install]
WantedBy=multi-user.target

# 4.设置开机自启
systemctl enable supervisord.service
systemctl daemon-reload

# 5.修改权限
chmod 766 supervisord.service

15. 安装和配置openvpn(x86)

(1). 安装

# 1.安装
apt install openvpn

# 2.连接配置
从server端获取key

(2). 配置supervisord保护

# 1.创建log日志存储位置
cd /root/server端获取的连接文件
mkdir log 

# 2.编辑supervisor的配置
cd /etc/supervisor/conf.d
vim open_vpn.ini
[program:open_vpn]
# 程序启动命令
command=openvpn --config beikong11.ovpn 
# 命令执行的目录
directory=/root/beikong11
# 添加环境变量
# environment=PATH="/home/pyvip/.virtualenvs/Cel_proj/bin",B="2"
# 输出日志文件
stdout_logfile=/root/beikong11/logs/supervisor_info.log
# 输入日志文件大小  默认是50MB
stdout_logfile_maxbytes=50MB
# 输入日志文件发备份  (0-不备份  默认是10)
stdout_logfile_backups=10
# capturemode 字节数  默认是10
stdout_capture_maxbytes=10MB   ; number of bytes in 'capturemode' (default 0)
# 突发事件写入 stfout中 默认是false
stdout_events_enabled=false
# 错误日志文件
stderr_logfile=/root/beikong11/logs/supervisor_error.log
# 输入日志文件大小  默认是50MB
stderr_logfile_maxbytes=50MB
# 输入日志文件发备份  (0-不备份  默认是10)
stderr_logfile_backups=10
# capturemode 字节数  默认是10
stderr_capture_maxbytes=10MB   ; number of bytes in 'capturemode' (default 0)
# 突发事件写入 stfout中 默认是false
stderr_events_enabled=false
# 是否自动启动
autostart=true
# 程序意外退出是否自动重启
autorestart=true
# 启动10秒后没有异常退出,就表示进程正常启动了,默认为1秒
startsecs=10
# 进程启动优先级,默认999,值小的优先启动
priority=1
# 进程执行的用户身份
user=root
# 启动失败自动重试次数,默认是3
startretries=3
# 把stderr重定向到stdout,默认false
redirect_stderr=true
# 默认为false,进程被杀死时,是否向这个进程组发送stop信号,包括子进程
stopasgroup=false
# 默认为false,向进程组发送kill信号,包括子进程
killasgroup=false
View Code

16. 卸载图形界面

# Ubuntu上安装轻量级LXDE桌面

# 先卸载图形界面
1.卸载gnome-shell主程序
sudo apt-get remove gnome-shell

2.卸载掉gnome
sudo apt-get remove gnome 

3.卸载不需要的依赖关系
sudo apt-get autoremove

4.彻底卸载删除gnome的相关配置文件
sudo apt-get purge gnome

5.清理安装gnome时候留下的缓存程序软件包
sudo apt-get autoclean
sudo apt-get clean

6.重启
shutdown -r now

17. 安装安装轻量级LXDE桌面

# 安装依赖
apt-get install lubuntu-gtk-core

# 安装桌面
apt-get install lubuntu-desktop

# 安装lxde
sudo apt-get install lxde

# 重启

18. 向日葵远程控制的配置

#####此方案废弃#####
# 桌面版ubuntu安装向日葵的前期配置
# 安装lightdm桌面系统
sudo apt install lightdm

# 切换
sudo dpkg-reconfigure lightdm
# 1.命令行查找向日葵的安装位置
dpkg -S sunloginclient

# 2.配置开机自启动(图形化界面配置)
gnome-session-properties

19. 修改用户名密码

# 1.修改用户名
# (1).转成root用户, 在下列文件种找到代表你的那一行,修改用户名为新用户名
vim /etc/passwd    # 将旧用户名改为新的用户名, 但不要动/home/旧用户名的名字,否则重启后可能会无法从图形界面登录系统
vim /etc/shadow
vim /etc/group

# (2).修改用户目录
sudo vim /etc/passwd

# (3)还是在我们之前修改的那一行, 只不过这一次是将/home/旧用户名修改为/home/新用户名。
sudo mv /home/oldUser /home/newUser
sudo reboot

# 2.修改用户密码
sudo passwd 用户名

 20. win版本部署

1. win+R,打开运行,输入"shell:startup",打开Windows启动文件夹
2. 将captain_node.bat复制到文件夹内

 

posted @ 2022-06-29 14:01  骑驴老神仙  阅读(114)  评论(0编辑  收藏  举报