鼎鼎知识库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. # 安装 .NET Core
  2. - 查看SDK: dotnet --list-sdks
  3. - 查看运行时:dotnet --list-runtimes
  4. - 把Microsoft Package Signing Key添加到信任列表并安装
  5. ```
  6. sudo wget https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb sudo dpkg -i packages-microsoft-prod.deb
  7. ```
  8. - 安装运行时组合
  9. ```
  10. sudo apt-get update;\
  11. sudo apt-get install -y apt-transport-https && \
  12. sudo apt-get update && \
  13. sudo apt-get install -y aspnetcore-runtime-3.0
  14. ```
  15. - 如果只安装 .NET Core运行时,一般用的就是这个
  16. ```
  17. sudo apt-get install -y dotnet-runtime-3.0
  18. ```
  19. # Ubuntu上使用Nginx
  20. - 更新apt: sudo apt update
  21. - 安装Nginx: sudo apt install nginx
  22. - 查看Nginx服务:sudo ufw app list
  23. ```
  24. Nginx Full
  25. Nginx HTTP
  26. Nginx HTTPS
  27. OpenSSH
  28. ```
  29. - 让防火墙允许Nginx:sudo ufw allow 'NginxHTTP'
  30. - 查看防火墙状态
  31. ```
  32. sudo ufw status
  33. sudo ufw enable
  34. sudo ufw status
  35. ```
  36. - 查看Nginx的状态:sudo systemctl status nginx
  37. - 获取公网IP: curl -4 icanhazip.com
  38. - 查看Nginx的登录页:http://ip
  39. - 停止服务:sudo systemctl stop nginx
  40. - 开始服务:sudo systemctl start nginx
  41. - 重启服务: sudo systemctl restart nginx
  42. - 随机启动的启用和禁用: sudo systemctl enable/disable nginx
  43. - 手动让修改文件生效:sudo systemctl reload nginx
  44. > Nginx支持多个域名
  45. - 默认文件夹:/var/www/html
  46. - 创建新目录:suoo mkdir -p /var/www/example.com/html
  47. - 给新目录分配当前用户的权限:sudo chown -R $USR:$USR /var/www/example.com/html
  48. ```
  49. 另外一个修改目录的读写权限: sudo chmod 666 some.txt
  50. ```
  51. - 确认是否有权限:sudo chmod -R 755 /var/www/example.com
  52. - 添加网页:/var/www/example.com/html/index.html
  53. - 需要为Serverblock添加新目录,即支持多个域名。来到/etc/nginx/sites-available/example.com
  54. ```
  55. server {
  56. listen 80;
  57. listen [::]:80;
  58. root /var/www/example.com/html
  59. index index.html index.htm index.nginx-debian.html
  60. server_name example.com www.example.com
  61. location / {
  62. try_files $uri $uri/ = 404;
  63. }
  64. }
  65. ```
  66. - 让Nginx可以读取到上面的文件:sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
  67. - 修改配置文件,防止hash bucket memory problem。来到:/etc/nginx/nginx.conf
  68. ```
  69. http {
  70. server_names_hash_bucket_size 64;
  71. }
  72. ```
  73. # 安装MySQL 5.7
  74. - 创建目录:sudo mkdir tmp
  75. - 进入目录:cd tmp
  76. - 下载deb文件:curl -OL https://dev.mysql.com/get/mysql-apt-config_0.8.15-1_all.deb
  77. - 安装:sudo dpkg -i ...deb
  78. - 安装过程选择mysql-5.7
  79. - sudo apt-get update
  80. - 真正安装MySQL的服务器版本:sudo apt-get install mysql-server
  81. - 登录:mysql -u root -p
  82. - 创建用户
  83. ```
  84. CREATE USER 'dd'@'%' IDENTIFIED BY 'dd@123'
  85. ```
  86. - 授权用户
  87. ```
  88. GRANT ALL PRIVILEGES ON *.* TO 'dd'@'%'
  89. ```
  90. - 让授权生效
  91. ```
  92. FLUSH PRIVILEGES;
  93. ```
  94. - 修改配置文件允许远程: /etc/mysql/mysql.d/mysqld.cnf
  95. - 修改目录权限:sudo chmod 666 mysqld.cnf
  96. - 修改配置文件
  97. ```
  98. bind-address=0.0.0.0
  99. ```
  100. - 重启服务:sudo systemctl restart/start/stop/status mysql.service
  101. - 测试连接
  102. ```
  103. ping 192.168.8.120
  104. mysql -u root ph 192.168.8.120 -p
  105. mysql -u root -p
  106. ```
  107. # 安装Redis
  108. - 更新软件中心:sudo apt update
  109. - 安装:sudo apt install redis-server
  110. - 配置文件:/etc/redis/redis.conf
  111. - 修改配置文件权限:sudo chmod 666 redis.conf
  112. - 重启:sudo systemctl restart redis.service
  113. - 查看状态:sudo systemctl status redis
  114. - 启用禁用随机启动:sudo systemctl enable/disable redis
  115. - 客户端登录:
  116. ```
  117. redis-cli
  118. ping
  119. set test "ok"
  120. get test
  121. exit
  122. ```
  123. - 修改配置文件密码
  124. ```
  125. requriepass teche123
  126. ```
  127. # 准备
  128. - 服务器地址:192.168.8.109:8080
  129. - 让模块和服务器都在一个局域网
  130. - 查看局域网内模块的IP:192.168.8.108:82,用户名root,密码abc123。
  131. - 连接MySQL数据库:192.168.8.109 3306 dd dd@123
  132. - Redis数据库:127.0.0.1 teche123
  133. # 创建主数据库teche
  134. ```
  135. 数据库名:teche
  136. 字符集:utf8mb4--UTF-8 Unicode
  137. 排序规则:utf8mbs_general_ci
  138. ```
  139. # 创建用户数据库techeusr
  140. ```
  141. 数据库名:techeusr
  142. 字符集:utf8mb4--UTF-8 Unicode
  143. 排序规则:utf8mbs_general_ci
  144. ```
  145. # 创建定时任务数据库quartznet
  146. - 创建数据库
  147. ```
  148. 数据库名:quartznet
  149. 字符集:utf8mb4--UTF-8 Unicode
  150. 排序规则:utf8mbs_general_ci
  151. ```
  152. - 执行语句
  153. ```
  154. # By: Ron Cordell - roncordell
  155. # I didn't see this anywhere, so I thought I'd post it here. This is the script from Quartz to create the tables in a MySQL database, modified to use INNODB instead of MYISAM.
  156. # make sure you have UTF-8 collaction for best .NET interoperability
  157. # CREATE DATABASE quartznet CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
  158. DROP TABLE IF EXISTS QRTZ_FIRED_TRIGGERS;
  159. DROP TABLE IF EXISTS QRTZ_PAUSED_TRIGGER_GRPS;
  160. DROP TABLE IF EXISTS QRTZ_SCHEDULER_STATE;
  161. DROP TABLE IF EXISTS QRTZ_LOCKS;
  162. DROP TABLE IF EXISTS QRTZ_SIMPLE_TRIGGERS;
  163. DROP TABLE IF EXISTS QRTZ_SIMPROP_TRIGGERS;
  164. DROP TABLE IF EXISTS QRTZ_CRON_TRIGGERS;
  165. DROP TABLE IF EXISTS QRTZ_BLOB_TRIGGERS;
  166. DROP TABLE IF EXISTS QRTZ_TRIGGERS;
  167. DROP TABLE IF EXISTS QRTZ_JOB_DETAILS;
  168. DROP TABLE IF EXISTS QRTZ_CALENDARS;
  169. CREATE TABLE QRTZ_JOB_DETAILS(
  170. SCHED_NAME VARCHAR(60) NOT NULL,
  171. JOB_NAME VARCHAR(60) NOT NULL,
  172. JOB_GROUP VARCHAR(60) NOT NULL,
  173. DESCRIPTION VARCHAR(250) NULL,
  174. JOB_CLASS_NAME VARCHAR(250) NOT NULL,
  175. IS_DURABLE BOOLEAN NOT NULL,
  176. IS_NONCONCURRENT BOOLEAN NOT NULL,
  177. IS_UPDATE_DATA BOOLEAN NOT NULL,
  178. REQUESTS_RECOVERY BOOLEAN NOT NULL,
  179. JOB_DATA BLOB NULL,
  180. PRIMARY KEY (SCHED_NAME,JOB_NAME,JOB_GROUP))
  181. ENGINE=InnoDB;
  182. CREATE TABLE QRTZ_TRIGGERS (
  183. SCHED_NAME VARCHAR(60) NOT NULL,
  184. TRIGGER_NAME VARCHAR(60) NOT NULL,
  185. TRIGGER_GROUP VARCHAR(60) NOT NULL,
  186. JOB_NAME VARCHAR(60) NOT NULL,
  187. JOB_GROUP VARCHAR(60) NOT NULL,
  188. DESCRIPTION VARCHAR(250) NULL,
  189. NEXT_FIRE_TIME BIGINT(19) NULL,
  190. PREV_FIRE_TIME BIGINT(19) NULL,
  191. PRIORITY INTEGER NULL,
  192. TRIGGER_STATE VARCHAR(16) NOT NULL,
  193. TRIGGER_TYPE VARCHAR(8) NOT NULL,
  194. START_TIME BIGINT(19) NOT NULL,
  195. END_TIME BIGINT(19) NULL,
  196. CALENDAR_NAME VARCHAR(60) NULL,
  197. MISFIRE_INSTR SMALLINT(2) NULL,
  198. JOB_DATA BLOB NULL,
  199. PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP),
  200. FOREIGN KEY (SCHED_NAME,JOB_NAME,JOB_GROUP)
  201. REFERENCES QRTZ_JOB_DETAILS(SCHED_NAME,JOB_NAME,JOB_GROUP))
  202. ENGINE=InnoDB;
  203. CREATE TABLE QRTZ_SIMPLE_TRIGGERS (
  204. SCHED_NAME VARCHAR(60) NOT NULL,
  205. TRIGGER_NAME VARCHAR(60) NOT NULL,
  206. TRIGGER_GROUP VARCHAR(60) NOT NULL,
  207. REPEAT_COUNT BIGINT(7) NOT NULL,
  208. REPEAT_INTERVAL BIGINT(12) NOT NULL,
  209. TIMES_TRIGGERED BIGINT(10) NOT NULL,
  210. PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP),
  211. FOREIGN KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
  212. REFERENCES QRTZ_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP))
  213. ENGINE=InnoDB;
  214. CREATE TABLE QRTZ_CRON_TRIGGERS (
  215. SCHED_NAME VARCHAR(60) NOT NULL,
  216. TRIGGER_NAME VARCHAR(60) NOT NULL,
  217. TRIGGER_GROUP VARCHAR(60) NOT NULL,
  218. CRON_EXPRESSION VARCHAR(120) NOT NULL,
  219. TIME_ZONE_ID VARCHAR(80),
  220. PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP),
  221. FOREIGN KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
  222. REFERENCES QRTZ_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP))
  223. ENGINE=InnoDB;
  224. CREATE TABLE QRTZ_SIMPROP_TRIGGERS
  225. (
  226. SCHED_NAME VARCHAR(60) NOT NULL,
  227. TRIGGER_NAME VARCHAR(60) NOT NULL,
  228. TRIGGER_GROUP VARCHAR(60) NOT NULL,
  229. STR_PROP_1 VARCHAR(512) NULL,
  230. STR_PROP_2 VARCHAR(512) NULL,
  231. STR_PROP_3 VARCHAR(512) NULL,
  232. INT_PROP_1 INT NULL,
  233. INT_PROP_2 INT NULL,
  234. LONG_PROP_1 BIGINT NULL,
  235. LONG_PROP_2 BIGINT NULL,
  236. DEC_PROP_1 NUMERIC(13,4) NULL,
  237. DEC_PROP_2 NUMERIC(13,4) NULL,
  238. BOOL_PROP_1 BOOLEAN NULL,
  239. BOOL_PROP_2 BOOLEAN NULL,
  240. TIME_ZONE_ID VARCHAR(80) NULL,
  241. PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP),
  242. FOREIGN KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
  243. REFERENCES QRTZ_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP))
  244. ENGINE=InnoDB;
  245. CREATE TABLE QRTZ_BLOB_TRIGGERS (
  246. SCHED_NAME VARCHAR(60) NOT NULL,
  247. TRIGGER_NAME VARCHAR(60) NOT NULL,
  248. TRIGGER_GROUP VARCHAR(60) NOT NULL,
  249. BLOB_DATA BLOB NULL,
  250. PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP),
  251. INDEX (SCHED_NAME,TRIGGER_NAME, TRIGGER_GROUP),
  252. FOREIGN KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
  253. REFERENCES QRTZ_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP))
  254. ENGINE=InnoDB;
  255. CREATE TABLE QRTZ_CALENDARS (
  256. SCHED_NAME VARCHAR(60) NOT NULL,
  257. CALENDAR_NAME VARCHAR(60) NOT NULL,
  258. CALENDAR BLOB NOT NULL,
  259. PRIMARY KEY (SCHED_NAME,CALENDAR_NAME))
  260. ENGINE=InnoDB;
  261. CREATE TABLE QRTZ_PAUSED_TRIGGER_GRPS (
  262. SCHED_NAME VARCHAR(60) NOT NULL,
  263. TRIGGER_GROUP VARCHAR(60) NOT NULL,
  264. PRIMARY KEY (SCHED_NAME,TRIGGER_GROUP))
  265. ENGINE=InnoDB;
  266. CREATE TABLE QRTZ_FIRED_TRIGGERS (
  267. SCHED_NAME VARCHAR(60) NOT NULL,
  268. ENTRY_ID VARCHAR(140) NOT NULL,
  269. TRIGGER_NAME VARCHAR(60) NOT NULL,
  270. TRIGGER_GROUP VARCHAR(60) NOT NULL,
  271. INSTANCE_NAME VARCHAR(60) NOT NULL,
  272. FIRED_TIME BIGINT(19) NOT NULL,
  273. SCHED_TIME BIGINT(19) NOT NULL,
  274. PRIORITY INTEGER NOT NULL,
  275. STATE VARCHAR(16) NOT NULL,
  276. JOB_NAME VARCHAR(60) NULL,
  277. JOB_GROUP VARCHAR(60) NULL,
  278. IS_NONCONCURRENT BOOLEAN NULL,
  279. REQUESTS_RECOVERY BOOLEAN NULL,
  280. PRIMARY KEY (SCHED_NAME,ENTRY_ID))
  281. ENGINE=InnoDB;
  282. CREATE TABLE QRTZ_SCHEDULER_STATE (
  283. SCHED_NAME VARCHAR(60) NOT NULL,
  284. INSTANCE_NAME VARCHAR(60) NOT NULL,
  285. LAST_CHECKIN_TIME BIGINT(19) NOT NULL,
  286. CHECKIN_INTERVAL BIGINT(19) NOT NULL,
  287. PRIMARY KEY (SCHED_NAME,INSTANCE_NAME))
  288. ENGINE=InnoDB;
  289. CREATE TABLE QRTZ_LOCKS (
  290. SCHED_NAME VARCHAR(60) NOT NULL,
  291. LOCK_NAME VARCHAR(40) NOT NULL,
  292. PRIMARY KEY (SCHED_NAME,LOCK_NAME))
  293. ENGINE=InnoDB;
  294. CREATE INDEX IDX_QRTZ_J_REQ_RECOVERY ON QRTZ_JOB_DETAILS(SCHED_NAME,REQUESTS_RECOVERY);
  295. CREATE INDEX IDX_QRTZ_J_GRP ON QRTZ_JOB_DETAILS(SCHED_NAME,JOB_GROUP);
  296. CREATE INDEX IDX_QRTZ_T_J ON QRTZ_TRIGGERS(SCHED_NAME,JOB_NAME,JOB_GROUP);
  297. CREATE INDEX IDX_QRTZ_T_JG ON QRTZ_TRIGGERS(SCHED_NAME,JOB_GROUP);
  298. CREATE INDEX IDX_QRTZ_T_C ON QRTZ_TRIGGERS(SCHED_NAME,CALENDAR_NAME);
  299. CREATE INDEX IDX_QRTZ_T_G ON QRTZ_TRIGGERS(SCHED_NAME,TRIGGER_GROUP);
  300. CREATE INDEX IDX_QRTZ_T_STATE ON QRTZ_TRIGGERS(SCHED_NAME,TRIGGER_STATE);
  301. CREATE INDEX IDX_QRTZ_T_N_STATE ON QRTZ_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP,TRIGGER_STATE);
  302. CREATE INDEX IDX_QRTZ_T_N_G_STATE ON QRTZ_TRIGGERS(SCHED_NAME,TRIGGER_GROUP,TRIGGER_STATE);
  303. CREATE INDEX IDX_QRTZ_T_NEXT_FIRE_TIME ON QRTZ_TRIGGERS(SCHED_NAME,NEXT_FIRE_TIME);
  304. CREATE INDEX IDX_QRTZ_T_NFT_ST ON QRTZ_TRIGGERS(SCHED_NAME,TRIGGER_STATE,NEXT_FIRE_TIME);
  305. CREATE INDEX IDX_QRTZ_T_NFT_MISFIRE ON QRTZ_TRIGGERS(SCHED_NAME,MISFIRE_INSTR,NEXT_FIRE_TIME);
  306. CREATE INDEX IDX_QRTZ_T_NFT_ST_MISFIRE ON QRTZ_TRIGGERS(SCHED_NAME,MISFIRE_INSTR,NEXT_FIRE_TIME,TRIGGER_STATE);
  307. CREATE INDEX IDX_QRTZ_T_NFT_ST_MISFIRE_GRP ON QRTZ_TRIGGERS(SCHED_NAME,MISFIRE_INSTR,NEXT_FIRE_TIME,TRIGGER_GROUP,TRIGGER_STATE);
  308. CREATE INDEX IDX_QRTZ_FT_TRIG_INST_NAME ON QRTZ_FIRED_TRIGGERS(SCHED_NAME,INSTANCE_NAME);
  309. CREATE INDEX IDX_QRTZ_FT_INST_JOB_REQ_RCVRY ON QRTZ_FIRED_TRIGGERS(SCHED_NAME,INSTANCE_NAME,REQUESTS_RECOVERY);
  310. CREATE INDEX IDX_QRTZ_FT_J_G ON QRTZ_FIRED_TRIGGERS(SCHED_NAME,JOB_NAME,JOB_GROUP);
  311. CREATE INDEX IDX_QRTZ_FT_JG ON QRTZ_FIRED_TRIGGERS(SCHED_NAME,JOB_GROUP);
  312. CREATE INDEX IDX_QRTZ_FT_T_G ON QRTZ_FIRED_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP);
  313. CREATE INDEX IDX_QRTZ_FT_TG ON QRTZ_FIRED_TRIGGERS(SCHED_NAME,TRIGGER_GROUP);
  314. commit;
  315. ```
  316. # 搭建网站,服务器指向
  317. - 修改模块的服务器指向:`192.168.8.109:8080/ebx-bishop/data/carry`
  318. - 通过软件重启模块
  319. - 创建目录:`sudo mkdir -p /var/www/znzm`
  320. - 为登录用户配权限:`sudo chown dingding:dingding /var/www/znzm`
  321. - 取消`Program`中的代码注释,修改`Startup`中有关`Quartz`的配置,发布网站
  322. - 给目录分配权限:`sudo chmod -R 777 /var/www`
  323. - 把发布网站拷贝到服务器的`znzm`目录。使用FileZilla。
  324. - 修改`appsettings.json`文件
  325. ```
  326. 192.168.8.109
  327. cloudgo:0,
  328. shixugo:0
  329. ```
  330. - 运行网站
  331. - 确认`teche`数据库
  332. - 在'kaiguanapplication'中增加一条记录,名称为`照明`
  333. - 确认`techeusr`数据库
  334. - 确认`redis`数据库
  335. ```
  336. 打开客户端:redis-cli
  337. 地址:127.0.0.1:6379
  338. 对外地址:192.168.8.109:6379 teche123
  339. 登录:auth teche123
  340. 查看键的数量:dbsize
  341. 列出所有的key:keys *(当key多的时候不要轻易用)
  342. 列出某个key: keys apple*
  343. 获取某个键值:get ...
  344. 让外界可访问:#bind 127.0.0.1 protected-mode:no
  345. 重启:sudo systemctl restart redis
  346. 查看状态:sudo systemctl status redis
  347. 诺德:option.Configuration = $"{Configuration["App:redis"]}:6321,password=_ebx_cnto_r_srv";
  348. ```
  349. - 确认`quartznet`
  350. ```
  351. 诺德:Port=3306;Database=quartznet;Uid=root;Pwd=lcDb_!@34%^_Mantunsci;SslMode=none
  352. 胶州:Port=3306;Database=quartznet;Uid=dd;Pwd=dd@123;SslMode=none
  353. ```
  354. - 关闭网站,把`Program`中的种子数据部分注释掉
  355. - 网站默认账号
  356. ```
  357. 管理员:13800000000 TecheFwd2018
  358. 设备工作人员:shebei 888888
  359. ```
  360. - 登录网站:`192.168.8.109:8080`
  361. - 管理员分配菜单权限
  362. - 创建项目楼层区域电箱开关:利群胶州购物广场
  363. - 测试可视化:先把可视化删除,再进入