前言
记录一些常用安装包
epel yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
systemctl的.service目录
/lib/systemd/system/
解决方案
jdk1.8
# yum install java-1.8.0-openjdk-devel
mongodb4.0
# cd /etc/yum.repos.d
# vim mongodb-org-4.0.repo
或
# vim /etc/yum.repos.d/mongodb-org-4.0.repo
[mongodb-org-4.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc
# yum list |grep mongodb
# yum install -y mongodb-org
# systemctl start mongod.service
# vim /etc/mongod.conf
- 使用秘钥
security:
authorization: enabled
- 创建用户
# mongo --port 端口
# db.auth("用户","密码") 默认没有
# show users; 查询当前库账户
//其他数据库
# use yapi(欲创建数据名称)
# db.createUser({user:"root",pwd:"root",roles:[{ role: "userAdmin", db: "yapi" },{ role: "dbAdmin", db: "yapi" },{ role: "dbOwner", db: "yapi" }]})
- docker systemctl 中无法启动问题
[Unit]
Description=MongoDB Database Server
Documentation=https://docs.mongodb.org/manual
After=network.target
[Service]
#User=mongod //注释
#Group=mongod //注释
Type=forking
Environment="OPTIONS=-f /etc/mongod.conf"
EnvironmentFile=-/etc/sysconfig/mongod
ExecStart=/usr/bin/mongod $OPTIONS
ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb
ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb
ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb
#PermissionsStartOnly=true //注释
#PIDFile=/var/run/mongodb/mongod.pid //注释
# file size
LimitFSIZE=infinity
# cpu time
LimitCPU=infinity
# virtual memory size
LimitAS=infinity
# open files
LimitNOFILE=64000
# processes/threads
LimitNPROC=64000
# locked memory
LimitMEMLOCK=infinity
# total threads (user+kernel)
TasksMax=infinity
TasksAccounting=false
# Recommended limits for for mongod as specified in
# http://docs.mongodb.org/manual/reference/ulimit/#recommended-settings
[Install]
WantedBy=multi-user.target
redis
# yum install -y redis
# systemctl start redis
# vim /etc/redis.conf
requirepass 秘钥
mysql
# yum install -y mariadb-server
# systemctl start mariadb.service
#vim /etc/my.cnf
- 端口配置
[client-server]
port=30000
- 命令操作
show databases;
use mysql;
show tables;
update user set host='%' where host = 'localhost';
update user set password=PASSWORD('我是秘钥') where user='root'
- 重启mariadb生效(外部链接)
mysql -p
- 配置binlog,查询是否开启
show variables like 'log_%';
# 文件mariadb-server.cnf
[mysqlId]
...
server_id=2
log_bin=mysql-bin
binlog_format=ROW
minio
官网
wget https://dl.min.io/server/minio/release/linux-amd64/minio
export MINIO_ACCESS_KEY=账户
export MINIO_SECRET_KEY=秘钥
chmod +x minio
./minio server --address 0.0.0.0:31000 /存放路径
- sh
#!/bin/sh
export MINIO_ACCESS_KEY=账户
export MINIO_SECRET_KEY=秘钥
./minio server --address 0.0.0.0:31000 /home/zmj/minio/storage
systemctl管理 /usr/lib/systemd/system
#!/bin/sh
cd /路径
./minio server --address 0.0.0.0:31000
systemctl servcie
[Unit]
Description=minio
After=network.target
[Service]
#Type=sample
#User=minio
#Group=minio
ExecStart=/home/路径/minio.sh
#ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
[Install]
WantedBy=multi-user.target
nginx
- yum源安装
# systemctl start nginx
# systemctl reload nginx
- 路径
# cd /etc/nignx
- 重要配置
try_files $uri $uri/ /index.html; #这句很重要
- 其他配置
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /home/nginx/80;
rewrite ^(.*)$ https://$host$1;
location / {
try_files $uri $uri/ /index.html;
}
location /minio/ {
proxy_pass http://localhost:30005/minio/;
}
location /authentication/ {
proxy_pass http://localhost:30005/authentication/;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
server {
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
server_name _;
root /home/nginx/80;
ssl_certificate "ssl/8598701_www.blogzmj.top.pem"; #配置目录加ssl文件
ssl_certificate_key "ssl/8598701_www.blogzmj.top.key";
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 10m;
ssl_ciphers PROFILE=SYSTEM;
ssl_prefer_server_ciphers on;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
if ($request_filename ~* .*\.(?:htm|html)$)
{
add_header Cache-Control "private, no-store, no-cache, must-revalidate, proxy-revalidate";
}
try_files $uri $uri/ /index.html;
}
location /administrator/ {
proxy_pass http://localhost:30005;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
docker
# curl https://download.docker.com/linux/centos/docker-ce.repo -o /etc/yum.repos.d/docker.repo
# yum list | grep docker
# yum install -y docker-ce
# systemctl start docker
使用
//启动容器
# docker run --privileged=true -tid -p 28000:28000 -p 30000-30010:30000-30010 镜像ID /usr/sbin/init
//进入容器
# docker exec -it centos01 /bin/bash
#保存容器为镜像
# docker commit c98c757a4dd8 854702200/zmj_centos:2.1.0
#登录
# docker login
# 上传镜像
# docker push 854702200/zmj_centos:2.1.0
# 下拉镜像
# docker image pull 854702200/zmj_centos:2.1.0
# 保存镜像文件
# docker save -o centos.tar centos
# 加载镜像文件
# docker load --input centos.tar
- wget docker中的centos没有wget功能
yum -y install wget
- ncurses docker中的centos没有clear之类的相关功能
# yum install -y ncurses
- net-tools docker中的centos没有netstat功能
# yum install -y net-tools
- openssh链接
# yum install -y openssh-server
# vim /etc/ssh/sshd_config
--配置修改(长时间不操作断开问题)
ClientAliveInterval 60
ClientAliveCountMax 15
# systemctl enable sshd
# systemctl start sshd
- passwd秘钥
# yum install -y passwd
# echo “123456” |passwd --stdin root
nodejs
# yum install -y nodejs
- npm私有库
# npm i -g verdaccio@4.12.0
# verdaccio
- 私有库配置
#
# This is the default config file. It allows all users to do anything,
# so don't use it on production systems.
#
# Look here for more config file examples:
# https://github.com/verdaccio/verdaccio/tree/master/conf
#
# path to a directory with all packages
storage: ./storage
# path to a directory with plugins to include
plugins: ./plugins
web:
title: Klzy
# comment out to disable gravatar support
# gravatar: false
# by default packages are ordercer ascendant (asc|desc)
# sort_packages: asc
# convert your UI to the dark side
# darkMode: true
# translate your registry, api i18n not available yet
# i18n:
# list of the available translations https://github.com/verdaccio/ui/tree/master/i18n/translations
# web: en-US
auth:
htpasswd:
file: ./htpasswd
max_users: 1
# Maximum amount of users allowed to register, defaults to "+inf".
# You can set this to -1 to disable registration.
# max_users: 1000
# a list of other known repositories we can talk to
uplinks:
npmjs:
url: https://registry.npm.taobao.org/
agent_options:
keepAlive: true
maxSockets: 40
maxFreeSockets: 10
packages:
'@*/*':
# scoped packages
access: $all
publish: $authenticated
unpublish: $authenticated
proxy: npmjs
'**':
# allow all users (including non-authenticated users) to read and
# publish all packages
#
# you can specify usernames/groupnames (depending on your auth plugin)
# and three keywords: "$all", "$anonymous", "$authenticated"
access: $all
# allow all known users to publish/publish packages
# (anyone can register by default, remember?)
publish: $authenticated
unpublish: $authenticated
# if package is not available locally, proxy requests to 'npmjs' registry
proxy: npmjs
# You can specify HTTP/1.1 server keep alive timeout in seconds for incoming connections.
# A value of 0 makes the http server behave similarly to Node.js versions prior to 8.0.0, which did not have a keep-alive timeout.
# WORKAROUND: Through given configuration you can workaround following issue https://github.com/verdaccio/verdaccio/issues/301. Set to 0 in case 60 is not enough.
server:
keepAliveTimeout: 60
middlewares:
audit:
enabled: true
listen: 0.0.0.0:7000
# log settings
logs:
- { type: stdout, format: pretty, level: http }
#- {type: file, path: verdaccio.log, level: info}
#experiments:
# # support for npm token command
# token: false
# # support for the new v1 search endpoint, functional by incomplete read more on ticket 1732
# search: false
# # disable writing body size to logs, read more on ticket 1912
# bytesin_off: false
# This affect the web and api (not developed yet)
#i18n:
#web: en-US
- 私有库运行
# chmod 755
#!/bin/sh
cd /home/zmj
nohup verdaccio > verdaccio/verdacco.out
- yapi
# npm i -g yapi-cli
# yapi server
//步骤执行--无密码跳过此步骤
# mongo --port 端口
# use admin
# db.auth("账户","密码")
# use yapi
# db.createUser({user:"账户",pwd:"密码",roles:[{ role: "userAdmin", db: "yapi" },{ role: "dbAdmin", db: "yapi" },{ role: "dbOwner", db: "yapi" }]})
//切换到部署目录
# node vendors/server/app.js
# npm install -g pm2 --unsafe-perm
# pm2 start 欲运行项目
# pm2 save
# pm2 startup systemd
# pm2 ls
- nacos
[Unit]
Description=nacos
After=network.target
[Service]
Type=forking
User=nacos
Group=nacos
WorkingDirectory=/home/nacos
ExecStart=/home/nacos/nacos/bin/startup.sh -m standalone
ExecReload=/home/nacos/nacos/bin/shutdown.sh
ExecStop=/home/nacos/nacos/bin/shutdown.sh
[Install]
WantedBy=multi-user.target
# systemctl enable nacos 设置开机自启
if [[ "${MODE}" == "standalone" ]]; then
JAVA_OPT="${JAVA_OPT} -Xms128m -Xmx128m -Xmn128m" #512改为128
JAVA_OPT="${JAVA_OPT} -Dnacos.standalone=true"