#! / bin/ bash #声明解释器路径
source / etc/ xiandian/ openrc. sh #生效环境变量
ping $HOST_IP - c 4 >> / dev/ null 2 > & 1
if [ 0 - ne $? ] ; thenecho - e "\033[31m Warning\nPlease make sure the network configuration is correct!\033[0m" exit 1
fi#shell语法不做解释,这一部分的作用是确保网络配置正确,错误则输出(Please make sure the network configuration is correct! )并终止执行脚本
#MariaDByum install - y mariadb mariadb- server python2- PyMySQL #安装MariaDB软件包
sed - i "/^symbolic-links/a\default-storage-engine = innodb\ninnodb_file_per_table\ncollation-server = utf8_general_ci\ninit-connect = 'SET NAMES utf8'\ncharacter-set-server = utf8\nmax_connections=10000" / etc/ my. cnf#修改 / etc/ my. cnf文件[ mysqld] 中添加max_connections= 10000
设置 mariadb最大连接数为10000 default - storage- engine = innodb
innodb_file_per_table
设置数据库默认存储引擎为innodbcollation- server = utf8_general_ci
init- connect = 'SET NAMES utf8'
character- set- server = utf8**
设置数据库的编码格式为utf8
sed - i 's/plugin-load-add*/#plugin-load-add/g' / etc/ my. cnf. d/ auth_gssapi. cnf #修改/ etc/ my. cnf. d/ auth_gssapi. cnf文件参数
[ mariadb]
注释一行参数
#plugin- load- add= auth_gssapi. so
crudini -- set / usr/ lib/ systemd/ system/ mariadb. service Service LimitNOFILE 10000
crudini -- set / usr/ lib/ systemd/ system/ mariadb. service Service LimitNPROC 10000 #由于mariadb有默认打开文件数限制。可以通过修改
/ usr/ lib/ systemd/ system/ mariadb. service文件参数
[ Service]
新添加两行如下参数:LimitNOFILE= 10000
LimitNPROC= 10000 来调大打开文件数目。
systemctl daemon- reload #后台程序重新加载,使配置文件生效生效
systemctl enable mariadb. service #设置开机自启mariadb服务
systemctl restart mariadb. service #重启mariadb服务
expect - c " #自动执行脚本
spawn / usr/ bin/ mysql_secure_installation #执行安全配置向导命令
expect \"Enter current password for root ( enter for none) : \"
send \"\r\"
expect \"Set root password? \"
send \"y\r\"
expect \"New password: \"
send \"$DB_PASS \r\"
expect \"Re- enter new password : \"
send \"$DB_PASS \r\"
expect \"Remove anonymous users? \"
send \"y\r\"
expect \"Disallow root login remotely? \"
send \"n\r\"
expect \"Remove test database and access to it? \"
send \"y\r\"
expect \"Reload privilege tables now? \"
send \"y\r\"
expect eof
"#借助expect处理交互的命令,配置Mysql#MariaDB简介:https: / / blog. csdn. net/ cxu0262/ article/ details/ 106257174
#RabbitMQyum install rabbitmq- server - y #安装rabbitmq软件包
systemctl start rabbitmq- server. service #启动rabbitmq服务
systemctl enable rabbitmq- server. service #设置rabbitmq服务开机自启
rabbitmqctl add_user $RABBIT_USER $RABBIT_PASS #创建RabbitMQ用户和密码
rabbitmqctl set_permissions $RABBIT_USER ".*" ".*" ".*" #设置用户访问虚拟机权限:授予用户可访问虚拟主机,在所有资源上都具备可配置,可写及可读的权限。#python- memcached:使用python语言开发的与memcached内存守护进程通信的接口程序#RabbitMQ简介:https: / / blog. csdn. net/ qq_45533841/ article/ details/ 106026991
#Memcacheyum install memcached python- memcached - y
sed - i - e 's/OPTIONS.*/OPTIONS="-l 127.0.0.1,::1,' $HOST_NAME '"/g' / etc/ sysconfig/ memcached
systemctl start memcached. service
systemctl enable memcached. service#Memcache简介:https: / / blog. csdn. net/ qq_33753147/ article/ details/ 79159410
#ETCD yum install etcd - y
sed - i - e 's/#ETCD_LISTEN_PEER_URLS.*/ETCD_LISTEN_PEER_URLS="http:\/\/' $HOST_IP ':2380"/g' \
- e 's/^ETCD_LISTEN_CLIENT_URLS.*/ETCD_LISTEN_CLIENT_URLS="http:\/\/' $HOST_IP ':2379"/g' \
- e 's/^ETCD_NAME="default"/ETCD_NAME="' $HOST_NAME '"/g' \
- e 's/#ETCD_INITIAL_ADVERTISE_PEER_URLS.*/ETCD_INITIAL_ADVERTISE_PEER_URLS="http:\/\/' $HOST_IP ':2380"/g' \
- e 's/^ETCD_ADVERTISE_CLIENT_URLS.*/ETCD_ADVERTISE_CLIENT_URLS="http:\/\/' $HOST_IP ':2379"/g' \
- e 's/#ETCD_INITIAL_CLUSTER=.*/ETCD_INITIAL_CLUSTER="' $HOST_NAME '=http:\/\/' $HOST_IP ':2380"/g' \
- e 's/#ETCD_INITIAL_CLUSTER_TOKEN.*/ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-01"/g' \
- e 's/#ETCD_INITIAL_CLUSTER_STATE.*/ETCD_INITIAL_CLUSTER_STATE="new"/g' / etc/ etcd/ etcd. conf#修改/ etc/ etcd/ etcd. conf配置文件,添加以下内容:
ETCD_LISTEN_PEER_URLS = "http://192.168.100.10:2380"
ETCD_LISTEN_CLIENT_URLS = "http://192.168.100.10:2379"
ETCD_NAME = "controller"
ETCD_INITIAL_ADVERTISE_PEER_URLS = "http://192.168.100.10:2380"
ETCD_ADVERTISE_CLIENT_URLS = "http://192.168.100.10:2379"
ETCD_INITIAL_CLUSTER = "controller=http://192.168.100.10:2380"
ETCD_INITIAL_CLUSTER_TOKEN = "etcd-cluster-01"
ETCD_INITIAL_CLUSTER_STATE = "new" #ETCD 简介:https: / / blog. csdn. net/ BlademasterDZ/ article/ details/ 113561889
systemctl start etcd
systemctl enable etcd