一、挂载服务器磁盘
#挂盘语句
fdisk /dev/vdb 在分别输入n、p、1、2048、1048575999、w
mkfs.ext4 /dev/vdb
mkdir /data
echo /dev/vdb /data ext4 defaults 0 0 >> /etc/fstab
mount -a
df -h
#防火墙开端口
firewall-cmd --zone=public --add-port=8002/tcp --permanent
#防火墙重新加载端口信息
firewall-cmd --reload
#防火墙移除开放的端口
firewall-cmd --zone=public --remove-port=80/tcp --permanent
#防火墙查看端口情况
firewall-cmd --zone=public --query-port=1521/tcp
二、Docker安装
yum install -y yum-utils
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum makecache fast
yum install docker-ce docker-ce-cli containerd.io
systemctl start docker
#开机启动
systemctl enable docker
#查询命令
docker version
docker images
docker ps -a
三、Docker Redis安装
docker network create --driver bridge --subnet=172.18.12.0/16 --gateway=172.18.1.1 wn_docker_net
docker search redis
docker pull redis
docker images -a
#创建映射目录
mkdir /data/docker/redis_6379
docker run --restart=always --log-opt max-size=200m --log-opt max-file=2 -p 6379:6379 --name redis_6379 -v /data/docker/redis_6379/myredis.conf:/etc/redis/redis.conf -v /data/docker/redis_6379/data:/data -d redis redis-server /etc/redis/redis.conf --appendonly yes --requirepass 你自己的密码
#测试
docker exec -it redis_6379 bash
redis-cli
keys *
auth 你自己的密码
四、Docker zookeeper安装
docker pull zookeeper
#创建映射目录
mkdir /data/docker/zookeeper
mkdir /data/docker/zookeeper/data
docker run -d -e TZ="Asia/Shanghai" -p 2181:2181 -v /data/docker/zookeeper:/data --name zookeeper --restart always zookeeper
#看看启动了吗
docker ps -a
五、Docker rabbitMQ安装
docker pull rabbitmq:latest
docker run -id --hostname myrabbit --name rabbitmq1 -p 15672:15672 -p 5672:5672 rabbitmq
docker exec -it rabbitmq1 /bin/bash
rabbitmq-plugins enable rabbitmq_management
exit
docker restart xxx #对应的rabbitmq id 不知道可以 docker ps -a 看一下
docker exec -it rabbitmq1 /bin/bash #进控制台
rabbitmqctl add_user 用户名 密码
rabbitmqctl set_user_tags 用户名 administrator
rabbitmqctl set_permissions -p / 用户名 ".*" ".*" ".*"
六、Docker mysql 5.7安装
docker pull mysql:5.7
cd /data/docker/mysql/conf
mkdir conf.d/
mkdir mysql.conf.d/
cd /data/docker/mysql
vi my.conf
# i 输入以下内容 :wq 保存退出 以下是设置表名忽略大小写
[mysqld]
lower_case_table_names=1
docker run -p 3306:3306 --name mysql --privileged=true -v /data/docker/mysql/log:/var/log/mysql -v /data/docker/mysql/data:/var/lib/mysql -v /data/docker/mysql/conf:/etc/mysql -v /data/docker/mysql/my.cnf:/etc/mysql/my.cnf -e MYSQL_ROOT_PASSWORD=553260cfq$ -e lower_case_table_names=1 -d mysql:5.7
#mysql 分配用户 权限 创建数据库等语句
--1、创建数据库
CREATE DATABASE IF NOT EXISTS test_db DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
--2、新建用户 user_test 设置密码
create user 'user_test'@'%;' identified by 'pwd@2023';
--3、授予用户user_test通过外网IP对数据库“test_db”的全部权限
grant all privileges on test_db.* to 'user_test'@'%' identified by 'pwd@2023';
--4、刷新权限
flush privileges;
七、安装nginx
#官网自己下一个tar.gz包上传到服务器解压 http://nginx.org/en/download.html
#安装依赖
yum -y install gcc automake make pam-devel openldap-devel cyrus-sasl-devel openssl-devel
yum install pcre-devel zlib zlib-devel openssl openssl-devel
#编译安装
./configure --with-stream --with-stream=dynamic --with-http_ssl_module
make
make install
#以下设置开机自动启动ng
vim /etc/init.d/nginx [内容在下面]
chmod 755 /etc/init.d/nginx
chkconfig nginx on
#编辑ng配置
vi /usr/local/nginx/conf/nginx.conf
#常用命令 也可以进入 /usr/local/nginx/sbin/nginx -s reload
systemctl start nginx
systemctl status nginx
systemctl restart nginx
#!/bin/sh
#
#nginx - this script starts and stops the nginx daemin
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /usr/local/nginx/conf/nginx.conf
# pidfile: /usr/local/nginx/logs/nginx.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
nginx="/usr/local/nginx/sbin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"
lockfile=/var/lock/subsys/nginx
start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
configtest || return $?
stop
start
}
reload() {
configtest || return $?
echo -n $"Reloading $prog: "
killproc $nginx -HUP
RETVAL=$?
echo
}
force_reload() {
restart
}
configtest() {
$nginx -t -c $NGINX_CONF_FILE
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit 2
esac
八、问题
jdk安装遇到问题:
解决办法:
yum install glibc.i686