• java部署linux系统


       关闭防火墙

    不管是windows还是linux,首先必须关闭防火墙

    1. # linux添加8080端口
    2. firewall-cmd --zone=public --add-port=8080/tcp --permanent
    3. #删除80端口
    4. firewall-cmd --zone=public --remove-port=8080/tcp --permanent
    5. # 刷新使端口立即生效
    6. firewall-cmd --reload

    JDK8安装

    windows

    找到【jdk-8u251-windows-x64.exe】,然后双击,一直点击【下一步】就行,不需要做任何修改,也不要修改安装路径。安装结束后,使用【CMD】命令,然后输入【java -version】,然后回车。出现了下面的版本号就表示JDK8安装完成。

    linux安装

    1. tar -zxvf jdk-8u144-linux-x64.tar.gz
    2. vim /etc/profile
    3. 在文本的最后一行粘贴如下:
    4. 注意JAVA_HOME=/usr/java/jdk1.8.0_144 就是你自己的目录
    5. #java environment
    6. export JAVA_HOME=/usr/java/jdk1.8.0_144
    7. export CLASSPATH=.:${JAVA_HOME}/jre/lib/rt.jar:${JAVA_HOME}/lib/dt.jar:${JAVA_HOME}/lib/tools.jar
    8. export PATH=$PATH:${JAVA_HOME}/bin
    9. 然后按esc,输入【:wq】
    10. 然后输入source /etc/profile
    11. 再次输入java -version

    mysql修改用户名账号密码

    1. # 修改root账号密码
    2. set password for 'root'@'localhost'=password('Rays@145!');
    3. flush privileges;
    4. set password for 'root'@'%'=password('Rays@145!');
    5. flush privileges;
    6. # 创建新用户并且授权
    7. grant all privileges on *.* to 'ecs'@'%' identified by 'Rays@149!';
    8. flush privileges;
    9. # 如果修改或使用新的账号来连接canal,需要删除canal中的dat配置文件

    mysql安装

    windows

    找到【mysql-installer-community-8.0.28.0.msi】,然后双击。

    密码验证方式(Authentication Method)这一步很重要

    第一个是强密码校验,mysql推荐使用最新的数据库和相关客户端,MySQL8换了加密插件,所以如果选第一种方式,很可能你的navicat等客户端连不上mysql8。

    所以这里一定要选第二个(下图红框的地方),因为我们后面使用客户端navicat,它连接mysql数据库用的是就是这个加密算法,所以这一步很重要。(重要的事情说三遍)

    设置的密码为统一的密码,统一密码在文档顶部。 

     如果出现下图红框的警告,表示名称重复了,换个其他名称

    linux安装 

    1. sudo yum localinstall https://repo.mysql.com/mysql80-community-release-el7-1.noarch.rpm
    2. sudo yum install mysql-server
    3. sudo service mysqld start
    4. service mysqld status
    5. # 默认没有密码
    6. mysql -uroot -p
    7. 直接回车,然后输入命令 flush privileges
    8. ALTER USER 'root'@'localhost' IDENTIFIED BY 'Rays@135!';
    9. ALTER USER 'root'@'%' IDENTIFIED BY 'Rays@135!';
    10. # create user rrays@'%' identified by 'Rays@135!';
    11. GRANT ALL PRIVILEGES ON *.* TO rrays;
    12. flush privileges;
    13. sudo service mysqld stop
    14. 在etc下新建my.cnf文件,如果my.cnf已经存在不要删除,也不要修改已经有的配置,添加自己的配置在下面即可。
    15. vim /etc/my.cnf
    16. [mysqld]
    17. port=3306
    18. user=mysql
    19. ft_min_word_len=1
    20. innodb_ft_min_token_size=1
    21. ft_stopword_file=('')
    22. default-time-zone='+8:00'
    23. max_allowed_packet=500M
    24. character-set-server=utf8mb4
    25. default-storage-engine=INNODB
    26. default_authentication_plugin=mysql_native_password
    27. default-character-setVariable=utf8mb4
    28. max_connections=1000
    29. max_connect_errors=100
    30. max_user_connections=500
    31. lower_case_table_names=1
    32. interactive_timeout=1800
    33. wait_timeout=1800
    34. lock_wait_timeout=3600
    35. table_open_cache=128
    36. key_buffer_size=268435456
    37. sort_buffer_size=16777208
    38. table_cache=512M
    39. innodb_log_buffer_size=64M
    40. innodb_additional_mem_pool_size=60M
    41. innodb_thread_concurrency=14
    42. query_cache_size=4096M
    43. query_cache_min_res_unit=1048576
    44. innodb_buffer_pool_size=5G
    45. innodb_buffer_pool_instances=-1
    46. innodb_io_capacity=4500
    47. # 关闭mysql8的ssl,执行下面的语句,可以看到ssl是打开的
    48. SHOW VARIABLES LIKE '%ssl%';
    49. | have_openssl | YES |
    50. | have_ssl | YES |
    51. # 停止mysql服务
    52. $ service mysql stop
    53. 修改配置,找到自己安装的my.cnf文件,下面的路径只是demo
    54. File: /path/to/file/my.cnf
    55. # 增加skip_ssl
    56. skip_ssl
    57. # 注释掉disable_ssl
    58. # disable_ssl
    59. # 重启服务
    60. $ service mysql restart

     sqlserver安装

     

     

     安装到指定的目录或者采用默认安装即可。

     密码请输入统一的密码

    选择当前用户即可。 

     

     

    安装好之后连接MYSQL数据库,修改root账号连接为所有机器可连接。如果不修改,其它机器是无法通过root账号连接mysql的。 

    1. -- 一定要在安装的mysql机器上安装navicat,mysql默认不能其它路径访问
    2. GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';
    3. FLUSH PRIVILEGES;

     修改完之后,一定要使用navicat新建一个通过IP连接的连接来测试是否可以连接,比如在自己的电脑上,插上网线,保证自己的电脑和MYSQL所在的机器在同一个IP网段内。

    canal-server安装 

    复制【canal-server-prod】文件夹到需要安装的地方。

    然后打开【canal-server-prod\canal\conf\ecs\instance.properties】文件,txt编辑或者editplus或vscode工具都行。

    启动只需要双击【startup.bat】即可。数据库都没有导入前不要启动。

    修改程序的配置文件

    修改配置文件中的所有数据库和redis的连接地址,端口,密码。修改服务间的调用的IP

     redis安装

    windows

    直接双击【Redis-x64-7.0.2.exe】就行,一步一步安装。

    安装完成后不要启动,然后在进程中找到【redis-server.exe】,然后结束任务。如果没有忽略该步骤。

    修改密码方法:--------------------------------必须修改密码

    在计划任务中暂时停止Auto_Run_RedisServer【没有忽略】

    在任务管理器中停止redis-server.exe进程

    1. # 以下2个文件都要修改
    2. # 修改安装文件中的conf文件(redis.windows-service.conf 和redis.windows.conf)中 905行
    3. # requirepass foobared
    4. # 将前面的#号移除即可实现设置密码的效果。如:
    5. requirepass Rays@123!
    6. # 则密码为Rays@123!

    在计划任务中启用Auto_Run_RedisServer服务,如果没有该服务直接双击【RunRedisServer.exe】即可启动

    至此,修改密码步骤完成。

    redis客户端工具安装

    双击【redisdesktop.exe】软件,一直按照提示安装即可,安装完成后记得连接redis,测试一下。

     linux安装

    1. Redis下载地址:https://redis.io/download/,或者使用命令直接下载:
    2. cd /opt/software
    3. wget http://download.redis.io/releases/redis-7.0.6.tar.gz
    4. yum install gcc
    5. # 解压
    6. tar -zxvf redis-7.0.6.tar.gz
    7. cd redis-7.0.6
    8. # 编译安装
    9. make
    10. # 修改配置文件
    11. port 6380
    12. # 注释掉
    13. # bind 127.0.0.1
    14. pidfile /var/run/redis_6380.pid
    15. requirepass iot#2023!
    16. # 增加redis callback功能
    17. notify-keyspace-events Ex
    18. # 后台启动命令
    19. /opt/redis-7.0.6/src/redis-server /opt/redis-7.0.6/redis.conf --daemonize yes
    20. # 关闭命令
    21. pkill redis-server
    22. kill redis-server进程号
    23. # 查看进程id
    24. ps -ef|grep redis
    25. kill -9 进程id

    MYSQL新建数据库

    设置字符集

    MYSQL导入数据库脚本

    SQLSERVER新建数据库

    应用程序打包部署

    dys-server部署

    打包后jar文件地址

    Windows机器发布

    进入到wharfIntf.jar所在的文件夹,在空白处右键,选择【在终端中打开】,然后输入启动命令,其中的test为自己需要启动连接的环境。

    java -Xms512m -Xmx512m -XX:PermSize=128m -jar wharfIntf.jar --spring.profiles.active=test

    关闭服务

    Windows关闭服务比较简单,直接关闭CMD窗口就行。

    windows启动关闭命令

    启动脚本

    1、新建一个txt文件,把下面的命令复制进去

    2、修改文件中对应的jar包名称和jar包路径

    3、保存

    4、将startup.txt文件修改为后缀为startup.bat文件

    5、双击运行

    6、不会有任何窗口弹出,都是后台隐藏式运行。

    7、等待20秒到1分钟左右,打开浏览器输入http://ip:pot/项目名/test/welcome

    8、如果看到有返回的json消息,说明项目启动成功。也可以查看启动日志。

    1. @echo off
    2. setlocal enabledelayedexpansion
    3. for /f "tokens=1" %%a in ('jps ^| findstr dyecs.jar') do taskkill /f /pid %%a
    4. start javaw -Xms512m -Xmx1024m -jar D:\server\dyecs.jar --spring.profiles.active=prod > D:\server\logs\dyecs.log 2>&1 &
    5. exit

    停止脚本

    只要修改7070为自己项目的端口号

    1. @echo off
    2. set port=7070
    3. for /f "tokens=1-5" %%i in ('netstat -ano^|findstr ":%port%"') do (
    4. echo kill the process %%m who use the port
    5. taskkill /pid %%m -t -f
    6. goto q
    7. )
    8. :q

    重启脚本

    注意修改端口号,项目名称,项目路径,启动环境

    1. @echo off
    2. set port=7070
    3. for /f "tokens=1-5" %%i in ('netstat -ano^|findstr ":%port%"') do (
    4. echo kill the process %%m who use the port
    5. taskkill /pid %%m -t -f
    6. goto start
    7. )
    8. :start
    9. START "wharfmng" javaw -Xms512m -Xmx512m -XX:PermSize=128m -jar D:/java_code/wharfmng/target/wharfmng.jar --spring.profiles.active=dev

    备注

    1、一般把这三个文件,放在和jar包同级目录

    Linux启动命令脚本

    启动命令

    1、根据自己的项目地址,修改对应的路径和项目名称

    2、把下面的命令复制到新建的startup.txt文件中,然后修改文件为startup.sh

    3、把文件上传到需要的文件夹下,下文的demo中,需要把startup.sh文件保存在/home/wharfmng-server/startup.sh

    4、上传完文件后,需要修改对应的文件夹和文件的权限为777

    nohup java -jar -Xms512m -Xmx512m -XX:PermSize=128m /home/wharfmng-server/wharfmng-service/wharfmng.jar --spring.profiles.acive=prod >> /dev/null 2>&1 &

    5、给文件夹赋予777读写权限,只有第一次新建文件或文件夹,或者删除了文件,修改了文件名之后重新上传文件,都需要赋权777.

    chmod -R 777 /home/wharfmng-server

    6、准备好之后,启动命令如下

    sh /home/wharfmng-server/startup.sh

    7、查看日志

    tail -f /home/wharfmng-server/logs/wahrfmng.log

    8、退出日志查看,直接同时按下Ctrl+C按键就行。

    停止命令 

    1. ps -ef|grep java回车
    2. root 54345 1 15 15:43 pts/0 00:03:08 java -Xms512m -Xmx512m -XX:Perm Size=128m -jar /home/wharfmng-server/wharfmng-service/wharfmng.jar --spring.profiles.active=prod
    3. #注意查看进程ID,ID每次都会变,不要关闭其它的项目
    4. #如果要关闭54345的进程
    5. kill -9 54345回车

    结束

    -----华丽的分割线,以下是凑字数,大家不用花时间看,快去改代码-----

    -----华丽的分割线,以下是凑字数,大家不用花时间看,快去改代码-----

    -----华丽的分割线,以下是凑字数,大家不用花时间看,快去改代码-----

    1. package cn.renkai721.bean.vo;
    2. import lombok.extern.slf4j.Slf4j;
    3. @Slf4j
    4. public class MakeUpTheWordCount {
    5. private String make_up_the_word_count_column_999999999_1;
    6. private String make_up_the_word_count_column_999999999_2;
    7. private String make_up_the_word_count_column_999999999_3;
    8. private String make_up_the_word_count_column_999999999_4;
    9. private String make_up_the_word_count_column_999999999_5;
    10. private String make_up_the_word_count_column_999999999_6;
    11. private String make_up_the_word_count_column_999999999_7;
    12. private String make_up_the_word_count_column_999999999_8;
    13. private String make_up_the_word_count_column_999999999_9;
    14. private String make_up_the_word_count_column_999999999_10;
    15. private String make_up_the_word_count_column_999999999_11;
    16. private String make_up_the_word_count_column_999999999_12;
    17. private String make_up_the_word_count_column_999999999_13;
    18. private String make_up_the_word_count_column_999999999_14;
    19. private String make_up_the_word_count_column_999999999_15;
    20. private String make_up_the_word_count_column_999999999_16;
    21. private String make_up_the_word_count_column_999999999_17;
    22. private String make_up_the_word_count_column_999999999_18;
    23. private String make_up_the_word_count_column_999999999_19;
    24. private String make_up_the_word_count_column_999999999_20;
    25. public String getMake_up_the_word_count_column_999999999_1() {
    26. return make_up_the_word_count_column_999999999_1;
    27. }
    28. public void setMake_up_the_word_count_column_999999999_1(String make_up_the_word_count_column_999999999_1) {
    29. this.make_up_the_word_count_column_999999999_1 = make_up_the_word_count_column_999999999_1;
    30. }
    31. public String getMake_up_the_word_count_column_999999999_2() {
    32. return make_up_the_word_count_column_999999999_2;
    33. }
    34. public void setMake_up_the_word_count_column_999999999_2(String make_up_the_word_count_column_999999999_2) {
    35. this.make_up_the_word_count_column_999999999_2 = make_up_the_word_count_column_999999999_2;
    36. }
    37. public String getMake_up_the_word_count_column_999999999_3() {
    38. return make_up_the_word_count_column_999999999_3;
    39. }
    40. public void setMake_up_the_word_count_column_999999999_3(String make_up_the_word_count_column_999999999_3) {
    41. this.make_up_the_word_count_column_999999999_3 = make_up_the_word_count_column_999999999_3;
    42. }
    43. public String getMake_up_the_word_count_column_999999999_4() {
    44. return make_up_the_word_count_column_999999999_4;
    45. }
    46. public void setMake_up_the_word_count_column_999999999_4(String make_up_the_word_count_column_999999999_4) {
    47. this.make_up_the_word_count_column_999999999_4 = make_up_the_word_count_column_999999999_4;
    48. }
    49. public String getMake_up_the_word_count_column_999999999_5() {
    50. return make_up_the_word_count_column_999999999_5;
    51. }
    52. public void setMake_up_the_word_count_column_999999999_5(String make_up_the_word_count_column_999999999_5) {
    53. this.make_up_the_word_count_column_999999999_5 = make_up_the_word_count_column_999999999_5;
    54. }
    55. public String getMake_up_the_word_count_column_999999999_6() {
    56. return make_up_the_word_count_column_999999999_6;
    57. }
    58. public void setMake_up_the_word_count_column_999999999_6(String make_up_the_word_count_column_999999999_6) {
    59. this.make_up_the_word_count_column_999999999_6 = make_up_the_word_count_column_999999999_6;
    60. }
    61. public String getMake_up_the_word_count_column_999999999_7() {
    62. return make_up_the_word_count_column_999999999_7;
    63. }
    64. public void setMake_up_the_word_count_column_999999999_7(String make_up_the_word_count_column_999999999_7) {
    65. this.make_up_the_word_count_column_999999999_7 = make_up_the_word_count_column_999999999_7;
    66. }
    67. public String getMake_up_the_word_count_column_999999999_8() {
    68. return make_up_the_word_count_column_999999999_8;
    69. }
    70. public void setMake_up_the_word_count_column_999999999_8(String make_up_the_word_count_column_999999999_8) {
    71. this.make_up_the_word_count_column_999999999_8 = make_up_the_word_count_column_999999999_8;
    72. }
    73. public String getMake_up_the_word_count_column_999999999_9() {
    74. return make_up_the_word_count_column_999999999_9;
    75. }
    76. public void setMake_up_the_word_count_column_999999999_9(String make_up_the_word_count_column_999999999_9) {
    77. this.make_up_the_word_count_column_999999999_9 = make_up_the_word_count_column_999999999_9;
    78. }
    79. public String getMake_up_the_word_count_column_999999999_10() {
    80. return make_up_the_word_count_column_999999999_10;
    81. }
    82. public void setMake_up_the_word_count_column_999999999_10(String make_up_the_word_count_column_999999999_10) {
    83. this.make_up_the_word_count_column_999999999_10 = make_up_the_word_count_column_999999999_10;
    84. }
    85. public String getMake_up_the_word_count_column_999999999_11() {
    86. return make_up_the_word_count_column_999999999_11;
    87. }
    88. public void setMake_up_the_word_count_column_999999999_11(String make_up_the_word_count_column_999999999_11) {
    89. this.make_up_the_word_count_column_999999999_11 = make_up_the_word_count_column_999999999_11;
    90. }
    91. public String getMake_up_the_word_count_column_999999999_12() {
    92. return make_up_the_word_count_column_999999999_12;
    93. }
    94. public void setMake_up_the_word_count_column_999999999_12(String make_up_the_word_count_column_999999999_12) {
    95. this.make_up_the_word_count_column_999999999_12 = make_up_the_word_count_column_999999999_12;
    96. }
    97. public String getMake_up_the_word_count_column_999999999_13() {
    98. return make_up_the_word_count_column_999999999_13;
    99. }
    100. public void setMake_up_the_word_count_column_999999999_13(String make_up_the_word_count_column_999999999_13) {
    101. this.make_up_the_word_count_column_999999999_13 = make_up_the_word_count_column_999999999_13;
    102. }
    103. public String getMake_up_the_word_count_column_999999999_14() {
    104. return make_up_the_word_count_column_999999999_14;
    105. }
    106. public void setMake_up_the_word_count_column_999999999_14(String make_up_the_word_count_column_999999999_14) {
    107. this.make_up_the_word_count_column_999999999_14 = make_up_the_word_count_column_999999999_14;
    108. }
    109. public String getMake_up_the_word_count_column_999999999_15() {
    110. return make_up_the_word_count_column_999999999_15;
    111. }
    112. public void setMake_up_the_word_count_column_999999999_15(String make_up_the_word_count_column_999999999_15) {
    113. this.make_up_the_word_count_column_999999999_15 = make_up_the_word_count_column_999999999_15;
    114. }
    115. public String getMake_up_the_word_count_column_999999999_16() {
    116. return make_up_the_word_count_column_999999999_16;
    117. }
    118. public void setMake_up_the_word_count_column_999999999_16(String make_up_the_word_count_column_999999999_16) {
    119. this.make_up_the_word_count_column_999999999_16 = make_up_the_word_count_column_999999999_16;
    120. }
    121. public String getMake_up_the_word_count_column_999999999_17() {
    122. return make_up_the_word_count_column_999999999_17;
    123. }
    124. public void setMake_up_the_word_count_column_999999999_17(String make_up_the_word_count_column_999999999_17) {
    125. this.make_up_the_word_count_column_999999999_17 = make_up_the_word_count_column_999999999_17;
    126. }
    127. public String getMake_up_the_word_count_column_999999999_18() {
    128. return make_up_the_word_count_column_999999999_18;
    129. }
    130. public void setMake_up_the_word_count_column_999999999_18(String make_up_the_word_count_column_999999999_18) {
    131. this.make_up_the_word_count_column_999999999_18 = make_up_the_word_count_column_999999999_18;
    132. }
    133. public String getMake_up_the_word_count_column_999999999_19() {
    134. return make_up_the_word_count_column_999999999_19;
    135. }
    136. public void setMake_up_the_word_count_column_999999999_19(String make_up_the_word_count_column_999999999_19) {
    137. this.make_up_the_word_count_column_999999999_19 = make_up_the_word_count_column_999999999_19;
    138. }
    139. public String getMake_up_the_word_count_column_999999999_20() {
    140. return make_up_the_word_count_column_999999999_20;
    141. }
    142. public void setMake_up_the_word_count_column_999999999_20(String make_up_the_word_count_column_999999999_20) {
    143. this.make_up_the_word_count_column_999999999_20 = make_up_the_word_count_column_999999999_20;
    144. }
    145. }

  • 相关阅读:
    Mysql 学习总结(89)—— Mysql 库表容量统计
    Elasticsearch7.x.x开启X-pack鉴权,按步骤执行就能成功!
    [运维|数据库] msql中的 FIND_IN_SET如何转化为pg数据中的ARRAY_POSITION的函数
    五、鼎捷T100月加权平均成本计算流程篇
    从零学习 InfiniBand-network架构(六)—IB协议链路层QoS如何实现
    Cocos Creator3.8 实战问题(三)去除scrollview背景色和label 对齐方式设置无效问题
    字符串压缩(一)之ZSTD
    LLVM编译安装
    抓的是周树人,与我鲁迅有什么关系?
    Java 对实例进行深拷贝操作
  • 原文地址:https://blog.csdn.net/renkai721/article/details/133881521