nacos部署 与 redis编译安装

一. 单机版

参考

https://www.jianshu.com/p/9f695cf38cf3
https://www.cnblogs.com/code-duck/p/13210280.html

环境

centos7LTS ubuntu18.04LTS

安装包

nacos1.1.0 安装包:

https://github.com/alibaba/nacos/releases
https://github.com/alibaba/nacos/releases/download/1.1.0/nacos-server-1.1.0.tar.gz

步骤概览

  • 部署jdk8的环境
  • 安装mysql5.7数据库
  • 导入nacos配置sql文件
  • 修改nacos连接数据库配置
  • jdk8环境部署参考 / 参考 zznn另一篇博客:https://www.wgstart.com/help/docs7.html

①. 获取压缩包并解压到指定目录

1
2
3
4
5
#常用软件安装
yum install -y wget vim
#将nacos下载并解压到opt目录
wget https://github.com/alibaba/nacos/releases/download/1.1.0/nacos-server-1.1.0.tar.gz
tar -xvf ./nacos-server-1.1.0.tar.gz -C /opt

配置数据库

1
2
3
4
5
6
7
8
9
# 数据库配置 修改root密码
ALTER USER root@localhost IDENTIFIED BY '123456';
# 创建数据库
create database nacos_config;
# 导入压缩包自带SQL文件到nacos_config数据库
show databases;
use nacos_config;
source /opt/nacos/conf/nacos-mysql.sql;
show tables;

②. 修改配置文件并启动nacos ( 按照实际填写数据库信息 )

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 备份application.properties 
cp /opt/nacos/conf/application.properties /opt/nacos/conf/application.properties.bf
# 修改application.properties配置文件
vim /opt/nacos/conf/application.properties

### 添加mysql数据库配置信息
spring.datasource.platform=mysql

# 添加
### Count of DB:
db.num=1

# 添加
### Connect URL of DB:
db.url.0=jdbc:mysql://127.0.0.1:3306/nacos_config?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
db.user=root
db.password=123456

启动nacos

1
2
# 启动nacos
cd /opt/nacos/bin && sh startup.sh -m standalone

效果

部署完成:
浏览器访问地址:http://ip:port:8848/nacos 输入默认账号密码:nacos/nacos
即可看到

image-20230801170244765

二. 集群版nacos较为简单此处略

参考:https://blog.csdn.net/sunxiaoju/article/details/115313049

三. redis编译安装

1. Redis配置远程设置密码等 > 传送门

2. centos7ubuntu通用编译安装脚本

参考:https://www.cnblogs.com/joyny/p/11555966.html

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
#环境:centos7 ubuntu18.04
#软件:redis5.0.5
#https://www.cnblogs.com/joyny/p/11555966.html
centos_app="wget gcc gcc-c++ make automake"
ubuntu_app="build-essential ca-certificates sshpass telnet vim wget curl unzip git gcc make lrzsz nmon smartmontools ntpdate tmux bc"
centos_download_redis() {
yum install ${centos_app} -y
cd /opt && wget http://download.redis.io/releases/redis-5.0.5.tar.gz
tar -zxvf redis-5.0.5.tar.gz
cd /opt/redis-5.0.5/ && make && make install
}
ubuntu_download_redis() {
apt install ${ubuntu_app} -yq
cd /opt && wget http://download.redis.io/releases/redis-5.0.5.tar.gz
tar -zxvf redis-5.0.5.tar.gz
cd /opt/redis-5.0.5/ && make && make install
}
system_redis() {
cat > /etc/systemd/system/redis.service << eric
[Unit]
Description=redis

[Service]
#Type=forking
Type=simple
#PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStart=/opt/redis-5.0.5/src/redis-server /opt/redis-5.0.5/redis.conf
ExecReload=/bin/kill -SIGHUP \$MAINPID
ExecStop=/bin/kill -SIGINT \$MAINPID
#Restart=always
#RestartSec=5
#StartLimitInterval=0

[Install]
WantedBy=multi-user.target
eric
systemctl daemon-reload
systemctl start redis.service
systemctl enable redis.service
systemctl restart redis.service
systemctl status redis.service
}
start_redis() {
echo -e "\033[36m 运行redis \033[0m"
/opt/redis-5.0.5/src/redis-server /opt/redis-5.0.5/redis.conf &
ss -ntulp |grep redis
}
main() {
centos_download_redis
#ubuntu_download_redis (根据版本选择注释条件)
system_redis # ubuntu与centos通用
#start_redis # 原始启动此项注释
}
main

四. 效果

Redis效果

image-20231130184240355

fighting!