Linux环境杂记

FerryBoatMan环境部署

Gitee

文章目录

  • FerryBoatMan环境部署
  • Nginx安装
  • Consul安装启动
  • Docker环境安装
  • 一、rabbitmq
  • 二、ferryboatman/mysql:2.0.0
  • 三、ferryboatman/zipkin:2.0.0
  • 四、fastdfs
  • 五、ferryboatman/mongo:2.0.0

Nginx安装

  242  05/12/21 11:37:00 wget http://nginx.org/download/nginx-1.16.1.tar.gz
  243  05/12/21 11:38:14 tar -xvf nginx-1.16.1.tar.gz
  244  05/12/21 11:38:22 ls
  245  05/12/21 11:39:21 cd /opt/Nginx
  246  05/12/21 11:39:26 mkdir Nginx-1.16.1_install
  247  05/12/21 11:39:31 cd nginx-1.16.1
  248  05/12/21 11:39:47 ls
  249  05/12/21 11:39:50 ./configure --prefix=/opt/Nginx/Nginx-1.16.1_install
  250  05/12/21 11:39:59 cd ..
  251  05/12/21 11:40:00 ls
  252  05/12/21 11:40:02 ./configure --prefix=/opt/Nginx/Nginx-1.16.1_install
  253  05/12/21 11:40:20 cd nginx-1.16.1
  254  05/12/21 11:40:23 ./configure --prefix=/opt/Nginx/Nginx-1.16.1_install
  255  05/12/21 11:40:36 make
  256  05/12/21 11:40:57 make install
  257  05/12/21 11:41:05 make install
  258  05/12/21 11:41:11 ls
  259  05/12/21 11:41:21 cd conf
  260  05/12/21 11:41:22 ls
  261  05/12/21 11:41:30 vim nginx.conf 

Consul安装启动

1.下载consul_0.7.5_linux_amd64.zip

wget https://releases.hashicorp.com/consul/0.7.5/consul_0.7.5_linux_amd64.zip

2.解压consul_0.7.5_linux_amd64.zip

unzip consul_0.7.5_linux_amd64.zip

3. 后台启动
nohup ./consul agent -dev -client 0.0.0.0 -ui &

4. 查看端口占用情况
netstat -anp|grep 8500 

Docker环境安装

点击这里
环境端口开放
Linux环境杂记_第1张图片

一、rabbitmq

如果没有镜像直接run会自动拉取镜像,不指定版本会拉取最新版本

docker run -d --hostname my-rabbit --name rabbit -p 15672:15672 -p 5672:5672 rabbitmq:management

安装后测试链接
http://ip:15672

二、ferryboatman/mysql:2.0.0

docker pull ferryboatman/mysql:2.0.0
docker run -itd --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=ferryboatman ferryboatman/mysql:2.0.0

三、ferryboatman/zipkin:2.0.0

docker pull ferryboatman/zipkin:2.0.0

docker run --name zipkin -d -p 9411:9411 ferryboatman/zipkin:2.0.0

安装后测试链接
http://ip/zipkin/

四、fastdfs

自己的打包镜像有问题,还是使用网上找到的一个惊喜吧

[root@VM-16-17-centos ~]# docker run -d --restart=always --privileged=true --net=host --name=fastdfs -e IP=121.5.129.126 -e WEB_PORT=80 -v /usr/local/fastdfs:/var/local/fdfs registry.cn-beijing.aliyuncs.com/tianzuo/fastdfs
40df4c0ed24c1c434119afdf663abedf1d64f83aafe9f9722ecdd8ee38dd671a
[root@VM-16-17-centos ~]# docker exec -it fastdfs /bin/bash
bash-4.4# echo "Hello FastDFS!">index.html
bash-4.4# fdfs_test /etc/fdfs/client.conf upload index.html
This is FastDFS client test program v5.12

Copyright (C) 2008, Happy Fish / YuQing

FastDFS may be copied only under the terms of the GNU General
Public License V3, which may be found in the FastDFS source kit.
Please visit the FastDFS Home Page http://www.csource.org/ 
for more detail.

[2021-12-05 04:55:26] DEBUG - base_path=/var/local/fdfs/storage, connect_timeout=30, network_timeout=60, tracker_server_count=1, anti_steal_token=0, anti_steal_secret_key length=0, use_connection_pool=0, g_connection_pool_max_idle_time=3600s, use_storage_id=0, storage server id count: 0

tracker_query_storage_store_list_without_group: 
	server 1. group_name=, ip_addr=121.5.129.126, port=23000

group_name=group1, ip_addr=121.5.129.126, port=23000
storage_upload_by_filename
group_name=group1, remote_filename=M00/00/00/CgAQEWGsRj6AcX7AAAAADwL5vO404.html
source ip address: 10.0.16.17
file timestamp=2021-12-05 04:55:26
file size=15
file crc32=49921262
example file url: http://121.5.129.126/group1/M00/00/00/CgAQEWGsRj6AcX7AAAAADwL5vO404.html
storage_upload_slave_by_filename
group_name=group1, remote_filename=M00/00/00/CgAQEWGsRj6AcX7AAAAADwL5vO404_big.html
source ip address: 10.0.16.17
file timestamp=2021-12-05 04:55:26
file size=15
file crc32=49921262
example file url: http://121.5.129.126/group1/M00/00/00/CgAQEWGsRj6AcX7AAAAADwL5vO404_big.html
bash-4.4# exit
exit

五、ferryboatman/mongo:2.0.0

docker pull ferryboatman/mongo:2.0.0

docker run -itd --name mongo -p 27017:27017 ferryboatman/mongo:2.0.0 --auth
//进入容器
docker exec -it 9ff342ce96fd mongo admin

// 创建用户
> db.createUser({ user: 'admin', pwd: 'hcz123456', roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] });
Successfully added user: {
	"user" : "admin",
	"roles" : [
		{
			"role" : "userAdminAnyDatabase",
			"db" : "admin"
		}
	]
}
db.auth('admin','admin')
1
> show dbs
admin   0.000GB
config  0.000GB
local   0.000GB
> db.createUser(
...     {
...         user: "hcz",
...         pwd: "hcz123456",
...         roles: [ {role:"dbOwner", db:"ferryGossip"} ]
...     }
...  )
Successfully added user: {
	"user" : "hcz",
	"roles" : [
		{
			"role" : "dbOwner",
			"db" : "ferryGossip"
		}
	]
}


> db.auth("admin","hcz123456")
1
> show dbs
admin   0.000GB
config  0.000GB
local   0.000GB

latest

docker pull mongo:latest
mkdir -p /root/mongo/{data,conf,backup}
docker run --name=mongodb --restart=always -p 27017:27017 -d  -v /root/mongo/data:/data/db -v /root/mongo/backup:/data/backup -v /root/mongo/conf:/data/configdb mongo --auth
docker exec -it mongodb mongo admin

db.createUser({user:'admin',pwd:'你的密码',roles:[{role:'root',db:'admin'}],})
db.auth('admin','密码')
#读取权限的账户
db.createUser({ user: 'test', pwd: '你的密码', roles: [ { role: "readWrite", db: "elec_safe" } ] });
db.auth("test","密码");`

# 六、redis

docker pull redis


docker run --name redis -p 6379:6379 -d redis:latest



示例:pandas 是基于NumPy 的一种工具,该工具是为了解决数据分析任务而创建的。



# 二、Linux其他相关命令
## 1.命令

代码如下(示例):



```c
 // 查看内存占用 20个
[root@VM-16-17-centos ~]# ps auxw|head -1;ps auxw|sort -rn -k4|head -20

// 启动命令  后台启动,日志文件输入到logs.txt
[root@VM-16-17-centos ~]# nohup java -jar Ferry-consul.jar >logs.txt &

// 启动docker
[root@VM-16-17-centos ~]# systemctl start docker

// 显示运行在系统上的所有进程
[root@VM-16-17-centos ~]# ps -ef
 
// 进入容器acbce180dfa3内部
[root@VM-16-17-centos ~]# docker exec -it acbce180dfa3 /bin/bash

// 查看后台运行的进程 
[root@VM-16-17-centos ~]# jobs 

// 排查日志相关
// 后50行日志
cat -n info-appender.log | tail -n 50
//关键字查看后20行
cat -n info-appender.log | grep "大方" -A 20
//关键字查看前20行
cat -n info-appender.log | grep "大方" -B 20
//关键字查看前后20行
cat -n info-appender.log | grep "大方" -C 20

//从第10行开始,显示20行
tail -n +10表示查询10行之后的日志
//head -n 20 则表示在前面的查询结果里再查前20条记录
cat -n info-appender.log |tail -n +10|head -n 20

//时间点日志
grep '2021-11-18 11:36:20' info-appender.log

sed -n '/2021-11-18 11:36:12/,/2021-11-18 11:36:36/p' info-appender.log


你可能感兴趣的:(docker,linux,nginx,运维)