Linux常用安装包

前言

记录一些常用安装包

解决方案

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"
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 213,047评论 6 492
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 90,807评论 3 386
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 158,501评论 0 348
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 56,839评论 1 285
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 65,951评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 50,117评论 1 291
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,188评论 3 412
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,929评论 0 268
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,372评论 1 303
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,679评论 2 327
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,837评论 1 341
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,536评论 4 335
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,168评论 3 317
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,886评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,129评论 1 267
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,665评论 2 362
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,739评论 2 351

推荐阅读更多精彩内容