Centos 7安装微服务环境

Mysql

官网安装说明:A Quick Guide to Using the MySQL Yum Repository
MySQL 5.6 (GA)

sudo rpm -Uvh mysql80-community-release-el7-1.noarch.rpm

sudo yum-config-manager --enable mysql56-community

遇到问题可以先卸载之前的相关软件

启动Mysql

sudo service mysqld start

# 重启
service mysqld restart

# 停止
service mysqld stop

查看Mysql状态

sudo service mysqld status

MySQL重置root密码

update user set authentication_string=password(‘密码’) where user=‘root’;

Host ‘115.236.61.42’ is not allowed to connect to this MySQL server

查看用户
use mysql;
select host,user from user;

# host有%才能远程访问
select host,user from user;
+-----------+------+
| host      | user |
+-----------+------+
| %         | root |
| 127.0.0.1 | root |
| ::1       | root |
| localhost | root |
+-----------+------+

刷新
FLUSH PRIVILEGES;

强制停止

mysqladmin -uroot -p -h127.0.0.1 --protocol=tcp shutdown

安装JDK1.8

安装maven

wget http://mirrors.hust.edu.cn/apache/maven/maven-3/3.5.4/binaries/apache-maven-3.5.4-bin.tar.gz

# 解压到opt目录
tar -xvzf /home/downloads/apache-maven-3.5.4-bin.tar.gz -C /opt

# 编辑系统配置文件 /etc/profile   
#set Maven environment
export MAVEN_HOME=/opt/apache-maven-3.5.4
export PATH=$MAVEN_HOME/bin:$PATH

# 重新加载系统配置文件
source /etc/profile

/opt/apache-maven-3.5.4/conf/settings.xml

nexus

官网

解压到opt目录

tar -xvzf /home/downloads/nexus-3.14.0-04-unix.tar.gz -C /opt

/opt/nexus-3.14.0-04/bin
./nexus {start|stop|run|run-redirect|status|restart|force-reload}

修改端口

By default, the repository manager listens on port 8081. You can change this port, by changing the value in the $NEXUS_HOME/conf/nexus.properties file shown in Contents of conf/nexus.properties . To change the port, stop the repository manager, change the value of application-port in this file, and then restart it. Once you do this, you should see a log statement in $NEXUS_HOME/logs/wrapper.log telling you that the repository manager is listening on the altered port.

$NEXUS_HOME/conf/nexus.properties

# Sonatype Nexus
# ==============
# This is the most basic configuration of Nexus.

# Jetty section
application-port=8081
application-host=0.0.0.0
nexus-webapp=${bundleBasedir}/nexus
nexus-webapp-context-path=/nexus
# Nexus section
nexus-work=${bundleBasedir}/../sonatype-work/nexus
runtime=${bundleBasedir}/nexus/WEB-INF
启动
# 1.更改目录所有者命令:
# chown -R 用户名称 目录名称
# 2.更改目录权限命令:
# chmod -R 755 目录名称
chown -R www /opt/sonatype-work
chmod -R 755 /opt/sonatype-work

# 安装目录 /opt/nexus-3.14.0-04/bin/
# 进入bin目录,运行如下命令启动(&符号表示后台启动):
./nexus run &
开放8081端口
firewall-cmd --zone=public --add-port=8081/tcp --permanent
firewall-cmd --reload

访问用户界面

http://localhost:8081/

Redis

安装、启动说明
tar -xvzf /home/downloads/redis-5.0.0.tar.gz -C /usr/local/
解压后进入redis目录,运行 make install
进入 /usr/local/redis-5.0.0/src

启动

#加上`&`号使redis以后台程序方式运行  
./redis-server &  

GitLab

备份

# 可以将此命令写入crontab,以实现定时备份
# 备份的数据会存储在/var/opt/gitlab/backups,用户通过自定义参数 gitlab_rails['backup_path'],改变默认值。
/usr/bin/gitlab-rake gitlab:backup:create

恢复

# 停止unicorn和sidekiq,保证数据库没有新的连接,不会有写数据情况 
sudo gitlab-ctl stop unicorn 
sudo gitlab-ctl stop sidekiq 

# 进入备份目录进行恢复,1476900742为备份文件的时间戳 
cd /var/opt/gitlab/backups gitlab-rake gitlab:backup:restore BACKUP=1476900742 
cd - 

# 启动unicorn和sidekiq 
sudo gitlab-ctl start unicorn 
sudo gitlab-ctl start sidekiq

GitLab常用命令

gitlab-ctl start # 启动所有 gitlab 组件; 
gitlab-ctl stop # 停止所有 gitlab 组件; 
gitlab-ctl restart # 重启所有 gitlab 组件; 
gitlab-ctl status # 查看服务状态; 
vim /etc/gitlab/gitlab.rb # 修改gitlab配置文件; 
gitlab-ctl reconfigure # 重新编译gitlab的配置; 
gitlab-rake gitlab:check SANITIZE=true --trace # 检查gitlab; 
gitlab-ctl tail # 查看日志; 
gitlab-ctl tail nginx/gitlab_access.log
开放8888端口
firewall-cmd --zone=public --add-port=8888/tcp --permanent
firewall-cmd --reload

Let’s Encrypt 证书

安装步骤

  1. Nginx
  2. Certbot
  3. PHP 使用支持通配符的证书,由《深入浅出HTTPS:从原理到实战》作者分享的简单安装方法需要用

Nginx

利用yum源安装nginx

rpm -ivh https://nginx.org/packages/centos/7/x86_64/RPMS/nginx-1.14.0-1.el7_4.ngx.x86_64.rpm

报错

错误:依赖检测失败:
	libcrypto.so.10(OPENSSL_1.0.2)(64bit) 被 nginx-1:1.14.0-1.el7_4.ngx.x86_64 需要

[解决方法](yum -y install openssl openssl-devel)

yum -y install openssl openssl-devel

# 继续安装
# 查看
yum info nginx

# 安装
yum install nginx

# 启动
service nginx start
# (start, stop, restart, try-restart, reload, force-reload, status)

所有的nginx配置文件都在 /etc/nginx下
nginx请求转发至tomcat(端口转发)

Certbot

# yum安装后有这个文件/usr/bin/certbot
# 测试是否有错误
$ ./certbot certonly  -d *.aoeai.com --manual --preferred-challenges dns  --manual-auth-hook /脚本目录/au.sh --dry-run  

# 实际申请
$ ./certbot certonly  -d *.aoeai.com --manual --preferred-challenges dns  --manual-auth-hook /脚本目录/au.sh    

# 加入 crontab
# 编辑文件 /etc/crontab
1 1 */1 * * root certbot-auto renew --manual --preferred-challenges dns  --manual-auth-hook /脚本目录/au.sh

# 重启服务
service crond restart

开启443端口
firewall-cmd --zone=public --add-port=443/tcp --permanent

查看错误日志 /var/log/nginx/error.log; 以定位问题

Jenkins

java -jar jenkins.war --httpPort=8082

firewall-cmd --zone=public --add-port=8082/tcp --permanent
firewall-cmd --reload

安装前最好可以设置一个速度较快的插件镜像

部署项目

执行sudo

# /etc/sudoers文件添加,www为启动Jenkins的用户
www  ALL=(ALL)  NOPASSWD: ALL
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值