热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Centos部署Java项目

一、修复网络链路1.vimetcsysconfignetwork-scriptsifcfg-ens33[注意一下,ifcfg-ens33后面的数字是随机产生的。]
 一、修复网络链路


1.vim /etc/sysconfig/network-scripts/ifcfg-ens33 [注意一下,ifcfg-ens33后面的数字是随机产生的。]


2.将ONBOOT改为yes


OnBOOT=yes


3. 重新启动网络


service network restart


4.测试


ping baidu.com


补:如果还失效(估计不会失效)


1.修改resolv.conf


vim /etc/resolv.conf


2.添加nameserver


nameserver 8.8.8.8


补镜像源


参考:https://lug.ustc.edu.cn/wiki/mirrors/help/centos


1.首先备份CentOS-Base.repo


mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup


2.修改CentOS-Base.repo


vim /etc/yum.repos.d/CentOS-Base.repo


3.下载对应版本的CentOS-Base.repo, 放入/etc/yum.repos.d/


①这是CentOS 7的:


# CentOS-Base.repo


#


# The mirror system uses the connecting IP address of the client and the


# update status of each mirror to pick mirrors that are updated to and


# geographically close to the client. You should use this for CentOS updates


# unless you are manually picking other mirrors.


#


# If the mirrorlist= does not work for you, as a fall back you can try the


# remarked out baseurl= line instead.


#


#


[base]


name=CentOS-$releasever - Base


#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os


baseurl=http://mirrors.ustc.edu.cn/centos/$releasever/os/$basearch/


gpgcheck=1


gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7


#released updates


[updates]


name=CentOS-$releasever - Updates


# mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates


baseurl=http://mirrors.ustc.edu.cn/centos/$releasever/updates/$basearch/


gpgcheck=1


gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7


#additional packages that may be useful


[extras]


name=CentOS-$releasever - Extras


# mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras


baseurl=http://mirrors.ustc.edu.cn/centos/$releasever/extras/$basearch/


gpgcheck=1


gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7


#additional packages that extend functionality of existing packages


[centosplus]


name=CentOS-$releasever - Plus


# mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus


baseurl=http://mirrors.ustc.edu.cn/centos/$releasever/centosplus/$basearch/


gpgcheck=1


enabled=0


gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7


②这是CentOS 6的:


# CentOS-Base.repo


#


# The mirror system uses the connecting IP address of the client and the


# update status of each mirror to pick mirrors that are updated to and


# geographically close to the client. You should use this for CentOS updates


# unless you are manually picking other mirrors.


#


# If the mirrorlist= does not work for you, as a fall back you can try the


# remarked out baseurl= line instead.


#


#


[base]


name=CentOS-$releasever - Base - mirrors.ustc.edu.cn


baseurl=http://mirrors.ustc.edu.cn/centos/$releasever/os/$basearch/


#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os


gpgcheck=1


gpgkey=http://mirrors.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-6


#released updates


[updates]


name=CentOS-$releasever - Updates - mirrors.ustc.edu.cn


baseurl=http://mirrors.ustc.edu.cn/centos/$releasever/updates/$basearch/


#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates


gpgcheck=1


gpgkey=http://mirrors.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-6


#additional packages that may be useful


[extras]


name=CentOS-$releasever - Extras - mirrors.ustc.edu.cn


baseurl=http://mirrors.ustc.edu.cn/centos/$releasever/extras/$basearch/


#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras


gpgcheck=1


gpgkey=http://mirrors.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-6


#additional packages that extend functionality of existing packages


[centosplus]


name=CentOS-$releasever - Plus - mirrors.ustc.edu.cn


baseurl=http://mirrors.ustc.edu.cn/centos/$releasever/centosplus/$basearch/


#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus


gpgcheck=1


enabled=0


gpgkey=http://mirrors.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-6


#contrib - packages by Centos Users


[contrib]


name=CentOS-$releasever - Contrib - mirrors.ustc.edu.cn


baseurl=http://mirrors.ustc.edu.cn/centos/$releasever/contrib/$basearch/


#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib


gpgcheck=1


enabled=0


gpgkey=http://mirrors.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-6


 二、安装图形化界面


1.在命令行下 输入下面的命令来安装Gnome包。


yum groupinstall "GNOME Desktop" "Graphical Administration Tools"


2.更新系统的运行级别。


ln -sf /lib/systemd/system/runlevel5.target /etc/systemd/system/default.target


3.重启机器。启动默认进入图形界面。


reboot


 安装jdk


1.检索yum中有没有java1.8的包


yum list java-1.8*


2.开始安装


yum install java-1.8.0-openjdk* -y


三、 安装mysql


1、配置YUM源


在MySQL官网中下载YUM源rpm安装包:https://dev.mysql.com/downloads/repo/yum/


2.下载mysql源安装包


wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm


3. 安装mysql源


yum localinstall mysql57-community-release-el7-8.noarch.rpm


4.检查mysql源是否安装成功


yum repolist enabled | grep "mysql.*-community.*"


5.装MySQL


yum install mysql-community-server


6.启动MySQL服务


systemctl start mysqld


7.MySQL的启动状态


systemctl status mysqld


8.修改root本地登录密码


①mysql成之后,在/var/log/mysqld.log文件中给root生成了一个默认密码。通过下面的方式找到root默


码,然后登录mysql进行修改:


grep 'temporary password' /var/log/mysqld.log


2018-04-10T09:36:50.584915Z 1 [Note] A temporary password is generated for root@localhost: hdzu=Uc4tbIw




②mysql -u root -p


③ 修改密码


ALTER USER 'root'@'localhost' IDENTIFIED BY 'Kate1996.';





set password for 'root'@'localhost'=password('Kate1996.');


④密码验证关闭


vim /etc/my.cnf


[mysqld]


validate_password=off


systemctl restart mysqld


9.编码utf8mb4


①查看编码


SHOW VARIABLES LIKE 'character_set%';


② 在[mysqld]字段里加入character_set_server=utf8mb4


vi /etc/my.cnf


character_set_server=utf8mb4


init_cOnnect='SET NAMES utf8mb4'(好像没用)





[mysql]


default-character-set=utf8mb4


③重启mysql服务就生效


systemctl restart mysqld


10.远程连接


①创建用户


CREATE USER 'karl'@'222.88.236.161' IDENTIFIED BY 'karl';


②赋权


CREATE USER 'karl'@'222.88.236.161' IDENTIFIED BY 'karl';


GRANT ALL PRIVILEGES ON *.* TO 'karl'@'222.88.236.161' IDENTIFIED BY 'karl' WITH GRANT OPTION;


FLUSH PRIVILEGES;


③在[mysqld]字段里加入


bind-address = 0.0.0.0


④重启


service mysqld restart


在mysql控制台执行命令中的 'root'@'%' 可以这样理解: root是用户名,%是主机名或IP地址,这里的%代表任意主机或IP地址,你也可替换成任意其它用户名或指定唯一的IP地址;'MyPassword'是给授权用户指定的登录数据库的密码;另外需要说明一点的是我这里的都是授权所有权限,可以指定部分权限,GRANT具体操作详情见:http://dev.mysql.com/doc/refman/5.1/en/grant.html


8.开机启动


systemctl enable mysqld


systemctl daemon-reload


 四、安装ssh


yum install openssh-server


 五、tomcat8


1.建目录


mkdir tomcat8


2.解压


tar -zxvf ap.war


3.配置管理员


①修改Tomcatuser.xml











②修改,如无新建conf/Catalina/localhost/manager.xml 内容如下




docBase="${catalina.home}/webapps/manager">








1) 停止服务器 sudo ./shutdown.sh


2) 稍等至服务器彻底停掉,大约30秒后


3) 输入启动命令:sudo ./startup.sh


④上传war


http://192.168.47.129/manager/html


查看tomcat安装目录下的logs目录下的manager.2015-02-09.log文件可发现上传的部署文件超过了设定的大小,因此部署失败


FAIL - Deploy Upload Failed, Exception: org.apache.tomcat.util.http.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (53891399) exceeds the configured maximum (52428800)


解决:修改一个配置文件即可,配置文件位置:$tomcat_home\webapps\manager\WEB-INF\web.xml






http://192.168.47.129/manager/html


⑤路径设置





开启端口


firewall-cmd --zOne=public --add-port=8080/tcp --permanent


将发往80端口的请求转发到8080


firewall-cmd --add-forward-port=port=80:proto=tcp:toport=8080


重启防火墙


systemctl restart firewalld.service


 六、redis


1.设置Redis的仓库地址


yum install epel-release


2.安装redis


yum install redis


3.修改配置文件,监听所有的IP地址


vim /etc/redis.conf


bind 127.0.0.1


注释掉


#bind 127.0.0.1


3.启动redis


service redis start


如果需要设置开机自动启动


chkconfig redis on


另外:


如果需要redis配置认证密码


1.通过配置文件进行配置


yum方式安装的redis配置文件通常在/etc/redis.conf中,打开配置文件找到


#requirepass foobared


去掉行前的注释,并修改密码为所需的密码,保存文件


requirepass 123456


重启redis完成

推荐阅读
author-avatar
无石笑_987
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有