jds jds0000.
chmod -R 777 给文件权限777
1.下载ubuntu镜像(18.04.4);
2.下载UltraISO启动盘制作工具;
(https://blog.csdn.net/baidu_36602427/article/details/86548203)
3.到服务器安装ubuntu;
4.安装完成,apt-get安装vim;
apt-get update
在修改/etc/apt/sources.list或/etc/apt/preferences之后运行该命令。
此外您需要定期运行这一命令以确保您的软件包列表是最新的。
apt-get install vim
5.添加Ip
(https://blog.csdn.net/davidhzq/article/details/102991577)
进入/etc/netplan/目录,找到yaml文件;
输入命令sudo gedit /etc/netplan/01-network-manager-all.yaml打开配置文件,
network:
version: 2
renderer: networkd
ethernets:
#网卡名称,先用ifconfig查清楚要更改的网卡名字
ens33:
addresses: [192.168.1.36/24]
gateway4: 192.168.1.1
nameservers:
addresses: [8.8.8.8]
其中/24是子网掩码,要添加不然报错(https://blog.csdn.net/m0_37052320/article/details/100107557,https://doc.m0n0.ch/quickstartpc/intro-CIDR.html)
6.安装ssh等工具
(开启ssh服务:https://www.jianshu.com/p/4b50b55ebb4d
https://blog.csdn.net/weixin_42739326/article/details/82260588
root用户下,非root用户所有指令前加sudo)
ps -e | grep ssh(查看ssh服务是否开启)
apt-get install openssh-client(安装ssh客户端程序)
apt-get install openssh-server(安装ssh服务端程序)
service ssh start 或者 /etc/init.d/ssh start(开启ssh服务)
service ssh stop 或者 /etc/init.d/ssh stop(关闭ssh服务)
指令 1:ps -e | grep ssh( 查看ssh服务是否开启)
)
5.安装docker;(https://blog.csdn.net/fei2636/article/details/79384969)
apt-get install -y docker.io
6.在docker容器内下载各种镜像
docker search nginx
docker search redis
docker pull redis
docker search mysql(查找镜像)
docker pull mysql(下载镜像)
docker pull nacos
docker pull rabbitmq
docker ps----查看正在运行的容器
docker stop 容器ID----停止容器
完美解决systemctl start docker.service启动容器报错
vim /etc/docker/daemon.json
在/etc/docker/目录下创建daemon.json,添加如下内容:
{
“insecure-registries” : [“storage-shshukun:5050”],
“registry-mirrors”: [“https://wwuqa7no.mirror.aliyuncs.com”],
“runtimes”: {
“nvidia”: {
“path”: “nvidia-container-runtime”,
“runtimeArgs”: []
}
}
}
再运行systemctl start docker.service命令进行重启即可。
sudo systemctl daemon-reload
systemctl restart docker
启动mysql
(https://jingyan.baidu.com/article/8275fc86db114007a03cf6a7.html)
docker run -itd --name mysql-test -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql
docker run -p 3306:3306 --name mymysql -v $PWD/conf:/etc/mysql/conf.d -v $PWD/logs:/logs -v $PWD/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -d mysql
8.0+
ps aux | grep mysqld 查看进程
ALTER USER ‘root’@’%’ IDENTIFIED BY ‘123456’ PASSWORD EXPIRE NEVER;
ALTER USER ‘root’@’%’ IDENTIFIED WITH mysql_native_password BY ‘123456’;
flush privileges;
grant all privileges on . to root@"%" identified by “123456”;
flush privileges;
5.6
UPDATE user SET Password=PASSWORD(‘123456’) where USER=‘root’;
grant all privileges on . to root@"%" identified by “123456”;
flush privileges;
https://www.cnblogs.com/yy-cola/p/11226924.html
启动nacos — https://www.jianshu.com/p/3d3e17bc629f (仅部署nacos-server,不使用prometheus/grafana等监控组件)
1、docker pull nacos/nacos-server
2、mkdir -p /home/nacos/logs/ #新建logs目录
3、mkdir -p /home/nacos/init.d/
4、vim /home/nacos/init.d/custom.properties #修改配置文件
5、server.contextPath=/nacos
server.servlet.contextPath=/nacos
server.port=8848
spring.datasource.platform=mysql
db.num=1
db.url.0=jdbc:mysql://xx.xx.xx.x:3306/nacos_devtest_prod?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true
db.user=user
db.password=pass
nacos.cmdb.dumpTaskInterval=3600
nacos.cmdb.eventTaskInterval=10
nacos.cmdb.labelTaskInterval=300
nacos.cmdb.loadDataAtStart=false
management.metrics.export.elastic.enabled=false
management.metrics.export.influx.enabled=false
server.tomcat.accesslog.enabled=true
server.tomcat.accesslog.pattern=%h %l %u %t “%r” %s %b %D %{User-Agent}i
nacos.security.ignore.urls=/,//*.css,//.js,/**/.html,//*.map,//.svg,/**/.png,//*.ico,/console-fe/public/,/v1/auth/login,/v1/console/health/,/v1/cs/,/v1/ns/,/v1/cmdb/,/actuator/,/v1/console/server/
nacos.naming.distro.taskDispatchThreadCount=1
nacos.naming.distro.taskDispatchPeriod=200
nacos.naming.distro.batchSyncKeyCount=1000
nacos.naming.distro.initDataRatio=0.9
nacos.naming.distro.syncRetryDelay=5000
nacos.naming.data.warmup=true
nacos.naming.expireInstance=true
6、docker run \ --name nacos -d \ -p 8848:8848 \ --privileged=true \ --restart=always \ -e JVM_XMS=256m \ -e JVM_XMX=256m \ -e MODE=standalone \ -e PREFER_HOST_MODE=hostname \ -v /etc/docker/nacos/logs \ -v /etc/docker/nacos/init.d/custom.properties:/home/nacos/init.d/custom.properties \ nacos/nacos-server
7.Docker 配置redis
https://blog.csdn.net/weixin_42456466/article/details/87270959 (更新 最近发现服务器被挖矿病毒入侵了 很有可能是因为redis没有设置密码的原因!)
1.获取redis镜像 docker pull redis
2、指定版本号: docker pull redis:4.0.9 (不加版本号默认获取最新版本,也可以使用 docker search redis 查看镜像来源)
3.然后启动容器,做映射
①创建配置文件目录存放redis.conf,文件从官网下载。
②创建文件夹,新建配置文件贴入从官网下载的配置文件并修改
4、mkdir /usr/local/docker
5、vi /usr/local/docker/redis.conf
6、docker启动redis命令
docker run -p 6379:6379 --name myredis -v /usr/local/docker/redis.conf:/etc/redis/redis.conf -v /usr/local/docker/data:/data -d redis redis-server /etc/redis/redis.conf --appendonly yes
7、命令解释说明:
-p 6379:6379 端口映射:前表示主机部分,:后表示容器部分。
–name myredis 指定该容器名称,查看和进行操作都比较方便。
-v 挂载目录,规则与端口映射相同。
为什么需要挂载目录:个人认为docker是个沙箱隔离级别的容器,这个是它的特点及安全机制,不能随便访问外部(主机)资源目录,所以需要这个挂载目录机制。
-d redis 表示后台启动redis
redis-server /etc/redis/redis.conf 以配置文件启动redis,加载容器内的conf文件,最终找到的是挂载的目录/usr/local/docker/redis.conf
8.docker内安装Nginx并挂载本地目录
https://www.cnblogs.com/ghl1024/p/9022890.html
1、从hup上pull镜像
docker pull nginx
2、创建将要挂载的目录
mkdir -p /data/nginx/{conf,conf.d,html,logs}
3、创建配置文件
4、vim /data/nginx/conf/nginx.conf
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
5、vim /data/nginx/conf.d/default.conf
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
location / {
#root /data/nginx/html;
root /usr/share/nginx/html;
index index.html index.htm;
#autoindex on;
#try_files $uri /index/index/page.html;
#try_files $uri /index/map/page.html;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
6、vim /data/nginx/html/index.html
<script>
setInterval("document.getElementById('datetime').innerHTML=new Date().toLocaleString();", 1000);
</script>
7、启动容器
#将容器中nginx的80端口映射到本地的81端口
docker run --name nginx81 -d -p 80:80 -v /data/nginx/html:/usr/share/nginx/html -v /data/nginx/conf/nginx.conf:/etc/nginx/nginx.conf -v /data/nginx/logs:/var/log/nginx -v /data/nginx/conf.d:/etc/nginx/conf.d -d nginx:latest
8、查看启动的容器
docker ps
9、网页访问nginx
9.docker 内安装fdfs文件服务器并配置Nginx
https://www.cnblogs.com/provence666/p/10987156.html
开启一个fastdfs客户端
docker run -tid --name fdfs_sh --net=host season/fastdfs sh (找不到stoge.conf)
docker run -dti --network=host --name storage -e TRACKER_SERVER=68.9.9.90:22122 -v /var/fdfs/storage:/var/fdfs -v /etc/localtime:/etc/localtime delron/fastdfs storage
docker 内安装rabbitmq
https://www.jianshu.com/p/14ffe0f3db94 只(pull了rabbitmq)
文件/图片存放路径: /var/fdfs/storage/data
修改服务器密码
passwd
U734F$e*bDX&%ioU
10.服务器内搭建elk
https://www.cnblogs.com/huaweicloud/p/11861573.html
出错: Unable to find image ‘hello-world:latest’ locally docker: Error response from daemon
用ubuntu配置好docker且下载好后,运行hello-world后出错
运行: sudo docker run hello-world
出错:
Unable to find image ‘hello-world:latest’ locally
docker: Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers).
See ‘docker run --help’.
docker在本地没有找到hello-world镜像,也没有从docker仓库中拉取镜像,出项这个问题的原因:是应为docker服务器再国外,我们在国内
无法正常拉取镜像,所以就需要我们为docker设置国内阿里云的镜像加速器;
需要修改配置文件 /etc/docker/daemon.json 如下
{
“registry-mirrors”: [“https://alzgoonw.mirror.aliyuncs.com”]
}
或者
如下内容:
{
“insecure-registries” : [“storage-shshukun:5050”],
“registry-mirrors”: [“https://wwuqa7no.mirror.aliyuncs.com”],
“runtimes”: {
“nvidia”: {
“path”: “nvidia-container-runtime”,
“runtimeArgs”: []
}
}
}
配置文件daemmon,json添加阿里云镜像地址,保存并退出,并且重启docker服务(systemctl restart docker)
Logstash
docker run -it --rm -v /tmp/nginx/logs/access.log:/tmp/nginx/logs/access.log docker.io/logstash:latest -f /config-dir/logstash.conf
-f 不是docker的参数,是logstash的参数,这条命令已交互模式启动logstash,后面的-f是让logstash加载指定的conf文件
11.修改系统时间
sudo ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
查看时间 date
查看时区 date -R
修改时区 tzselect
修改日期 sudo date -s MM/DD/YY
修改时间 sudo date -s hh:mm:ss
最后更新 CMOS
sudo hwclock --systohc //非常重要,如果没有这一步的话,后面时间还是不准
12.Docker内替换源
https://learnku.com/articles/26066
13.Linux 上安装配置 VNC Server
https://blog.csdn.net/llag_haveboy/article/details/84960479
https://blog.csdn.net/kldyutou/article/details/86129634
重启vnc vncserver
docker
使用docker 出现Error response from daemon: Conflict. The container name “***” is already in use
解决方法:
(1)给容器换一个名字, 比如说 docker run -it --name=mycentos2 centos:7 /bin/bash, 可以解决问题.
(2)将原来的容器删除
查询当前容器:docker container ls -all
在这里插入图片描述
删除当前容器:docker container rm mycentos(提示: 这一步要确定删除容器没问题的情况下, 才可以做)